private void LoadMeshFromCgfCallback(NodeData node, Matrix m, CgfLoader cgf, List <MeshData> meshesPack) { if (node.Mesh.vertices.Length <= 0 || node.Mesh.indices.Length <= 0) { //VERBOSE Console.WriteLine(" Skipping (empty): " + node.Mesh.vertices.Length + "/" + node.Mesh.indices.Length); } /*else if ((node.Mesh.vertices.Length & 0xffff0000) != 0 || ((node.Mesh.indices.Length * 3) & 0xffff0000) != 0) || { || Console.WriteLine("*** ERROR: Count of elements is bigger than MAX_SHORT"); || Console.WriteLine(" Skipping: " + node.Mesh.vertices.Length + "/" + node.Mesh.indices.Length * 3 + " [" + node.Mesh.indices.Length + " * 3]"); + }*/ else if (!cgf.IsNodeCollidable(node)) { //VERBOSE Console.WriteLine(" Skipping (not collidable): " + node.Mesh.vertices.Length + "/" + node.Mesh.indices.Length); } else { // transform the node into object coordinates. indices stay the same. var xformMesh = new MeshData(); xformMesh.vertices = new Vector3[node.Mesh.vertices.Length]; Vector3.Transform(node.Mesh.vertices, ref m, xformMesh.vertices); xformMesh.indices = node.Mesh.indices; meshesPack.Add(xformMesh); } }
private void NodeHandler(CgfLoader cgf, NodeData node, Vector3 worldPosition, Matrix transform, List <VertexPositionColor> vertices, List <VertexPositionColor> collisionVertices, List <VertexPositionColor> lineVertices, CgfDrawStyle style) { var hackackack = true; //Debug.WriteLine($"NODE {transform.Translation} === {node.chunkId}"); bool isNodeCollidable = cgf.IsNodeCollidable(node); foreach (var vi in node.Mesh.indices) { var v0 = Vector3.Transform(node.Mesh.vertices[vi.v0], transform); var v1 = Vector3.Transform(node.Mesh.vertices[vi.v1], transform); var v2 = Vector3.Transform(node.Mesh.vertices[vi.v2], transform); if (hackackack && DOOR_HACK) { m_renderData.labels.Add(new Label3D { position = v0, text = node.objectId.ToString() }); hackackack = false; } Color color = NodeColorizer(style, isNodeCollidable, vi.v0); var dest = isNodeCollidable ? collisionVertices : vertices; dest.Add(new VertexPositionColor(v1, color)); dest.Add(new VertexPositionColor(v0, color)); dest.Add(new VertexPositionColor(v2, color)); } var zero = Vector3.Transform(Vector3.Zero, transform); lineVertices.Add(new VertexPositionColor(zero, Color.Blue)); lineVertices.Add(new VertexPositionColor(Vector3.Transform(Vector3.UnitX, transform), Color.Blue)); lineVertices.Add(new VertexPositionColor(zero, Color.Red)); lineVertices.Add(new VertexPositionColor(Vector3.Transform(Vector3.UnitY, transform), Color.Red)); lineVertices.Add(new VertexPositionColor(zero, Color.Yellow)); lineVertices.Add(new VertexPositionColor(Vector3.Transform(Vector3.UnitZ, transform), Color.Yellow)); lineVertices.Add(new VertexPositionColor(worldPosition, Color.Cyan)); lineVertices.Add(new VertexPositionColor(zero, Color.Cyan)); }
private static void NodeHandler(CgfLoader cgf, NodeData node, Vector3 worldPosition, Matrix transform) { if (!cgf.IsNodeCollidable(node)) { return; } foreach (var vi in node.Mesh.indices) { var v0 = Vector3.Transform(node.Mesh.vertices[vi.v0], transform); var v1 = Vector3.Transform(node.Mesh.vertices[vi.v1], transform); var v2 = Vector3.Transform(node.Mesh.vertices[vi.v2], transform); s_tempVertices.Add(v1); s_tempVertices.Add(v0); s_tempVertices.Add(v2); } }