示例#1
0
        private void AddToMeshesGeo(string cgfPath, CgfLoader cgf, BinaryWriter meshesGeoDataStream,
                                    byte collisionIntention)
        {
            Matrix identity = Matrix.Identity;

            // process each unique filename only once.
            if (m_loadedCgfs.Contains(cgfPath))
            {
                throw new InvalidOperationException("input should have been deduped already");
            }
            m_loadedCgfs.Add(cgfPath);

            try
            {
                // collect not empty, collidable meshes.
                var meshesPack = new List <MeshData>();
                cgf.TraverseNodes((node, m) => LoadMeshFromCgfCallback(node, m, cgf, meshesPack), ref identity);

                if (meshesPack.Count > 0)
                {
                    WriteToMeshsGeo(cgfPath, meshesPack, meshesGeoDataStream, collisionIntention);
                }
                else
                {
                    m_emptyCgfs.Add(cgfPath);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("***     ERROR: Cannot process mesh: " + e);
            }
        }
示例#2
0
        private static void AddCgfToWorld(CgfLoader cgf, ref Matrix xform,
                                          Vector3 position, GeoSpace geoSpace)
        {
            s_tempVertices.Clear();

            // traverse nodes
            cgf.TraverseNodes((node, transform) =>
                              NodeHandler(cgf, node, position, transform), ref xform);

            // Add collected vertices as a new mesh.
            geoSpace.AddCollidableMeshToTree(s_tempVertices);
        }
示例#3
0
        private void DrawCgfInWorld(CgfLoader cgf, ref Matrix xform, Vector3 position, CgfDrawStyle style,
                                    List <VertexPositionColor> vertices,
                                    List <VertexPositionColor> collisionVertices,
                                    List <VertexPositionColor> lineVertices)
        {
            // Collect collidable meshes
            int collisionStart = collisionVertices.Count;

            // traverse nodes
            cgf.TraverseNodes((node, transform)
                              => NodeHandler(cgf, node, position, transform, vertices, collisionVertices, lineVertices, style),
                              ref xform);

            // Add collected vertices as a new mesh.
            m_geoSpace.AddCollidableMeshToTree(collisionVertices, collisionStart, collisionVertices.Count - collisionStart);
        }