Ejemplo n.º 1
0
        public int[][] GetOpenGLEnvironment()
        {
            ObjImporter.meshStruct[][] loadObjects = new ObjImporter.meshStruct[ShapeFilename.Count][];

            for (int i = 0; i < ShapeFilename.Count; i++)
            {
                loadObjects[i] = new ObjImporter.meshStruct[1];

                for (int j = 0; j < 1; j++)
                {
                    loadObjects[i][j] = LoadObjMesh(ShapeFilename[i], ShapeScale[i], new Vector3d(0.0, 0.0, 0.0), 0.0);
                    if (i == 1)
                    {
                        loadObjects[i][j] = LoadObjMesh(ShapeFilename[i], ShapeScale[i], new Vector3d(1.0, 0.0, 0.0), 0.75);
                    }
                    if (i > 1)
                    {
                        loadObjects[i][j] = LoadObjMesh(ShapeFilename[i], ShapeScale[i], new Vector3d(1.0, 0.0, 0.0), 0.75);
                    }
                }
            }

            return(OpenGLUtilities.LoadGLObjects(
                       loadObjects,
                       ShapeFilename.Count,
                       true,
                       false,
                       true));
        }
        private ObjImporter.meshStruct LoadObjMesh(
            string fileName,
            double scale)
        {
            ObjImporter importer = new ObjImporter();

            ObjImporter.meshStruct mesh = importer.ImportFile(fileName);

            Vector3d[] vertexStartPoint = new Vector3d[mesh.vertices.Length];

            for (int i = 0; i < mesh.vertices.Length; i++)
            {
                vertexStartPoint[i] = mesh.vertices[i];
            }

            OpenGLUtilities.UnitizeObject(ref vertexStartPoint);
            OpenGLUtilities.ScaleObject(ref vertexStartPoint, scale);

            for (int i = 0; i < mesh.vertices.Length; i++)
            {
                mesh.vertices[i] = vertexStartPoint[i];
            }

            return(mesh);
        }
Ejemplo n.º 3
0
        public int[][] LoadTexture()
        {
            var xmlDoc = new XmlDocument();

            xmlDoc.Load(FileNameObjectProperties);

            XmlNodeList xmlList = xmlDoc.SelectNodes(nodePathObjects);

            int[][] textureID = new int[xmlList.Count][];

            for (int i = 0; i < xmlList.Count; i++)
            {
                XmlNodeList xmlGeometryList = xmlList[i].SelectNodes(nodePathGeometry);

                textureID[i] = new int[xmlGeometryList.Count];

                for (int j = 0; j < xmlGeometryList.Count; j++)
                {
                    //Object geometry file name
                    string textureFileName = xmlGeometryList[j][textureAttribute].InnerText;

                    textureID[i][j] = OpenGLUtilities.LoadTexture(textureFileName);
                }
            }

            return(textureID);
        }
        public int[][] LoadTexture()
        {
            int[][] textureID = new int[TextureFilename.Count][];

            for (int i = 0; i < TextureFilename.Count; i++)
            {
                textureID[i] = new int[1];

                for (int j = 0; j < 1; j++)
                {
                    textureID[i][j] = OpenGLUtilities.LoadTexture(TextureFilename[i]);
                }
            }
            return(textureID);
        }
Ejemplo n.º 5
0
        public int[][] LoadTexture()
        {
            int[][] textureID = new int[TextureFilename.Length][];

            for (int i = 0; i < TextureFilename.Length; i++)
            {
                textureID[i] = new int[TextureFilename[i].Length];

                for (int j = 0; j < TextureFilename[i].Length; j++)
                {
                    textureID[i][j] = OpenGLUtilities.LoadTexture(TextureFilename[i][j]);
                }
            }
            return(textureID);
        }
        private LoadResult LoadObjSolid(
            string fileName,
            float scale)
        {
            var        objLoaderFactory = new ObjLoaderFactory();
            var        objLoader        = objLoaderFactory.Create();
            var        fileStream       = new FileStream(fileName, FileMode.OpenOrCreate);
            LoadResult solid            = objLoader.Load(fileStream);

            fileStream.Close();

            OpenGLUtilities.UnitizeObject(ref solid);
            OpenGLUtilities.ScaleObject(ref solid, scale);

            return(solid);
        }
Ejemplo n.º 7
0
        public int[][] GetOpenGLEnvironment()
        {
            ObjImporter.meshStruct[][] loadObjects = new ObjImporter.meshStruct[ShapeFilename.Length][];

            for (int i = 0; i < ShapeFilename.Length; i++)
            {
                loadObjects[i] = new ObjImporter.meshStruct[ShapeFilename[i].Length];

                for (int j = 0; j < ShapeFilename[i].Length; j++)
                {
                    loadObjects[i][j] = LoadObjMesh(ShapeFilename[i][j], ShapeScale[i][j]);
                }
            }

            return(OpenGLUtilities.LoadGLObjects(
                       loadObjects,
                       ShapeFilename.Length,
                       true,
                       false,
                       true));
        }
Ejemplo n.º 8
0
        public static int[][] GetOpenGLObjectList(
            string fileName,
            double scale)
        {
            ObjImporter.meshStruct[][] loadObjects = new ObjImporter.meshStruct[1][];

            loadObjects[0] = new ObjImporter.meshStruct[1];

            loadObjects[0][0] = LoadObjSolid(fileName, scale);

            Vector3d[][] translate = new Vector3d[1][];

            translate[0] = new Vector3d[] { new Vector3d(0, 0, 0) };

            return(OpenGLUtilities.LoadGLObjects(
                       loadObjects,
                       translate,
                       1,
                       true,
                       false,
                       true));
        }
Ejemplo n.º 9
0
        public int[][] GetOpenGLObjectList()
        {
            var xmlDoc = new XmlDocument();

            xmlDoc.Load(FileNameObjectProperties);

            XmlNodeList xmlList = xmlDoc.SelectNodes(nodePathObjects);

            ObjImporter.meshStruct[][] loadObjects = new ObjImporter.meshStruct[xmlList.Count][];

            Vector3d[][] translate = new Vector3d[xmlList.Count][];

            for (int i = 0; i < xmlList.Count; i++)
            {
                XmlNodeList xmlGeometryList = xmlList[i].SelectNodes(nodePathGeometry);

                translate[i]   = new Vector3d[xmlGeometryList.Count];
                loadObjects[i] = new ObjImporter.meshStruct[xmlGeometryList.Count];

                for (int j = 0; j < xmlGeometryList.Count; j++)
                {
                    //Object geometry file name
                    string geometryFileName = xmlGeometryList[j][objectGeometryAttribute].InnerText;

                    //Scale
                    float scale = Convert.ToSingle(xmlGeometryList[j][scaleAttribute].InnerText);

                    loadObjects[i][j] = LoadObjSolid(geometryFileName, scale);
                }
            }

            return(OpenGLUtilities.LoadGLObjects(
                       loadObjects,
                       translate,
                       xmlList.Count,
                       true,
                       false,
                       true));
        }