本文整理汇总了C#中Vector3.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.ToList方法的具体用法?C# Vector3.ToList怎么用?C# Vector3.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.ToList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadPositions
/// <summary>
/// Loads in positions saved on file
/// </summary>
private static void LoadPositions()
{
var sandboxConfig = EloBuddy.Sandbox.SandboxConfig.DataDirectory + @"\PandaTeemoReborn\";
var xFile = sandboxConfig + Game.MapId + @"\" + "xFile" + ".txt";
var yFile = sandboxConfig + Game.MapId + @"\" + "yFile" + ".txt";
var zFile = sandboxConfig + Game.MapId + @"\" + "zFile" + ".txt";
if (!File.Exists(xFile) || !File.Exists(yFile) || !File.Exists(zFile))
{
SavePositions();
}
string[] xPositions = null;
string[] yPositions = null;
string[] zPositions = null;
if (File.Exists(xFile) && File.Exists(yFile) && File.Exists(zFile))
{
xPositions = File.ReadAllLines(xFile);
yPositions = File.ReadAllLines(yFile);
zPositions = File.ReadAllLines(zFile);
}
if (xPositions == null)
{
return;
}
var xFloat = new float[xPositions.Length];
var yFloat = new float[yPositions.Length];
var zFloat = new float[zPositions.Length];
for (var i = 0; i < xPositions.Length; i++)
{
var x = xPositions[i];
float.TryParse(x, out xFloat[i]);
}
for (var i = 0; i < yPositions.Length; i++)
{
var y = yPositions[i];
float.TryParse(y, out yFloat[i]);
}
for (var i = 0; i < zPositions.Length; i++)
{
var z = zPositions[i];
float.TryParse(z, out zFloat[i]);
}
var positions = new Vector3[xFloat.Length];
for (var i = 0; i < positions.Length; i++)
{
positions[i] = new Vector3(xFloat[i], yFloat[i], zFloat[i]);
}
AddShroomLocations(positions.ToList());
AssignPosition();
}
示例2: setVertices
void setVertices(Vector3[] vertices)
{
TargetMesh.SetVertices(vertices.ToList());
}
示例3: ApplyDeform
/// <summary>
/// Changes terrain geometry in realtime based on new path. Path can be obtained from <see cref="GetPath()"/> method
/// </summary>
/// <param name="newPath">Array of new terrain path points</param>
public void ApplyDeform(Vector3[] newPath, bool applySmoothly = false)
{
if (!RealtimeDeformEnabled)
return;
Mesh pathMesh = gameObject.GetComponent<MeshFilter>().mesh;
if (FixSides)
{
newPath[0].y = LeftFixedPoint;
newPath[newPath.Length - 1].y = RightFixedPoint;
}
#region Generate vertices
Vector3[] vertices = GetVertsPos();
Vector3[] backupVertices = null;
if (applySmoothly)
{
DesiredVertices = newPath.ToList<Vector3>();
backupVertices = vertices;
}
else
{
int pathIndex = 0;
for (int i = 0; i < vertices.Length; i += 2)
{
if (newPath[pathIndex].y < 0)
newPath[pathIndex].y = 0;
if (newPath[pathIndex].y > Height)
newPath[pathIndex].y = Height;
vertices[i] = newPath[pathIndex];
pathIndex++;
}
pathMesh.vertices = vertices;
}
#endregion
if (!applySmoothly && RealtimeDeformUpdateUv)
{
#region Generate UV
Vector2[] uv = new Vector2[vertices.Length];
for (int i = 0; i < uv.Length; i += 2)
{
uv[i] = new Vector2((float)i / (uv.Length - 2) * MainTextureSize, (vertices[i].y / Height) * ((float)Height / Width) * MainTextureSize);
uv[i + 1] = new Vector2((float)i / (uv.Length - 2) * MainTextureSize, (vertices[i + 1].y / Height) * ((float)Height / Width) * MainTextureSize);
}
pathMesh.uv = uv;
#endregion
}
pathMesh.RecalculateBounds();
UpdateCap(false);
if (RealtimeDeformUpdateColliders)
{
UpdateCollider2D();
UpdateCollider3D(false);
}
if (applySmoothly && backupVertices != null)
{
pathMesh.vertices = vertices;
pathMesh.RecalculateBounds();
UpdateCap(false);
}
}
示例4: GenerateSquareVBO
void GenerateSquareVBO()
{
Vector3[] vecs = new Vector3[6];
uint[] inds = new uint[6];
Vector3[] norms = new Vector3[6];
Vector3[] texs = new Vector3[6];
Vector4[] cols = new Vector4[6];
Vector4[] BoneIDs = new Vector4[6];
Vector4[] BoneWeights = new Vector4[6];
Vector4[] BoneIDs2 = new Vector4[6];
Vector4[] BoneWeights2 = new Vector4[6];
for (uint n = 0; n < 6; n++)
{
inds[n] = n;
norms[n] = new Vector3(0, 0, 1);
cols[n] = new Vector4(1, 1, 1, 1);
BoneIDs[n] = new Vector4(0, 0, 0, 0);
BoneWeights[n] = new Vector4(0, 0, 0, 0);
BoneIDs2[n] = new Vector4(0, 0, 0, 0);
BoneWeights2[n] = new Vector4(0, 0, 0, 0);
}
vecs[0] = new Vector3(1, 0, 0);
texs[0] = new Vector3(1, 0, 0);
vecs[1] = new Vector3(1, 1, 0);
texs[1] = new Vector3(1, 1, 0);
vecs[2] = new Vector3(0, 1, 0);
texs[2] = new Vector3(0, 1, 0);
vecs[3] = new Vector3(1, 0, 0);
texs[3] = new Vector3(1, 0, 0);
vecs[4] = new Vector3(0, 1, 0);
texs[4] = new Vector3(0, 1, 0);
vecs[5] = new Vector3(0, 0, 0);
texs[5] = new Vector3(0, 0, 0);
Square = new VBO();
Square.Vertices = vecs.ToList();
Square.Indices = inds.ToList();
Square.Normals = norms.ToList();
Square.TexCoords = texs.ToList();
Square.Colors = cols.ToList();
Square.BoneIDs = BoneIDs.ToList();
Square.BoneWeights = BoneWeights.ToList();
Square.BoneIDs2 = BoneIDs2.ToList();
Square.BoneWeights2 = BoneWeights2.ToList();
Square.GenerateVBO();
}
示例5: GenerateLineVBO
void GenerateLineVBO()
{
Vector3[] vecs = new Vector3[2];
uint[] inds = new uint[2];
Vector3[] norms = new Vector3[2];
Vector3[] texs = new Vector3[2];
Vector4[] cols = new Vector4[2];
for (uint u = 0; u < 2; u++)
{
inds[u] = u;
}
for (int n = 0; n < 2; n++)
{
norms[n] = new Vector3(0, 0, 1);
}
for (int c = 0; c < 2; c++)
{
cols[c] = new Vector4(1, 1, 1, 1);
}
Vector4[] BoneIDs = new Vector4[2];
Vector4[] BoneWeights = new Vector4[2];
Vector4[] BoneIDs2 = new Vector4[2];
Vector4[] BoneWeights2 = new Vector4[2];
for (int n = 0; n < 2; n++)
{
BoneIDs[n] = new Vector4(0, 0, 0, 0);
BoneWeights[n] = new Vector4(0, 0, 0, 0);
BoneIDs2[n] = new Vector4(0, 0, 0, 0);
BoneWeights2[n] = new Vector4(0, 0, 0, 0);
}
vecs[0] = new Vector3(0, 0, 0);
texs[0] = new Vector3(0, 0, 0);
vecs[1] = new Vector3(1, 0, 0);
texs[1] = new Vector3(1, 0, 0);
Line = new VBO();
Line.Vertices = vecs.ToList();
Line.Indices = inds.ToList();
Line.Normals = norms.ToList();
Line.TexCoords = texs.ToList();
Line.Colors = cols.ToList();
Line.BoneIDs = BoneIDs.ToList();
Line.BoneWeights = BoneWeights.ToList();
Line.BoneIDs2 = BoneIDs2.ToList();
Line.BoneWeights2 = BoneWeights2.ToList();
Line.GenerateVBO();
}
示例6: GenerateBoxVBO
void GenerateBoxVBO()
{
// TODO: Optimize?
Vector3[] vecs = new Vector3[24];
uint[] inds = new uint[24];
Vector3[] norms = new Vector3[24];
Vector3[] texs = new Vector3[24];
Vector4[] cols = new Vector4[24];
for (uint u = 0; u < 24; u++)
{
inds[u] = u;
}
for (int t = 0; t < 24; t++)
{
texs[t] = new Vector3(0, 0, 0);
}
for (int n = 0; n < 24; n++)
{
norms[n] = new Vector3(0, 0, 1); // TODO: Accurate normals somehow? Do lines even have normals?
}
for (int c = 0; c < 24; c++)
{
cols[c] = new Vector4(1, 1, 1, 1);
}
Vector4[] BoneIDs = new Vector4[24];
Vector4[] BoneWeights = new Vector4[24];
Vector4[] BoneIDs2 = new Vector4[24];
Vector4[] BoneWeights2 = new Vector4[24];
for (int n = 0; n < 24; n++)
{
BoneIDs[n] = new Vector4(0, 0, 0, 0);
BoneWeights[n] = new Vector4(0, 0, 0, 0);
BoneIDs2[n] = new Vector4(0, 0, 0, 0);
BoneWeights2[n] = new Vector4(0, 0, 0, 0);
}
int i = 0;
int zero = -1; // Ssh.
vecs[i] = new Vector3(zero, zero, zero); i++;
vecs[i] = new Vector3(1, zero, zero); i++;
vecs[i] = new Vector3(1, zero, zero); i++;
vecs[i] = new Vector3(1, 1, zero); i++;
vecs[i] = new Vector3(1, 1, zero); i++;
vecs[i] = new Vector3(zero, 1, zero); i++;
vecs[i] = new Vector3(zero, 1, zero); i++;
vecs[i] = new Vector3(zero, zero, zero); i++;
vecs[i] = new Vector3(zero, zero, 1); i++;
vecs[i] = new Vector3(1, zero, 1); i++;
vecs[i] = new Vector3(1, zero, 1); i++;
vecs[i] = new Vector3(1, 1, 1); i++;
vecs[i] = new Vector3(1, 1, 1); i++;
vecs[i] = new Vector3(zero, 1, 1); i++;
vecs[i] = new Vector3(zero, 1, 1); i++;
vecs[i] = new Vector3(zero, zero, 1); i++;
vecs[i] = new Vector3(zero, zero, zero); i++;
vecs[i] = new Vector3(zero, zero, 1); i++;
vecs[i] = new Vector3(1, zero, zero); i++;
vecs[i] = new Vector3(1, zero, 1); i++;
vecs[i] = new Vector3(1, 1, zero); i++;
vecs[i] = new Vector3(1, 1, 1); i++;
vecs[i] = new Vector3(zero, 1, zero); i++;
vecs[i] = new Vector3(zero, 1, 1); i++;
Box = new VBO();
Box.Vertices = vecs.ToList();
Box.Indices = inds.ToList();
Box.Normals = norms.ToList();
Box.TexCoords = texs.ToList();
Box.Colors = cols.ToList();
Box.BoneIDs = BoneIDs.ToList();
Box.BoneWeights = BoneWeights.ToList();
Box.BoneIDs2 = BoneIDs2.ToList();
Box.BoneWeights2 = BoneWeights2.ToList();
Box.GenerateVBO();
}