Ejemplo n.º 1
0
        public void DrawFace(WavefrontObject meshObj, WavefrontFace face, Shader shader)
        {
            //WavefontFace是一个triangle fan
            //可能会有多个三角形;这些三角形共用第一个顶点做v0
            if (face.Vertices.Count < 3)
            {
                Debug.Assert(false);
                return;
            }
            Vertex   vertex0 = Vertex.FromWavefrontVertex(meshObj, face.Vertices[0]);
            VSOutput vClip0  = shader.VertShader(vertex0);

            context.statics.vertexCount += 1;

            for (int i = 1; i + 1 < face.Vertices.Count; i += 1)
            {
                Vertex vertex1 = Vertex.FromWavefrontVertex(meshObj, face.Vertices[i]);
                Vertex vertex2 = Vertex.FromWavefrontVertex(meshObj, face.Vertices[i + 1]);
                //顶点着色器
                VSOutput vClip1 = shader.VertShader(vertex1);
                VSOutput vClip2 = shader.VertShader(vertex2);
                context.statics.vertexCount += 2;
                DrawTriangle(vClip0, vClip1, vClip2);
            }
        }
Ejemplo n.º 2
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Material newMaterial = new Material(_materialName, _fileName);

            wavefrontObject.Materials.Add(_materialName, newMaterial);
            wavefrontObject.CurrentMaterial = newMaterial;
        }
Ejemplo n.º 3
0
        /*
         * public void DrawGameObject(GameObject gameobject, Shader shader)
         * {
         *  context.statics.meshCount += 1;
         *
         *  //设置Shader相关
         *  Transform transform = gameobject.transform;
         *  Matrix4x4 modelMatrix = transform.ModelToWorld;
         *  shader.SetModelMatrix(modelMatrix);
         *
         *  Texture texture = gameobject.texture;
         *  shader.texture = texture;
         *  rasterizer.shader = shader;
         *
         *  WavefrontObject meshObj = gameobject.meshObj;
         *
         *  foreach( var faceGroup in meshObj.Groups)
         *  {
         *      context.statics.submeshCount += 1;
         *      //faceGroup相当于submesh
         *      foreach( var face in faceGroup.Faces )
         *      {
         *          //face为triangle fan;可能会有多个三角形
         *          Debug.Assert(face.Vertices.Count > 2);
         *          Vertex vertex0 = Vertex.FromWavefrontVertex(meshObj, face.Vertices[0]);
         *          context.statics.vertexCount += 1;
         *          VSOutput vClip0 = shader.VertShader(vertex0);
         *          //TODO 做Clipping
         *          VSOutput vNDC0 = Rasterizer.PerspectiveDivide(vClip0);
         *          if(vNDC0 == null)
         *          {
         *              continue;
         *          }
         *          VSOutput vScreen0 = rasterizer.ViewportTransform(vNDC0);
         *
         *          for ( int i = 1; i+1 < face.Vertices.Count; i+=1)
         *          {
         *              context.statics.vertexCount += 2;
         *              Vertex vertex1 = Vertex.FromWavefrontVertex(meshObj, face.Vertices[i]);
         *              Vertex vertex2 = Vertex.FromWavefrontVertex(meshObj, face.Vertices[i+1]);
         *
         *              VSOutput vClip1 = shader.VertShader(vertex1);
         *              VSOutput vClip2 = shader.VertShader(vertex2);
         *              if (!FrontEndCulling(vClip0, vClip1, vClip2))
         *              {
         *                  continue;
         *              }
         *
         *              VSOutput vNDC1 = Rasterizer.PerspectiveDivide(vClip1);
         *              VSOutput vNDC2 = Rasterizer.PerspectiveDivide(vClip2);
         *              if(vNDC1 == null || vNDC2 == null)
         *              {
         *                  continue;
         *              }
         *              VSOutput vScreen1 = rasterizer.ViewportTransform(vNDC1);
         *              VSOutput vScreen2 = rasterizer.ViewportTransform(vNDC2);
         *
         *              context.statics.triangleCount += 1;
         *              rasterizer.RasterizeTriangle(vScreen0, vScreen1, vScreen2);
         *          }
         *      }
         *
         *  }
         *
         *  rasterizer.shader = null;
         *
         *
         *
         * }
         */
        public void DrawGameObject(GameObject gameobject, Shader shader)
        {
            WavefrontObject meshObj = gameobject.meshObj;

            if (meshObj == null)
            {
                return;
            }
            context.statics.meshCount += 1;

            //设置Shader相关
            Transform transform   = gameobject.transform;
            Matrix4x4 modelMatrix = transform.ModelToWorld;

            shader.SetModelMatrix(modelMatrix);

            Texture texture = gameobject.texture;

            shader.texture    = texture;
            rasterizer.shader = shader;


            foreach (var faceGroup in meshObj.Groups)
            {
                context.statics.submeshCount += 1;
                //faceGroup相当于submesh
                foreach (var face in faceGroup.Faces)
                {
                    DrawFace(meshObj, face, shader);
                }
            }

            rasterizer.shader = null;
        }
Ejemplo n.º 4
0
        private static Mesh CreateMesh(WavefrontObject obj)
        {
            var builder = new MeshBuilder(obj);

            foreach (var objGroup in obj.Groups)
            {
                foreach (var face in objGroup.Faces)
                {
                    builder.SetMaterial(face.Material);
                    // TODO: add support for Concave faces (triangles done this way might overlap)

                    // RH
                    // 1st face => vertex 0, 1, 2
                    // 2nd face => vertex 0, 2, 3
                    // 3rd face => vertex 0, 4, 5
                    // 4th face => ...

                    var vertices = face.Vertices;
                    // more than 3 vertices per face, we need to triangulate the face to be able to use it in the engine.
                    for (var i = 2; i < vertices.Length; ++i)
                    {
                        builder.AddVertex(vertices[0]);
                        //Flip the order to convert from RH to LH (d3d)
                        builder.AddVertex(vertices[i]);
                        builder.AddVertex(vertices[i - 1]);
                    }
                }
            }
            return(builder.Build());
        }
Ejemplo n.º 5
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Material newMaterial = new Material(_materialName, _fileName);

            wavefrontObject.Materials.Add(_materialName, newMaterial);
            wavefrontObject.CurrentMaterial = newMaterial;
        }
Ejemplo n.º 6
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Group group = wavefrontObject.CurrentGroup;

            if (group == null)
            {
                group = new Group();
                wavefrontObject.Groups.Add(group);
                wavefrontObject.CurrentGroup = group;
            }

            if (vertices.Length == 3)
            {
                // Add list of vertex/normal/texcoord to current group
                // Each object keeps a list of its own data, apart from the global list
                group.Vertices.Add(this.vertices[0]);
                group.Vertices.Add(this.vertices[1]);
                group.Vertices.Add(this.vertices[2]);
                group.Normals.Add(this.normals[0]);
                group.Normals.Add(this.normals[1]);
                group.Normals.Add(this.normals[2]);
                group.TextureCoordinates.Add(this.textures[0]);
                group.TextureCoordinates.Add(this.textures[1]);
                group.TextureCoordinates.Add(this.textures[2]);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);	// create index list for current object
            }
            else
            {
                // Add list of vertex/normal/texcoord to current group
                // Each object keeps a list of its own data, apart from the global list
                group.Vertices.Add(this.vertices[0]);
                group.Vertices.Add(this.vertices[1]);
                group.Vertices.Add(this.vertices[2]);
                group.Vertices.Add(this.vertices[3]);
                group.Normals.Add(this.normals[0]);
                group.Normals.Add(this.normals[1]);
                group.Normals.Add(this.normals[2]);
                group.Normals.Add(this.normals[3]);
                group.TextureCoordinates.Add(this.textures[0]);
                group.TextureCoordinates.Add(this.textures[1]);
                group.TextureCoordinates.Add(this.textures[2]);
                group.TextureCoordinates.Add(this.textures[3]);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);	// create index list for current object
            }

            face.VertexIndices = vindices;
            face.NormalIndices = nindices;
            face.TextureIndices = tindices;
            face.Normals = normals;
            face.Vertices = vertices;
            face.TextureCoordinates = textures;

            wavefrontObject.CurrentGroup.AddFace(face);
        }
Ejemplo n.º 7
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Group group = wavefrontObject.CurrentGroup;

            if (group == null)
            {
                group = new Group();
                wavefrontObject.Groups.Add(group);
                wavefrontObject.CurrentGroup = group;
            }

            if (_vertices.Length == 3)
            {
                // Add list of vertex/normal/texcoord to current group.
                // Each object keeps a list of its own data, apart from the global list.
                group.Vertices.Add(_vertices[0]);
                group.Vertices.Add(_vertices[1]);
                group.Vertices.Add(_vertices[2]);
                group.Normals.Add(_normals[0]);
                group.Normals.Add(_normals[1]);
                group.Normals.Add(_normals[2]);
                group.TextureCoordinates.Add(_textures[0]);
                group.TextureCoordinates.Add(_textures[1]);
                group.TextureCoordinates.Add(_textures[2]);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);                  // create index list for current object
            }
            else
            {
                // Add list of vertex/normal/texcoord to current group.
                // Each object keeps a list of its own data, apart from the global list.
                group.Vertices.Add(_vertices[0]);
                group.Vertices.Add(_vertices[1]);
                group.Vertices.Add(_vertices[2]);
                group.Vertices.Add(_vertices[3]);
                group.Normals.Add(_normals[0]);
                group.Normals.Add(_normals[1]);
                group.Normals.Add(_normals[2]);
                group.Normals.Add(_normals[3]);
                group.TextureCoordinates.Add(_textures[0]);
                group.TextureCoordinates.Add(_textures[1]);
                group.TextureCoordinates.Add(_textures[2]);
                group.TextureCoordinates.Add(_textures[3]);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);
                group.Indices.Add(group.IndexCount++);                  // create index list for current object
            }

            _face.VertexIndices      = _vindices;
            _face.NormalIndices      = _nindices;
            _face.TextureIndices     = _tindices;
            _face.Normals            = _normals;
            _face.Vertices           = _vertices;
            _face.TextureCoordinates = _textures;

            wavefrontObject.CurrentGroup.AddFace(_face);
        }
Ejemplo n.º 8
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            if (wavefrontObject.CurrentGroup != null)
                wavefrontObject.CurrentGroup.Pack();

            wavefrontObject.Groups.Add(_newGroup);

            wavefrontObject.CurrentGroup = _newGroup;
        }
Ejemplo n.º 9
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            if (wavefrontObject.CurrentGroup != null)
            {
                wavefrontObject.CurrentGroup.Pack();
            }

            wavefrontObject.Groups.Add(_newGroup);
            wavefrontObject.CurrentGroup = _newGroup;
        }
Ejemplo n.º 10
0
 public MtlLineParserFactory(WavefrontObject @object)
     : base(@object)
 {
     Parsers.Add("newmtl", new MaterialParser());
     Parsers.Add("Ka", new KaParser());
     Parsers.Add("Kd", new KdParser());
     Parsers.Add("Ks", new KsParser());
     Parsers.Add("Ns", new NsParser());
     Parsers.Add("map_Kd", new KdMapParser(@object));
     Parsers.Add("#", new CommentParser());
 }
 public MtlLineParserFactory(WavefrontObject @object)
     : base(@object)
 {
     Parsers.Add("newmtl", new MaterialParser());
     Parsers.Add("Ka", new AmbientColorParser());
     Parsers.Add("Kd", new DiffuseColorParser());
     Parsers.Add("Ks", new SpecularColorParser());
     Parsers.Add("Ns", new SpecularExponentParser());
     Parsers.Add("map_Kd", new TextureNameParser(@object));
     Parsers.Add("#", new CommentParser());
 }
Ejemplo n.º 12
0
        public void CanParseStyle7()
        {
            WavefrontObject wavefrontObject = new WavefrontObject();

            wavefrontObject.Vertices.Add(new Vector3());
            wavefrontObject.Normals.Add(new Vector3());
            const string line   = "f 1 1 1";
            FaceParser   parser = (FaceParser) new ObjLineParserFactory(wavefrontObject).GetLineParser(line);

            parser.Parse();
        }
Ejemplo n.º 13
0
 public MtlLineParserFactory(WavefrontObject @object)
     : base(@object)
 {
     Parsers.Add("newmtl", new MaterialParser());
     Parsers.Add("Ka", new KaParser());
     Parsers.Add("Kd", new KdParser());
     Parsers.Add("Ks", new KsParser());
     Parsers.Add("Ns", new NsParser());
     Parsers.Add("map_Kd", new KdMapParser(@object));
     Parsers.Add("#", new CommentParser());
 }
Ejemplo n.º 14
0
 public ObjLineParserFactory(WavefrontObject @object)
     : base(@object)
 {
     Parsers.Add("v", new VertexParser());
     Parsers.Add("vn", new NormalParser());
     Parsers.Add("vp", new FreeFormParser());
     Parsers.Add("vt", new TextureCoordinateParser());
     Parsers.Add("f", new FaceParser(@object));
     Parsers.Add("#", new CommentParser());
     Parsers.Add("mtllib", new MaterialFileParser(@object));
     Parsers.Add("usemtl", new MaterialParser());
     Parsers.Add("g", new GroupParser());
 }
Ejemplo n.º 15
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            if (!wavefrontObject.Materials.ContainsKey(_materialName))
                return;

            Material newMaterial = wavefrontObject.Materials[_materialName];

            // CurrentGroup could be null at this point - this is allowed by the OBJ spec.
            if (wavefrontObject.CurrentGroup == null)
                wavefrontObject.CurrentGroup = new Group();

            wavefrontObject.CurrentGroup.Material = newMaterial;
        }
Ejemplo n.º 16
0
        public void CanParseStyle6()
        {
            // Arrange.
            WavefrontObject wavefrontObject = new WavefrontObject();

            wavefrontObject.Vertices.Add(new Vertex());
            wavefrontObject.Normals.Add(new Vertex());
            const string line   = "f 1/1 1/1 1/1 1/1";
            FaceParser   parser = (FaceParser) new ObjLineParserFactory(wavefrontObject).GetLineParser(line);

            // Act.
            parser.Parse();
        }
Ejemplo n.º 17
0
 public ObjLineParserFactory(WavefrontObject @object)
     : base(@object)
 {
     Parsers.Add("v", new VertexParser());
     Parsers.Add("vn", new NormalParser());
     Parsers.Add("vp", new FreeFormParser());
     Parsers.Add("vt", new TextureCoordinateParser());
     Parsers.Add("f", new FaceParser(@object));
     Parsers.Add("#", new CommentParser());
     Parsers.Add("mtllib", new MaterialFileParser(@object));
     Parsers.Add("usemtl", new MaterialParser());
     Parsers.Add("g", new GroupParser());
 }
Ejemplo n.º 18
0
        //材质
        //public static Material mat = new Material(new Color(0, 0, 0.1f), 0.1f, new Color(0.3f, 0.3f, 0.3f), new Color(1, 1, 1), 99);


        public static WavefrontObject ToWavefrontObject()
        {
            WavefrontObject obj = new WavefrontObject();

            for (int i = 0; i < CubeTestData.pointList.Length; ++i)
            {
                Vector3 point = CubeTestData.pointList[i];
                obj.Positions.Add(point);
            }
            for (int i = 0; i < CubeTestData.normals.Length; ++i)
            {
                Vector3 normal = CubeTestData.normals[i];
                obj.Normals.Add(normal);
            }
            for (int i = 0; i < CubeTestData.uvs.Length; ++i)
            {
                Vector2 uv = CubeTestData.uvs[i];
                obj.Texcoords.Add(uv);
            }
            for (int i = 0; i < CubeTestData.vertColors.Length; ++i)
            {
                Vector4 color = new Vector4(CubeTestData.vertColors[i], 1);
                obj.Colors.Add(color);
            }

            //处理三角形
            WavefrontFaceGroup faceGroup = new WavefrontFaceGroup();

            obj.Groups.Add(faceGroup);
            for (int i = 0; i + 2 < CubeTestData.indexs.Length; i += 3)
            {
                WavefrontFace face = new WavefrontFace();
                faceGroup.Faces.Add(face);
                int             index0 = i;
                int             index1 = i + 1;
                int             index2 = i + 2;
                int             p0     = CubeTestData.indexs[i];
                int             p1     = CubeTestData.indexs[i + 1];
                int             p2     = CubeTestData.indexs[i + 2];
                WavefrontVertex v0     = new WavefrontVertex(p0 + 1, index0 + 1, index0 + 1);
                WavefrontVertex v1     = new WavefrontVertex(p1 + 1, index1 + 1, index1 + 1);
                WavefrontVertex v2     = new WavefrontVertex(p2 + 1, index2 + 1, index2 + 1);
                v0.Color = index0 + 1;
                v1.Color = index1 + 1;
                v2.Color = index2 + 1;
                face.Vertices.Add(v0);
                face.Vertices.Add(v1);
                face.Vertices.Add(v2);
            }
            return(obj);
        }
Ejemplo n.º 19
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            if (!wavefrontObject.Materials.ContainsKey(_materialName))
            {
                return;
            }

            Material newMaterial = wavefrontObject.Materials[_materialName];

            // CurrentGroup could be null at this point - this is allowed by the OBJ spec.
            if (wavefrontObject.CurrentGroup == null)
            {
                wavefrontObject.CurrentGroup = new Group();
            }

            wavefrontObject.CurrentGroup.Material = newMaterial;
        }
Ejemplo n.º 20
0
        public static Vertex FromWavefrontVertex(WavefrontObject obj, WavefrontVertex v)
        {
            Vertex vertex = new Vertex();

            vertex.position = new Vector4(obj.Positions[v.Position - 1], 1f);
            if (v.Normal > 0)
            {
                vertex.normal = new Vector4(obj.Normals[v.Normal - 1], 0f);
            }
            vertex.texcoord = obj.Texcoords[v.Texcoord - 1];
            if (v.Color >= 0 && v.Color < obj.Colors.Count)
            {
                vertex.color = obj.Colors[v.Color - 1];
            }
            else
            {
                vertex.color = Vector4.One;
            }
            return(vertex);
        }
Ejemplo n.º 21
0
 public MaterialFileParser(WavefrontObject @object)
 {
     _object        = @object;
     _parserFactory = new MtlLineParserFactory(@object);
 }
Ejemplo n.º 22
0
 protected LineParserFactory(WavefrontObject @object)
 {
     Object = @object;
 }
Ejemplo n.º 23
0
 public KdMapParser(WavefrontObject @object)
 {
     _object = @object;
 }
Ejemplo n.º 24
0
 public FaceParser(WavefrontObject @object)
 {
     _object = @object;
 }
Ejemplo n.º 25
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     Material currentMaterial = wavefrontObject.CurrentMaterial;
     currentMaterial.Shininess = _ns;
 }
Ejemplo n.º 26
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     Material currentMaterial = wavefrontObject.CurrentMaterial;
     currentMaterial.Ka = _ka;
 }
Ejemplo n.º 27
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     wavefrontObject.Textures.Add(_coordinate);
 }
Ejemplo n.º 28
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
 }
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     wavefrontObject.Textures.Add(_coordinate);
 }
Ejemplo n.º 30
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            MaterialBase currentMaterial = wavefrontObject.CurrentMaterial;

            currentMaterial.AmbientColor = _ambientColor;
        }
Ejemplo n.º 31
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
 }
Ejemplo n.º 32
0
 public MaterialFileParser(WavefrontObject @object)
 {
     _object = @object;
     parserFactory = new MtlLineParserFactory(@object);
 }
Ejemplo n.º 33
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            MaterialBase currentMaterial = wavefrontObject.CurrentMaterial;

            currentMaterial.SpecularExponent = _specularExponent;
        }
Ejemplo n.º 34
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     // Material are directly added by the parser, no need to do anything here...
 }
Ejemplo n.º 35
0
 protected LineParserFactory(WavefrontObject @object)
 {
     Object = @object;
 }
Ejemplo n.º 36
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Material currentMaterial = wavefrontObject.CurrentMaterial;

            currentMaterial.Shininess = _ns;
        }
Ejemplo n.º 37
0
        public override Scene ImportFile(FileStream fileStream, string fileName)
        {
            WavefrontObject wavefrontObject = WavefrontObject.Load(fileName);

            Material defaultMaterial = new Material
            {
                Name          = "Default",
                DiffuseColor  = ColorsRgbF.Gray,
                SpecularColor = ColorsRgbF.White,
                Shininess     = 64
            };

            Scene scene = new Scene();

            foreach (Group g in wavefrontObject.Groups)
            {
                Mesh mesh = new Mesh();
                scene.Meshes.Add(mesh);

                Objects.Material gm = g.Material;

                Material material;
                if (gm != null)
                {
                    material = new Material
                    {
                        Name     = gm.Name,
                        FileName = gm.FileName
                    };
                    // material.Ambient

                    if (!string.IsNullOrEmpty(gm.TextureName))
                    {
                        material.DiffuseTextureName = gm.TextureName;
                    }
                    else
                    {
                        material.DiffuseColor = (gm.Kd != null)
                                                        ? new ColorRgbF(gm.Kd.X, gm.Kd.Y, gm.Kd.Z)
                                                        : ColorsRgbF.Gray;
                    }

                    material.SpecularColor = (gm.Ks != null)
                                                ? new ColorRgbF(gm.Ks.X, gm.Ks.Y, gm.Ks.Z)
                                                : ColorsRgbF.Black;
                    material.Shininess = (int)gm.Shininess;                     // TODO: Check
                }
                else
                {
                    material = defaultMaterial;
                }
                mesh.Material = material;
                if (!scene.Materials.Contains(material))
                {
                    scene.Materials.Add(material);
                }

                // Currently this is not utilising indices.
                int counter = 0;
                foreach (Face f in g.Faces)
                {
                    // Copy normals.
                    foreach (int normalIndex in f.NormalIndices)
                    {
                        Vertex n = wavefrontObject.Normals[normalIndex];
                        mesh.Normals.Add(new Vector3D(n.X, n.Y, n.Z));
                    }

                    // Copy normals.
                    foreach (int textureIndex in f.TextureIndices)
                    {
                        TextureCoordinate tc = wavefrontObject.Textures[textureIndex];
                        mesh.TextureCoordinates.Add(new Point3D(tc.U, tc.V, tc.W));
                    }

                    switch (f.Type)
                    {
                    case FaceType.Triangles:
                        // Copy positions.
                        foreach (int vertexIndex in f.VertexIndices)
                        {
                            Vertex v = wavefrontObject.Vertices[vertexIndex];
                            mesh.Positions.Add(new Point3D(v.X, v.Y, v.Z));
                        }
                        mesh.Indices.Add(counter++);
                        mesh.Indices.Add(counter++);
                        mesh.Indices.Add(counter++);
                        //mesh.Indices.AddRange(f.VertexIndices);
                        break;

                    default:
                        throw new NotSupportedException();
                    }
                }

                /*foreach (Vertex v in wavefrontObject.Vertices)
                 *      mesh.Positions.Add(new Point3D(v.X, v.Y, v.Z));
                 *
                 * foreach (Vertex v in wavefrontObject.Normals)
                 *      mesh.Normals.Add(new Vector3D(v.X, v.Y, v.Z));
                 *
                 * foreach (TextureCoordinate tc in wavefrontObject.Textures)
                 *      mesh.TextureCoordinates.Add(new Point3D(tc.U, tc.V, 0));*/
            }

            return(scene);
        }
Ejemplo n.º 38
0
 public abstract void IncorporateResults(WavefrontObject wavefrontObject);
Ejemplo n.º 39
0
 public TexturedVertexMapper(WavefrontObject model)
 {
     _model = model;
 }
Ejemplo n.º 40
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     wavefrontObject.Normals.Add(_normal);
 }
Ejemplo n.º 41
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Material currentMaterial = wavefrontObject.CurrentMaterial;

            currentMaterial.Kd = _kd;
        }
Ejemplo n.º 42
0
 public KdMapParser(WavefrontObject @object)
 {
     _object = @object;
 }
Ejemplo n.º 43
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     wavefrontObject.Vertices.Add(_vertex);
 }
Ejemplo n.º 44
0
        public override void IncorporateResults(WavefrontObject wavefrontObject)
        {
            Material currentMaterial = wavefrontObject.CurrentMaterial;

            currentMaterial.TextureName = _fullTextureFileName;
        }
Ejemplo n.º 45
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     Material currentMaterial = wavefrontObject.CurrentMaterial;
     currentMaterial.TextureName = _fullTextureFileName;
 }
Ejemplo n.º 46
0
 public override void IncorporateResults(WavefrontObject wavefrontObject)
 {
     // Material are directly added by the parser, no need to do anything here...
 }
Ejemplo n.º 47
0
 public MeshBuilder(WavefrontObject obj)
 {
     _obj = obj;
 }
Ejemplo n.º 48
0
 public abstract void IncorporateResults(WavefrontObject wavefrontObject);