Exemplo n.º 1
0
        public Skeleton(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            Name = m_Reader.ReadPascalString();
            BoneCount = m_Reader.ReadUShort();

            for(int i = 0; i < BoneCount; i++)
            {
                Bones.Add(new Bone(m_Reader, i));
            }

            /** Construct tree **/
            foreach (Bone bone in Bones)
                bone.Children = Bones.Where(x => x.ParentName == bone.Name).ToArray();

            RootBone = Bones.FirstOrDefault(x => x.ParentName == "NULL");

            m_Reader.Close();
        }
Exemplo n.º 2
0
        public CST(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Version = Reader.ReadInt16();
            ushort NumStrings = 0;

            if ((Reader.StreamLength - Reader.Position) > 2)
            {
                switch (Version)
                {
                    case 0:
                        NumStrings = Reader.ReadUShort();

                        for (int i = 0; i < NumStrings; i++)
                        {
                            TranslatedString Str = new TranslatedString();
                            Str.LangCode = LanguageCodes.unused;
                            Str.TranslatedStr = Reader.ReadPascalString();

                            if (Strings.ContainsKey(Str.LangCode))
                                Strings[Str.LangCode].Add(Str);
                            else
                            {
                                List<TranslatedString> LanguageSet = new List<TranslatedString>();
                                LanguageSet.Add(Str);
                                Strings.Add(Str.LangCode, LanguageSet);
                            }
                        }

                        break;
                    case -1:
                        NumStrings = Reader.ReadUShort();

                        for (int i = 0; i < NumStrings; i++)
                        {
                            TranslatedString Str = new TranslatedString();
                            Str.LangCode = LanguageCodes.unused;
                            Str.TranslatedStr = Reader.ReadCString();

                            if (Strings.ContainsKey(Str.LangCode))
                                Strings[Str.LangCode].Add(Str);
                            else
                            {
                                List<TranslatedString> LanguageSet = new List<TranslatedString>();
                                LanguageSet.Add(Str);
                                Strings.Add(Str.LangCode, LanguageSet);
                            }
                        }

                        break;
                    case -2:
                        NumStrings = Reader.ReadUShort();

                        for (int i = 0; i < NumStrings; i++)
                        {
                            TranslatedString Str = new TranslatedString();
                            Str.LangCode = LanguageCodes.unused;
                            Str.TranslatedStr = Reader.ReadCString();
                            Reader.ReadCString(); //Comment

                            if (Strings.ContainsKey(Str.LangCode))
                                Strings[Str.LangCode].Add(Str);
                            else
                            {
                                List<TranslatedString> LanguageSet = new List<TranslatedString>();
                                LanguageSet.Add(Str);
                                Strings.Add(Str.LangCode, LanguageSet);
                            }
                        }

                        break;
                    case -3:
                        NumStrings = Reader.ReadUShort();

                        for (int i = 0; i < NumStrings; i++)
                        {
                            TranslatedString Str = new TranslatedString();
                            Str.LangCode = (LanguageCodes)Reader.ReadByte();
                            Str.TranslatedStr = Reader.ReadCString();
                            Reader.ReadCString(); //Comment

                            if (Strings.ContainsKey(Str.LangCode))
                                Strings[Str.LangCode].Add(Str);
                            else
                            {
                                List<TranslatedString> LanguageSet = new List<TranslatedString>();
                                LanguageSet.Add(Str);
                                Strings.Add(Str.LangCode, LanguageSet);
                            }
                        }

                        break;
                    case -4:
                        byte LanguageSets = Reader.ReadByte();
                        for (int i = 0; i < LanguageSets; i++)
                        {
                            NumStrings = Reader.ReadUShort();

                            for (int j = 0; j < NumStrings; j++)
                            {
                                TranslatedString Str = new TranslatedString();
                                Str.LangCode = (LanguageCodes)(Reader.ReadByte() + 1);
                                Str.TranslatedStr = Reader.ReadString();
                                Reader.ReadString(); //Comment

                                if (Strings.ContainsKey(Str.LangCode))
                                    Strings[Str.LangCode].Add(Str);
                                else
                                {
                                    List<TranslatedString> LanguageSet = new List<TranslatedString>();
                                    LanguageSet.Add(Str);
                                    Strings.Add(Str.LangCode, LanguageSet);
                                }
                            }
                        }

                        break;
                }
            }

            Reader.Close();
            m_Data = null;
        }
Exemplo n.º 3
0
        public Mesh(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            BoneCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BoneCount; i++)
                Bones.Add(m_Reader.ReadPascalString());

            FaceCount = m_Reader.ReadUInt32();

            for (int i = 0; i < FaceCount; i++)
                Faces.Add(new Vector3(m_Reader.ReadUInt32(), m_Reader.ReadUInt32(), m_Reader.ReadUInt32()));

            BindingCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BindingCount; i++)
                BoneBindings.Add(new BoneBinding(m_Reader));

            RealVertexCount = m_Reader.ReadUInt32();
            List<Vector2> TexVertices = new List<Vector2>();

            for (int i = 0; i < RealVertexCount; i++)
                TexVertices.Add(new Vector2(m_Reader.ReadFloat(), m_Reader.ReadFloat()));

            BlendVertexCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BlendVertexCount; i++)
                BlendVertexProps.Add(new BlendVertexProperty(m_Reader));

            TotalVertexCount = m_Reader.ReadUInt32();
            TransformedVertices = new VertexPositionNormalTexture[TotalVertexCount];

            for (int i = 0; i < RealVertexCount; i++)
            {
                RealVertices.Add(new VertexPositionNormalTexture(new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()),
                    new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()), TexVertices[i]));
            }

            for(int i = 0; i < BlendVertexCount; i++)
            {
                BlendedVertices.Add(new VertexPositionNormalTexture(new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()),
                    new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()), TexVertices[i]));
            }

            m_Reader.Close();
        }