本文整理汇总了C++中ogre::VertexDeclaration::addElement方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexDeclaration::addElement方法的具体用法?C++ VertexDeclaration::addElement怎么用?C++ VertexDeclaration::addElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::VertexDeclaration
的用法示例。
在下文中一共展示了VertexDeclaration::addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateAreaVertexBuffer
// 创建定点缓冲区
void CCustomShape::CreateAreaVertexBuffer()
{
if(0 == m_planePointArray.size())
{
return;
}
// 先把上次创建的缓冲区删掉
ClearVertexBuffer();
mRenderOp.vertexData = new Ogre::VertexData;
mRenderOp.vertexData->vertexCount = m_planePointArray.size();
mRenderOp.vertexData->vertexStart = 0;
Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
// 声明定点格式
size_t offset = 0;
decl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
decl->addElement(0, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
m_vbuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
mRenderOp.vertexData->vertexCount,
Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
mRenderOp.vertexData->vertexBufferBinding->setBinding(0, m_vbuf);
}
示例2: initialise
void LIRenImageOverlay::initialise ()
{
if (mInitialised)
return;
mInitialised = true;
/* Initialize the render operation. */
render_op.vertexData = new Ogre::VertexData ();
render_op.vertexData->vertexStart = 0;
render_op.vertexData->vertexCount = 0;
/* Setup the vertex format. */
size_t offset = 0;
Ogre::VertexDeclaration* format = render_op.vertexData->vertexDeclaration;
format->addElement (0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize (Ogre::VET_FLOAT3);
format->addElement (0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
offset += Ogre::VertexElement::getTypeSize (Ogre::VET_FLOAT2);
format->addElement (0, offset, Ogre::VET_COLOUR_ABGR, Ogre::VES_DIFFUSE);
offset += Ogre::VertexElement::getTypeSize (Ogre::VET_COLOUR_ABGR);
lisys_assert (offset == VERTEX_SIZE);
/* Create the vertex buffer. */
vbuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer (
offset, VERTEX_COUNT_INIT, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
/* Bind the vertex buffer. */
render_op.vertexData->vertexBufferBinding->setBinding (0, vbuf);
render_op.useIndexes = false;
render_op.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
}
示例3:
void OgreImGui::ImGUIRenderable::initImGUIRenderable(void)
{
// use identity projection and view matrices
mUseIdentityProjection = true;
mUseIdentityView = true;
mRenderOp.vertexData = OGRE_NEW Ogre::VertexData();
mRenderOp.indexData = OGRE_NEW Ogre::IndexData();
mRenderOp.vertexData->vertexCount = 0;
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.indexData->indexCount = 0;
mRenderOp.indexData->indexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
mRenderOp.useIndexes = true;
mRenderOp.useGlobalInstancingVertexBufferIsAvailable = false;
Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
// vertex declaration
size_t offset = 0;
decl->addElement(0,offset,Ogre::VET_FLOAT2,Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT2 );
decl->addElement(0,offset,Ogre::VET_FLOAT2,Ogre::VES_TEXTURE_COORDINATES,0);
offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT2 );
decl->addElement(0,offset,Ogre::VET_COLOUR,Ogre::VES_DIFFUSE);
// set basic white material
this->setMaterial( "imgui/material" );
}
示例4:
Line3D::Line3D()
{
mRenderOp.vertexData = new Ogre::VertexData();
this->SelfNode = Entresol::GetSingletonPtr()->GetSceneManager()->GetGraphicsWorldPointer()->getRootSceneNode()->createChildSceneNode();
// Initialization stuff
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = 1024;
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration* VDecl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* VBind = mRenderOp.vertexData->vertexBufferBinding;
size_t Offset = 0;
// Position.
VDecl->addElement(0,0,Ogre::VET_FLOAT3,Ogre::VES_POSITION);
Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
// Colour
VDecl->addElement(0,Offset,Ogre::VET_FLOAT4,Ogre::VES_DIFFUSE);
Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
this->VertexBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
VDecl->getVertexSize(0),
mRenderOp.vertexData->vertexCount,
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
false);
VBind->setBinding(0,this->VertexBuffer);
this->setMaterial("BaseWhiteNoLighting");
}
示例5:
void
IntersectGrid::_createBuffer()
{
// 先把上次创建的缓冲区删掉
if ( mRenderOp.vertexData )
{
delete mRenderOp.vertexData;
mRenderOp.vertexData = 0;
}
if ( mCurrentVertexCount <= 0 )
return;
mRenderOp.vertexData = new Ogre::VertexData;
mRenderOp.vertexData->vertexCount = mCurrentVertexCount;
mRenderOp.vertexData->vertexStart = 0;
Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
size_t offset = 0;
decl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
decl->addElement(0, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
vbuf =
Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
mRenderOp.vertexData->vertexCount,
Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
mRenderOp.vertexData->vertexBufferBinding->setBinding(0, vbuf);
}
示例6: createPureColourMaterial
AxisRenderable::AxisRenderable(int lineCount,Ogre::Camera* camera,Ogre::Viewport* viewport)
{
// Disable cast shadows by default
mCastShadows = false;
mPrevAxisGizmoSelAxis = -1;
mCamera = camera;
mViewport = viewport;
m_max_line_count = m_line_count = lineCount;
m_line_count = 0;
mLength = 200;
mProjectDistance = mCamera->getFarClipDistance();
m_local = false;
m_locked_data = 0;
//m_locked_buffer = 0;
mRenderOp.vertexData = new Ogre::VertexData();
m_radius = 0;
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = m_line_count*2;
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
decl->addElement(0, 3*sizeof(Ogre::Real), Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
Ogre::HardwareVertexBufferSharedPtr vbuf =
Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
2*m_max_line_count,
Ogre::HardwareBuffer::HBU_WRITE_ONLY);
bind->setBinding(0, vbuf);
// Obtain the pure colour material
Ogre::MaterialPtr pureColourMaterial = createPureColourMaterial(Ogre::ColourValue(1,1,0));
Ogre::String realName = pureColourMaterial->getName() + "_NoDepthBuffer";
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(realName);
if (material.isNull())
{
// Clone to avoid confuse somewhere else that using the same material
material = pureColourMaterial->clone(realName);
material->setDepthCheckEnabled(false);
material->setDepthWriteEnabled(false);
}
setMaterial(material->getName());
mBox.setExtents(-10,-10,-10,10,10,10);
setQueryFlags(0);
}
示例7: resizeBuffers
void Canvas::resizeBuffers()
{
if(bufferSize < quadList.size())
{
bufferSize = quadList.size() * 2;
destroyBuffers();
}
if(!vertexData)
{
vertexData = new Ogre::VertexData();
vertexData->vertexStart = 0;
vertexData->vertexCount = bufferSize * 4;
Ogre::VertexDeclaration* decl = vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* binding = vertexData->vertexBufferBinding;
size_t offset = 0;
decl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
decl->addElement(0, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_COLOUR);
decl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
buffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0), vertexData->vertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
binding->setBinding(0, buffer);
}
if(!indexData)
{
indexData = new Ogre::IndexData();
indexData->indexStart = 0;
indexData->indexCount = bufferSize * 6;
indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
Ogre::HardwareIndexBuffer::IT_16BIT, indexData->indexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
unsigned short* indexBuffer = (unsigned short*)indexData->indexBuffer->lock(0, indexData->indexBuffer->getSizeInBytes(), Ogre::HardwareBuffer::HBL_DISCARD);
// Indexes are generated here because we know that we will only be rendering quads
// This means that we only have to handle updating the vertex buffer in Canvas::updateGeometry
for(size_t indexIdx, vertexIdx, quadIdx = 0; quadIdx < bufferSize; quadIdx++)
{
indexIdx = quadIdx * 6;
vertexIdx = quadIdx * 4;
indexBuffer[indexIdx++] = (unsigned short)(vertexIdx + 0);
indexBuffer[indexIdx++] = (unsigned short)(vertexIdx + 2);
indexBuffer[indexIdx++] = (unsigned short)(vertexIdx + 1);
indexBuffer[indexIdx++] = (unsigned short)(vertexIdx + 1);
indexBuffer[indexIdx++] = (unsigned short)(vertexIdx + 2);
indexBuffer[indexIdx++] = (unsigned short)(vertexIdx + 3);
}
indexData->indexBuffer->unlock();
}
}
示例8: CreateVertexDeclaration
void CDynamicLineDrawer::CreateVertexDeclaration()
{
// Points
Ogre::VertexDeclaration *Decl = mRenderOp.vertexData->vertexDeclaration;
Decl->addElement(POSITION_BINDING, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
// Colour
Decl->addElement(COLOUR_BINDING, 0, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
}
示例9: createVertexDeclaration
void NxTriangles::createVertexDeclaration()
{
Ogre::VertexDeclaration* vdecl = mRenderOp.vertexData-> vertexDeclaration;
vdecl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
vdecl->addElement(1, 0, Ogre::VET_FLOAT3, Ogre::VES_NORMAL);
if(mUseVertexColour) {
vdecl->addElement( 2, 0, VET_COLOUR, VES_DIFFUSE );
}
else {
vdecl->addElement( 2, 0, mUVW ? VET_FLOAT3 : VET_FLOAT2, VES_TEXTURE_COORDINATES );
}
}
示例10: queries
Selection2D::Selection2D(bool includeTextureCoords)
{
// use identity projection and view matrices
mUseIdentityProjection = true;
mUseIdentityView = true;
mRenderOp.vertexData = OGRE_NEW Ogre::VertexData();
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = 5;
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_STRIP;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0), mRenderOp.vertexData->vertexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
// Bind buffer
bind->setBinding(0, vbuf);
this->setCastShadows(false);
this->setQueryFlags(0); // set a query flag to exlude from queries (if necessary).
// set basic white material
this->setMaterial("BaseWhiteNoLighting");
}
示例11: queries
PortalOutlineRenderable::PortalOutlineRenderable(Ogre::String matname, Ogre::ColourValue colour)
{
mRenderOp.vertexData = OGRE_NEW Ogre::VertexData();
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = 10;//8
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0), mRenderOp.vertexData->vertexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
// Bind buffer
bind->setBinding(0, vbuf);
// setup material
createPortalMaterials();
//Ogre::ResourceManager::ResourceCreateOrRetrieveResult result = Ogre::MaterialManager::getSingleton().createOrRetrieve(matname, "General");
//if(result.second)
//{
// Ogre::MaterialPtr matptrOBBoxManualMaterial = result.first;
// matptrOBBoxManualMaterial->setReceiveShadows(false);
// matptrOBBoxManualMaterial->getTechnique(0)->setLightingEnabled(true);
// matptrOBBoxManualMaterial->getTechnique(0)->getPass(0)->setDiffuse(colour);
// matptrOBBoxManualMaterial->getTechnique(0)->getPass(0)->setAmbient(colour);
// matptrOBBoxManualMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(colour);
//}
this->setCastShadows(false);
this->setQueryFlags(0); // set a query flag to exlude from queries (if necessary).
this->setMaterial("PortalOutlineMaterial");
}
示例12: 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);
}
示例13: createFakeEntity
void ESKOgre::createFakeEntity(Ogre::SceneManager *mSceneMgr) {
Ogre::MeshPtr msh = Ogre::MeshManager::getSingleton().createManual(name + "_skeleton", XENOVIEWER_RESOURCE_GROUP);
msh->setSkeletonName(name);
Ogre::SubMesh* sub = msh->createSubMesh();
const size_t nVertices = 3;
const size_t nVertCount = 3;
const size_t vbufCount = nVertCount*nVertices;
float *vertices = (float *)malloc(sizeof(float)*vbufCount);
for (size_t i = 0; i < nVertices; i++) {
vertices[i*nVertCount] = 0.0;
vertices[i*nVertCount + 1] = 0.0;
vertices[i*nVertCount + 2] = 0.0;
}
const size_t ibufCount = 3;
unsigned short *faces = (unsigned short *)malloc(sizeof(unsigned short) * ibufCount);
for (size_t i = 0; i < ibufCount; i++) {
faces[i] = i;
}
msh->sharedVertexData = new Ogre::VertexData();
msh->sharedVertexData->vertexCount = nVertices;
Ogre::VertexDeclaration* decl = msh->sharedVertexData->vertexDeclaration;
size_t offset = 0;
decl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
Ogre::HardwareVertexBufferSharedPtr vbuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(offset, msh->sharedVertexData->vertexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
vbuf->writeData(0, vbuf->getSizeInBytes(), vertices, true);
Ogre::VertexBufferBinding* bind = msh->sharedVertexData->vertexBufferBinding;
bind->setBinding(0, vbuf);
Ogre::HardwareIndexBufferSharedPtr ibuf = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(Ogre::HardwareIndexBuffer::IT_16BIT, ibufCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
ibuf->writeData(0, ibuf->getSizeInBytes(), faces, true);
sub->useSharedVertices = true;
sub->indexData->indexBuffer = ibuf;
sub->indexData->indexCount = ibufCount;
sub->indexData->indexStart = 0;
msh->_setBounds(Ogre::AxisAlignedBox(-100, -100, -100, 100, 100, 100));
msh->_setBoundingSphereRadius(100);
msh->load();
free(faces);
free(vertices);
skeleton_entity = mSceneMgr->createEntity(name + "_skeleton");
skeleton_node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
skeleton_node->attachObject(skeleton_entity);
skeleton_node->setVisible(false);
}
示例14: lock
void
TerrainGridRenderable::initTerrainGrid(int vertexCount)
{
m_locked_data = 0;
mRenderOp.vertexData = new Ogre::VertexData();
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = mVertexCount;
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
decl->addElement(0, 3*sizeof(Ogre::Real), Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
Ogre::HardwareVertexBufferSharedPtr vbuf =
Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
vertexCount,
Ogre::HardwareBuffer::HBU_WRITE_ONLY);
bind->setBinding(0, vbuf);
// set basic white material
this->setMaterial("BaseWhiteNoLighting");
mBox.setExtents(-10,-10,-10,10,10,10);
lock();
drawGridLines();
unlock();
// getMaterial()->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
setQueryFlags(0);
}
示例15: createVertexDeclaration
void DynamicLines::createVertexDeclaration()
{
// we define the meaning of each batch of vertices added to the buffer
//http://grahamedgecombe.com/blog/custom-meshes-in-ogre3d
Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
size_t offset = 0;
decl->addElement(POSITION_BINDING, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
// dynamic renderable only has 1 buffer
// decl->addElement(POSITION_BINDING, offset, Ogre::VET_FLOAT4, Ogre::VES_POSITION);
// offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
}