Esempio n. 1
0
        /// <summary>
        /// Defines a part in the current mesh.
        /// </summary>
        /// <param name="materialIndex">Index of the material.</param>
        /// <param name="firstIndex">The first index.</param>
        /// <param name="indexCount">The index count.</param>
        /// <param name="vertexCount">The vertex count.</param>
        /// <exception cref="System.InvalidOperationException">Cannot define a part if no mesh is active</exception>
        public void DefinePart(short materialIndex, ushort firstIndex, ushort indexCount, ushort vertexCount)
        {
            if (_currentMesh == null)
            {
                throw new InvalidOperationException("Cannot define a part if no mesh is active");
            }

            var part = new Mesh.Part
            {
                MaterialIndex     = materialIndex,
                Unknown2          = -1,
                FirstIndex        = firstIndex,
                IndexCount        = indexCount,
                FirstSubPartIndex = (short)_currentMesh.Mesh.SubParts.Count,
                SubPartCount      = 1,
                // TODO: Unknown values here
                VertexCount = vertexCount,
            };

            // It doesn't seem like the game really ever uses subparts for
            // most models, but define one anyway
            var subPart = new Mesh.SubPart
            {
                FirstIndex  = firstIndex,
                IndexCount  = indexCount,
                PartIndex   = (short)_currentMesh.Mesh.Parts.Count,
                VertexCount = vertexCount,
            };

            _currentMesh.Mesh.Parts.Add(part);
            _currentMesh.Mesh.SubParts.Add(subPart);
        }
        /// <summary>
        /// Defines a part in the current mesh.
        /// </summary>
        /// <param name="materialIndex">Index of the material.</param>
        /// <param name="firstIndex">The first index.</param>
        /// <param name="indexCount">The index count.</param>
        /// <param name="vertexCount">The vertex count.</param>
        /// <exception cref="System.InvalidOperationException">Cannot define a part if no mesh is active</exception>
        public void DefinePart(short materialIndex, ushort firstIndex, ushort indexCount, ushort vertexCount)
        {
            if (_currentMesh == null)
                throw new InvalidOperationException("Cannot define a part if no mesh is active");

            var part = new Mesh.Part
            {
                MaterialIndex = materialIndex,
                Unknown2 = -1,
                FirstIndex = firstIndex,
                IndexCount = indexCount,
                FirstSubPartIndex = (short)_currentMesh.Mesh.SubParts.Count,
                SubPartCount = 1,
                // TODO: Unknown values here
                VertexCount = vertexCount,
            };

            // It doesn't seem like the game really ever uses subparts for
            // most models, but define one anyway
            var subPart = new Mesh.SubPart
            {
                FirstIndex = firstIndex,
                IndexCount = indexCount,
                PartIndex = (short)_currentMesh.Mesh.Parts.Count,
                VertexCount = vertexCount,
            };

            _currentMesh.Mesh.Parts.Add(part);
            _currentMesh.Mesh.SubParts.Add(subPart);
        }