Exemple #1
0
        public Model(Scene scene, string modelDirectory)
        {
            VertexData = new VTX1(scene);
            Joints     = new JNT1(scene);
            Scenegraph = new INF1(scene, Joints);
            Textures   = new TEX1(scene, modelDirectory);
            Materials  = new MAT3(scene, Textures);

            //EVP1 evpFromScene;
            //DRW1 drwFromScene;
            //Shapes = SHP1.Create(scene, Joints.BoneNameIndices, VertexData.Attributes, out evpFromScene, out drwFromScene);

            //SkinningEnvelopes = evpFromScene;
            //PartialWeightData = drwFromScene;

            //foreach (Geometry.Shape shape in Shapes.Shapes)
            //packetCount += shape.Packets.Count;

            vertexCount = VertexData.Attributes.Positions.Count;
        }
Exemple #2
0
        public Model(EndianBinaryReader reader)
        {
            int j3d2Magic  = reader.ReadInt32();
            int modelMagic = reader.ReadInt32();

            if (j3d2Magic != 0x4A334432)
            {
                throw new Exception("Model was not a BMD or BDL! (J3D2 magic not found)");
            }
            if ((modelMagic != 0x62646C34) && (modelMagic != 0x626D6433))
            {
                throw new Exception("Model was not a BMD or BDL! (Model type was not bmd3 or bdl4)");
            }

            int modelSize    = reader.ReadInt32();
            int sectionCount = reader.ReadInt32();

            // Skip the dummy section, SVR3
            reader.Skip(16);

            Scenegraph        = new INF1(reader, 32);
            VertexData        = new VTX1(reader, (int)reader.BaseStream.Position);
            SkinningEnvelopes = new EVP1(reader, (int)reader.BaseStream.Position);
            PartialWeightData = new DRW1(reader, (int)reader.BaseStream.Position);
            Joints            = new JNT1(reader, (int)reader.BaseStream.Position);
            Shapes            = SHP1.Create(reader, (int)reader.BaseStream.Position);
            Materials         = new MAT3(reader, (int)reader.BaseStream.Position);
            SkipMDL3(reader);
            Textures = new TEX1(reader, (int)reader.BaseStream.Position);

            foreach (Geometry.Shape shape in Shapes.Shapes)
            {
                packetCount += shape.Packets.Count;
            }

            vertexCount = VertexData.Attributes.Positions.Count;
        }