本文整理汇总了C#中Vector3.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Clone方法的具体用法?C# Vector3.Clone怎么用?C# Vector3.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.Clone方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
gameObject.AddComponent<MeshFilter>();
gameObject.AddComponent<MeshRenderer>();
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = new Vector3[4];
vertices[0] = new Vector3(0, 0);
vertices[1] = new Vector3(1, 0);
vertices[2] = new Vector3(1, 1);
vertices[3] = new Vector3(0, 1);
baseVertices = vertices;
int[] triangles = new int[2 * 3];
triangles[0 * 3 + 0] = 0;
triangles[0 * 3 + 1] = 1;
triangles[0 * 3 + 2] = 2;
triangles[1 * 3 + 0] = 0;
triangles[1 * 3 + 1] = 2;
triangles[1 * 3 + 2] = 3;
mesh.vertices = (Vector3[]) vertices.Clone();
mesh.triangles = triangles;
}
示例2: there
private Vector3[] mNormalAtVertices = null; // may not be there (only present for triangles created from a mesh)
#endregion Fields
#region Constructors
/// <summary>
/// Constructs from given positions, normal, and uv then intialize for intersection computation.
/// </summary>
/// <param name="parser"></param>
protected RTTriangle(Vector3[] vertices, Vector3[] normalAtVertex, Vector2[] uvAtVertex, int material)
{
mType = RTGeometryType.Triangle;
mMaterialIndex = material;
mVertices = (Vector3[])vertices.Clone();
if (null != normalAtVertex)
mNormalAtVertices = (Vector3[])normalAtVertex.Clone();
mVertexUV = (Vector2[])uvAtVertex.Clone();
InitializeTriangle();
}
示例3: Load
//.........这里部分代码省略.........
Vector3 distVec = inputPoints[num + 1] - inputPoints[num];
float xyDist = (float)Math.Sqrt(
distVec.X*distVec.X+distVec.Y*distVec.Y);
float zDist = Math.Abs(distVec.Z);
// Also check if next point is down again.
Vector3 distVec2 = inputPoints[num + 2] - inputPoints[num + 1];
if (zDist / 2 > xyDist &&
Math.Abs(distVec.Z + distVec2.Z) < zDist / 2)
{
// Find out which direction we are going
Vector3 dir = inputPoints[num] - inputPoints[num - 1];
dir.Normalize();
Vector3 upVec = new Vector3(0, 0, 1);
Vector3 rightVec = Vector3.Cross(dir, upVec);
// Matrix build helper matrix to rotate our looping points
Matrix rotMatrix = new Matrix(
rightVec.X, rightVec.Y, rightVec.Z, 0,
dir.X, dir.Y, dir.Z, 0,
upVec.X, upVec.Y, upVec.Z, 0,
0, 0, 0, 1);
// Ok do a looping with zDist as height.
// Start with the current point, loop around and end with the
// point after the looping. We will remove the current and the
// next 2 points, but add 9 new points instead for our smooth loop.
// See LoopingPoints for the looping itself.
Vector3 startLoopPos = inputPoints[num];
Vector3 endLoopPos = inputPoints[num + 2];
// Insert 7 new points (9 new points, but we reuse
// start, middle and end points which are num, num+1 and num+2,
// plus an additional point after the looping to keep the road
// straight!)
Vector3[] remInputPoints = (Vector3[])inputPoints.Clone();
inputPoints = new Vector3[inputPoints.Length + 7];
// Copy everything over
for (int copyNum = 0; copyNum < remInputPoints.Length; copyNum++)
if (copyNum < num)
inputPoints[copyNum] = remInputPoints[copyNum];
else
inputPoints[copyNum + 7] = remInputPoints[copyNum];
// Ok, now we can add our loop
for (int loopNum = 0; loopNum < LoopingPoints.Length; loopNum++)
{
// Interpolate between start and end pos to land at the end pos!
float loopPercent = loopNum / (float)(LoopingPoints.Length - 1);
inputPoints[num + loopNum] =
startLoopPos * (1 - loopPercent) +
endLoopPos * loopPercent +
zDist * Vector3.Transform(LoopingPoints[loopNum], rotMatrix);
} // for (loopNum)
// Add extra point to keep the road straight
Vector3 newRoadDir =
inputPoints[num + 10] - inputPoints[num + 8];
// Don't go more than zDist * 2 units away!
if (newRoadDir.Length() > zDist * 2)
{
newRoadDir.Normalize();
newRoadDir = newRoadDir * zDist;
inputPoints[num + 9] = inputPoints[num + 8] + newRoadDir;
} // if (newRoadDir.Length)
else
// Just add an interpolation point
inputPoints[num + 9] =
示例4: UpdateFairing
void UpdateFairing()
{
ProceduralPart ppart = PPart;
if (useFairing && ppart != null)
{
ProceduralAbstractSoRShape shape = ppart.CurrentShape as ProceduralAbstractSoRShape;
if (shape != null)
{
Vector3[] topEndcapVerticies = shape.GetEndcapVerticies(true);
Vector3[] topInner = new Vector3[topEndcapVerticies.Length + 1];
topEndcapVerticies.CopyTo(topInner, 0);
topInner[topEndcapVerticies.Length] = topEndcapVerticies[0];
int vertCount = topInner.Length;
//foreach (Vector3 v in topInner)
// Debug.Log(v);
Vector3[] topOuter = (Vector3[])topInner.Clone();
for (int i = 0; i < vertCount; ++i)
{
float r = topInner[i].magnitude;
float r_ = r + fairingThickness;
float scaleFactor = r_ / r;
topOuter[i].x *= scaleFactor;
topOuter[i].z *= scaleFactor;
}
TextureScale.x = topOuter[0].magnitude * 2 * Mathf.PI;
Vector3[] sideTop = (Vector3[])topOuter.Clone();
Vector3[] sideBottom = (Vector3[])sideTop.Clone();
Vector3[] bottomInner = (Vector3[])topInner.Clone();
Vector3[] bottomOuter = (Vector3[])topOuter.Clone();
for (int i = 0; i < vertCount; ++i)
{
if (bottomNode != null)
{
sideBottom[i].y = bottomNode.position.y;
bottomInner[i].y = bottomNode.position.y;
bottomOuter[i].y = bottomNode.position.y;
}
}
TextureScale.y = Mathf.Abs(topOuter[0].y - bottomOuter[0].y);
Vector3[] innerSideTop = (Vector3[])topInner.Clone();
Vector3[] innerSideBottom = (Vector3[])bottomInner.Clone();
int topInnerStart = 0;
int topOuterStart = topInnerStart + vertCount;
int sideTopStart = topOuterStart + vertCount;
int sideBottomStart = sideTopStart + vertCount;
int bottomInnerStart = sideBottomStart + vertCount;
int bottomOuterStart = bottomInnerStart + vertCount;
int innerSideTopStart = bottomOuterStart + vertCount;
int innerSideBottomStart = innerSideTopStart + vertCount;
UncheckedMesh m = new UncheckedMesh(vertCount * 8, vertCount * 8 * 6);
//int tri = 0;
for (int i = 0; i < vertCount; ++i)
{
m.verticies[topInnerStart + i] = topInner[i];
m.verticies[topOuterStart + i] = topOuter[i];
m.verticies[sideTopStart + i] = sideTop[i];
m.verticies[sideBottomStart + i] = sideBottom[i];
m.verticies[bottomInnerStart + i] = bottomInner[i];
m.verticies[bottomOuterStart + i] = bottomOuter[i];
m.verticies[innerSideTopStart + i] = innerSideTop[i];
m.verticies[innerSideBottomStart + i] = innerSideBottom[i];
m.normals[topInnerStart + i] = new Vector3(0.0f, 1.0f, 0.0f);
m.normals[topOuterStart + i] = new Vector3(0.0f, 1.0f, 0.0f);
m.normals[sideTopStart + i] = m.verticies[sideTopStart + i].xz().normalized;
m.normals[sideBottomStart + i] = m.verticies[sideBottomStart + i].xz().normalized;
m.normals[bottomInnerStart + i] = new Vector3(0.0f, -1.0f, 0.0f);
m.normals[bottomOuterStart + i] = new Vector3(0.0f, -1.0f, 0.0f);
m.normals[innerSideTopStart + i] = -m.verticies[innerSideTopStart + i].xz().normalized;
m.normals[innerSideBottomStart + i] = -m.verticies[innerSideBottomStart + i].xz().normalized;
m.uv[topInnerStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 0.0f);
m.uv[topOuterStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 1.0f);
m.uv[sideTopStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 1.0f);
m.uv[sideBottomStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 0.0f);
m.uv[bottomInnerStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 0.0f);
m.uv[bottomOuterStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 1.0f);
m.uv[innerSideTopStart + i] = new Vector2(Mathf.InverseLerp(0, vertCount - 1, i), 0.0f);
//.........这里部分代码省略.........
示例5: CoplanarPosit
/// <summary>
/// Initializes a new instance of the <see cref="Posit"/> class.
/// </summary>
///
/// <param name="model">Array of vectors containing coordinates of four real model's point.</param>
/// <param name="focalLength">Effective focal length of the camera used to capture the model.</param>
///
/// <exception cref="ArgumentException">The model must have 4 points.</exception>
///
public CoplanarPosit( Vector3[] model, float focalLength )
{
if ( model.Length != 4 )
{
throw new ArgumentException( "The model must have 4 points." );
}
this.focalLength = focalLength;
modelPoints = (Vector3[]) model.Clone( );
// compute model vectors
modelVectors = Matrix3x3.CreateFromRows(
model[1] - model[0],
model[2] - model[0],
model[3] - model[0] );
// compute pseudo inverse of the model matrix
Matrix3x3 u, v;
Vector3 e;
modelVectors.SVD( out u, out e, out v );
modelPseudoInverse = v * Matrix3x3.CreateDiagonal( e.Inverse( ) ) * u.Transpose( );
// computer unit vector normal to the model
modelNormal = v.GetColumn( e.MinIndex );
}
示例6: BezierCurve
public BezierCurve(Vector3[] points)
{
allPoints = new Vector3[points.Length][];
allPoints[0] = (Vector3[])points.Clone();
for (int i = points.Length-1, j = 1; j < allPoints.Length; --i, j++)
{
allPoints[j] = new Vector3[i];
}
}
示例7: SetObject
public void SetObject( Vector3[] vertices, Color[] colors, int[,] ribs )
{
if ( vertices.Length != colors.Length )
{
throw new ArgumentException( "Number of colors must be equal to number of vertices." );
}
if ( ribs.GetLength( 1 ) != 2 )
{
throw new ArgumentException( "Ribs array must have 2 coordinates per rib." );
}
this.objectPoints = (Vector3[]) vertices.Clone( );
this.colors = (Color[]) colors.Clone( );
this.lines = (int[,]) ribs.Clone( );
Recalculate( );
}
示例8: Posit
/// <summary>
/// Initializes a new instance of the <see cref="Posit"/> class.
/// </summary>
///
/// <param name="model">Array of vectors containing coordinates of four real model's point (points
/// must not be on the same plane).</param>
/// <param name="focalLength">Effective focal length of the camera used to capture the model.</param>
///
/// <exception cref="ArgumentException">The model must have 4 points.</exception>
///
public Posit( Vector3[] model, float focalLength )
{
if ( model.Length != 4 )
{
throw new ArgumentException( "The model must have 4 points." );
}
this.focalLength = focalLength;
modelPoints = (Vector3[]) model.Clone( );
// compute model vectors
modelVectors = Matrix3x3.CreateFromRows(
model[1] - model[0],
model[2] - model[0],
model[3] - model[0] );
// compute pseudo inverse matrix
modelPseudoInverse = modelVectors.PseudoInverse( );
}
示例9: ConvexResult
public ConvexResult(Vector3[] hvertices, int[] hindices)
{
mHullVertices = (Vector3[])hvertices.Clone();
mHullIndices = (int[])hindices.Clone();
}
示例10: CloneList
//Clone an array and the inner array
Vector3[][] CloneList(Vector3[][] arrayToClone) {
//First clone the outer array
Vector3[][] newArray = arrayToClone.Clone() as Vector3[][];
//Then clone the inner arrays
for (int i = 0; i < newArray.Length; i++) {
newArray[i] = newArray[i].Clone() as Vector3[];
}
return newArray;
}
示例11: TransformCurrent
/// <summary>
/// Transforms a poly with the current matrices and viewport. Useful for perspective projection matrices
/// </summary>
public Vector3[] TransformCurrent(Vector3[] poly)
{
Vector3[] ret = (Vector3[])poly.Clone();
for(int i=0;i<ret.Length;i++) {
ret[i] = Device.Viewport.Project(ret[i], Matrices.projection, Matrices.view, Matrices.world);
}
return ret;
}
示例12: Transform
/// <summary>
/// Transforms a poly with the provided matrix
/// </summary>
public static Vector3[] Transform(Matrix mat, Vector3[] poly)
{
Vector3[] ret = (Vector3[])poly.Clone();
Vector3.Transform(ret, ref mat, ret);
return ret;
}
示例13: getTopLinePoints
private Vector3[] getTopLinePoints(Vector3[] points)
{
Vector3[] secondPoints = (Vector3[])points.Clone();
for (int i = 0; i < secondPoints.Length; i++)
{
secondPoints[i].y = secondPoints[i].y + getVerticalCollisionDistance();
}
return secondPoints;
}
示例14: getRightLinePoints
private Vector3[] getRightLinePoints(Vector3[] points)
{
Vector3[] secondPoints = (Vector3[])points.Clone();
for(int i = 0; i < secondPoints.Length; i++)
{
secondPoints[i].x = secondPoints[i].x + getHorizontalCollisionDistance();
}
return secondPoints;
}