Example #1
0
        public DoubleFloorModel(EntityInfo entity, GraphicsDevice graphicsDevice) : base(entity, graphicsDevice)
        {
            if (ModelVertices.Count > 0)
            {
                Setup();
                return;
            }

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.5f), Vector3.Up, new Vector2(0, 1)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, -0.5f), Vector3.Up, new Vector2(0, 0)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, -0.5f), Vector3.Up, new Vector2(1, 0)));

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, -0.5f), Vector3.Up, new Vector2(1, 0)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, 0.5f), Vector3.Up, new Vector2(1, 1)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.5f), Vector3.Up, new Vector2(0, 1)));

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0.5f), Vector3.Up, new Vector2(0, 1)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, -0.5f), Vector3.Up, new Vector2(0, 0)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, 0.5f, -0.5f), Vector3.Up, new Vector2(1, 0)));

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, 0.5f, -0.5f), Vector3.Up, new Vector2(1, 0)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, 0.5f, 0.5f), Vector3.Up, new Vector2(1, 1)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0.5f), Vector3.Up, new Vector2(0, 1)));

            Setup();
        }
Example #2
0
        public CornerModel(EntityInfo entity, GraphicsDevice graphicsDevice) : base(entity, graphicsDevice)
        {
            if (ModelVertices.Count > 0)
            {
                Setup();
                return;
            }

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-1, 0, 0), new Vector2(1.0f, 0.0f)));   //e
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-1, 0, 0), new Vector2(1.0f, 1.0f)));  //h
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-1, 0, 0), new Vector2(0.0f, 1.0f))); //a

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0, 0, 1), new Vector2(0.0f, 1.0f)));   //h
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0, 0, 1), new Vector2(0.0f, 0.0f)));    //e
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0, 0, 1), new Vector2(1.0f, 1.0f)));    //c

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector3(1, 0, 0), new Vector2(1.0f, 1.0f)));   //b
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector3(1, 0, 0), new Vector2(0.0f, 1.0f)));    //c
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(1, 0, 0), new Vector2(0.0f, 0.0f)));    //e

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0, 0, -1), new Vector2(1.0f, 0.0f)));   //e
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0, 0, -1), new Vector2(1.0f, 1.0f))); //a
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0, 0, -1), new Vector2(0.0f, 1.0f)));  //b

            Setup();
        }
Example #3
0
        public CliffInsideModel(EntityInfo entity, GraphicsDevice graphicsDevice) : base(entity, graphicsDevice)
        {
            if (ModelVertices.Count > 0)
            {
                Setup();
                return;
            }

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.5f), Vector3.Up, new Vector2(0, 1)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, -0.5f), Vector3.Up, new Vector2(0, 0)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, -0.5f), Vector3.Up, new Vector2(1, 0)));

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, -0.5f), Vector3.Up, new Vector2(1, 0)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, 0.5f), Vector3.Up, new Vector2(1, 1)));
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.5f), Vector3.Up, new Vector2(0, 1)));

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0.25f), Vector3.Forward, new Vector2(0.0f, 1.0f)));        //h
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.25f, 0.5f), Vector3.Forward, new Vector2(0.0f, 0.0f)));        //e
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, 0.25f), Vector3.Forward, new Vector2(1.0f, 1.0f)));         //c

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.5f, 0.25f), Vector3.Forward, new Vector2(1.0f, 1.0f)));         //c
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.25f, 0.5f), Vector3.Forward, new Vector2(0.0f, 0.0f)));        //e
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(0.5f, -0.25f, 0.5f), Vector3.Forward, new Vector2(1.0f, 0.0f)));         //d

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.25f, 0.5f), new Vector3(-1, 0, 0), new Vector2(1.0f, 0.0f)));  //e
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.25f, -0.5f, 0.5f), new Vector3(-1, 0, 0), new Vector2(1.0f, 1.0f)));  //h
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.25f, -0.5f, -0.5f), new Vector3(-1, 0, 0), new Vector2(0.0f, 1.0f))); //a

            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.25f, -0.5f, -0.5f), new Vector3(-1, 0, 0), new Vector2(0.0f, 1.0f))); //a
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.25f, -0.5f), new Vector3(-1, 0, 0), new Vector2(0.0f, 0.0f))); //f
            ModelVertices.Add(new VertexPositionNormalTexture(new Vector3(-0.5f, -0.25f, 0.5f), new Vector3(-1, 0, 0), new Vector2(1.0f, 0.0f)));  //e

            Setup();
        }
        private void BuildIndices()
        {
            var geometry = new Geometry <VertexPositionNormalTexture>();

            geometry.AddVertices(ModelVertices.ToArray());
            ModelIndices.AddRange(geometry.Indices);
        }
Example #5
0
        static void ReadVertices(BinaryReader br, M2Model model)
        {
            var vertInfo = model.Header.Vertices;

            model.Vertices = new ModelVertices[vertInfo.Count];

            br.BaseStream.Position = vertInfo.Offset;
            for (int i = 0; i < vertInfo.Count; i++)
            {
                var mv = new ModelVertices
                {
                    Position           = br.ReadVector3(),
                    BoneWeight         = br.ReadBytes(4),
                    BoneIndices        = br.ReadBytes(4),
                    Normal             = br.ReadVector3(),
                    TextureCoordinates = br.ReadVector2(),
                    Float_1            = br.ReadSingle(),
                    Float_2            = br.ReadSingle()
                };

                model.Vertices[i] = mv;
            }
        }
Example #6
0
        /// <summary>
        /// Deserialzes the provided binary data of the object. This is the full data block which follows the data
        /// signature and data block length.
        /// </summary>
        /// <param name="inData">The binary data containing the object.</param>
        public void LoadBinaryData(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.GroupNameOffset            = br.ReadUInt32();
                    this.DescriptiveGroupNameOffset = br.ReadUInt32();

                    this.Flags = (GroupFlags)br.ReadUInt32();

                    this.BoundingBox = br.ReadBox();

                    this.PortalReferenceStartingIndex = br.ReadUInt16();
                    this.PortalReferenceCount         = br.ReadUInt16();

                    this.RenderBatchCountA        = br.ReadUInt16();
                    this.RenderBatchCountInterior = br.ReadUInt16();
                    this.RenderBatchCountExterior = br.ReadUInt16();
                    this.Unknown = br.ReadUInt16();

                    for (int i = 0; i < 4; ++i)
                    {
                        this.FogIndices.Add(br.ReadByte());
                    }

                    this.LiquidType = br.ReadUInt32();
                    this.GroupID    = new UInt32ForeignKey("WMOAreaTable", "WMOGroupID", br.ReadUInt32());

                    this.UnknownFlags = br.ReadUInt32();
                    this.Unused       = br.ReadUInt32();

                    // Required subchunks
                    this.PolygonMaterials   = br.ReadIFFChunk <ModelPolygonMaterials>();
                    this.VertexIndices      = br.ReadIFFChunk <ModelVertexIndices>();
                    this.Vertices           = br.ReadIFFChunk <ModelVertices>();
                    this.Normals            = br.ReadIFFChunk <ModelNormals>();
                    this.TextureCoordinates = br.ReadIFFChunk <ModelTextureCoordinates>();
                    this.RenderBatches      = br.ReadIFFChunk <ModelRenderBatches>();

                    // Optional chunks
                    if (br.PeekChunkSignature() == MOBS.Signature)
                    {
                        this.mobs = br.ReadIFFChunk <MOBS>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasLights))
                    {
                        this.LightReferences = br.ReadIFFChunk <ModelLightReferences>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasDoodads))
                    {
                        this.DoodadReferences = br.ReadIFFChunk <ModelDoodadReferences>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasBSP))
                    {
                        this.BSPNodes       = br.ReadIFFChunk <ModelBSPNodes>();
                        this.BSPFaceIndices = br.ReadIFFChunk <ModelBSPFaceIndices>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.UnknownLODRelated))
                    {
                        this.mpbv = br.ReadIFFChunk <MPBV>();
                        this.mpbp = br.ReadIFFChunk <MPBP>();
                        this.mpbi = br.ReadIFFChunk <MPBI>();
                        this.mpbg = br.ReadIFFChunk <MPBG>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasVertexColours))
                    {
                        this.VertexColours = br.ReadIFFChunk <ModelVertexColours>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasLiquids))
                    {
                        this.Liquids = br.ReadIFFChunk <ModelLiquids>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasTriangleStrips))
                    {
                        this.TriangleStripIndices = br.ReadIFFChunk <ModelTriangleStripIndices>();
                        this.TriangleStrips       = br.ReadIFFChunk <ModelTriangleStrips>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasTwoTextureCoordinateSets))
                    {
                        this.AdditionalTextureCoordinates = br.ReadIFFChunk <ModelTextureCoordinates>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasTwoVertexShadingSets))
                    {
                        this.AdditionalVertexColours = br.ReadIFFChunk <ModelVertexColours>();
                    }

                    if (this.Flags.HasFlag(GroupFlags.HasThreeTextureCoordinateSets))
                    {
                        this.SecondAddtionalTextureCoordinates = br.ReadIFFChunk <ModelTextureCoordinates>();
                    }
                }
            }
        }
Example #7
0
 protected Graph(TVertex[] vertices, Vector3[] positions)
 {
     ModelVertices.AddRange(vertices);
     Positions.AddRange(positions);
 }