本文整理汇总了C++中HardwareVertexBufferSharedPtr类的典型用法代码示例。如果您正苦于以下问题:C++ HardwareVertexBufferSharedPtr类的具体用法?C++ HardwareVertexBufferSharedPtr怎么用?C++ HardwareVertexBufferSharedPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HardwareVertexBufferSharedPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void DebugLines::draw()
{
if(_drawn) return;
else _drawn = true;
// Initialization stuff
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = _points.size();
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = RenderOperation::OT_LINE_LIST;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding *bind = mRenderOp.vertexData->vertexBufferBinding;
decl->addElement(0, 0, VET_FLOAT3, VES_POSITION);
HardwareVertexBufferSharedPtr vbuf =
HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
mRenderOp.vertexData->vertexCount,
HardwareBuffer::HBU_STATIC_WRITE_ONLY);
bind->setBinding(0, vbuf);
// Drawing stuff
size_t size = _points.size();
Vector3 vaabMin = _points[0];
Vector3 vaabMax = _points[0];
Real *prPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
for(size_t i = 0; i < size; i++)
{
*prPos++ = _points[i].x;
*prPos++ = _points[i].y;
*prPos++ = _points[i].z;
if(_points[i].x < vaabMin.x)
vaabMin.x = _points[i].x;
if(_points[i].y < vaabMin.y)
vaabMin.y = _points[i].y;
if(_points[i].z < vaabMin.z)
vaabMin.z = _points[i].z;
if(_points[i].x > vaabMax.x)
vaabMax.x = _points[i].x;
if(_points[i].y > vaabMax.y)
vaabMax.y = _points[i].y;
if(_points[i].z > vaabMax.z)
vaabMax.z = _points[i].z;
}
vbuf->unlock();
mBox.setExtents(vaabMin, vaabMax);
}
示例2: assert
void GeomUtils::createCone(Ogre::VertexData*& vertexData, Ogre::IndexData*& indexData,
float radius , float height, int nVerticesInBase)
{
assert(vertexData && indexData);
// define the vertex format
VertexDeclaration* vertexDecl = vertexData->vertexDeclaration;
// positions
vertexDecl->addElement(0, 0, VET_FLOAT3, VES_POSITION);
// allocate the vertex buffer
vertexData->vertexCount = nVerticesInBase + 1;
HardwareVertexBufferSharedPtr vBuf = HardwareBufferManager::getSingleton().createVertexBuffer(vertexDecl->getVertexSize(0), vertexData->vertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);
VertexBufferBinding* binding = vertexData->vertexBufferBinding;
binding->setBinding(0, vBuf);
float* pVertex = static_cast<float*>(vBuf->lock(HardwareBuffer::HBL_DISCARD));
// allocate index buffer - cone and base
indexData->indexCount = (3 * nVerticesInBase) + (3 * (nVerticesInBase - 2));
indexData->indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer(HardwareIndexBuffer::IT_16BIT, indexData->indexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);
HardwareIndexBufferSharedPtr iBuf = indexData->indexBuffer;
unsigned short* pIndices = static_cast<unsigned short*>(iBuf->lock(HardwareBuffer::HBL_DISCARD));
//Positions : cone head and base
for (int i=0; i<3; i++)
*pVertex++ = 0.0f;
//Base :
float fDeltaBaseAngle = (2 * Math::PI) / nVerticesInBase;
for (int i=0; i<nVerticesInBase; i++)
{
float angle = i * fDeltaBaseAngle;
*pVertex++ = radius * cosf(angle);
*pVertex++ = height;
*pVertex++ = radius * sinf(angle);
}
//Indices :
//Cone head to vertices
for (int i=0; i<nVerticesInBase; i++)
{
*pIndices++ = 0;
*pIndices++ = (i%nVerticesInBase) + 1;
*pIndices++ = ((i+1)%nVerticesInBase) + 1;
}
//Cone base
for (int i=0; i<nVerticesInBase-2; i++)
{
*pIndices++ = 1;
*pIndices++ = i + 3;
*pIndices++ = i + 2;
}
// Unlock
vBuf->unlock();
iBuf->unlock();
}
示例3:
//-----------------------------------------------------------------------
HardwareVertexBufferSharedPtr
HardwareBufferManagerBase::makeBufferCopy(
const HardwareVertexBufferSharedPtr& source,
HardwareBuffer::Usage usage, bool useShadowBuffer)
{
return this->createVertexBuffer(
source->getVertexSize(),
source->getNumVertices(),
usage, useShadowBuffer);
}
示例4: setGlobalInstanceVertexBuffer
//---------------------------------------------------------------------
void RenderSystem::setGlobalInstanceVertexBuffer( const HardwareVertexBufferSharedPtr val )
{
if ( !val.isNull() && !val->getIsInstanceData() )
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"A none instance data vertex buffer was set to be the global instance vertex buffer.",
"RenderSystem::setGlobalInstanceVertexBuffer");
}
mGlobalInstanceVertexBuffer = val;
}
示例5: prepareHardwareBuffers
void NxLine::fillHardwareBuffers()
{
int size = mPoints.size();
prepareHardwareBuffers(size,0, mUseVertexColour);
if (!size)
{
mBox.setExtents(Vector3::ZERO,Vector3::ZERO);
mDirty=false;
return;
}
Nx::Vector3 vaabMin = mPoints[0];
Nx::Vector3 vaabMax = mPoints[0];
HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Real *prPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
{
for(int i = 0; i < size; i++)
{
*prPos++ = mPoints[i].x;
*prPos++ = mPoints[i].y;
*prPos++ = mPoints[i].z;
if(mPoints[i].x < vaabMin.x)
vaabMin.x = mPoints[i].x;
if(mPoints[i].y < vaabMin.y)
vaabMin.y = mPoints[i].y;
if(mPoints[i].z < vaabMin.z)
vaabMin.z = mPoints[i].z;
if(mPoints[i].x > vaabMax.x)
vaabMax.x = mPoints[i].x;
if(mPoints[i].y > vaabMax.y)
vaabMax.y = mPoints[i].y;
if(mPoints[i].z > vaabMax.z)
vaabMax.z = mPoints[i].z;
}
}
vbuf->unlock();
if( mUseVertexColour ) {
HardwareVertexBufferSharedPtr cbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(1);
cbuf->writeData(0, size * sizeof(unsigned int), &mPointsColor[0], true );
}
mBox.setExtents( NxVec3ToOgre( vaabMin ), NxVec3ToOgre( vaabMax ) );
mDirty = false;
}
示例6: VertexData
//---------------------------------------------------------------------
void PrefabFactory::createPlane(Mesh* mesh)
{
SubMesh* sub = mesh->createSubMesh();
float vertices[32] = {
-100, -100, 0, // pos
0,0,1, // normal
0,1, // texcoord
100, -100, 0,
0,0,1,
1,1,
100, 100, 0,
0,0,1,
1,0,
-100, 100, 0 ,
0,0,1,
0,0
};
mesh->sharedVertexData = OGRE_NEW VertexData();
mesh->sharedVertexData->vertexCount = 4;
VertexDeclaration* decl = mesh->sharedVertexData->vertexDeclaration;
VertexBufferBinding* bind = mesh->sharedVertexData->vertexBufferBinding;
size_t offset = 0;
decl->addElement(0, offset, VET_FLOAT3, VES_POSITION);
offset += VertexElement::getTypeSize(VET_FLOAT3);
decl->addElement(0, offset, VET_FLOAT3, VES_NORMAL);
offset += VertexElement::getTypeSize(VET_FLOAT3);
decl->addElement(0, offset, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
offset += VertexElement::getTypeSize(VET_FLOAT2);
HardwareVertexBufferSharedPtr vbuf =
HardwareBufferManager::getSingleton().createVertexBuffer(
offset, 4, HardwareBuffer::HBU_STATIC_WRITE_ONLY);
bind->setBinding(0, vbuf);
vbuf->writeData(0, vbuf->getSizeInBytes(), vertices, true);
sub->useSharedVertices = true;
HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().
createIndexBuffer(
HardwareIndexBuffer::IT_16BIT,
6,
HardwareBuffer::HBU_STATIC_WRITE_ONLY);
unsigned short faces[6] = {0,1,2,
0,2,3 };
sub->indexData->indexBuffer = ibuf;
sub->indexData->indexCount = 6;
sub->indexData->indexStart =0;
ibuf->writeData(0, ibuf->getSizeInBytes(), faces, true);
mesh->_setBounds(AxisAlignedBox(-100,-100,0,100,100,0), true);
mesh->_setBoundingSphereRadius(Math::Sqrt(100*100+100*100));
}
示例7: SetTextureCoordinates
void NxTriangles::SetTextureCoordinates( const float * Coordinates )
{
HardwareVertexBufferSharedPtr cbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(2);
cbuf->writeData(0, cbuf->getNumVertices() * sizeof(float) * (mUVW ? 3 : 2), Coordinates, true );
}
示例8: ModVertexAlpha
void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
{
// Get the vertex colour buffer of this mesh
const Ogre::VertexElement* ves_diffuse = ent->getMesh()->getSubMesh(0)->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE );
HardwareVertexBufferSharedPtr colourBuffer = ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource());
// Lock
void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL);
// Iterate over all vertices
int vertex_size = colourBuffer->getVertexSize();
float * currentVertex = NULL;
for (unsigned int i=0; i<colourBuffer->getNumVertices(); ++i)
{
// Get a pointer to the vertex colour
ves_diffuse->baseVertexPointerToElement( pData, ¤tVertex );
unsigned char alpha=0;
if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row
else if (meshType == 1)
{
if (i>= 49 && i <= 64) alpha = 0; // bottom-most row
else if (i>= 33 && i <= 48) alpha = 64; // second bottom-most row
else alpha = 255;
}
uint8 tmpR = static_cast<uint8>(255);
uint8 tmpG = static_cast<uint8>(255);
uint8 tmpB = static_cast<uint8>(255);
uint8 tmpA = static_cast<uint8>(alpha);
// This does not matter since R and B are always 1.
/*VertexElementType format = Root::getSingleton().getRenderSystem()->getColourVertexElementType();
switch (format)
{
case VET_COLOUR_ARGB:
std::swap(tmpR, tmpB);
break;
case VET_COLOUR_ABGR:
break;
default:
break;
}*/
// Modify
*((uint32*)currentVertex) = tmpR | (tmpG << 8) | (tmpB << 16) | (tmpA << 24);
// Move to the next vertex
pData = static_cast<unsigned char *> (pData) + vertex_size;
}
// Unlock
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
}
示例9: destroyGpuVertexBackupData
//------------------------------------------------------------------------
void TerrainBatch::destroyGpuVertexBackupData()
{
if (mGpuVertexData)
{
HardwareVertexBufferSharedPtr destPosbuf = mGpuVertexData->vertexBufferBinding->getBuffer(TerrainTileRender::POSITION_BUFFER);
if ( destPosbuf.isNull() == false )
{
destPosbuf->freeSystemMemoryBuffer();
}
}
}
示例10: assert
void MovableText::_updateColors(void){
assert(mpFont);
assert(!mpMaterial.isNull());
// Convert to system-specific
RGBA color;
Root::getSingleton().convertColourValue(mColor, &color);
HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(COLOUR_BINDING);
RGBA *pDest = static_cast<RGBA*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
for (int i = 0; i < (int)mRenderOp.vertexData->vertexCount; ++i)
*pDest++ = color;
vbuf->unlock();
mUpdateColors = false;
}
示例11: testSingleIndexBufSingleVertexBuf
void EdgeBuilderTests::testSingleIndexBufSingleVertexBuf()
{
/* This tests the edge builders ability to find shared edges in the simple case
of a single index buffer referencing a single vertex buffer
*/
VertexData vd;
IndexData id;
// Test pyramid
vd.vertexCount = 4;
vd.vertexStart = 0;
vd.vertexDeclaration = HardwareBufferManager::getSingleton().createVertexDeclaration();
vd.vertexDeclaration->addElement(0, 0, VET_FLOAT3, VES_POSITION);
HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer(sizeof(float)*3, 4, HardwareBuffer::HBU_STATIC,true);
vd.vertexBufferBinding->setBinding(0, vbuf);
float* pFloat = static_cast<float*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
*pFloat++ = 0 ; *pFloat++ = 0 ; *pFloat++ = 0 ;
*pFloat++ = 50 ; *pFloat++ = 0 ; *pFloat++ = 0 ;
*pFloat++ = 0 ; *pFloat++ = 100; *pFloat++ = 0 ;
*pFloat++ = 0 ; *pFloat++ = 0 ; *pFloat++ = -50;
vbuf->unlock();
id.indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer(
HardwareIndexBuffer::IT_16BIT, 12, HardwareBuffer::HBU_STATIC, true);
id.indexCount = 12;
id.indexStart = 0;
unsigned short* pIdx = static_cast<unsigned short*>(id.indexBuffer->lock(HardwareBuffer::HBL_DISCARD));
*pIdx++ = 0; *pIdx++ = 1; *pIdx++ = 2;
*pIdx++ = 0; *pIdx++ = 2; *pIdx++ = 3;
*pIdx++ = 1; *pIdx++ = 3; *pIdx++ = 2;
*pIdx++ = 0; *pIdx++ = 3; *pIdx++ = 1;
id.indexBuffer->unlock();
EdgeListBuilder edgeBuilder;
edgeBuilder.addVertexData(&vd);
edgeBuilder.addIndexData(&id);
EdgeData* edgeData = edgeBuilder.build();
// Should be only one group, since only one vertex buffer
CPPUNIT_ASSERT(edgeData->edgeGroups.size() == 1);
// 4 tris
CPPUNIT_ASSERT(edgeData->triangles.size() == 4);
EdgeData::EdgeGroup& eg = edgeData->edgeGroups[0];
// 6 edges
CPPUNIT_ASSERT(eg.edges.size() == 6);
delete edgeData;
}
示例12: _getDerivedLeft
//---------------------------------------------------------------------
void PanelOverlayElement::updatePositionGeometry(void)
{
/*
0-----2
| /|
| / |
|/ |
1-----3
*/
Real left, right, top, bottom;
/* Convert positions into -1, 1 coordinate space (homogenous clip space).
- Left / right is simple range conversion
- Top / bottom also need inverting since y is upside down - this means
that top will end up greater than bottom and when computing texture
coordinates, we have to flip the v-axis (ie. subtract the value from
1.0 to get the actual correct value).
*/
left = _getDerivedLeft() * 2 - 1;
right = left + (mWidth * 2);
top = -((_getDerivedTop() * 2) - 1);
bottom = top - (mHeight * 2);
HardwareVertexBufferSharedPtr vbuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);
float* pPos = static_cast<float*>(
vbuf->lock(HardwareBuffer::HBL_DISCARD) );
// Use the furthest away depth value, since materials should have depth-check off
// This initialised the depth buffer for any 3D objects in front
Real zValue = Root::getSingleton().getRenderSystem()->getMaximumDepthInputValue();
*pPos++ = left;
*pPos++ = top;
*pPos++ = zValue;
*pPos++ = left;
*pPos++ = bottom;
*pPos++ = zValue;
*pPos++ = right;
*pPos++ = top;
*pPos++ = zValue;
*pPos++ = right;
*pPos++ = bottom;
*pPos++ = zValue;
vbuf->unlock();
}
示例13: prepareHardwareBuffers
void DynamicLines::fillHardwareBuffers()
{
int size = (int)mPoints.size();
prepareHardwareBuffers(size, 0);
if (!size)
{
mBox.setExtents(Vector3::ZERO, Vector3::ZERO);
mDirty = false;
return;
}
Vector3 vaabMin = mPoints[0];
Vector3 vaabMax = mPoints[0];
HardwareVertexBufferSharedPtr vbuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Real* prPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
{
for (int i = 0; i < size; i++)
{
*prPos++ = mPoints[i].x;
*prPos++ = mPoints[i].y;
*prPos++ = mPoints[i].z;
if (mPoints[i].x < vaabMin.x)
vaabMin.x = mPoints[i].x;
if (mPoints[i].y < vaabMin.y)
vaabMin.y = mPoints[i].y;
if (mPoints[i].z < vaabMin.z)
vaabMin.z = mPoints[i].z;
if (mPoints[i].x > vaabMax.x)
vaabMax.x = mPoints[i].x;
if (mPoints[i].y > vaabMax.y)
vaabMax.y = mPoints[i].y;
if (mPoints[i].z > vaabMax.z)
vaabMax.z = mPoints[i].z;
}
}
vbuf->unlock();
mBox.setExtents(vaabMin, vaabMax);
mDirty = false;
}
示例14:
void DebugRectangle2D::setCorners(Real left, Real top, Real right, Real bottom)
{
VertexDeclaration * const decl = mRenderOp.vertexData->vertexDeclaration;
const VertexElement* poselem = decl->findElementBySemantic(VES_POSITION);
const VertexElement* colorelem = decl->findElementBySemantic(VES_DIFFUSE);
HardwareVertexBufferSharedPtr vbuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);
const size_t vertexSize = vbuf->getVertexSize ();
float *pPos;
RGBA *pColor;
Root * const root = Root::getSingletonPtr();
uchar* pMain = static_cast<uchar *>(
vbuf->lock(HardwareBuffer::HBL_DISCARD));
// #define V3(AX, AY, AZ, ACOLOR) poselem->baseVertexPointerToElement(pMain, &pPos); \
// *pPos++ = AX; *pPos++ = AY; *pPos++ = AZ; \
// pMain += vertexSize;
#define V3(A_X, A_Y, A_Z, ACOLOR) poselem->baseVertexPointerToElement(pMain, &pPos); \
*pPos++ = static_cast <float> (A_X); \
*pPos++ = static_cast <float> (A_Y); \
*pPos++ = static_cast <float> (A_Z); \
colorelem->baseVertexPointerToElement(pMain, &pColor); \
root->convertColourValue (ACOLOR, pColor); \
pMain += vertexSize;
V3(left, top, -1.0f, ColourValue::White)
V3(left, bottom, -1.0f, ColourValue::White)
V3(right, bottom, -1.0f, ColourValue::White)
V3(right, top, -1.0f, ColourValue::White)
vbuf->unlock();
HardwareIndexBufferSharedPtr iBuf = mRenderOp.indexData->indexBuffer;
ushort* pIdx = static_cast<ushort*>(
iBuf->lock(0, iBuf->getSizeInBytes(),HardwareBuffer::HBL_DISCARD));
*pIdx++ = static_cast<ushort> (0); *pIdx++ = static_cast<ushort> (1); // line 1
*pIdx++ = static_cast<ushort> (1); *pIdx++ = static_cast<ushort> (2);// line 2
*pIdx++ = static_cast<ushort> (2); *pIdx++ = static_cast<ushort> (3);// line 3
*pIdx++ = static_cast<ushort> (3); *pIdx++ = static_cast<ushort> (0);// line 4
iBuf->unlock();
}
示例15: checkAndUpdateGpuVertexBackupData
//------------------------------------------------------------------------
void TerrainBatch::checkAndUpdateGpuVertexBackupData()
{
if ( mGpuVertexData )
{
HardwareVertexBufferSharedPtr destPosbuf = mGpuVertexData->vertexBufferBinding->getBuffer(TerrainTileRender::POSITION_BUFFER);
if ( destPosbuf.isNull() == false )
{
destPosbuf->createSystemMemoryBuffer();
{
updateVertexData( mVertexRectInTile );
}
destPosbuf->freeSystemMemoryBuffer();
}
}
}