本文整理汇总了C#中Vector3.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.CopyTo方法的具体用法?C# Vector3.CopyTo怎么用?C# Vector3.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.CopyTo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Vector3CopyToTest
public void Vector3CopyToTest()
{
Vector3 v1 = new Vector3(2.0f, 3.0f, 3.3f);
Single[] a = new Single[4];
Single[] b = new Single[3];
v1.CopyTo(a, 1);
v1.CopyTo(b);
Assert.Equal(0.0f, a[0]);
Assert.Equal(2.0f, a[1]);
Assert.Equal(3.0f, a[2]);
Assert.Equal(3.3f, a[3]);
Assert.Equal(2.0f, b[0]);
Assert.Equal(3.0f, b[1]);
Assert.Equal(3.3f, b[2]);
}
示例2: SetAnimation
public void SetAnimation(float[] keys, Vector3[] values, Vector3[] rotations)
{
animationKeys = new float[keys.Length];
animationValues = new Vector3[values.Length];
animationRotations = new Vector3[rotations.Length];
keys.CopyTo (animationKeys,0);
values.CopyTo (animationValues,0);
rotations.CopyTo (animationRotations,0);
PopulateAnimation();
}
示例3: addToVBO
public int addToVBO(Vector3[] newVertices)
{
int startIndex = vertices.Length;
Vector3[] newarr = new Vector3[vertices.Length + newVertices.Length];
vertices.CopyTo(newarr, 0);
newVertices.CopyTo(newarr, vertices.Length);
vertices = newarr;
return startIndex;
}
示例4: BeginFracture
protected override void BeginFracture(Vector3 point, float size)
{
if (Complete) return;
Complete = true;
//Debug.Log("Destruction Triggered : " + name);
LastImpactPoint = point;
// Create an array of random points that pivot around the main fracture point.
Vector3[] points = new Vector3[shards.Random()];
for (int i = 0; i < points.Length; i++)
{
points[i] = Vector3.Scale(transform.lossyScale, transform.InverseTransformPoint(point)) + Random.insideUnitSphere * size;
}
Stopwatch timer = new Stopwatch();
timer.Start();
InitializeDestruction();
sortedVoronoiPoints = new Vector3[points.Length];
points.CopyTo(sortedVoronoiPoints, 0);
// Start the worker methods here.
if (immediate)
{
ImmediateFracture(points);
}
else
{
StartCoroutine(SpreadFracture(points));
}
timer.Stop();
//Debug.Log("Time taken to compute, " + timer.ElapsedMilliseconds + " shards : " + points.Length);
}
示例5: Vector3CopyToTest
public void Vector3CopyToTest()
{
Vector3 v1 = new Vector3(2.0f, 3.0f, 3.3f);
float[] a = new float[4];
float[] b = new float[3];
Assert.Throws<NullReferenceException>(() => v1.CopyTo(null, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => v1.CopyTo(a, a.Length));
Assert.Throws<ArgumentException>(() => v1.CopyTo(a, a.Length - 2));
v1.CopyTo(a, 1);
v1.CopyTo(b);
Assert.Equal(0.0f, a[0]);
Assert.Equal(2.0f, a[1]);
Assert.Equal(3.0f, a[2]);
Assert.Equal(3.3f, a[3]);
Assert.Equal(2.0f, b[0]);
Assert.Equal(3.0f, b[1]);
Assert.Equal(3.3f, b[2]);
}
示例6: Add
public void Add(string c, OTAtlasData data, Vector3[] verts, Vector2[] uv)
{
text+=c;
int tx = 0;
string dx = data.GetMeta("dx");
if (dx=="")
tx = (int)(data.offset.x + data.size.x);
else
tx = System.Convert.ToUInt16(dx);
txList.Add(tx);
atlasData.Add(data);
int tt = 0;
for (int i=0; i<txList.Count-1; i++)
tt+=txList[i];
Matrix4x4 mx = new Matrix4x4();
mx.SetTRS(new Vector3(tt,0,0), Quaternion.identity, Vector3.one);
for (int i=0; i<verts.Length; i++)
verts[i] = mx.MultiplyPoint3x4(verts[i]);
System.Array.Resize<Vector3>(ref this.verts, this.verts.Length + verts.Length);
verts.CopyTo(this.verts, this.verts.Length - verts.Length);
System.Array.Resize<Vector2>(ref this.uv, this.uv.Length + uv.Length);
uv.CopyTo(this.uv, this.uv.Length - uv.Length);
}
示例7: CompressChannel
void CompressChannel(MegaMorph mr, MegaMorphChan mc)
{
// for now change system to work off mapping, just have 1 to 1 mapping to test its working
mc.mapping = new int[mr.oPoints.Length];
for ( int i = 0; i < mr.oPoints.Length; i++ )
{
mc.mapping[i] = i;
}
#if false
BitArray modded = new BitArray(mr.oPoints.Length);
modded.SetAll(false);
for ( int t = 0; t < mc.mTargetCache.Count; t++ )
{
MegaMorphTarget mt = mc.mTargetCache[t];
for ( int i = 0; i < mr.oPoints.Length; i++ )
{
if ( mt.points[i] != mr.oPoints[i] ) // Have a threshold for this
{
modded[i] = true;
break;
}
}
}
List<int> points = new List<int>();
for ( int i = 0; i < modded.Count; i++ )
{
if ( modded[i] )
points.Add(i);
}
// points now holds indexes of morphed verts for the channel, so now need to collapse points
Vector3[] pts = new Vector3[points.Count];
for ( int t = 0; t < mc.mTargetCache.Count; t++ )
{
MegaMorphTarget mt = mc.mTargetCache[t];
for ( int i = 0; i < points.Count; i++ )
{
pts[i] = mt.points[points[i]];
}
pts.CopyTo(mt.points, 0);
}
// If one target deal with deltas
#endif
}
示例8: BuildMesh
/// <summary>Construct the mesh of the tile.</summary>
/// <param name="mf">Mesh filter of the tile.</param>
/// <param name="mc">Mesh collider of the tile.</param>
/// <param name="layer">Layer of the object.</param>
/// <param name="sector">Sector of the object.</param>
private void BuildMesh(MeshFilter mf, MeshCollider mc, int layer, int sector)
{
var mesh = new Mesh();
mesh.Clear();
// the vertices of our new mesh, separated into two groups
var inner = new Vector3[grid.smoothness + 1]; // the inner vertices (closer to the centre)
var outer = new Vector3[grid.smoothness + 1]; // the outer vertices
// vertices must be given in local space
Transform trnsfrm = mf.gameObject.transform;
// the amount of vertices depends on how much the grid is smoothed
for (int k = 0; k < grid.smoothness + 1; k++) {
// rad is the current distance from the centre, sctr is the current sector and i * (1.0f / grid.smoothness) is the fraction inside the current sector
inner[k] = trnsfrm.InverseTransformPoint(grid.GridToWorld(new Vector3(layer, sector + k * (1.0f / grid.smoothness), 0)));
outer[k] = trnsfrm.InverseTransformPoint(grid.GridToWorld(new Vector3(layer + 1, sector + k * (1.0f / grid.smoothness), 0)));
}
//this is wher the actual vertices go
var vertices = new Vector3[2 * (grid.smoothness + 1)];
// copy the sorted vertices into the new array
inner.CopyTo(vertices, 0);
// for each inner vertex its outer counterpart has the same index plus grid.smoothness + 1, this will be relevant later
outer.CopyTo(vertices, grid.smoothness + 1);
// assign them as the vertices of the mesh
mesh.vertices = vertices;
// now we have to assign the triangles
var triangles = new int[6 * grid.smoothness]; // for each smoothing step we need two triangles and each triangle is three indices
int counter = 0; // keeps track of the current index
for (int k = 0; k < grid.smoothness; k++) {
// triangles are assigned in a clockwise fashion
triangles[counter] = k;
triangles[counter+1] = k + (grid.smoothness + 1) + 1;
triangles[counter+2] = k + (grid.smoothness + 1);
triangles[counter+3] = k + 1;
triangles[counter+4] = k + (grid.smoothness + 1) + 1;
triangles[counter+5] = k;
counter += 6; // increment the counter for the nex six indices
}
mesh.triangles = triangles;
// add some dummy UVs to keep the shader happy or else it complains, but they are not used in this example
var uvs = new Vector2[vertices.Length];
for (int k = 0; k < uvs.Length; k++) {
uvs[k] = new Vector2(vertices[k].x, vertices[k].y);
}
mesh.uv = uvs;
// the usual cleanup
mesh.RecalculateNormals();
mesh.RecalculateBounds();
mesh.Optimize();
// assign the mesh to the mesh filter and mesh collider
mf.mesh = mesh;
mc.sharedMesh = mesh;
}
示例9: DrawSpline
public void DrawSpline(Vector3[] points, float[] thicknesses = null, Color[] colors = null)
{
if(points.Length < 2) return;
Vector3[] pts = new Vector3[points.Length+2];
points.CopyTo(pts, 1);
pts[0] = points[0];
pts[pts.Length-1] = points[points.Length-1];
float thickness = m_thickness;
if(thicknesses != null){
thickness = thicknesses[0];
}
Color color = m_color;
if(colors != null){
color = colors[0];
}
this.MoveTo(pts[0], color, thickness);
int j = 0;
for(int i=0; i < pts.Length-3; i++, j++)
{
Vector3 p0 = pts[i+0];
Vector3 p1 = pts[i+1];
Vector3 p2 = pts[i+2];
Vector3 p3 = pts[i+3];
float d = Vector3.Distance(p3, p0) / 100;
//int numSegments = 5;//曲線分割数(補完する数)
int numSegments = (int)(d * 2.0f)+1;
float fromThickness = m_thickness;
float toThickness = m_thickness;
if(thicknesses != null){
fromThickness = thicknesses[j];
toThickness = thicknesses[j+1];
}
Color fromColor = m_color;
Color toColor = m_color;
if(colors != null){
fromColor = colors[j];
toColor = colors[j+1];
}
splineTo(p0, p1, p2, p3, numSegments, fromThickness, toThickness, fromColor, toColor);
}
}
示例10: mbAddToRenderBuffer
public void mbAddToRenderBuffer(ref Vector3[] vertices, ref Vector2[] uvs, ref Color[] colors)
{
if (mBufferPtr == mVertices.Length)
mbEnlargeBuffers(LayerBlocksize);
vertices.CopyTo(mVertices, mBufferPtr);
uvs.CopyTo(mUVs, mBufferPtr);
colors.CopyTo(mColors, mBufferPtr);
int i = (mBufferPtr / 4) * 6;
mTriangles[i++] = mBufferPtr;
mTriangles[i++] = mBufferPtr + 1;
mTriangles[i++] = mBufferPtr + 2;
mTriangles[i++] = mBufferPtr + 2;
mTriangles[i++] = mBufferPtr + 3;
mTriangles[i++] = mBufferPtr;
mBufferPtr += 4;
}
示例11: SetForcedStateVerts
void SetForcedStateVerts(Vector3[] verts, Color[] cols)
{
if(m_forced_state_verts == null || m_forced_state_verts.Length != verts.Length)
m_forced_state_verts = new Vector3[verts.Length];
verts.CopyTo(m_forced_state_verts, 0);
if(m_forced_state_cols == null || m_forced_state_cols.Length != cols.Length)
m_forced_state_cols = new Color[cols.Length];
cols.CopyTo(m_forced_state_cols, 0);
}