• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Graphics.VertexData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Axiom.Graphics.VertexData的典型用法代码示例。如果您正苦于以下问题:C# VertexData类的具体用法?C# VertexData怎么用?C# VertexData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VertexData类属于Axiom.Graphics命名空间,在下文中一共展示了VertexData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetSubmeshVertexData

 public static void GetSubmeshVertexData(out Vector3[] points, VertexData vertexData)
 {
     //				if (subMesh.operationType != RenderMode.TriangleList)
     //					continue;
     points = null;
     for (ushort bindIdx = 0; bindIdx < vertexData.vertexDeclaration.ElementCount; ++bindIdx) {
         VertexElement element = vertexData.vertexDeclaration.GetElement(bindIdx);
         HardwareVertexBuffer vBuffer = vertexData.vertexBufferBinding.GetBuffer(bindIdx);
         if (element.Semantic != VertexElementSemantic.Position)
             continue;
         points = new Vector3[vertexData.vertexCount];
         ReadBuffer(vBuffer, vertexData.vertexCount, element.Size, ref points);
         return;
     }
     Debug.Assert(points != null, "Unable to retrieve position vertex data");
 }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:16,代码来源:MeshUtility.cs


示例2: WireBoundingBox

        /// <summary>
        ///    Default constructor.
        /// </summary>
        public WireBoundingBox()
        {
            vertexData = new VertexData();
            vertexData.vertexCount = 24;
            vertexData.vertexStart = 0;

            // get a reference to the vertex declaration and buffer binding
            VertexDeclaration decl = vertexData.vertexDeclaration;
            VertexBufferBinding binding = vertexData.vertexBufferBinding;

            // add elements for position and color only
            decl.AddElement(POSITION, 0, VertexElementType.Float3, VertexElementSemantic.Position);
            decl.AddElement(COLOR, 0, VertexElementType.Color, VertexElementSemantic.Diffuse);

            // create a new hardware vertex buffer for the position data
            HardwareVertexBuffer buffer  =
                HardwareBufferManager.Instance.CreateVertexBuffer(
                decl.GetVertexSize(POSITION),
                vertexData.vertexCount,
                BufferUsage.StaticWriteOnly);

            // bind the position buffer
            binding.SetBinding(POSITION, buffer);

            // create a new hardware vertex buffer for the color data
            buffer  = 	HardwareBufferManager.Instance.CreateVertexBuffer(
                decl.GetVertexSize(COLOR),
                vertexData.vertexCount,
                BufferUsage.StaticWriteOnly);

            // bind the color buffer
            binding.SetBinding(COLOR, buffer);

            Material mat = MaterialManager.Instance.GetByName("Core/WireBB");

            if(mat == null) {
                mat = MaterialManager.Instance.GetByName("BaseWhite");
                mat = mat.Clone("Core/WireBB");
                mat.Lighting = false;
            }

            this.Material = mat;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:46,代码来源:WireBoundingBox.cs


示例3: GeometryBucket

        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);
            }
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:41,代码来源:GeometryBucket.cs


示例4: Rectangle2D

        public Rectangle2D(bool includeTextureCoordinates)
        {
            vertexData = new VertexData();
            vertexData.vertexStart = 0;
            vertexData.vertexCount = 4;

            VertexDeclaration decl = vertexData.vertexDeclaration;
            VertexBufferBinding binding = vertexData.vertexBufferBinding;

            decl.AddElement(POSITION, 0, VertexElementType.Float3, VertexElementSemantic.Position);

            HardwareVertexBuffer buffer =
                HardwareBufferManager.Instance.CreateVertexBuffer(
                    decl.GetVertexSize(POSITION),
                    vertexData.vertexCount,
                    BufferUsage.StaticWriteOnly);

            binding.SetBinding(POSITION, buffer);

            if(includeTextureCoordinates) {
                decl.AddElement(TEXCOORD, 0, VertexElementType.Float2, VertexElementSemantic.TexCoords);

                buffer =
                    HardwareBufferManager.Instance.CreateVertexBuffer(
                    decl.GetVertexSize(TEXCOORD),
                    vertexData.vertexCount,
                    BufferUsage.StaticWriteOnly);

                binding.SetBinding(TEXCOORD, buffer);

                buffer.WriteData(0, buffer.Size, texCoords, true);
            }

            // TODO: Fix
            material = MaterialManager.Instance.GetByName("BaseWhite");
            material.Lighting = false;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:37,代码来源:Rectangle2D.cs


示例5: Clone

		/// <summary>
		///		Clones this vertex data, potentially including replicating any vertex buffers.
		/// </summary>
		/// <param name="copyData">
		///		If true, makes a copy the vertex buffer in addition to the definition.
		///		If false, the clone will refer to the same vertex buffer this object refers to.
		/// </param>
		/// <returns>A cloned vertex data object.</returns>
		public VertexData Clone( bool copyData )
		{
			VertexData dest = new VertexData();

			// Copy vertex buffers in turn
			Dictionary<short, HardwareVertexBuffer> bindings = vertexBufferBinding.Bindings;

			foreach ( short source in bindings.Keys )
			{
				HardwareVertexBuffer srcbuf = bindings[ source ];
				HardwareVertexBuffer dstBuf;

				if ( copyData )
				{
					// create new buffer with the same settings
					dstBuf =
						HardwareBufferManager.Instance.CreateVertexBuffer( srcbuf.VertexDeclaration, srcbuf.VertexCount, srcbuf.Usage,	srcbuf.HasShadowBuffer );

					// copy data
					dstBuf.CopyData( srcbuf, 0, 0, srcbuf.Size, true );
				}
				else
				{
					// don't copy, point at existing buffer
					dstBuf = srcbuf;
				}

				// Copy binding
				dest.vertexBufferBinding.SetBinding( source, dstBuf );
			}

			// Basic vertex info
			dest.vertexStart = this.vertexStart;
			dest.vertexCount = this.vertexCount;

			// Copy elements
			for ( int i = 0; i < vertexDeclaration.ElementCount; i++ )
			{
				VertexElement element = vertexDeclaration.GetElement( i );

				dest.vertexDeclaration.AddElement( element.Source, element.Offset, element.Type, element.Semantic, element.Index );
			}

			// Copy hardware shadow buffer if set up
			if ( hardwareShadowVolWBuffer != null )
			{
				dest.hardwareShadowVolWBuffer =
					HardwareBufferManager.Instance.CreateVertexBuffer( hardwareShadowVolWBuffer.VertexDeclaration, hardwareShadowVolWBuffer.VertexCount, hardwareShadowVolWBuffer.Usage, hardwareShadowVolWBuffer.HasShadowBuffer );

				// copy data
				dest.hardwareShadowVolWBuffer.CopyData( hardwareShadowVolWBuffer, 0, 0, hardwareShadowVolWBuffer.Size,true );
			}

			// copy anim data
			dest.HWAnimationDataList = HWAnimationDataList;
			dest.HWAnimDataItemsUsed = HWAnimDataItemsUsed;

			return dest;
		}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:67,代码来源:VertexIndexData.cs


示例6: FindBlendedVertexData

		/// <summary>
		///		Internal method - given vertex data which could be from the <see cref="Mesh"/> or
		///		any <see cref="SubMesh"/>, finds the temporary blend copy.
		/// </summary>
		/// <param name="originalData"></param>
		/// <returns></returns>
		protected VertexData FindBlendedVertexData( VertexData originalData )
		{
			if ( originalData == this.mesh.SharedVertexData )
			{
				return HasSkeleton ? this.skelAnimVertexData : this.softwareVertexAnimVertexData;
			}

			foreach ( var se in this.subEntityList )
			{
				if ( originalData == se.SubMesh.vertexData )
				{
					return HasSkeleton ? se.SkelAnimVertexData : se.SoftwareVertexAnimVertexData;
				}
			}

			throw new Exception( "Cannot find blended version of the vertex data specified." );
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:23,代码来源:Entity.cs


示例7: RebindPositionBuffer

			/// <summary>
			///		Rebind the source positions for temp buffer users.
			/// </summary>
			public void RebindPositionBuffer( VertexData vertexData, bool force )
			{
				if ( force || this.currentVertexData != vertexData )
				{
					this.currentVertexData = vertexData;
					this.positionBuffer = this.currentVertexData.vertexBufferBinding.GetBuffer( this.originalPosBufferBinding );
					renderOperation.vertexData.vertexBufferBinding.SetBinding( 0, this.positionBuffer );
					if ( lightCap != null )
					{
						( (EntityShadowRenderable)lightCap ).RebindPositionBuffer( vertexData, force );
					}
				}
			}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:16,代码来源:Entity.cs


示例8: EntityShadowRenderable

			public EntityShadowRenderable( Entity parent, HardwareIndexBuffer indexBuffer, VertexData vertexData,
			                               bool createSeperateLightCap, SubEntity subEntity )
				: this( parent, indexBuffer, vertexData, createSeperateLightCap, subEntity, false )
			{
			}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:5,代码来源:Entity.cs


示例9: CloneVertexDataRemoveBlendInfo

		/// <summary>
		///		Internal method to clone vertex data definitions but to remove blend buffers.
		/// </summary>
		/// <param name="source">Vertex data to clone.</param>
		/// <returns>A cloned instance of 'source' without blending information.</returns>
		protected internal VertexData CloneVertexDataRemoveBlendInfo( VertexData source )
		{
			// Clone without copying data
			var ret = source.Clone( false );
			var blendIndexElem = source.vertexDeclaration.FindElementBySemantic( VertexElementSemantic.BlendIndices );
			var blendWeightElem = source.vertexDeclaration.FindElementBySemantic( VertexElementSemantic.BlendWeights );

			// Remove blend index
			if ( blendIndexElem != null )
			{
				// Remove buffer reference
				ret.vertexBufferBinding.UnsetBinding( blendIndexElem.Source );
			}

			if ( blendWeightElem != null && blendWeightElem.Source != blendIndexElem.Source )
			{
				// Remove buffer reference
				ret.vertexBufferBinding.UnsetBinding( blendWeightElem.Source );
			}
			// remove elements from declaration
			ret.vertexDeclaration.RemoveElement( VertexElementSemantic.BlendIndices );
			ret.vertexDeclaration.RemoveElement( VertexElementSemantic.BlendWeights );

			// copy reference to w-coord buffer
			if ( source.hardwareShadowVolWBuffer != null )
			{
				ret.hardwareShadowVolWBuffer = source.hardwareShadowVolWBuffer;
			}

			return ret;
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:36,代码来源:Entity.cs


示例10: InitHardwareAnimationElements

		/// <summary>
		///     Initialize the hardware animation elements for given vertex data
		/// </summary>
		private void InitHardwareAnimationElements( VertexData vdata, ushort numberOfElements )
		{
			if ( vdata.HWAnimationDataList.Count < numberOfElements )
			{
				vdata.AllocateHardwareAnimationElements( numberOfElements );
			}
			// Initialize parametrics incase we don't use all of them
			for ( var i = 0; i < vdata.HWAnimationDataList.Count; i++ )
			{
				vdata.HWAnimationDataList[ i ].Parametric = 0.0f;
			}
			// reset used count
			vdata.HWAnimDataItemsUsed = 0;
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:17,代码来源:Entity.cs


示例11: ReadGeometryVertexElement

		protected virtual void ReadGeometryVertexElement( BinaryReader reader, VertexData data )
		{
			var source = ReadShort( reader );
			var type = (VertexElementType)ReadUShort( reader );
			var semantic = (VertexElementSemantic)ReadUShort( reader );
			var offset = ReadShort( reader );
			var index = ReadShort( reader );

			// add the element to the declaration for the current vertex data
			data.vertexDeclaration.AddElement( source, offset, type, semantic, index );

			if ( type == VertexElementType.Color )
			{
				LogManager.Instance.Write(
					"Warning: VET_COLOUR element type is deprecated, you should use " +
					"one of the more specific types to indicate the byte order. " + "Use OgreMeshUpgrade on {0} as soon as possible. ",
					this.mesh.Name );
			}
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:19,代码来源:MeshSerializerImpl.cs


示例12: ReadGeometryVertexDeclaration

		protected virtual void ReadGeometryVertexDeclaration( BinaryReader reader, VertexData data )
		{
			// find optional geometry chunks
			if ( !IsEOF( reader ) )
			{
				var chunkID = ReadChunk( reader );

				while ( !IsEOF( reader ) && ( chunkID == MeshChunkID.GeometryVertexElement ) )
				{
					switch ( chunkID )
					{
						case MeshChunkID.GeometryVertexElement:
							ReadGeometryVertexElement( reader, data );
							break;
					}

					// get the next chunk
					if ( !IsEOF( reader ) )
					{
						chunkID = ReadChunk( reader );
					}
				}

				if ( !IsEOF( reader ) )
				{
					// backpedal to start of non-submesh chunk
					Seek( reader, -ChunkOverheadSize );
				}
			}
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:30,代码来源:MeshSerializerImpl.cs


示例13: ReadGeometry

		protected virtual void ReadGeometry( BinaryReader reader, VertexData data )
		{
			data.vertexStart = 0;
			data.vertexCount = ReadInt( reader );

			// find optional geometry chunks
			if ( !IsEOF( reader ) )
			{
				var chunkID = ReadChunk( reader );

				while ( !IsEOF( reader ) &&
				        ( chunkID == MeshChunkID.GeometryVertexDeclaration || chunkID == MeshChunkID.GeometryVertexBuffer ) )
				{
					switch ( chunkID )
					{
						case MeshChunkID.GeometryVertexDeclaration:
							ReadGeometryVertexDeclaration( reader, data );
							break;

						case MeshChunkID.GeometryVertexBuffer:
							ReadGeometryVertexBuffer( reader, data );
							break;
					}

					// get the next chunk
					if ( !IsEOF( reader ) )
					{
						chunkID = ReadChunk( reader );
					}
				}

				if ( !IsEOF( reader ) )
				{
					// backpedal to start of non-submesh chunk
					Seek( reader, -ChunkOverheadSize );
				}

				// TODO : Implement color conversions
				// Perform any necessary color conversion for an active rendersystem
				//if ( Root.Instance != null && Root.Instance.RenderSystem != null )
				//{
				//    // We don't know the source type if it's VET_COLOUR, but assume ARGB
				//    // since that's the most common. Won't get used unless the mesh is
				//    // ambiguous anyway, which will have been warned about in the log
				//    data.ConvertPackedColor( VertexElementType.Color, VertexElement.BestColorVertexElementType );
				//}
			}
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:48,代码来源:MeshSerializerImpl.cs


示例14: CreateBuffers

		/// <summary>
		///     Allocate / reallocate vertex data
		///     Note that we allocate enough space for ALL the billboards in the pool, but only issue
		///     rendering operations for the sections relating to the active billboards
		/// </summary>
		private void CreateBuffers()
		{
			/* Alloc positions   ( 1 or 4 verts per billboard, 3 components )
					 colours     ( 1 x RGBA per vertex )
					 indices     ( 6 per billboard ( 2 tris ) if not point rendering )
					 tex. coords ( 2D coords, 1 or 4 per billboard )
			*/

			//             LogManager.Instance.Write(string.Format("BillBoardSet.CreateBuffers entered; vertexData {0}, indexData {1}, mainBuffer {2}",
			//                     vertexData == null ? "null" : vertexData.ToString(),
			//                     indexData == null ? "null" : indexData.ToString(),
			//                     mainBuffer == null ? "null" : mainBuffer.ToString()));

			// Warn if user requested an invalid setup
			// Do it here so it only appears once
			if ( this.pointRendering && this.billboardType != BillboardType.Point )
			{
				LogManager.Instance.Write(
						"Warning: BillboardSet {0} has point rendering enabled but is using a type " +
						"other than BillboardType.Point, this may not give you the results you " +
						"expect.",
						this.name );
			}

			this.vertexData = new VertexData();
			if ( this.pointRendering )
			{
				this.vertexData.vertexCount = this.poolSize;
			}
			else
			{
				this.vertexData.vertexCount = this.poolSize * 4;
			}

			this.vertexData.vertexStart = 0;

			// Vertex declaration
			VertexDeclaration decl = this.vertexData.vertexDeclaration;
			VertexBufferBinding binding = this.vertexData.vertexBufferBinding;

			int offset = 0;
			decl.AddElement( 0, offset, VertexElementType.Float3, VertexElementSemantic.Position );
			offset += VertexElement.GetTypeSize( VertexElementType.Float3 );
			decl.AddElement( 0, offset, VertexElementType.Color, VertexElementSemantic.Diffuse );
			offset += VertexElement.GetTypeSize( VertexElementType.Color );
			// Texture coords irrelevant when enabled point rendering (generated
			// in point sprite mode, and unused in standard point mode)
			if ( !this.pointRendering )
			{
				decl.AddElement( 0, offset, VertexElementType.Float2, VertexElementSemantic.TexCoords, 0 );
			}

			this.mainBuffer =
					HardwareBufferManager.Instance.CreateVertexBuffer( decl.Clone( 0 ), this.vertexData.vertexCount, BufferUsage.DynamicWriteOnlyDiscardable );

			// bind position and diffuses
			binding.SetBinding( 0, this.mainBuffer );

			if ( !this.pointRendering )
			{
				this.indexData = new IndexData();

				// calc index buffer size
				this.indexData.indexStart = 0;
				this.indexData.indexCount = this.poolSize * 6;

				// create the index buffer
				this.indexData.indexBuffer =
						HardwareBufferManager.Instance.CreateIndexBuffer(
								IndexType.Size16,
								this.indexData.indexCount,
								BufferUsage.StaticWriteOnly );

				/* Create indexes (will be the same every frame)
				   Using indexes because it means 1/3 less vertex transforms (4 instead of 6)

				   Billboard layout relative to camera:

					0-----1
					|    /|
					|  /  |
					|/    |
					2-----3
				*/

				// lock the index buffer
				IntPtr idxPtr = this.indexData.indexBuffer.Lock( BufferLocking.Discard );

				unsafe
				{
					ushort* pIdx = (ushort*)idxPtr.ToPointer();

					for ( int idx, idxOffset, bboard = 0; bboard < this.poolSize; ++bboard )
					{
						// Do indexes
//.........这里部分代码省略.........
开发者ID:WolfgangSt,项目名称:axiom,代码行数:101,代码来源:BillboardSet.cs


示例15: InitVertexBuffer

        private VertexData InitVertexBuffer(int numVerts)
        {
            vertexData = new VertexData();

            vertexData.vertexCount = numVerts;
            vertexData.vertexStart = 0;

            // set up the vertex declaration
            int vDecOffset = 0;
            vertexData.vertexDeclaration.AddElement(0, vDecOffset, VertexElementType.Float3, VertexElementSemantic.Position);
            vDecOffset += VertexElement.GetTypeSize(VertexElementType.Float3);

            vertexData.vertexDeclaration.AddElement(0, vDecOffset, VertexElementType.Float3, VertexElementSemantic.Normal);
            vDecOffset += VertexElement.GetTypeSize(VertexElementType.Float3);

            vertexData.vertexDeclaration.AddElement(0, vDecOffset, VertexElementType.Float2, VertexElementSemantic.TexCoords);
            vDecOffset += VertexElement.GetTypeSize(VertexElementType.Float2);

            // create the hardware vertex buffer and set up the buffer binding
            HardwareVertexBuffer hvBuffer = HardwareBufferManager.Instance.CreateVertexBuffer(
                vertexData.vertexDeclaration.GetVertexSize(0), vertexData.vertexCount,
                BufferUsage.StaticWriteOnly, false);

            vertexData.vertexBufferBinding.SetBinding(0, hvBuffer);

            return vertexData;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:27,代码来源:EditableHeightField.cs


示例16: Rectangle2D

		public Rectangle2D( bool includeTextureCoordinates )
		{
			// use identity projection and view matrices
			vertexData = new VertexData();
			renderOperation.vertexData = vertexData;
			renderOperation.vertexData.vertexStart = 0;
			renderOperation.vertexData.vertexCount = 4;
			renderOperation.useIndices = false;
			renderOperation.operationType = OperationType.TriangleStrip;

			var decl = vertexData.vertexDeclaration;
			var binding = vertexData.vertexBufferBinding;

			decl.AddElement( POSITION, 0, VertexElementType.Float3, VertexElementSemantic.Position );

			var buffer = HardwareBufferManager.Instance.CreateVertexBuffer( decl.Clone( POSITION ), vertexData.vertexCount,
			                                                                BufferUsage.StaticWriteOnly );

			binding.SetBinding( POSITION, buffer );

			decl.AddElement( NORMAL, 0, VertexElementType.Float3, VertexElementSemantic.Normal );

			buffer = HardwareBufferManager.Instance.CreateVertexBuffer( decl.Clone( NORMAL ),
			                                                            renderOperation.vertexData.vertexCount,
			                                                            BufferUsage.StaticWriteOnly );

			binding.SetBinding( NORMAL, buffer );

#if !AXIOM_SAFE_ONLY
			unsafe
#endif
			{
				var pNormBuf = buffer.Lock( BufferLocking.Discard ).ToFloatPointer();
				var pNorm = 0;
				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 1.0f;

				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 1.0f;

				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 1.0f;

				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm++ ] = 0.0f;
				pNormBuf[ pNorm ] = 1.0f;

				buffer.Unlock();
			}
			if ( includeTextureCoordinates )
			{
				decl.AddElement( TEXCOORD, 0, VertexElementType.Float2, VertexElementSemantic.TexCoords );

				buffer = HardwareBufferManager.Instance.CreateVertexBuffer( decl.Clone( TEXCOORD ), vertexData.vertexCount,
				                                                            BufferUsage.StaticWriteOnly );

				binding.SetBinding( TEXCOORD, buffer );

				buffer.WriteData( 0, buffer.Size, texCoords, true );
			}

			// TODO: Fix
			material = (Material)MaterialManager.Instance[ "BaseWhite" ];
			material.Lighting = false;
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:68,代码来源:Rectangle2D.cs


示例17: ReadGeometryVertexBuffer

		protected virtual void ReadGeometryVertexBuffer( BinaryReader reader, VertexData data )
		{
			// Index to bind this buffer to
			var bindIdx = ReadShort( reader );

			// Per-vertex size, must agree with declaration at this index
			var vertexSize = ReadShort( reader );

			// check for vertex data header
			var chunkID = ReadChunk( reader );

			if ( chunkID != MeshChunkID.GeometryVertexBufferData )
			{
				throw new AxiomException( "Can't find vertex buffer data area!" );
			}

			// check that vertex size agrees
			if ( data.vertexDeclaration.GetVertexSize( bindIdx ) != vertexSize )
			{
				throw new AxiomException( "Vertex buffer size does not agree with vertex declaration!" );
			}

			// create/populate vertex buffer
			var buffer = HardwareBufferManager.Instance.CreateVertexBuffer( data.vertexDeclaration.Clone( bindIdx ),
			                                                                data.vertexCount, this.mesh.VertexBufferUsage,
			                                                                this.mesh.UseVertexShadowBuffer );

			var bufferPtr = buffer.Lock( BufferLocking.Discard );

			ReadBytes( reader, data.vertexCount*vertexSize, bufferPtr );

			buffer.Unlock();

			// set binding
			data.vertexBufferBinding.SetBinding( bindIdx, buffer );
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:36,代码来源:MeshSerializerImpl.cs


示例18: PrepareTempBlendedBuffers

		/// <summary>
		///		Internal method for preparing this Entity for use in animation.
		/// </summary>
		protected internal void PrepareTempBlendedBuffers()
		{
			if ( this.skelAnimVertexData != null )
			{
				this.skelAnimVertexData = null;
			}
			if ( this.softwareVertexAnimVertexData != null )
			{
				this.softwareVertexAnimVertexData = null;
			}
			if ( this.hardwareVertexAnimVertexData != null )
			{
				this.hardwareVertexAnimVertexData = null;
			}

			if ( this.mesh.HasVertexAnimation )
			{
				// Shared data
				if ( this.mesh.SharedVertexData != null && this.mesh.SharedVertexDataAnimationType != VertexAnimationType.None &&
				     this.tempVertexAnimInfo != null )
				{
					// Create temporary vertex blend info
					// Prepare temp vertex data if needed
					// Clone without copying data, don't remove any blending info
					// (since if we skeletally animate too, we need it)
					this.softwareVertexAnimVertexData = this.mesh.SharedVertexData.Clone( false );
					ExtractTempBufferInfo( this.softwareVertexAnimVertexData, this.tempVertexAnimInfo );

					// Also clone for hardware usage, don't remove blend info since we'll
					// need it if we also hardware skeletally animate
					this.hardwareVertexAnimVertexData = this.mesh.SharedVertexData.Clone( false );
				}
			}

			if ( HasSkeleton )
			{
				// shared data
				if ( this.mesh.SharedVertexData != null )
				{
					// Create temporary vertex blend info
					// Prepare temp vertex data if needed
					// Clone without copying data, remove blending info
					// (since blend is performed in software)
					this.skelAnimVertexData = CloneVertexDataRemoveBlendInfo( this.mesh.SharedVertexData );
					ExtractTempBufferInfo( this.skelAnimVertexData, this.tempSkelAnimInfo );
				}
			}

			// prepare temp blending buffers for subentites as well
			foreach ( var se in this.subEntityList )
			{
				se.PrepareTempBlendBuffers();
			}
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:57,代码来源:Entity.cs


示例19: ExtractTempBufferInfo

		/// <summary>
		///		Internal method for extracting metadata out of source vertex data
		///		for fast assignment of temporary buffers later.
		/// </summary>
		/// <param name="sourceData"></param>
		/// <param name="info"></param>
		protected internal void ExtractTempBufferInfo( VertexData sourceData, TempBlendedBufferInfo info )
		{
			info.ExtractFrom( sourceData );
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:10,代码来源:Entity.cs


示例20: ReadGeometryPositions

		protected virtual void ReadGeometryPositions( short bindIdx, BinaryReader reader, VertexData data )
		{
			data.vertexDeclaration.AddElement( bindIdx, 0, VertexElementType.Float3, VertexElementSemantic.Position );

			// vertex buffers
			var vBuffer = HardwareBufferManager.Instance.CreateVertexBuffer( data.vertexDeclaration.Clone( bindIdx ),
			                                                                 data.vertexCount, mesh.VertexBufferUsage,
			                                                                 mesh.UseVertexShadowBuffer );

			var posData = vBuffer.Lock( BufferLocking.Discard );

			// ram the floats into the buffer data
			ReadFloats( reader, data.vertexCount*3, posData );

			// unlock the buffer
			vBuffer.Unlock();

			// bind the position data
			data.vertexBufferBinding.SetBinding( bindIdx, vBuffer );
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:20,代码来源:MeshSerializerImpl.cs



注:本文中的Axiom.Graphics.VertexData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Math.AxisAlignedBox类代码示例发布时间:2022-05-24
下一篇:
C# Graphics.GpuProgramParameters类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap