本文整理汇总了C++中ogre::HardwareVertexBufferSharedPtr类的典型用法代码示例。如果您正苦于以下问题:C++ HardwareVertexBufferSharedPtr类的具体用法?C++ HardwareVertexBufferSharedPtr怎么用?C++ HardwareVertexBufferSharedPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HardwareVertexBufferSharedPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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();}
}
示例3:
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);
}
}
示例4: 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();
}
示例5: gfx_decal_init
void gfx_decal_init (void)
{
// TODO: The 4x3 transform will need to be
// TODO: Eventually we'd like this uv rect to be configurable per decal.
Vector2 uv1(0, 0);
Vector2 uv2(1, 1);
box_op.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
Ogre::VertexData *vdata = OGRE_NEW Ogre::VertexData();
box_op.vertexData = vdata;
vdata->vertexStart = 0;
const unsigned vertex_count = 8;
vdata->vertexCount = vertex_count;
unsigned vdecl_size = 0;
// strict alignment required here
struct Vertex { Vector3 position; Vector2 uv1; Vector2 uv2; };
vdecl_size += vdata->vertexDeclaration->addElement(
0, vdecl_size, Ogre::VET_FLOAT3, Ogre::VES_POSITION).getSize();
vdecl_size += vdata->vertexDeclaration->addElement(
0, vdecl_size, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0).getSize();
vdecl_size += vdata->vertexDeclaration->addElement(
0, vdecl_size, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 1).getSize();
Ogre::HardwareVertexBufferSharedPtr vbuf =
Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
vdecl_size, vdata->vertexCount,
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
vdata->vertexBufferBinding->setBinding(0, vbuf);
Vertex vdata_raw[vertex_count] = {
{ Vector3(-0.5, -0.5, -0.5), uv1, uv2 },
{ Vector3(-0.5, -0.5, 0.5), uv1, uv2 },
{ Vector3(-0.5, 0.5, -0.5), uv1, uv2 },
{ Vector3(-0.5, 0.5, 0.5), uv1, uv2 },
{ Vector3( 0.5, -0.5, -0.5), uv1, uv2 },
{ Vector3( 0.5, -0.5, 0.5), uv1, uv2 },
{ Vector3( 0.5, 0.5, -0.5), uv1, uv2 },
{ Vector3( 0.5, 0.5, 0.5), uv1, uv2 }
};
vbuf->writeData(vdata->vertexStart, vdata->vertexCount*vdecl_size, vdata_raw, true);
Ogre::IndexData *idata = OGRE_NEW Ogre::IndexData();
box_op.indexData = idata;
box_op.useIndexes = true;
const unsigned indexes = 36; // 3 per triangle therefore 6 per face, 6 faces total
idata->indexStart = 0;
idata->indexCount = indexes;
idata->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
Ogre::HardwareIndexBuffer::IT_16BIT, indexes, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
uint16_t idata_raw[indexes] = {
quad_vertexes(2,6,0,4),
quad_vertexes(7,3,5,1),
quad_vertexes(3,2,1,0),
quad_vertexes(6,7,4,5),
quad_vertexes(0,4,1,5),
quad_vertexes(3,7,2,6)
};
idata->indexBuffer->writeData(0, sizeof(idata_raw), idata_raw, true);
}
示例6: 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;
}
示例7: 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();
}
示例8: 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);
}
示例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: 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();
}
示例15: 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;
}