示例#1
0
        public RTSUnitModel(RTSRenderer renderer, Stream sModel, Texture2D tAnim)
        {
            // Create With The Animation Texture
            AnimationTexture = tAnim;

            // Parse The Model File
            VertexPositionNormalTexture[] pVerts;
            VertexPositionTexture[]       verts;
            int[] inds;
            if (!ObjParser.TryParse(sModel, out pVerts, out inds, MODEL_READ_FLAGS))
            {
                throw new ArgumentException("Bad Model File Format");
            }

            // Reformat Vertices
            verts = new VertexPositionTexture[pVerts.Length];
            for (int i = 0; i < verts.Length; i++)
            {
                verts[i].Position          = new Vector3((float)((i + 0.1) / AnimationTexture.Width), 0, 0);
                verts[i].TextureCoordinate = pVerts[i].TextureCoordinate;
            }

            // Create Model Geometry
            RTSModelHelper.CreateBuffers(renderer, verts, VertexPositionTexture.VertexDeclaration, inds, out vbModel, out ibModel, BufferUsage.WriteOnly);
        }
示例#2
0
        public RTSBuildingModel(RTSRenderer renderer, Stream sModel)
        {
            // Parse The Model File
            VertexPositionNormalTexture[] pVerts;
            VertexPositionTexture[]       verts;
            int[] inds;
            if (!ObjParser.TryParse(sModel, out pVerts, out inds, MODEL_READ_FLAGS))
            {
                throw new ArgumentException("Bad Model File Format");
            }
            verts = new VertexPositionTexture[pVerts.Length];
            for (int i = 0; i < verts.Length; i++)
            {
                verts[i].Position          = pVerts[i].Position;
                verts[i].TextureCoordinate = pVerts[i].TextureCoordinate;
            }

            // Create Model Geometry
            RTSModelHelper.CreateBuffers(renderer, verts, VertexPositionTexture.VertexDeclaration, inds, out vbModel, out ibModel, BufferUsage.WriteOnly);
        }