本文整理汇总了C++中ogre::HardwareVertexBufferSharedPtr::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareVertexBufferSharedPtr::lock方法的具体用法?C++ HardwareVertexBufferSharedPtr::lock怎么用?C++ HardwareVertexBufferSharedPtr::lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::HardwareVertexBufferSharedPtr
的用法示例。
在下文中一共展示了HardwareVertexBufferSharedPtr::lock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillHardwareBuffers
void FrameGraphRenderable::fillHardwareBuffers()
{
Ogre::HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Ogre::Real *vertices = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
Ogre::HardwareVertexBufferSharedPtr vcbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(1);
Ogre::RGBA* pColours = static_cast<Ogre::RGBA*>(vcbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
uint16_t index = 0;
for (uint16_t i = 0; i < mNumFrames; i++) {
float x = i * mLineSpace - 1.0f;
// OgreTime line
vertices[index + 0] = x;
vertices[index + 1] = -1;
vertices[index + 2] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(1.0f, 0.0f, 0.0f), pColours++); // Color
vertices[index + 3] = x;
vertices[index + 4] = -1;
vertices[index + 5] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(1.0f, 0.0f, 0.0f), pColours++); // Color
// BulletTime line
vertices[index + 6] = x;
vertices[index + 7] = -1;
vertices[index + 8] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(0.0f, 1.0f, 0.0f), pColours++); // Color
vertices[index + 9] = x;
vertices[index + 10] = -1;
vertices[index + 11] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(0.0f, 1.0f, 0.0f), pColours++); // Color
// WorldTime line
vertices[index + 12] = x;
vertices[index + 13] = -1;
vertices[index + 14] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(0.0f, 0.0f, 1.0f), pColours++); // Color
vertices[index + 15] = x;
vertices[index + 16] = -1;
vertices[index + 17] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(0.0f, 0.0f, 1.0f), pColours++); // Color
// UnknownTime line
vertices[index + 18] = x;
vertices[index + 19] = -1;
vertices[index + 20] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(1.0f, 1.0f, 1.0f), pColours++); // Color
vertices[index + 21] = x;
vertices[index + 22] = -1;
vertices[index + 23] = 0; // Vertex
rs->convertColourValue(Ogre::ColourValue(1.0f, 1.0f, 1.0f), pColours++); // Color
index += ValuesPerGraphLine;
}
vcbuf->unlock();
vbuf->unlock();
mBox.setInfinite();
}
示例2: FillHardwareBuffers
void CDynamicLineDrawer::FillHardwareBuffers()
{
int Size = int(Points.size());
PrepareHardwareBuffers(Size);
if (!Size) {
mBox.setExtents( Ogre::Vector3::ZERO, Ogre::Vector3::ZERO );
Dirty = false;
return;
}
Ogre::Vector3 AABMin = Points[0];
Ogre::Vector3 AABMax = Points[0];
Ogre::HardwareVertexBufferSharedPtr VBuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Ogre::HardwareVertexBufferSharedPtr CBuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(1);
// get rendersystem to pack colours
Ogre::RenderSystem* RS = Ogre::Root::getSingleton().getRenderSystem();
Ogre::Real* VPrPos = static_cast<Ogre::Real*>(VBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
Ogre::RGBA* CPrPos = static_cast<Ogre::RGBA*>(CBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
for(int i = 0; i < Size; i++)
{
*VPrPos++ = Points[i].x;
*VPrPos++ = Points[i].y;
*VPrPos++ = Points[i].z;
Ogre::RGBA color;
RS->convertColourValue(Colours[i], &color);
*CPrPos++ = color;
//*CPrPos++ = unsigned int(Colours[i].g);
//*CPrPos++ = unsigned int(Colours[i].b);
if(Points[i].x < AABMin.x)
AABMin.x = Points[i].x;
if(Points[i].y < AABMin.y)
AABMin.y = Points[i].y;
if(Points[i].z < AABMin.z)
AABMin.z = Points[i].z;
if(Points[i].x > AABMax.x)
AABMax.x = Points[i].x;
if(Points[i].y > AABMax.y)
AABMax.y = Points[i].y;
if(Points[i].z > AABMax.z)
AABMax.z = Points[i].z;
}
VBuf->unlock();
CBuf->unlock();
mBox.setExtents(AABMin, AABMax);
Dirty = false;
}
示例3: drawGraphLine
void FrameGraphRenderable::drawGraphLine(TimeGraphLine& line, uint16_t graphLine)
{
Ogre::Real ogreTop, bulletTop, worldTop, unknownTop;
ogreTop = (line.ogre / mCurrentScaling);
bulletTop = ogreTop + (line.bullet / mCurrentScaling);
worldTop = bulletTop + (line.world / mCurrentScaling);
unknownTop = worldTop + (line.unknown / mCurrentScaling);
ogreTop = ogreTop * 2 - 1.0f;
bulletTop = bulletTop * 2 - 1.0f;
worldTop = worldTop * 2 - 1.0f;
unknownTop = unknownTop * 2 - 1.0f;
Ogre::HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Ogre::Real *vertices = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
vertices += graphLine * ValuesPerGraphLine;
// Set the ogre line top vertex
vertices[ 4] = ogreTop;
// Set the bullet line vertices
vertices[ 7] = ogreTop;
vertices[10] = bulletTop;
// Set the world line vertices
vertices[13] = bulletTop;
vertices[16] = worldTop;
// Set the unknown line vertices
vertices[19] = worldTop;
vertices[22] = unknownTop;
vbuf->unlock();
}
示例4: processPositionElement
void processPositionElement( VertexData* vertexData, const VertexElement* vertexElem )
{
int nMaxVert= vertexData->vertexCount ;
//const Ogre::VertexElement* VertexEle_POS = vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_POSITION );
// get vertex buffer info via the input element
Ogre::HardwareVertexBufferSharedPtr VertexBufPOS = vertexData->vertexBufferBinding->getBuffer( vertexElem->getSource() );
//LOCK BUFFER
unsigned char* VertexPtrPOS = static_cast<unsigned char*>( VertexBufPOS->lock( Ogre::HardwareBuffer::HBL_NORMAL) );
int VertSizePOS=VertexBufPOS->getVertexSize();
float * pElementPOS=NULL;
//A vector of every vertices position
std::vector<Ogre::Vector3> positions(nMaxVert);
//Copy each position into position vector
for(int nVert=0 ; nVert<nMaxVert ; nVert++)
{
vertexElem->baseVertexPointerToElement( VertexPtrPOS, &pElementPOS );
Ogre::Vector3 vertex(pElementPOS);
vertex = mTransform * vertex;
pElementPOS[0] = vertex.x;
pElementPOS[1] = vertex.y;
pElementPOS[2] = vertex.z;
mBoundingBox.merge(vertex);
VertexPtrPOS+=VertSizePOS ;
}
//UNLOCK BUFFER
if(VertexBufPOS->isLocked()){VertexBufPOS->unlock();}
}
示例5:
void Selection2D::setCorners(Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom, bool updateAABB)
{
Ogre::HardwareVertexBufferSharedPtr vbuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
float* pFloat = static_cast<float*>(vbuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
*pFloat++ = left;
*pFloat++ = top;
*pFloat++ = -1;
*pFloat++ = left;
*pFloat++ = bottom;
*pFloat++ = -1;
*pFloat++ = right;
*pFloat++ = bottom;
*pFloat++ = -1;
*pFloat++ = right;
*pFloat++ = top;
*pFloat++ = -1;
*pFloat++ = left;
*pFloat++ = top;
*pFloat++ = -1;
vbuf->unlock();
if(updateAABB)
{
mBox.setExtents(
std::min(left, right), std::min(top, bottom), 0,
std::max(left, right), std::max(top, bottom), 0);
}
}
示例6: redrawGraph
void FrameGraphRenderable::redrawGraph()
{
Ogre::Real ogreTop, bulletTop, worldTop, unknownTop;
Ogre::HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Ogre::Real *vertices = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
for (size_t i = 0; i < mNumFrames; i++) {
ogreTop = (mlastTimes[i].ogre / mCurrentScaling);
bulletTop = ogreTop + (mlastTimes[i].bullet / mCurrentScaling);
worldTop = bulletTop + (mlastTimes[i].world / mCurrentScaling);
unknownTop = worldTop + (mlastTimes[i].unknown / mCurrentScaling);
ogreTop = ogreTop * 2 - 1.0f;
bulletTop = bulletTop * 2 - 1.0f;
worldTop = worldTop * 2 - 1.0f;
unknownTop = unknownTop * 2 - 1.0f;
// Set the ogre line top vertex
vertices[ 4] = ogreTop;
// Set the bullet line vertices
vertices[ 7] = ogreTop;
vertices[10] = bulletTop;
// Set the world line vertices
vertices[13] = bulletTop;
vertices[16] = worldTop;
// Set the unknown line vertices
vertices[19] = worldTop;
vertices[22] = unknownTop;
vertices += ValuesPerGraphLine;
}
vbuf->unlock();
}
示例7: fillHardwareBuffers
void DynamicLines::fillHardwareBuffers()
{
unsigned int size = (unsigned int)mPoints.size();
prepareHardwareBuffers(size, 0);
if(!size)
{
mBox.setExtents(Ogre::Vector3::ZERO, Ogre::Vector3::ZERO);
mDirty = false;
return;
}
Ogre::Vector3 vaabMin = mPoints[0];
Ogre::Vector3 vaabMax = mPoints[0];
Ogre::HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
Ogre::Real *prPos = static_cast<Ogre::Real *>(vbuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
{
for(unsigned int i = 0; i < size; i++)
{
*prPos++ = mPoints[i].x;
*prPos++ = mPoints[i].y;
*prPos++ = mPoints[i].z;
if(!mUse2D)
{
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(mUse2D)
mBox.setInfinite();
else
mBox.setExtents(vaabMin, vaabMax);
mDirty = false;
}
示例8: memcpy
void
TerrainTileEditable::_notifyHeightModified(int xstart, int zstart, int xend, int zend)
{
assert(0 <= xstart && xstart < xend && xend <= mXSize+1);
assert(0 <= zstart && zstart < zend && zend <= mZSize+1);
if (mVertexDatas.empty())
{
// Nothing todo when buffer never initialised
return;
}
// TODO: (optimization) some grid may be need to recompute normal only
TerrainData* data = mOwner->getData();
Ogre::HardwareVertexBufferSharedPtr posNormBuffer = mVertexDatas.front()->vertexBufferBinding->getBuffer(0);
float* pPosNormBuffer = static_cast<float*>(posNormBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL));
float buffer[6];
int xsize = mXSize;
int zsize = mZSize;
int xbase = mXBase;
int zbase = mZBase;
for (int z = zstart; z < zend; ++z)
{
for (int x = xstart; x < xend; ++x)
{
Ogre::Vector3 v;
v = data->_getPosition(x+xbase, z+zbase);
buffer[0] = v.x; buffer[1] = v.y; buffer[2] = v.z;
v = data->_getNormal(x+xbase, z+zbase);
buffer[3] = v.x; buffer[4] = v.y; buffer[5] = v.z;
if (0 < z)
{
if (0 < x)
memcpy(pPosNormBuffer + (((z-1) * xsize + (x-1)) * 4 + 3) * 6, buffer, 6*sizeof(float));
if (x < xsize)
memcpy(pPosNormBuffer + (((z-1) * xsize + (x-0)) * 4 + 2) * 6, buffer, 6*sizeof(float));
}
if (z < zsize)
{
if (0 < x)
memcpy(pPosNormBuffer + (((z-0) * xsize + (x-1)) * 4 + 1) * 6, buffer, 6*sizeof(float));
if (x < xsize)
memcpy(pPosNormBuffer + (((z-0) * xsize + (x-0)) * 4 + 0) * 6, buffer, 6*sizeof(float));
}
}
}
posNormBuffer->unlock();
// re-compue bounding box
data->_computeTileBoundingBox(mBounds, xbase, zbase, xsize, zsize);
// trigger update of bounding box
getParentNode()->needUpdate();
}
示例9: Update
void GrassPatch::Update(const Ogre::Vector3 &sphere_center, float sphere_radius, Ogre::Real t)
{
int i;
static bool inited = false;
Ogre::Vector3 delta;
float length;
int end=0;
Ogre::Vector3 a, b;
float radius=sphere_radius*sphere_radius*2.2;
// Update the particle field
m_Particles->Step(0.001f); // use of t ?
Ogre::HardwareVertexBufferSharedPtr vVertices = mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING);
Ogre::Real *pVertices = static_cast<Ogre::Real*>( vVertices->lock(
//Ogre::HardwareBuffer::HBL_DISCARD
Ogre::HardwareBuffer::HBL_NORMAL
) );
// Upload new blade positions
if(!inited)
{
for (i = 0; i < m_NbBlades; i++)
{
m_Blades[i]->Constrain(sphere_center, sphere_radius);
m_Particles->GetGrassParticle(i).ClearForce();
m_Blades[i]->UpdateVertexBuffer(i, pVertices);
}
inited=true;
vVertices->unlock();
}
else
{
for (i = 0; i < m_NbBlades; i++)
{
m_Blades[i]-> GetPosition(a);
delta = a - sphere_center;
length = delta.x * delta.x + delta.y * delta.y+ delta.z*delta.z;
if ((m_Blades[i]->moving)||(length-radius<0))
{
m_Blades[i]->Constrain(sphere_center, sphere_radius);
m_Particles->GetGrassParticle(i).ClearForce();
m_Blades[i]->UpdateVertexBuffer(i, pVertices);
end++;
}
}
vVertices->unlock();
}
int ttt = sprintf(iterations, "Iterations: %d ", end);
end=0;
}
示例10: RenderDrawLists
void ImGuiInterface::RenderDrawLists(ImDrawList** const cmdLists, int cmdListsCount)
{
// Assume render system is configured according to InterfaceManager::_configureRenderSystem
mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
// For each command list
for (int i = 0; i < cmdListsCount; i++)
{
ImVector<ImDrawCmd>& commands = cmdLists[i]->commands;
// Allocate more space if needed
if (mSize < cmdLists[i]->vtx_buffer.size())
{
mSize = cmdLists[i]->vtx_buffer.size();
AllocateVertexBuffer(mSize);
}
// Copy vertices into VB
Ogre::HardwareVertexBufferSharedPtr vb =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
ImDrawVert* vertices = static_cast<ImDrawVert*>(
vb->lock(0, vb->getSizeInBytes(), Ogre::HardwareBuffer::HBL_DISCARD));
memcpy(vertices, &cmdLists[i]->vtx_buffer[0], cmdLists[i]->vtx_buffer.size() * sizeof(ImDrawVert));
vb->unlock();
// Execute draw calls
int offset = 0;
for (auto c : commands)
{
mRenderSystem->setScissorTest(true, c.clip_rect.x, c.clip_rect.y, c.clip_rect.z, c.clip_rect.w);
// Set texture
if (c.texture_id)
{
ImguiTextureHandle* handle = reinterpret_cast<ImguiTextureHandle*>(c.texture_id);
mRenderSystem->_setTexture(0, true, handle->texturePtr);
mRenderSystem->_setTextureBlendMode(0, mAlphaBlendMode);
}
else
{
mRenderSystem->_disableTextureUnit(0);
}
// Draw vertices
mRenderOp.vertexData->vertexStart = offset;
mRenderOp.vertexData->vertexCount = c.vtx_count;
mRenderSystem->_render(mRenderOp);
offset += c.vtx_count;
}
}
mRenderSystem->setScissorTest(false);
}
示例11: fillHardwareBuffers
//------------------------------------------------------------------------------------------------
void DynamicLines::fillHardwareBuffers()
{
int size = m_Points.size();
prepareHardwareBuffers(size,0);
if (!size) {
mBox.setExtents(Vec3::ZERO,Vec3::ZERO);
m_bDirty=false;
return;
}
Vec3 vaabMin = m_Points[0];
Vec3 vaabMax = m_Points[0];
Ogre::HardwareVertexBufferSharedPtr vbuf =
mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
real *prPos = static_cast<real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_DISCARD));
{
for(int i = 0; i < size; i++)
{
*prPos++ = m_Points[i].x;
*prPos++ = m_Points[i].y;
*prPos++ = m_Points[i].z;
if(m_Points[i].x < vaabMin.x)
vaabMin.x = m_Points[i].x;
if(m_Points[i].y < vaabMin.y)
vaabMin.y = m_Points[i].y;
if(m_Points[i].z < vaabMin.z)
vaabMin.z = m_Points[i].z;
if(m_Points[i].x > vaabMax.x)
vaabMax.x = m_Points[i].x;
if(m_Points[i].y > vaabMax.y)
vaabMax.y = m_Points[i].y;
if(m_Points[i].z > vaabMax.z)
vaabMax.z = m_Points[i].z;
}
}
vbuf->unlock();
mBox.setExtents(vaabMin, vaabMax);
m_bDirty = false;
}
示例12: addStaticVertexData
//------------------------------------------------------------------------------------------------
void VertexIndexToShape::addStaticVertexData(const Ogre::VertexData *vertex_data)
{
if (!vertex_data)
{
return;
}
const Ogre::VertexData *data = vertex_data;
const unsigned int prev_size = mVertexCount;
mVertexCount += (unsigned int)data->vertexCount;
Ogre::Vector3 *tmp_vert = new Ogre::Vector3[mVertexCount];
if (mVertexBuffer)
{
memcpy(tmp_vert, mVertexBuffer, sizeof(Ogre::Vector3) * prev_size);
delete[] mVertexBuffer;
}
mVertexBuffer = tmp_vert;
// Get the positional buffer element
{
const Ogre::VertexElement *posElem = data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf = data->vertexBufferBinding->getBuffer(posElem->getSource());
const unsigned int vSize = (unsigned int)vbuf->getVertexSize();
unsigned char *vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
float *pReal = NULL;
Ogre::Vector3 * curVertices = &mVertexBuffer[prev_size];
const unsigned int vertexCount = (unsigned int)data->vertexCount;
for (unsigned int j = 0; j < vertexCount; ++j)
{
posElem->baseVertexPointerToElement(vertex, &pReal);
vertex += vSize;
curVertices->x = (*pReal++);
curVertices->y = (*pReal++);
curVertices->z = (*pReal++);
*curVertices = mTransform * (*curVertices);
curVertices++;
}
vbuf->unlock();
}
}
示例13: make_pair
//-------------------------------------------------------
// http://www.ogre3d.org/tikiwiki/Raycasting+to+the+polygon+level
std::pair<bool, float> Ground::GetVertexIntersection(const Ogre::Ray & ray, const Ogre::SubMesh* subMesh)
{
OgreAssert(false == subMesh->useSharedVertices, "Mesh with shared data is not supported");
const Ogre::VertexElement* posElem = subMesh->vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuffer = subMesh->vertexData->vertexBufferBinding->getBuffer(posElem->getSource());
unsigned char* vertexes = reinterpret_cast<unsigned char*>(vbuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t count = subMesh->vertexData->vertexCount;
float intersection = -1.0f;
OgreAssert(count == REGION_SIZE * REGION_SIZE * 4, "Wrong buffer size");
float* pReal;
for (size_t i = 0; i < REGION_SIZE * REGION_SIZE; ++i)
{
Ogre::Vector3 v0, v1, v2, v3;
for (auto vp : { &v0, &v1, &v2, &v3 })
{
posElem->baseVertexPointerToElement(vertexes, &pReal);
*vp = Ogre::Vector3(pReal[0], pReal[1], pReal[2]);
vertexes += vbuffer->getVertexSize();
}
auto hit1 = Ogre::Math::intersects(ray, v1, v2, v0, true, false);
if (hit1.first && (intersection < 0.0f || hit1.second < intersection))
{
intersection = hit1.second;
}
auto hit2 = Ogre::Math::intersects(ray, v3, v2, v1, true, false);
if (hit2.first && (intersection < 0.0f || hit2.second < intersection))
{
intersection = hit2.second;
}
}
vbuffer->unlock();
if (intersection >= 0.0f)
{
return std::make_pair(true, intersection);
}
return std::make_pair(false, -1.0f);
}
示例14: AddFromVertexData
void VertexBuffer::AddFromVertexData(Ogre::VertexData* vertexData)
{
// Get vertex count
const unsigned int addedCount = vertexData->vertexCount;
if(_reserved < _size + addedCount)
{
Reserve(_size + addedCount);
}
// Get VertexElement with info on used vertex semantics
const Ogre::VertexElement* vertexElement =
vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
// Get actual vertex buffer and its size
Ogre::HardwareVertexBufferSharedPtr hardwareBuffer =
vertexData->vertexBufferBinding->getBuffer(vertexElement->getSource());
const unsigned int vertexSize = (unsigned int)hardwareBuffer->getVertexSize();
// Lock buffer with read-only to retrieve vertex data
unsigned char* buffer = static_cast<unsigned char*>(
hardwareBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
// Pointer to one component of vertex vector
float *curVertexData = NULL;
for (unsigned int j = 0; j < addedCount; ++j)
{
vertexElement->baseVertexPointerToElement(buffer, &curVertexData);
buffer += vertexSize;
_buffer.push_back(Ogre::Vector3(
*curVertexData,
*(curVertexData+1) ,
*(curVertexData+2)));
curVertexData += 3;
}
_size = _buffer.size();
hardwareBuffer->unlock();
}
示例15:
void
TerrainTileEditable::fillLayerBuffer(size_t layer, const Ogre::HardwareVertexBufferSharedPtr& buffer)
{
float* pFloat = static_cast<float*>(buffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));
const TerrainData* data = mOwner->getData();
int xbase = mXBase;
int zbase = mZBase;
int xsize = mXSize;
int zsize = mZSize;
for (int z = 0; z < zsize; ++z)
{
for (int x = 0; x < xsize; ++x)
{
size_t grid = (zbase + z) * data->mXSize + (xbase + x);
const TerrainData::GridInfo& gridInfo = data->mGridInfos[grid];
const TerrainData::LayerInfo& layerInfo = gridInfo.layers[layer];
if (layerInfo.pixmapId)
{
std::pair<Real, Real> t;
t = mOwner->_getPixmapCorner(layerInfo, TerrainData::LEFT_TOP, gridInfo.flags);
*pFloat++ = t.first; *pFloat++ = t.second;
t = mOwner->_getPixmapCorner(layerInfo, TerrainData::RIGHT_TOP, gridInfo.flags);
*pFloat++ = t.first; *pFloat++ = t.second;
t = mOwner->_getPixmapCorner(layerInfo, TerrainData::LEFT_BOTTOM, gridInfo.flags);
*pFloat++ = t.first; *pFloat++ = t.second;
t = mOwner->_getPixmapCorner(layerInfo, TerrainData::RIGHT_BOTTOM, gridInfo.flags);
*pFloat++ = t.first; *pFloat++ = t.second;
}
else
{
pFloat += 2 * 4;
}
}
}
buffer->unlock();
}