public InstancedVertexPositionNormalTextureBumpSkin(VertexPositionNormalTextureBumpSkin source, Matrix meshToObject, byte index)
        {
            Position = source.Position;
            Normal = source.Normal;
            TextureCoordinate1 = source.TextureCoordinate;
            TextureCoordinate2 = source.TextureCoordinate;
            Tangent = source.Tangent;
            Binormal = source.Binormal;

            BoneIndices = new Byte4(source.BoneIndex0, source.BoneIndex1, source.BoneIndex2, source.BoneIndex3);
            BoneWeights = source.BoneWeights;     
        }
        public InstancedVertexPositionNormalTextureBumpSkin(VertexPositionNormalTextureBumpSkin source, Matrix meshToObject, byte index)
        {
            Position           = source.Position;
            Normal             = source.Normal;
            TextureCoordinate1 = source.TextureCoordinate;
            TextureCoordinate2 = source.TextureCoordinate;
            Tangent            = source.Tangent;
            Binormal           = source.Binormal;

            BoneIndices = new Byte4(source.BoneIndex0, source.BoneIndex1, source.BoneIndex2, source.BoneIndex3);
            BoneWeights = source.BoneWeights;
        }
예제 #3
0
        /// <summary>
        ///   Add the required Geometry for hardware instancing
        /// </summary>
        /// <param name = "instancetransformindex">the index used in the SceneObejct.SkinBones array to position the instance</param>
        /// <returns>Returns true if succeeed; false otherwise.</returns>
        private bool AddGeometry(int instancetransformindex)
        {
            // Get the number of vertices already in the container object to readjust the new instance's destination indices.
            int indexoffset = _vertices.Count;

            // Avoid overflowing the indices.
            int finalmaxindex = indexoffset + _source.Vertices.Length;

            if (finalmaxindex > short.MaxValue)
            {
                return(false);
            }

            // Copy all vertices into the container object.
            foreach (VertexPositionNormalTextureBump vert in _source.Vertices)
            {
                VertexPositionNormalTextureBumpSkin dest = new VertexPositionNormalTextureBumpSkin();

                // Copy source data.
                dest.Position          = vert.Position;
                dest.TextureCoordinate = vert.TextureCoordinate;
                dest.Normal            = vert.Normal;
                dest.Tangent           = vert.Tangent;
                dest.Binormal          = vert.Binormal;

                // Add instance information that tells SunBurn which transform to use in the instance transform array.
                dest.BoneIndex0 = (byte)instancetransformindex;
                // Required for instancing.
                dest.BoneWeights = Vector4.UnitX;

                _vertices.Add(dest);
            }

            // Copy all indices into the container object, adjusting for existing instances.
            foreach (short index in _source.Indices)
            {
                _indices.Add((short)(index + indexoffset));
            }

            return(true);
        }
예제 #4
0
        /// <summary>
        ///   Add the required Geometry for hardware instancing
        /// </summary>
        /// <param name = "instancetransformindex">the index used in the SceneObejct.SkinBones array to position the instance</param>
        /// <returns>Returns true if succeeed; false otherwise.</returns>
        private bool AddGeometry(int instancetransformindex)
        {
            // Get the number of vertices already in the container object to readjust the new instance's destination indices.
            int indexoffset = _vertices.Count;

            // Avoid overflowing the indices.
            int finalmaxindex = indexoffset + _source.Vertices.Length;
            if (finalmaxindex > short.MaxValue)
                return false;

            // Copy all vertices into the container object.
            foreach (VertexPositionNormalTextureBump vert in _source.Vertices)
            {
                VertexPositionNormalTextureBumpSkin dest = new VertexPositionNormalTextureBumpSkin();

                // Copy source data.
                dest.Position = vert.Position;
                dest.TextureCoordinate = vert.TextureCoordinate;
                dest.Normal = vert.Normal;
                dest.Tangent = vert.Tangent;
                dest.Binormal = vert.Binormal;

                // Add instance information that tells SunBurn which transform to use in the instance transform array.
                dest.BoneIndex0 = (byte) instancetransformindex;
                // Required for instancing.
                dest.BoneWeights = Vector4.UnitX;

                _vertices.Add(dest);
            }

            // Copy all indices into the container object, adjusting for existing instances.
            foreach (short index in _source.Indices)
                _indices.Add((short) (index + indexoffset));

            return true;
        }