示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CAMR"/> class.
        /// </summary>
        /// <param name="from">The <see cref="BaseChunk" /> to use for creating this Chunk. The given data will be interpreted respectively.</param>
        public CAMR(BaseChunk from) : base(from)
        {
            while (!EndOfData)
            {
                BaseChunk nextChunk = ReadChunk();

                switch (nextChunk.ChunkName)
                {
                case "NAME":
                    Name = nextChunk.ReadString(nextChunk.Data.Length);
                    break;

                case "DATA":
                    //consists of floats only
                    //a float has a size of 4 bytes
                    int len = nextChunk.Data.Length / 4;
                    CameraData = new float[len];

                    for (int i = 0; i < CameraData.Length; i++)
                    {
                        CameraData[i] = nextChunk.ReadFloat();
                    }
                    break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MODL"/> class.
        /// </summary>
        /// <param name="from">The <see cref="BaseChunk" /> to use for creating this Chunk. The given data will be interpreted respectively.</param>
        public MODL(BaseChunk from) : base(from)
        {
            while (!EndOfData)
            {
                BaseChunk nextChunk = ReadChunk();

                switch (nextChunk.ChunkName)
                {
                case "MTYP":
                    Type = (MTYP)nextChunk.ReadInt32();
                    break;

                case "MNDX":
                    index = nextChunk.ReadInt32();
                    break;

                case "NAME":
                    Name = nextChunk.ReadString(nextChunk.Data.Length);
                    break;

                case "PRNT":
                    parentName = nextChunk.ReadString(nextChunk.Data.Length);
                    break;

                case "FLGS":
                    Flag = new ModelFlag(true, nextChunk.ReadInt32());
                    break;

                case "TRAN":
                    Scale       = nextChunk.ReadVector3();
                    Rotation    = nextChunk.ReadVector3();
                    Translation = nextChunk.ReadVector3();
                    UnknownTRAN = nextChunk.ReadFloat();
                    break;

                case "GEOM":
                    Geometry = new GEOM(nextChunk);
                    break;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MATD"/> class.
        /// </summary>
        /// <param name="from">The <see cref="BaseChunk" /> to use for creating this Chunk. The given data will be interpreted respectively.</param>
        public MATD(BaseChunk from) : base(from)
        {
            while (!EndOfData)
            {
                BaseChunk nextChunk = ReadChunk();

                switch (nextChunk.ChunkName)
                {
                case "NAME":
                    Name = nextChunk.ReadString(nextChunk.Data.Length);
                    break;

                case "DATA":
                    Diffuse  = nextChunk.ReadColor();
                    Ambient  = nextChunk.ReadColor();
                    Specular = nextChunk.ReadColor();

                    SpecularSharpness = nextChunk.ReadFloat();
                    break;

                case "ATRB":
                    attribute = nextChunk.ReadInt32();
                    break;
                }

                //catch texture entrys (usually TX0D)
                Match txMatch = Regex.Match(nextChunk.ChunkName, "TX[0-9]{1}D");
                if (txMatch.Success)
                {
                    //the number sits at the 3rd position = [2]
                    //the symbol "0" ist at position 48 in the ascii table
                    int index = txMatch.Value[2] - 48;
                    Textures[index] = nextChunk.ReadString(nextChunk.Data.Length);
                }
            }
        }