Exemple #1
0
        public static int IndexCountFromPrimitiveType(ModelPrimitiveType t)
        {
            switch (t)
            {
            case ModelPrimitiveType.TriangleList:
                return(3);

            default:
                throw new NotImplementedException();
            }
        }
Exemple #2
0
            private void Parse(Stream s)
            {
                BinaryReader br           = new BinaryReader(s);
                long         expectedSize = br.ReadUInt32();
                long         start        = s.Position;

                mName              = br.ReadUInt32();
                mMaterialIndex     = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, s);
                mVertexFormatIndex = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, s);
                mVertexBufferIndex = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, s);
                mIndexBufferIndex  = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, s);
                uint val = br.ReadUInt32();

                mPrimitiveType       = (ModelPrimitiveType)(val & 0x000000FF);
                mFlags               = (MeshFlags)(val >> 8);
                mStreamOffset        = br.ReadUInt32();
                mStartVertex         = br.ReadInt32();
                mStartIndex          = br.ReadInt32();
                mMinVertexIndex      = br.ReadInt32();
                mVertexCount         = br.ReadInt32();
                mPrimitiveCount      = br.ReadInt32();
                mBounds              = new BoundingBox(0, handler, s);
                mSkinControllerIndex = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, s);
                mJointReferences     = new UIntList(handler, s);
                mScaleOffsetIndex    = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, s);
                mGeometryStates      = new GeometryStateList(handler, s);
                if (mOwner.Version > 0x00000201)
                {
                    mParentName  = br.ReadUInt32();
                    mMirrorPlane = new Vector4(0, handler, s);
                }
                if (mOwner.Version > 0x00000203)
                {
                    mUnknown1 = br.ReadUInt32();
                }
                long actualSize = s.Position - start;

                if (checking && actualSize != expectedSize)
                {
                    throw new Exception(String.Format("Expected end at {0}, actual end was {1}", expectedSize,
                                                      actualSize));
                }
            }
Exemple #3
0
            public Mesh(int apiVersion, EventHandler handler, MLOD owner,
                        uint name,
                        GenericRCOLResource.ChunkReference materialIndex, GenericRCOLResource.ChunkReference vertexFormatIndex,
                        GenericRCOLResource.ChunkReference vertexBufferIndex, GenericRCOLResource.ChunkReference indexBufferIndex,
                        ModelPrimitiveType primitiveType, MeshFlags flags,
                        uint streamOffset, int startVertex, int startIndex, int minVertexIndex, int vertexCount, int primitiveCount,
                        BoundingBox bounds, GenericRCOLResource.ChunkReference skinControllerIndex,
                        UIntList jointReferences, GeometryStateList geometryStates, GenericRCOLResource.ChunkReference scaleOffsetIndex,
                        uint parentName, Vector4 mirrorPlane, uint unknown1
                        )
                : base(apiVersion, handler)
            {
                mOwner = owner;

                mName                = name;
                mMaterialIndex       = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, materialIndex);
                mVertexFormatIndex   = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, vertexFormatIndex);
                mVertexBufferIndex   = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, vertexBufferIndex);
                mIndexBufferIndex    = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, indexBufferIndex);
                mPrimitiveType       = primitiveType;
                mFlags               = flags;
                mStreamOffset        = streamOffset;
                mStartVertex         = startVertex;
                mStartIndex          = startIndex;
                mMinVertexIndex      = minVertexIndex;
                mVertexCount         = vertexCount;
                mPrimitiveCount      = primitiveCount;
                mBounds              = new BoundingBox(requestedApiVersion, handler, bounds);
                mSkinControllerIndex = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, skinControllerIndex);
                mJointReferences     = jointReferences == null ? null : new UIntList(handler, jointReferences);
                mGeometryStates      = geometryStates == null ? null : new GeometryStateList(handler, geometryStates);
                mScaleOffsetIndex    = new GenericRCOLResource.ChunkReference(requestedApiVersion, handler, scaleOffsetIndex);
                if (mOwner.Version > 0x00000201)
                {
                    mParentName  = parentName;
                    mMirrorPlane = new Vector4(requestedApiVersion, handler, mirrorPlane);
                }
                if (mOwner.Version > 0x00000203)
                {
                    mUnknown1 = unknown1;
                }
            }
Exemple #4
0
 public Int32[] GetIndices(ModelPrimitiveType type, Int32 startIndex, Int32 count)
 {
     return(GetIndices(IndexCountFromPrimitiveType(type), startIndex, count));
 }
Exemple #5
0
 void SetIndices(MLOD mlod, s3pi.GenericRCOLResource.GenericRCOLResource.ChunkReference myIBI, ModelPrimitiveType type, Int32 startIndex, Int32 primCount, Int32[] indices)
 {
     SetIndices(mlod, myIBI, startIndex, startIndex + primCount * IndexCountFromPrimitiveType(type), indices);
 }
Exemple #6
0
 void SetIndices(MLOD mlod, s4pi.GenericRCOLResource.GenericRCOLResource.ChunkReference myIBI, ModelPrimitiveType type, Int32 startIndex, Int32 primCount, Int32[] indices)
 {
     SetIndices(mlod, myIBI, startIndex, startIndex + primCount * IndexCountFromPrimitiveType(type), indices);
 }
Exemple #7
0
 public Int32[] GetIndices(ModelPrimitiveType type, Int32 startIndex, Int32 count)
 {
     return GetIndices(IndexCountFromPrimitiveType(type), startIndex, count);
 }
Exemple #8
0
 public static int IndexCountFromPrimitiveType(ModelPrimitiveType t)
 {
     switch (t)
     {
         case ModelPrimitiveType.TriangleList:
             return 3;
         default:
             throw new NotImplementedException();
     }
 }