예제 #1
0
        public Mesh(AssetCabinet file) :
            this(file, 0, UnityClassID.Mesh, UnityClassID.Mesh)
        {
            file.ReplaceSubfile(-1, this, null);

            m_Shapes         = new BlendShapeData();
            m_IsReadable     = true;
            m_KeepVertices   = true;
            m_KeepIndices    = true;
            m_CompressedMesh = new CompressedMesh();
            m_LocalAABB      = new AABB();
            m_MeshUsageFlags = 1;
        }
예제 #2
0
파일: Mesh.cs 프로젝트: kkdevs/sb3u
        public Mesh(AssetCabinet file) :
            this(file, 0, UnityClassID.Mesh, UnityClassID.Mesh)
        {
            file.ReplaceSubfile(-1, this, null);

            m_Shapes = new BlendShapeData();
            if (file.VersionNumber >= AssetCabinet.VERSION_5_0_0)
            {
                m_StreamCompression = 1;
            }
            m_IsReadable     = true;
            m_KeepVertices   = true;
            m_KeepIndices    = true;
            m_CompressedMesh = new CompressedMesh(file.VersionNumber);
            m_LocalAABB      = new AABB();
            m_MeshUsageFlags = 1;
            if (file.VersionNumber >= AssetCabinet.VERSION_5_0_0)
            {
                m_BakedConvexCollisionMesh   = new byte[0];
                m_BakedTriangleCollisionMesh = new byte[0];
            }
        }
예제 #3
0
파일: Mesh.cs 프로젝트: hejob/SB3Utility
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            m_Name = reader.ReadNameA4();

            int numSubMeshes = reader.ReadInt32();
            m_SubMeshes = new List<SubMesh>(numSubMeshes);
            for (int i = 0; i < numSubMeshes; i++)
            {
                m_SubMeshes.Add(new SubMesh(stream));
            }

            m_Shapes = new BlendShapeData(stream);

            int numBones = reader.ReadInt32();
            m_BindPose = new List<Matrix>(numBones);
            for (int i = 0; i < numBones; i++)
            {
                m_BindPose.Add(reader.ReadMatrix());
            }

            int numHashes = reader.ReadInt32();
            m_BoneNameHashes = new List<uint>(numHashes);
            for (int i = 0; i < numHashes; i++)
            {
                m_BoneNameHashes.Add(reader.ReadUInt32());
            }

            m_RootBoneNameHash = reader.ReadUInt32();
            m_MeshCompression = reader.ReadByte();
            m_StreamCompression = reader.ReadByte();
            m_IsReadable = reader.ReadBoolean();
            m_KeepVertices = reader.ReadBoolean();
            m_KeepIndices = reader.ReadBoolean();
            reader.BaseStream.Position += 3;

            int numIndexBytes = reader.ReadInt32();
            m_IndexBuffer = reader.ReadBytes(numIndexBytes);
            if ((numIndexBytes & 3) > 0)
            {
                reader.BaseStream.Position += 4 - (numIndexBytes & 3);
            }

            int numInfluences = reader.ReadInt32();
            m_Skin = new List<BoneInfluence>(numInfluences);
            for (int i = 0; i < numInfluences; i++)
            {
                m_Skin.Add(new BoneInfluence(stream));
            }

            m_VertexData = new VertexData(stream);
            m_CompressedMesh = new CompressedMesh(stream);
            m_LocalAABB = new AABB(stream);
            m_MeshUsageFlags = reader.ReadInt32();
        }
예제 #4
0
파일: Mesh.cs 프로젝트: hejob/SB3Utility
        public Mesh(AssetCabinet file)
            : this(file, 0, UnityClassID.Mesh, UnityClassID.Mesh)
        {
            file.ReplaceSubfile(-1, this, null);

            m_Shapes = new BlendShapeData();
            m_IsReadable = true;
            m_KeepVertices = true;
            m_KeepIndices = true;
            m_CompressedMesh = new CompressedMesh();
            m_LocalAABB = new AABB();
            m_MeshUsageFlags = 1;
        }
예제 #5
0
        private VertexBuffer CreateMorphVertexBuffer(BlendShapeData shapes, int keyframeIdx, List<Operations.vVertex> vertexList, int firstVertexIndex)
        {
            int vertBufferSize = vertexList.Count * Marshal.SizeOf(typeof(TweeningWithoutNormalsVertexBufferFormat.Stream0));
            VertexBuffer vertBuffer = new VertexBuffer(device, vertBufferSize, Usage.WriteOnly, VertexFormat.Position, Pool.Managed);
            Vector3[] positions = new Vector3[vertexList.Count];
            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = vertexList[i].position;
            }
            List<BlendShapeVertex> blendVerts = shapes.vertices;
            int nextShapeVertIdx = (int)(shapes.shapes[keyframeIdx].firstVertex + shapes.shapes[keyframeIdx].vertexCount);
            for (int i = (int)shapes.shapes[keyframeIdx].firstVertex; i < nextShapeVertIdx; i++)
            {
                int morphVertIdx = (int)blendVerts[i].index - firstVertexIndex;
                if (morphVertIdx >= 0 && morphVertIdx < vertexList.Count)
                {
                    positions[morphVertIdx] += blendVerts[i].vertex;
                }
            }

            using (DataStream vertexStream = vertBuffer.Lock(0, vertBufferSize, LockFlags.None))
            {
                for (int i = 0; i < positions.Length; i++)
                {
                    Vector3 pos = positions[i];
                    vertexStream.Write(-pos.X);
                    vertexStream.Write(pos.Y);
                    vertexStream.Write(pos.Z);
                }
                vertBuffer.Unlock();
            }

            return vertBuffer;
        }
예제 #6
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_Name = reader.ReadNameA4();

            int numSubMeshes = reader.ReadInt32();

            m_SubMeshes = new List <SubMesh>(numSubMeshes);
            for (int i = 0; i < numSubMeshes; i++)
            {
                m_SubMeshes.Add(new SubMesh(stream));
            }

            m_Shapes = new BlendShapeData(stream);

            int numBones = reader.ReadInt32();

            m_BindPose = new List <Matrix>(numBones);
            for (int i = 0; i < numBones; i++)
            {
                m_BindPose.Add(reader.ReadMatrix());
            }

            int numHashes = reader.ReadInt32();

            m_BoneNameHashes = new List <uint>(numHashes);
            for (int i = 0; i < numHashes; i++)
            {
                m_BoneNameHashes.Add(reader.ReadUInt32());
            }

            m_RootBoneNameHash          = reader.ReadUInt32();
            m_MeshCompression           = reader.ReadByte();
            m_StreamCompression         = reader.ReadByte();
            m_IsReadable                = reader.ReadBoolean();
            m_KeepVertices              = reader.ReadBoolean();
            m_KeepIndices               = reader.ReadBoolean();
            reader.BaseStream.Position += 3;

            int numIndexBytes = reader.ReadInt32();

            m_IndexBuffer = reader.ReadBytes(numIndexBytes);
            if ((numIndexBytes & 3) > 0)
            {
                reader.BaseStream.Position += 4 - (numIndexBytes & 3);
            }

            int numInfluences = reader.ReadInt32();

            m_Skin = new List <BoneInfluence>(numInfluences);
            for (int i = 0; i < numInfluences; i++)
            {
                m_Skin.Add(new BoneInfluence(stream));
            }

            m_VertexData     = new VertexData(stream);
            m_CompressedMesh = new CompressedMesh(stream);
            m_LocalAABB      = new AABB(stream);
            m_MeshUsageFlags = reader.ReadInt32();
        }
예제 #7
0
파일: Mesh.cs 프로젝트: kkdevs/sb3u
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            m_Name = reader.ReadNameA4U8();

            int numSubMeshes = reader.ReadInt32();

            m_SubMeshes = new List <SubMesh>(numSubMeshes);
            for (int i = 0; i < numSubMeshes; i++)
            {
                m_SubMeshes.Add(new SubMesh(stream));
            }

            m_Shapes = new BlendShapeData(stream);

            int numBones = reader.ReadInt32();

            m_BindPose = new List <Matrix>(numBones);
            for (int i = 0; i < numBones; i++)
            {
                m_BindPose.Add(reader.ReadMatrix());
            }

            int numHashes = reader.ReadInt32();

            m_BoneNameHashes = new List <uint>(numHashes);
            for (int i = 0; i < numHashes; i++)
            {
                m_BoneNameHashes.Add(reader.ReadUInt32());
            }

            m_RootBoneNameHash = reader.ReadUInt32();
            m_MeshCompression  = reader.ReadByte();
            if (file.VersionNumber < AssetCabinet.VERSION_5_0_0)
            {
                m_StreamCompression = reader.ReadByte();
            }
            else
            {
                m_StreamCompression = 1;
            }
            m_IsReadable   = reader.ReadBoolean();
            m_KeepVertices = reader.ReadBoolean();
            m_KeepIndices  = reader.ReadBoolean();
            if (file.VersionNumber < AssetCabinet.VERSION_5_0_0)
            {
                reader.BaseStream.Position += 3;
            }

            int numIndexBytes = reader.ReadInt32();

            m_IndexBuffer = reader.ReadBytes(numIndexBytes);
            if ((numIndexBytes & 3) > 0)
            {
                reader.BaseStream.Position += 4 - (numIndexBytes & 3);
            }

            int numInfluences = reader.ReadInt32();

            m_Skin = new List <BoneInfluence>(numInfluences);
            for (int i = 0; i < numInfluences; i++)
            {
                m_Skin.Add(new BoneInfluence(stream));
            }

            m_VertexData     = new VertexData(stream, m_StreamCompression > 0 || file.VersionNumber >= AssetCabinet.VERSION_5_0_0);
            m_CompressedMesh = new CompressedMesh(stream, file.VersionNumber);
            m_LocalAABB      = new AABB(stream);
            m_MeshUsageFlags = reader.ReadInt32();
            if (file.VersionNumber >= AssetCabinet.VERSION_5_0_0)
            {
                int numMeshBytes = reader.ReadInt32();
                m_BakedConvexCollisionMesh = reader.ReadBytes(numMeshBytes);
                if ((numMeshBytes & 3) > 0)
                {
                    stream.Position += 4 - (numMeshBytes & 3);
                }

                numMeshBytes = reader.ReadInt32();
                m_BakedTriangleCollisionMesh = reader.ReadBytes(numMeshBytes);
                if ((numMeshBytes & 3) > 0)
                {
                    stream.Position += 4 - (numMeshBytes & 3);
                }
            }
        }