ton*_*nza 1 3d processing geometry cube particles
我正在尝试在处理中随机且均匀地在立方体表面上生成点。我正在尝试制作动画,所以我需要点的x,y和z最终位置。
有什么建议么?谢谢。
只需结合三个均匀的随机分布。此方法假定您有一个单位立方体[0..1] ^ 3。如果不是这种情况,请在生成点后缩放并偏移点。
这是一些C ++伪代码:
vec3 result;
int s=randomSide(); // returns 0 to 5, uniformly distributed
int c=s%3; // get the axis perpendicular to the side you just picked
result[c]=s>2 ? 1.f : 0.f;
result[(c+1)%3]=random01();
result[(c+2)%3]=random01();
Run Code Online (Sandbox Code Playgroud)
如果您有一个更普通的盒子而不是立方体,则必须根据盒子侧面的面积来偏斜侧面拾取。
| 归档时间: |
|
| 查看次数: |
2096 次 |
| 最近记录: |