本文整理汇总了C#中Mesh.SetVertices方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.SetVertices方法的具体用法?C# Mesh.SetVertices怎么用?C# Mesh.SetVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.SetVertices方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateQuad
public static Mesh CreateQuad()
{
Mesh mesh = new Mesh();
List<Vertex> vertices = new List<Vertex>();
vertices.Add(new Vertex(new Vector3f(-1f, -1f, 0), new Vector2f(0, 0), new Vector3f(0, 0, 1)));
vertices.Add(new Vertex(new Vector3f(1, -1f, 0), new Vector2f(1f, 0), new Vector3f(0, 0, 1)));
vertices.Add(new Vertex(new Vector3f(1f, 1f, 0), new Vector2f(1f, 1f), new Vector3f(0, 0, 1)));
vertices.Add(new Vertex(new Vector3f(-1f, 1f, 0), new Vector2f(0, 1f), new Vector3f(0, 0, 1)));
mesh.SetVertices(vertices);
mesh.PrimitiveType = Mesh.PrimitiveTypes.TriangleFan;
return mesh;
}
示例2: SimplifyMesh
private void SimplifyMesh()
{
newMesh = new Mesh();
List<Vertex> newVerts = new List<Vertex>();
for (int i = 0; i < mesh.indices.Count; i+=6)
{
// triangle
newVerts.Add(mesh.vertices[mesh.indices[i]]);
newVerts.Add(mesh.vertices[mesh.indices[i+1]]);
newVerts.Add(mesh.vertices[mesh.indices[i+2]]);
}
newMesh.SetVertices(newVerts);
}
示例3: FillMesh
public void FillMesh(Mesh mesh)
{
mesh.Clear();
if (m_Positions.Count >= 65000)
throw new ArgumentException("Mesh can not have more than 65000 vertices");
mesh.SetVertices(m_Positions);
mesh.SetColors(m_Colors);
mesh.SetUVs(0, m_Uv0S);
mesh.SetUVs(1, m_Uv1S);
mesh.SetNormals(m_Normals);
mesh.SetTangents(m_Tangents);
mesh.SetTriangles(m_Indices, 0);
mesh.RecalculateBounds();
}
示例4: CreateCube
public static Mesh CreateCube(Vector3f min, Vector3f max)
{
List<Vertex> vertices = new List<Vertex>();
vertices.Add(new Vertex(new Vector3f(max.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, max.z)));
vertices.Add(new Vertex(new Vector3f(min.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, max.y, min.z)));
vertices.Add(new Vertex(new Vector3f(max.x, min.y, min.z)));
vertices.Add(new Vertex(new Vector3f(min.x, max.y, min.z)));
Mesh mesh = new Mesh();
mesh.SetVertices(vertices);
return mesh;
}
示例5: MergeMeshes
private static Mesh MergeMeshes(List<Mesh> meshes, List<Material> materials, List<Matrix4f> transforms)
{
Mesh resMesh = new Mesh();
if (meshes.Count > 0)
{
List<Vertex> finalVertices = new List<Vertex>();
for (int m = 0; m < meshes.Count; m++)
{
for (int i = 0; i < meshes[m].indices.Count; i++)
{
Vertex vertex = meshes[m].vertices[meshes[m].indices[i]];
Vertex newVert = new Vertex(vertex);
newVert.SetPosition(vertex.GetPosition().Multiply(transforms[m]));
if (vertex.GetNormal() != null)
newVert.SetNormal(vertex.GetNormal().Multiply(transforms[m].Invert().TransposeStore()));
finalVertices.Add(newVert);
}
}
resMesh.SetVertices(finalVertices);
resMesh.Material = materials[0];
resMesh.PrimitiveType = meshes[0].PrimitiveType;
}
return resMesh;
}
示例6: QuadFromLine
public Mesh QuadFromLine(Line line)
{
float width = 2f;
float scale = 2f;
Vector3f quadSize = line.To.Subtract(line.From);
float texCoordScale = ((float)System.Math.Abs(quadSize.x) + (float)System.Math.Abs(quadSize.z)) / 4;
quadSize.NormalizeStore();
Node rNode = new Node();
Mesh mesh = new Mesh();
List<Vertex> vertices = new List<Vertex>();
vertices.Add(new Vertex(new Vector3f(line.From.x - quadSize.z, line.From.y, line.From.z + quadSize.x), new Vector2f(0, 0), new Vector3f(0, 1, 0)));
vertices.Add(new Vertex(new Vector3f(line.From.x + quadSize.z, line.From.y, line.From.z - quadSize.x), new Vector2f(0, 1), new Vector3f(0, 1, 0)));
vertices.Add(new Vertex(new Vector3f(line.To.x + quadSize.z, line.To.y, line.To.z - quadSize.x), new Vector2f(texCoordScale, 1), new Vector3f(0, 1, 0)));
vertices.Add(new Vertex(new Vector3f(line.To.x + quadSize.z, line.To.y, line.To.z - quadSize.x), new Vector2f(texCoordScale, 1), new Vector3f(0, 1, 0)));
vertices.Add(new Vertex(new Vector3f(line.To.x - quadSize.z, line.To.y, line.To.z + quadSize.x), new Vector2f(texCoordScale, 0), new Vector3f(0, 1, 0)));
vertices.Add(new Vertex(new Vector3f(line.From.x - quadSize.z, line.From.y, line.From.z + quadSize.x), new Vector2f(0, 0), new Vector3f(0, 1, 0)));
mesh.SetVertices(vertices);
rNode.AddChild(new Geometry(mesh));
return mesh;
}
示例7: Load
//.........这里部分代码省略.........
faces.Add(int.Parse(xmlReader.GetAttribute(0)));
faces.Add(int.Parse(xmlReader.GetAttribute(1)));
faces.Add(int.Parse(xmlReader.GetAttribute(2)));
}
else if (useSubmeshes)
{
CurrentSubmesh().faces.Add(int.Parse(xmlReader.GetAttribute(0)));
CurrentSubmesh().faces.Add(int.Parse(xmlReader.GetAttribute(1)));
CurrentSubmesh().faces.Add(int.Parse(xmlReader.GetAttribute(2)));
}
}
else if (xmlReader.Name == "skeletonlink")
{
string parentPath = System.IO.Directory.GetParent(asset.FilePath).ToString();
string skeletonPath = parentPath + "\\" + xmlReader.GetAttribute(0) + ".xml";
skeleton = (Skeleton)AssetManager.Load(skeletonPath, OgreXmlSkeletonLoader.GetInstance());
}
else if (xmlReader.Name == "vertexboneassignment" || xmlReader.Name == "boneassignment")
{
int vidx = int.Parse(xmlReader.GetAttribute("vertexindex"));
float boneWeight = float.Parse(xmlReader.GetAttribute("weight"));
int boneIndex = int.Parse(xmlReader.GetAttribute("boneindex"));
AddToBoneAssigns(vidx, new BoneAssign(vidx, boneWeight, boneIndex));
}
else if (xmlReader.Name == "submesh")
{
useSubmeshes = true;
if (xmlReader.GetAttribute("operationtype") != null)
{
// material
Submesh sm = new Submesh();
subMeshes.Add(sm);
}
}
}
}
xmlReader.Close();
List<Vertex> vertices = new List<Vertex>();
if (!useSubmeshes)
{
LoopThrough(faces, ref vertices);
}
else
{
for (int i = subMeshes.Count - 1; i > -1; i--)
{
Submesh s = subMeshes[i];
if (s.faces.Count > 0)
LoopThrough(s.faces, ref s.vertices);
else
subMeshes.Remove(s);
}
}
if (skeleton.GetNumBones() > 0)
{
for (int i = 0; i < skeleton.GetNumBones(); i++)
skeleton.GetBone(i).SetToBindingPose();
skeleton.GetBone(0).CalculateBindingRotation();
skeleton.GetBone(0).CalculateBindingTranslation();
for (int i = 0; i < skeleton.GetNumBones(); i++)
{
skeleton.GetBone(i).StoreBindingPose();
skeleton.GetBone(i).ClearPose();
}
skeleton.GetBone(0).UpdateTransform();
}
bool hasAnimations = skeleton.GetAnimations().Count > 0;
AnimationController animControl = new AnimationController(skeleton);
Node res = new Node();
if (!useSubmeshes)
{
Mesh mesh = new Mesh();
mesh.SetSkeleton(skeleton);
mesh.SetVertices(vertices);
Geometry geom = new Geometry();
geom.Mesh = mesh;
res.AddChild(geom);
}
else
{
for (int i = 0; i < subMeshes.Count; i++)
{
Submesh sm = subMeshes[i];
Mesh mesh = new Mesh();
mesh.SetSkeleton(skeleton);
mesh.SetVertices(sm.vertices);
Geometry geom = new Geometry();
geom.Mesh = mesh;
res.AddChild(geom);
}
}
if (hasAnimations)
{
res.AddController(animControl);
}
ResetLoader();
return res;
}