Ejemplo n.º 1
0
        public IComplexGeometry Clone()
        {
            Mesh <TVertex>            newMesh    = new Mesh <TVertex>(mesh.vertices);
            Indices                   newIndices = indices.Clone();
            ComplexGeometry <TVertex> newGeom    = new ComplexGeometry <TVertex>(newMesh, newIndices);

            return(newGeom);
        }
Ejemplo n.º 2
0
        static public IComplexGeometry CreateIcosphere(int subDivisions)
        {
            Vertex3DColor[] verts  = new Vertex3DColor[12];
            Vector4         color  = new Vector4(0.2f, 0.2f, 1.0f, 1.0f);
            Vector4         color2 = new Vector4(1.0f, 0.2f, 1.0f, 1.0f);
            Vector4         color3 = new Vector4(0.2f, 1.0f, 1.0f, 1.0f);

            const float t = 1.61803398875f;                                                 // approximation of golden ratio

            verts[0] = new Vertex3DColor(Vector3.Normalize(new Vector3(-1, t, 0)), color2); // Subdivision generates Sierpinski triangle at pole
            verts[1] = new Vertex3DColor(Vector3.Normalize(new Vector3(1, t, 0)), color);
            verts[2] = new Vertex3DColor(Vector3.Normalize(new Vector3(-1, -t, 0)), color);
            verts[3] = new Vertex3DColor(Vector3.Normalize(new Vector3(1, -t, 0)), color3); // Subdivision generates Sierpinski triangle at other pole

            verts[4] = new Vertex3DColor(Vector3.Normalize(new Vector3(0, -1, t)), color);
            verts[5] = new Vertex3DColor(Vector3.Normalize(new Vector3(0, 1, t)), color);
            verts[6] = new Vertex3DColor(Vector3.Normalize(new Vector3(0, -1, -t)), color);
            verts[7] = new Vertex3DColor(Vector3.Normalize(new Vector3(0, 1, -t)), color);

            verts[8]  = new Vertex3DColor(Vector3.Normalize(new Vector3(t, 0, -1)), color);
            verts[9]  = new Vertex3DColor(Vector3.Normalize(new Vector3(t, 0, 1)), color);
            verts[10] = new Vertex3DColor(Vector3.Normalize(new Vector3(-t, 0, -1)), color);
            verts[11] = new Vertex3DColor(Vector3.Normalize(new Vector3(-t, 0, 1)), color);
            var mesh    = new Mesh <Vertex3DColor>(verts);
            var indices = new List <uint>();

            AddIndices(ref indices, 0, 1, 7);
            AddIndices(ref indices, 0, 5, 1);
            AddIndices(ref indices, 0, 11, 5);
            AddIndices(ref indices, 0, 10, 11);
            AddIndices(ref indices, 0, 7, 10);

            AddIndices(ref indices, 1, 5, 9);
            AddIndices(ref indices, 5, 4, 9);
            AddIndices(ref indices, 5, 11, 4);
            AddIndices(ref indices, 11, 2, 4);
            AddIndices(ref indices, 11, 10, 2);

            AddIndices(ref indices, 10, 6, 2);
            AddIndices(ref indices, 10, 7, 6);
            AddIndices(ref indices, 7, 8, 6);
            AddIndices(ref indices, 7, 1, 8);
            AddIndices(ref indices, 1, 9, 8);

            AddIndices(ref indices, 3, 4, 2);
            AddIndices(ref indices, 3, 2, 6);
            AddIndices(ref indices, 3, 6, 8);
            AddIndices(ref indices, 3, 8, 9);
            AddIndices(ref indices, 3, 9, 4);

            var geometry  = new ComplexGeometry <Vertex3DColor>(mesh, indices.ToArray());
            int vertCount = geometry.SubDivide(subDivisions);

            return(geometry);
        }
Ejemplo n.º 3
0
        public void Update()
        {
            camera.Update();

            worldRenderGeometry = world.geometry.GenerateDualMesh <Vertex3DColorUV>();
            borderGeometry      = world.plates.GenerateBorderGeometry <Vertex3DColor>();
            borderRenderer.Update(borderGeometry);
            worldRenderer.Update(worldRenderGeometry);
            worldVertsDebugRenderer.Update(world.geometry);

            ComplexGeometry <Vertex3D> centroidGeom = new ComplexGeometry <Vertex3D>(world.geometry.GenerateCentroidPointMesh())
            {
                PrimitiveType = PrimitiveType.Points
            };

            worldCentroidDebugRenderer.Update(centroidGeom);
            var spinGeom = world.plates.GenerateSpinDriftDebugGeom(true);

            worldPlateSpinDebugRenderer.Update(spinGeom);
            spinGeom = world.plates.GenerateSpinDriftDebugGeom(false);
            worldPlateDriftDebugRenderer.Update(spinGeom);
        }
Ejemplo n.º 4
0
        public IComplexGeometry ClonePosition <TVertex2>() where TVertex2 : struct, IVertex
        {
            TVertex2[] newVerts = new TVertex2[mesh.vertices.Length];
            int        index    = 0;

            foreach (var iter in mesh.vertices)
            {
                TVertex vertex = iter;
                Vector3 pos    = MeshAttr.GetPosition(ref vertex);
                newVerts[index] = new TVertex2();
                MeshAttr.SetPosition(ref newVerts[index], ref pos);
                index++;
            }
            Mesh <TVertex2> newMesh    = new Mesh <TVertex2>(newVerts);
            Indices         newIndices = null;

            if (indices != null)
            {
                newIndices = indices.Clone();
            }
            ComplexGeometry <TVertex2> newGeom = new ComplexGeometry <TVertex2>(newMesh, newIndices);

            return(newGeom);
        }