Пример #1
0
        public bool SetVertices(MLOD mlod, MLOD.Mesh mesh, VRTF vrtf, Vertex[] vertices, float[] uvscales)
        {
            bool okay = SetVertices(mlod, mesh.VertexBufferIndex, mesh.StreamOffset, mesh.VertexCount, vrtf, vertices, uvscales);

            mesh.VertexCount = vertices.Length;
            return(okay);
        }
Пример #2
0
        void SetIndices(MLOD mlod, GenericRCOLResource.GenericRCOLResource.ChunkReference myIBI, Int32 beforeLength, Int32 afterPos, Int32[] indices)
        {
            Int32[] before = new Int32[beforeLength];
            Array.Copy(mBuffer, 0, before, 0, before.Length);

            Int32[] after = new Int32[mBuffer.Length - afterPos];
            Array.Copy(mBuffer, afterPos, after, 0, after.Length);

            mBuffer = new Int32[before.Length + indices.Length + after.Length];
            Array.Copy(before, 0, mBuffer, 0, before.Length);
            Array.Copy(indices, 0, mBuffer, before.Length, indices.Length);
            Array.Copy(after, 0, mBuffer, before.Length + indices.Length, after.Length);

            int offset = beforeLength + indices.Length - afterPos;

            if (offset != 0)
            {
                foreach (MLOD.Mesh m in mlod.Meshes.FindAll(m => m.IndexBufferIndex.Equals(myIBI)))
                {
                    if (m.StartIndex > beforeLength)
                    {
                        m.StartIndex += offset;
                        foreach (MLOD.GeometryState g in m.GeometryStates)
                        {
                            if (g.StartIndex > beforeLength)
                            {
                                g.StartIndex += offset;
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        public bool SetVertices(MLOD mlod, MLOD.Mesh mesh, MLOD.GeometryState geo, VRTF vrtf, Vertex[] vertices, float[] uvscales)
        {
            long beforeLength = mesh.StreamOffset + (geo.MinVertexIndex * vrtf.Stride);
            bool okay         = SetVertices(mlod, mesh.VertexBufferIndex, beforeLength, geo.VertexCount, vrtf, vertices, uvscales);

            geo.VertexCount = vertices.Length;
            return(okay);
        }
Пример #4
0
        public static VBSI FromMLOD(MLOD mlod, GenericRCOLResource.GenericRCOLResource container)
        {
            VBSI vbsi = new VBSI(null);

            foreach (MLOD.Mesh mesh in mlod.Meshes)
            {
                VRTF vrtf = (VRTF)GenericRCOLResource.GenericRCOLResource.ChunkReference.GetBlock(container, mesh.VertexFormatIndex);
                vbsi.Segments.Add(SegmentInfo.FromMesh(mesh, vrtf));
            }
            return(vbsi);
        }
Пример #5
0
 public MeshList(EventHandler handler, MLOD owner, IEnumerable <Mesh> ilt)
     : base(null)
 {
     mOwner         = owner;
     elementHandler = handler;
     foreach (Mesh t in ilt)
     {
         base.Add(t);
         t.Owner = mOwner;
     }
     this.handler = handler;
 }
Пример #6
0
        private bool SetVertices(MLOD mlod, GenericRCOLResource.GenericRCOLResource.ChunkReference myVBI, long beforeLength, int count, VRTF vrtf, IEnumerable <Vertex> vertices, float[] uvscales)
        {
            bool okay = true;

            byte[] before = new byte[beforeLength];
            Array.Copy(mBuffer, before, before.Length);

            long afterPos = Math.Min(mBuffer.Length, beforeLength + (count * vrtf.Stride));

            byte[] after = new byte[mBuffer.Length - afterPos];
            Array.Copy(mBuffer, afterPos, after, 0, after.Length);

            long offset = 0;

            using (MemoryStream mg = new MemoryStream())
            {
                if (!SetVertices(mg, vrtf, vertices, uvscales))
                {
                    okay = false;
                }
                offset = beforeLength + mg.Length - afterPos;

                mBuffer = new byte[before.Length + mg.Length + after.Length];
                Array.Copy(before, mBuffer, before.Length);
                Array.Copy(mg.ToArray(), 0, mBuffer, before.Length, mg.Length);
                Array.Copy(after, 0, mBuffer, before.Length + mg.Length, after.Length);

                mg.Close();
            }

            int voffset = (int)offset / vrtf.Stride;

            if (offset != 0)
            {
                foreach (MLOD.Mesh m in mlod.Meshes.Where(m => m.VertexBufferIndex.Equals(myVBI) && m.StreamOffset > beforeLength))
                {
                    m.StreamOffset = (uint)(m.StreamOffset + offset);
                    foreach (MLOD.GeometryState g in m.GeometryStates)
                    {
                        if (g.MinVertexIndex * vrtf.Stride > beforeLength)
                        {
                            g.MinVertexIndex += voffset;
                        }
                    }
                }
            }
            return(okay);
        }
Пример #7
0
            public Mesh(EventHandler handler, MLOD owner)
                : base(handler)
            {
                mOwner = owner;

                mMaterialIndex       = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, 0);
                mVertexFormatIndex   = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, 0);
                mVertexBufferIndex   = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, 0);
                mIndexBufferIndex    = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, 0);
                mBounds              = new BoundingBox(handler);
                mSkinControllerIndex = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, 0);
                mJointReferences     = new UIntList(handler);
                mGeometryStates      = new GeometryStateList(handler);
                mScaleOffsetIndex    = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, 0);
                mMirrorPlane         = new Vector4(handler);//mOwner.Version > 0x00000201
            }
Пример #8
0
            public Mesh(EventHandler handler, MLOD owner,
                        uint name,
                        GenericRCOLResource.GenericRCOLResource.ChunkReference materialIndex, GenericRCOLResource.GenericRCOLResource.ChunkReference vertexFormatIndex,
                        GenericRCOLResource.GenericRCOLResource.ChunkReference vertexBufferIndex, GenericRCOLResource.GenericRCOLResource.ChunkReference indexBufferIndex,
                        ModelPrimitiveType primitiveType, MeshFlags flags,
                        uint streamOffset, int startVertex, int startIndex, int minVertexIndex, int vertexCount,
                        int primitiveCount,
                        BoundingBox bounds, GenericRCOLResource.GenericRCOLResource.ChunkReference skinControllerIndex,
                        UIntList jointReferences, GeometryStateList geometryStates, GenericRCOLResource.GenericRCOLResource.ChunkReference scaleOffsetIndex,
                        uint parentName, Vector4 mirrorPlane)
                : base(handler)
            {
                mOwner = owner;

                mName                = name;
                mMaterialIndex       = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, materialIndex);
                mVertexFormatIndex   = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, vertexFormatIndex);
                mVertexBufferIndex   = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, vertexBufferIndex);
                mIndexBufferIndex    = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, indexBufferIndex);
                mPrimitiveType       = primitiveType;
                mFlags               = flags;
                mStreamOffset        = streamOffset;
                mStartVertex         = startVertex;
                mStartIndex          = startIndex;
                mMinVertexIndex      = minVertexIndex;
                mVertexCount         = vertexCount;
                mPrimitiveCount      = primitiveCount;
                mBounds              = new BoundingBox(handler, bounds);
                mSkinControllerIndex = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, skinControllerIndex);
                mJointReferences     = jointReferences == null ? null : new UIntList(handler, jointReferences);
                mGeometryStates      = geometryStates == null ? null : new GeometryStateList(handler, geometryStates);
                mScaleOffsetIndex    = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, scaleOffsetIndex);
                if (mOwner.Version > 0x00000201)
                {
                    mParentName  = parentName;
                    mMirrorPlane = new Vector4(handler, mirrorPlane);
                }
            }
Пример #9
0
 public MeshList(EventHandler handler, MLOD owner) : base(handler)
 {
     mOwner = owner;
 }
Пример #10
0
 public Mesh(EventHandler handler, MLOD owner, Stream s) : base(handler)
 {
     mOwner = owner; Parse(s);
 }
Пример #11
0
 public MLOD(EventHandler handler, MLOD basis) : this(handler, basis.Version, new MeshList(handler, basis, basis.mMeshes))
 {
 }
Пример #12
0
 public void SetIndices(MLOD mlod, MLOD.Mesh mesh, Int32[] indices)
 {
     SetIndices(mlod, mesh.IndexBufferIndex, mesh.PrimitiveType, mesh.StartIndex, mesh.PrimitiveCount, indices);
     mesh.PrimitiveCount = indices.Length / IndexCountFromPrimitiveType(mesh.PrimitiveType);
 }
Пример #13
0
 void SetIndices(MLOD mlod, GenericRCOLResource.GenericRCOLResource.ChunkReference myIBI, ModelPrimitiveType type, Int32 startIndex, Int32 primCount, Int32[] indices)
 {
     SetIndices(mlod, myIBI, startIndex, startIndex + primCount * IndexCountFromPrimitiveType(type), indices);
 }
Пример #14
0
 public void SetIndices(MLOD mlod, MLOD.Mesh mesh, MLOD.GeometryState geometryState, Int32[] indices)
 {
     SetIndices(mlod, mesh.IndexBufferIndex, mesh.PrimitiveType, geometryState.StartIndex, geometryState.PrimitiveCount,
                indices.Select(x => x + geometryState.MinVertexIndex).ToArray());
     geometryState.PrimitiveCount = indices.Length / IndexCountFromPrimitiveType(mesh.PrimitiveType);
 }
Пример #15
0
 public bool SetVertices(MLOD mlod, MLOD.Mesh mesh, int geoIndex, VRTF vrtf, Vertex[] vertices, float[] uvscales)
 {
     return(SetVertices(mlod, mesh, mesh.GeometryStates[geoIndex], vrtf, vertices, uvscales));
 }
Пример #16
0
 public MeshList(EventHandler handler, MLOD owner, Stream s) : this(handler, owner)
 {
     Parse(s);
 }
Пример #17
0
 public void SetIndices(MLOD mlod, MLOD.Mesh mesh, int geoStateIndex, Int32[] indices)
 {
     MLOD.GeometryState geometryState = mesh.GeometryStates[geoStateIndex];
     SetIndices(mlod, mesh, geometryState, indices);
 }
Пример #18
0
 public bool SetVertices(MLOD mlod, int meshIndex, VRTF vrtf, Vertex[] vertices, float[] uvscales)
 {
     return(SetVertices(mlod, mlod.Meshes[meshIndex], vrtf, vertices, uvscales));
 }