getVertices() public method

public getVertices ( ) : Point3d[]
return Point3d[]
Exemplo n.º 1
0
    // Update is called once per frame
    public static void GenerateMesh(GameObject go, Material ObjMaterial, Solid mesh)
    {
        MeshFilter mf = go.GetComponent<MeshFilter> ();
        if(mf == null)
            mf = go.AddComponent<MeshFilter> ();

        Mesh tmesh = new Mesh();
        int mlen = mesh.getVertices().Length;
        Vector3 [] vertices = new Vector3[mlen];
        for(int i=0; i<mlen; i++)
        {
            Net3dBool.Point3d p = mesh.getVertices()[i];
            vertices[i] = new Vector3((float)p.x, (float)p.y, (float)p.z);
        }
        tmesh.vertices = vertices;

        tmesh.triangles = mesh.getIndices ();
        int clen = mesh.getColors ().Length;
        Color [] clrs = new Color[clen];
        for (int j=0; j<clen; j++) {
            Net3dBool.Color3f c = mesh.getColors()[j];
            clrs[j] = new Color((float)c.r, (float)c.g, (float)c.b);
        }
        tmesh.colors = clrs;
        tmesh.RecalculateNormals();
        mf.mesh = tmesh;

        MeshRenderer mr = go.GetComponent<MeshRenderer> ();
        if(mr == null) mr = go.AddComponent<MeshRenderer> ();
        mr.sharedMaterials = new Material[1];
        mr.sharedMaterials[0] = ObjMaterial;
        mr.sharedMaterial = ObjMaterial;
    }
Exemplo n.º 2
0
        //BoundsOctree<int> octree = new BoundsOctree<int>();

        /// <summary>
        /// Constructs a Object3d object based on a solid file.
        /// </summary>
        /// <param name="solid">solid used to construct the Object3d object</param>
        public CsgObject3D(Solid solid)
        {
            Vertex v1, v2, v3, vertex;

            Vector3[] verticesPoints = solid.getVertices();
            int[]     indices        = solid.getIndices();
            var       verticesTemp   = new List <Vertex>();

            AxisAlignedBoundingBox totalBounds = new AxisAlignedBoundingBox(verticesPoints[0], verticesPoints[0]);

            //create vertices
            vertices = new List <Vertex>();
            for (int i = 0; i < verticesPoints.Length; i++)
            {
                vertex = AddVertex(verticesPoints[i], FaceStatus.Unknown);
                totalBounds.ExpandToInclude(verticesPoints[i]);
                verticesTemp.Add(vertex);
            }

            //create faces
            totalBounds.Expand(1);
            Faces = new Octree <CsgFace>(5, totalBounds);
            for (int i = 0; i < indices.Length; i = i + 3)
            {
                v1 = verticesTemp[indices[i]];
                v2 = verticesTemp[indices[i + 1]];
                v3 = verticesTemp[indices[i + 2]];
                AddFace(v1, v2, v3);
            }

            //create bound
            Bounds = new AxisAlignedBoundingBox(verticesPoints);
        }
Exemplo n.º 3
0
        //----------------------------------CONSTRUCTOR---------------------------------//

        /**
         * Constructs a Object3d object based on a solid file.
         *
         * @param solid solid used to construct the Object3d object
         */
        public Object3D(Solid solid)
        {
            Vertex v1, v2, v3, vertex;

            Point3d[] verticesPoints = solid.getVertices();
            int[]     indices        = solid.getIndices();
            Color3f[] colors         = solid.getColors();
            var       verticesTemp   = new List <Vertex>();

            //create vertices
            vertices = new List <Vertex>();
            for (int i = 0; i < verticesPoints.Length; i++)
            {
                vertex = addVertex(verticesPoints[i], colors[i], Vertex.UNKNOWN);
                verticesTemp.Add(vertex);
            }

            //create faces
            faces = new List <Face>();
            for (int i = 0; i < indices.Length; i = i + 3)
            {
                v1 = verticesTemp[indices[i]];
                v2 = verticesTemp[indices[i + 1]];
                v3 = verticesTemp[indices[i + 2]];
                addFace(v1, v2, v3);
            }

            //create bound
            bound = new Bound(verticesPoints);
        }
Exemplo n.º 4
0
        //----------------------------------CONSTRUCTOR---------------------------------//

        /**
         * Constructs a Object3d object based on a solid file.
         *
         * @param solid solid used to construct the Object3d object
         */
        public Object3D(Solid solid)
        {
            Vertex v1, v2, v3, vertex;

            Point3d[] verticesPoints = solid.getVertices();
            int[]     indices        = solid.getIndices();
            Color3f[] colors         = solid.getColors();
            var       verticesTemp   = new List <Vertex>();

            Dictionary <int, int> revlookup = new Dictionary <int, int> ();

            for (int d = 0; d < indices.Length; d++)
            {
                revlookup [indices [d]] = d;
            }

            //create vertices
            vertices = new List <Vertex>();
            for (int i = 0; i < verticesPoints.Length; i++)
            {
                Color3f col = new Color3f(1, 1, 1);
                if (colors.Length > 0)
                {
                    col = colors[i];
                }

                vertex = addVertex(verticesPoints[i], col, Vertex.UNKNOWN);
                verticesTemp.Add(vertex);
            }

            //create faces
            faces = new List <Face>();
            for (int i = 0; i < indices.Length; i = i + 3)
            {
                v1 = verticesTemp[indices[i]];
                v2 = verticesTemp[indices[i + 1]];
                v3 = verticesTemp[indices[i + 2]];
                addFace(v1, v2, v3);
            }

            //create bound
            bound = new Bound(verticesPoints);
        }
Exemplo n.º 5
0
        //----------------------------------CONSTRUCTOR---------------------------------//
        /**
         * Constructs a Object3d object based on a solid file.
         *
         * @param solid solid used to construct the Object3d object
         */
        public Object3D(Solid solid)
        {
            Vertex v1, v2, v3, vertex;
            Point3d[] verticesPoints = solid.getVertices();
            int[] indices = solid.getIndices();
            Color3f[] colors = solid.getColors();
            var verticesTemp = new List<Vertex>();

            Dictionary<int,int> revlookup = new Dictionary<int, int> ();
            for (int d=0; d<indices.Length; d++)
                revlookup [indices [d]] = d;

            //create vertices
            vertices = new List<Vertex>();
            for (int i = 0; i < verticesPoints.Length; i++)
            {
                Color3f col = new Color3f(1, 1, 1);
                if(colors.Length > 0)
                    col = colors[i];

                vertex = addVertex(verticesPoints[i], col, Vertex.UNKNOWN);
                verticesTemp.Add(vertex);
            }

            //create faces
            faces = new List<Face>();
            for (int i = 0; i < indices.Length; i = i + 3)
            {
                v1 = verticesTemp[indices[i]];
                v2 = verticesTemp[indices[i + 1]];
                v3 = verticesTemp[indices[i + 2]];
                addFace(v1, v2, v3);
            }

            //create bound
            bound = new Bound(verticesPoints);
        }