예제 #1
0
            public void Assign(QueuedSubMesh qsm, ushort atlod)
            {
                var q = new QueuedGeometry();

                this.queuedGeometryList.Add(q);
                q.position    = qsm.position;
                q.orientation = qsm.orientation;
                q.scale       = qsm.scale;
                if (qsm.geometryLodList.Count > atlod)
                {
                    // This submesh has enough lods, use the right one
                    q.geometry = (SubMeshLodGeometryLink)qsm.geometryLodList[atlod];
                }
                else
                {
                    // Not enough lods, use the lowest one we have
                    q.geometry = (SubMeshLodGeometryLink)qsm.geometryLodList[qsm.geometryLodList.Count - 1];
                }
                // Locate a material bucket
                MaterialBucket mbucket;

                if (this.materialBucketMap.ContainsKey(qsm.materialName))
                {
                    mbucket = this.materialBucketMap[qsm.materialName];
                }
                else
                {
                    mbucket = new MaterialBucket(this, qsm.materialName);
                    this.materialBucketMap.Add(qsm.materialName, mbucket);
                }
                mbucket.Assign(q);
            }
예제 #2
0
            public GeometryBucket(MaterialBucket parent,
                                  String formatString, VertexData vData,
                                  IndexData iData)
                : base()
            {
                mParent       = parent;
                mFormatString = formatString;
                mVertexData   = null;
                mIndexData    = null;
                mBatch        = mParent.Parent.Parent.Parent;
                if (mBatch.BaseSkeleton != null)
                {
                    SetCustomParameter(0, new Vector4(mBatch.BaseSkeleton.BoneCount, 0, 0, 0));
                }

                mVertexData = vData.Clone(false);

                renderOperation.useIndices = true;
                renderOperation.indexData  = new IndexData();

                renderOperation.indexData.indexCount   = 0;
                renderOperation.indexData.indexStart   = 0;
                renderOperation.vertexData             = new VertexData();
                renderOperation.vertexData.vertexCount = 0;

                renderOperation.vertexData.vertexDeclaration = (VertexDeclaration)vData.vertexDeclaration.Clone();
                mIndexType = iData.indexBuffer.Type;
                // Derive the max vertices
                if (mIndexType == IndexType.Size32)
                {
                    mMaxVertexIndex = 0xFFFFFFFF;
                }
                else
                {
                    mMaxVertexIndex = 0xFFFF;
                }

                int   offset = 0, tcOffset = 0;
                short texCoordOffset = 0;
                short texCoordSource = 0;

                for (int i = 0; i < renderOperation.vertexData.vertexDeclaration.ElementCount; i++)
                {
                    if (renderOperation.vertexData.vertexDeclaration.GetElement(i).Semantic == VertexElementSemantic.TexCoords)
                    {
                        texCoordOffset++;
                        texCoordSource = renderOperation.vertexData.vertexDeclaration.GetElement(i).Source;
                        tcOffset       = renderOperation.vertexData.vertexDeclaration.GetElement(i).Offset + VertexElement.GetTypeSize(
                            renderOperation.vertexData.vertexDeclaration.GetElement(i).Type);
                    }
                    offset += VertexElement.GetTypeSize(renderOperation.vertexData.vertexDeclaration.GetElement(i).Type);
                }

                renderOperation.vertexData.vertexDeclaration.AddElement(texCoordSource, tcOffset, VertexElementType.Float1,
                                                                        VertexElementSemantic.TexCoords, texCoordOffset);

                mTexCoordIndex = texCoordOffset;
            }
예제 #3
0
 private GeometryBucket(MaterialBucket parent, String formatString, GeometryBucket bucket)
     : base()
 {
     mParent       = parent;
     mFormatString = formatString;
     mBatch        = mParent.Parent.Parent.Parent;
     if (mBatch.BaseSkeleton != null)
     {
         SetCustomParameter(0, new Vector4(mBatch.BaseSkeleton.BoneCount, 0, 0, 0));
     }
     renderOperation = bucket.RenderOperation;
     mVertexData     = renderOperation.vertexData;
     mIndexData      = renderOperation.indexData;
     BoundingBox     = new BoundingBox(new Vector3(-10000, -10000, -10000), new Vector3(10000, 10000, 10000));
 }
예제 #4
0
        public GeometryBucket(MaterialBucket parent, string formatString,
                              VertexData vData, IndexData iData)
        {
            // Clone the structure from the example
            this.parent            = parent;
            this.formatString      = formatString;
            vertexData             = vData.Clone(false);
            indexData              = iData.Clone(false);
            vertexData.vertexCount = 0;
            vertexData.vertexStart = 0;
            indexData.indexCount   = 0;
            indexData.indexStart   = 0;
            indexType              = indexData.indexBuffer.Type;
            queuedGeometry         = new List <QueuedGeometry>();
            // Derive the max vertices
            if (indexType == IndexType.Size32)
            {
                maxVertexIndex = int.MaxValue;
            }
            else
            {
                maxVertexIndex = ushort.MaxValue;
            }

            // Check to see if we have blend indices / blend weights
            // remove them if so, they can try to blend non-existent bones!
            VertexElement blendIndices =
                vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.BlendIndices);
            VertexElement blendWeights =
                vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.BlendWeights);

            if (blendIndices != null && blendWeights != null)
            {
                Debug.Assert(blendIndices.Source == blendWeights.Source,
                             "Blend indices and weights should be in the same buffer");
                // Get the source
                ushort source = blendIndices.Source;
                Debug.Assert(blendIndices.Size + blendWeights.Size ==
                             vertexData.vertexBufferBinding.GetBuffer(source).VertexSize,
                             "Blend indices and blend buffers should have buffer to themselves!");
                // Unset the buffer
                vertexData.vertexBufferBinding.UnsetBinding(source);
                // Remove the elements
                vertexData.vertexDeclaration.RemoveElement(VertexElementSemantic.BlendIndices);
                vertexData.vertexDeclaration.RemoveElement(VertexElementSemantic.BlendWeights);
            }
        }
        public GeometryBucket(MaterialBucket parent, string formatString, 
                              VertexData vData, IndexData iData)
        {
            // Clone the structure from the example
            this.parent = parent;
            this.formatString = formatString;
            vertexData = vData.Clone(false);
            indexData = iData.Clone(false);
            vertexData.vertexCount = 0;
            vertexData.vertexStart = 0;
            indexData.indexCount = 0;
            indexData.indexStart = 0;
            indexType = indexData.indexBuffer.Type;
            queuedGeometry = new List<QueuedGeometry>();
            // Derive the max vertices
            if (indexType == IndexType.Size32)
                maxVertexIndex = int.MaxValue;
            else
                maxVertexIndex = ushort.MaxValue;

            // Check to see if we have blend indices / blend weights
            // remove them if so, they can try to blend non-existent bones!
            VertexElement blendIndices =
                vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.BlendIndices);
            VertexElement blendWeights =
                vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.BlendWeights);
            if (blendIndices != null && blendWeights != null) {
                Debug.Assert(blendIndices.Source == blendWeights.Source,
                             "Blend indices and weights should be in the same buffer");
                // Get the source
                ushort source = blendIndices.Source;
                Debug.Assert(blendIndices.Size + blendWeights.Size ==
                    vertexData.vertexBufferBinding.GetBuffer(source).VertexSize,
                    "Blend indices and blend buffers should have buffer to themselves!");
                // Unset the buffer
                vertexData.vertexBufferBinding.UnsetBinding(source);
                // Remove the elements
                vertexData.vertexDeclaration.RemoveElement(VertexElementSemantic.BlendIndices);
                vertexData.vertexDeclaration.RemoveElement(VertexElementSemantic.BlendWeights);
            }
        }
예제 #6
0
			public void Assign( QueuedSubMesh qsm, ushort atlod )
			{
				var q = new QueuedGeometry();
				this.queuedGeometryList.Add( q );
				q.position = qsm.position;
				q.orientation = qsm.orientation;
				q.scale = qsm.scale;
				if ( qsm.geometryLodList.Count > atlod )
				{
					// This submesh has enough lods, use the right one
					q.geometry = (SubMeshLodGeometryLink)qsm.geometryLodList[ atlod ];
				}
				else
				{
					// Not enough lods, use the lowest one we have
					q.geometry = (SubMeshLodGeometryLink)qsm.geometryLodList[ qsm.geometryLodList.Count - 1 ];
				}
				// Locate a material bucket
				MaterialBucket mbucket;
				if ( this.materialBucketMap.ContainsKey( qsm.materialName ) )
				{
					mbucket = this.materialBucketMap[ qsm.materialName ];
				}
				else
				{
					mbucket = new MaterialBucket( this, qsm.materialName );
					this.materialBucketMap.Add( qsm.materialName, mbucket );
				}
				mbucket.Assign( q );
			}
예제 #7
0
			private GeometryBucket( MaterialBucket parent, String formatString, GeometryBucket bucket )
				: base()
			{
				mParent = parent;
				mFormatString = formatString;
				mBatch = mParent.Parent.Parent.Parent;
				if ( mBatch.BaseSkeleton != null )
				{
					SetCustomParameter( 0, new Vector4( mBatch.BaseSkeleton.BoneCount, 0, 0, 0 ) );
				}
				renderOperation = bucket.RenderOperation;
				mVertexData = renderOperation.vertexData;
				mIndexData = renderOperation.indexData;
				BoundingBox = new BoundingBox( new Vector3( -10000, -10000, -10000 ), new Vector3( 10000, 10000, 10000 ) );
			}
예제 #8
0
			public GeometryBucket( MaterialBucket parent,
			                       String formatString, VertexData vData,
			                       IndexData iData )
				: base()
			{
				mParent = parent;
				mFormatString = formatString;
				mVertexData = null;
				mIndexData = null;
				mBatch = mParent.Parent.Parent.Parent;
				if ( mBatch.BaseSkeleton != null )
				{
					SetCustomParameter( 0, new Vector4( mBatch.BaseSkeleton.BoneCount, 0, 0, 0 ) );
				}

				mVertexData = vData.Clone( false );

				renderOperation.useIndices = true;
				renderOperation.indexData = new IndexData();

				renderOperation.indexData.indexCount = 0;
				renderOperation.indexData.indexStart = 0;
				renderOperation.vertexData = new VertexData();
				renderOperation.vertexData.vertexCount = 0;

				renderOperation.vertexData.vertexDeclaration = (VertexDeclaration)vData.vertexDeclaration.Clone();
				mIndexType = iData.indexBuffer.Type;
				// Derive the max vertices
				if ( mIndexType == IndexType.Size32 )
				{
					mMaxVertexIndex = 0xFFFFFFFF;
				}
				else
				{
					mMaxVertexIndex = 0xFFFF;
				}

				int offset = 0, tcOffset = 0;
				short texCoordOffset = 0;
				short texCoordSource = 0;
				for ( int i = 0; i < renderOperation.vertexData.vertexDeclaration.ElementCount; i++ )
				{
					if ( renderOperation.vertexData.vertexDeclaration.GetElement( i ).Semantic == VertexElementSemantic.TexCoords )
					{
						texCoordOffset++;
						texCoordSource = renderOperation.vertexData.vertexDeclaration.GetElement( i ).Source;
						tcOffset = renderOperation.vertexData.vertexDeclaration.GetElement( i ).Offset + VertexElement.GetTypeSize(
							renderOperation.vertexData.vertexDeclaration.GetElement( i ).Type );
					}
					offset += VertexElement.GetTypeSize( renderOperation.vertexData.vertexDeclaration.GetElement( i ).Type );
				}

				renderOperation.vertexData.vertexDeclaration.AddElement( texCoordSource, tcOffset, VertexElementType.Float1,
				                                                         VertexElementSemantic.TexCoords, texCoordOffset );

				mTexCoordIndex = texCoordOffset;
			}