Exemplo n.º 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;
        }
Exemplo n.º 2
0
        public MAT3(Assimp.Scene scene, TEX1 textures)
        {
            InitLists();

            foreach (Assimp.Mesh mesh in scene.Meshes)
            {
                Assimp.Material    meshMat     = scene.Materials[mesh.MaterialIndex];
                Materials.Material bmdMaterial = new Material();

                if (meshMat.HasTextureDiffuse)
                {
                    bmdMaterial.AddTexGen(TexGenType.Matrix2x4, TexGenSrc.TexCoord0, Materials.Enums.TexMatrix.Identity);
                    bmdMaterial.AddTexMatrix(TexGenType.Matrix3x4, 0, OpenTK.Vector3.Zero, OpenTK.Vector2.One, 0, OpenTK.Vector2.Zero, OpenTK.Matrix4.Identity);

                    string texName = System.IO.Path.GetFileNameWithoutExtension(meshMat.TextureDiffuse.FilePath);
                    bmdMaterial.AddTexIndex(textures.Textures.IndexOf(textures[texName]));

                    bmdMaterial.AddTevStage(SetUpTevStageParametersForTexture());
                }
            }

            FillMaterialDataBlocks();
        }
Exemplo n.º 3
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;
        }