本文整理汇总了C#中Axiom.Graphics.VertexData类的典型用法代码示例。如果您正苦于以下问题:C# VertexData类的具体用法?C# VertexData怎么用?C# VertexData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VertexData类属于Axiom.Graphics命名空间,在下文中一共展示了VertexData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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." );
}
示例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 );
}
}
}
示例8: EntityShadowRenderable
public EntityShadowRenderable( Entity parent, HardwareIndexBuffer indexBuffer, VertexData vertexData,
bool createSeperateLightCap, SubEntity subEntity )
: this( parent, indexBuffer, vertexData, createSeperateLightCap, subEntity, false )
{
}
示例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;
}
示例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;
}
示例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 );
}
}
示例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 );
}
}
}
示例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 );
//}
}
}
示例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
//.........这里部分代码省略.........
示例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;
}