本文整理汇总了C#中System.Vector3.set方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.set方法的具体用法?C# Vector3.set怎么用?C# Vector3.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getPhoton
public void getPhoton(double randX1, double randY1, double randX2, double randY2, Point3 p, Vector3 dir, Color power)
{
float phi = (float)(2 * Math.PI * randX1);
float s = (float)Math.Sqrt(1.0f - randY1);
dir.x = r * (float)Math.Cos(phi) * s;
dir.y = r * (float)Math.Sin(phi) * s;
dir.z = 0;
basis.transform(dir);
Point3.add(src, dir, p);
dir.set(this.dir);
power.set(radiance).mul((float)Math.PI * r2);
}
示例2: generate
private TriangleMesh generate(int[] tris, float[] verts, bool smoothNormals)
{
ParameterList pl = new ParameterList();
pl.addIntegerArray("triangles", tris);
pl.addPoints("points", ParameterList.InterpolationType.VERTEX, verts);
if (smoothNormals)
{
float[] normals = new float[verts.Length]; // filled with 0's
Point3 p0 = new Point3();
Point3 p1 = new Point3();
Point3 p2 = new Point3();
Vector3 n = new Vector3();
for (int i3 = 0; i3 < tris.Length; i3 += 3)
{
int v0 = tris[i3 + 0];
int v1 = tris[i3 + 1];
int v2 = tris[i3 + 2];
p0.set(verts[3 * v0 + 0], verts[3 * v0 + 1], verts[3 * v0 + 2]);
p1.set(verts[3 * v1 + 0], verts[3 * v1 + 1], verts[3 * v1 + 2]);
p2.set(verts[3 * v2 + 0], verts[3 * v2 + 1], verts[3 * v2 + 2]);
Point3.normal(p0, p1, p2, n); // compute normal
// add face normal to each vertex
// note that these are not normalized so this in fact weights
// each normal by the area of the triangle
normals[3 * v0 + 0] += n.x;
normals[3 * v0 + 1] += n.y;
normals[3 * v0 + 2] += n.z;
normals[3 * v1 + 0] += n.x;
normals[3 * v1 + 1] += n.y;
normals[3 * v1 + 2] += n.z;
normals[3 * v2 + 0] += n.x;
normals[3 * v2 + 1] += n.y;
normals[3 * v2 + 2] += n.z;
}
// normalize all the vectors
for (int i3 = 0; i3 < normals.Length; i3 += 3)
{
n.set(normals[i3 + 0], normals[i3 + 1], normals[i3 + 2]);
n.normalize();
normals[i3 + 0] = n.x;
normals[i3 + 1] = n.y;
normals[i3 + 2] = n.z;
}
pl.addVectors("normals", ParameterList.InterpolationType.VERTEX, normals);
}
TriangleMesh m = new TriangleMesh();
if (m.update(pl, null))
return m;
// something failed in creating the mesh, the error message will be
// printed by the mesh itself - no need to repeat it here
return null;
}
示例3: untransform
public Vector3 untransform(Vector3 a)
{
float x = Vector3.dot(a, u);
float y = Vector3.dot(a, v);
float z = Vector3.dot(a, w);
return a.set(x, y, z);
}
示例4: transform
public Vector3 transform(Vector3 a)
{
float x = (a.x * u.x) + (a.y * v.x) + (a.z * w.x);
float y = (a.x * u.y) + (a.y * v.y) + (a.z * w.y);
float z = (a.x * u.z) + (a.y * v.z) + (a.z * w.z);
return a.set(x, y, z);
}