本文整理汇总了C++中ogre::VertexDeclaration::getVertexSize方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexDeclaration::getVertexSize方法的具体用法?C++ VertexDeclaration::getVertexSize怎么用?C++ VertexDeclaration::getVertexSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::VertexDeclaration
的用法示例。
在下文中一共展示了VertexDeclaration::getVertexSize方法的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: 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");
}
示例3: 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");
}
示例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: 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);
}
示例9: vertex_size
BufferType*
ManualObject::createBuffer( const BufferBinding binding
,Ogre::VertexElementType type
,Ogre::VertexElementSemantic semantic )
{
Ogre::VertexDeclaration* decl = m_section->vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* bind = m_section->vertexData->vertexBufferBinding;
decl->addElement( binding, 0, type, semantic );
size_t vertex_size( decl->getVertexSize( binding ) );
VertexBuffer buffer = Ogre::HardwareBufferManager::getSingleton()
.createVertexBuffer( vertex_size
,m_section->vertexData->vertexCount
,Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
bind->setBinding( binding, buffer );
m_vertex_buffers[binding] = buffer;
return static_cast<BufferType*>( buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
}
示例10: 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);
}
示例11:
void Ogre2dManager::createHardwareBuffer(unsigned int size)
{
Ogre::VertexDeclaration* vd;
renderOp.vertexData=new Ogre::VertexData;
renderOp.vertexData->vertexStart=0;
vd=renderOp.vertexData->vertexDeclaration;
vd->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
vd->addElement(0, Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3),
Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
hardwareBuffer=Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
vd->getVertexSize(0),
size,// buffer size
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
false);// use shadow buffer? no
renderOp.vertexData->vertexBufferBinding->setBinding(0, hardwareBuffer);
renderOp.operationType=Ogre::RenderOperation::OT_TRIANGLE_LIST;
renderOp.useIndexes=false;
}
示例12: buildBuffer
//------------------------------------------------------
void DrawBuffer::buildBuffer() {
// if size differs, we reallocate the buffers
if (mQuadCount < mQuadList.size()) {
// raise the buffer, with some padding to avoid frequent reallocations
mQuadCount = mQuadList.size() * 2;
destroyBuffers();
}
if (mQuadCount == 0)
return;
if (!mVertexData) {
// no vertex data, let's reallocate some!
mVertexData = new Ogre::VertexData();
mVertexData->vertexStart = 0;
mVertexData->vertexCount = mQuadCount * 4;
Ogre::VertexDeclaration* decl = mVertexData->vertexDeclaration;
Ogre::VertexBufferBinding* binding = mVertexData->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_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2);
decl->addElement(0, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
mBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0), mVertexData->vertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
binding->setBinding(0, mBuffer);
}
if (!mIndexData) {
// no index data, so let's rebuilt it.
mIndexData = new Ogre::IndexData();
mIndexData->indexStart = 0;
mIndexData->indexCount = mQuadCount * 6; // quad count, so we have a reserve
// As canvas does it - build the IBO statically, we don't need no per-update updates
mIndexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
Ogre::HardwareIndexBuffer::IT_16BIT,
mIndexData->indexCount,
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, false);
// now we'll fill the buffer with indices of triangles (0,2,1; 1,2,3)
unsigned short* iData = reinterpret_cast<unsigned short*>(mIndexData->indexBuffer->lock(0, mIndexData->indexBuffer->getSizeInBytes(),
Ogre::HardwareBuffer::HBL_DISCARD));
// Inspired by Canvas. It's true we don't need to do this per frame,
// we'll just set the mIndexData->indexCount to the proper value after building
for (size_t iindex = 0, ivertex = 0, iquad = 0; iquad < mQuadCount; ++iquad, ivertex += 4) {
iindex = iquad * 6;
// tri 1
iData[iindex++] = (unsigned short)(ivertex);
iData[iindex++] = (unsigned short)(ivertex + 2);
iData[iindex++] = (unsigned short)(ivertex + 1);
// tri 2
iData[iindex++] = (unsigned short)(ivertex + 1);
iData[iindex++] = (unsigned short)(ivertex + 2);
iData[iindex++] = (unsigned short)(ivertex + 3);
}
mIndexData->indexBuffer->unlock();
};
// now we'll build the vertex part - we are already sorted so we'll just need quad rewritten
// to the vertex part
float* buf = reinterpret_cast<float*>(mBuffer->lock(0, mQuadList.size() * mBuffer->getVertexSize() * 4, Ogre::HardwareBuffer::HBL_DISCARD));
Ogre::RGBA* colptr;
for (DrawQuadList::iterator it = mQuadList.begin(); it != mQuadList.end(); ++it) {
// all the vertices
const DrawQuad* dq = *it;
/// Top Left corner
*buf++ = dq->positions.left;
*buf++ = dq->positions.top;
*buf++ = dq->depth;
*buf++ = dq->texCoords.left;
*buf++ = dq->texCoords.top;
colptr = reinterpret_cast<Ogre::RGBA*>(buf);
Ogre::Root::getSingleton().convertColourValue(dq->color, colptr);
colptr++;
buf = reinterpret_cast<float*>(colptr);
/// Top right corner
*buf++ = dq->positions.right;
*buf++ = dq->positions.top;
*buf++ = dq->depth;
*buf++ = dq->texCoords.right;
*buf++ = dq->texCoords.top;
colptr = reinterpret_cast<Ogre::RGBA*>(buf);
Ogre::Root::getSingleton().convertColourValue(dq->color, colptr);
//.........这里部分代码省略.........
示例13: draw
//------------------------------------------------------------------------------------------------
void DebugLines::draw()
{
if (_lines.empty())
{
mRenderOp.vertexData->vertexCount = 0;
return;
}
// Initialization stuff
mRenderOp.vertexData->vertexCount = _lines.size() * 2;
Ogre::VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding *bind = mRenderOp.vertexData->vertexBufferBinding;
if (_vbuf.isNull())
{
decl->addElement(0, 0, VET_FLOAT3, VES_POSITION);
decl->addElement(0, 12, VET_COLOUR, VES_DIFFUSE);
_vbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
mRenderOp.vertexData->vertexCount,
HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
bind->setBinding(0, _vbuf);
}
else
{
if (_vbuf->getNumVertices() != mRenderOp.vertexData->vertexCount)
{
bind->unsetAllBindings();
_vbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
mRenderOp.vertexData->vertexCount,
HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
bind->setBinding(0, _vbuf);
}
}
// Drawing stuff
unsigned int size = (unsigned int)_lines.size();
Ogre::Vector3 vaabMin = _lines[0]._start;
Ogre::Vector3 vaabMax = _lines[0]._start;
float *prPos = static_cast<float*>(_vbuf->lock(HardwareBuffer::HBL_DISCARD));
Ogre::RenderSystem* rs = Root::getSingleton().getRenderSystem();
Ogre::VertexElementType vet = VET_COLOUR_ARGB;
if (rs)
vet = rs->getColourVertexElementType();
for(unsigned int i = 0; i < size; i++)
{
const DebugLine& line = _lines[i];
uint32 packedColor;
if (vet == VET_COLOUR_ARGB)
packedColor = line._color.getAsARGB();
else
packedColor = line._color.getAsABGR();
*prPos++ = line._start.x;
*prPos++ = line._start.y;
*prPos++ = line._start.z;
*((uint32*)prPos) = packedColor;
prPos++;
*prPos++ = line._end.x;
*prPos++ = line._end.y;
*prPos++ = line._end.z;
*((uint32*)prPos) = packedColor;
prPos++;
if (line._start.x < vaabMin.x)
vaabMin.x = line._start.x;
else if (line._start.x > vaabMax.x)
vaabMax.x = line._start.x;
if (line._start.y < vaabMin.y)
vaabMin.y = line._start.y;
else if (line._start.y > vaabMax.y)
vaabMax.y = line._start.y;
if (line._start.z < vaabMin.z)
vaabMin.z = line._start.z;
else if (line._start.z > vaabMax.z)
vaabMax.z = line._start.z;
if (line._end.x < vaabMin.x)
vaabMin.x = line._end.x;
else if (line._end.x > vaabMax.x)
vaabMax.x = line._end.x;
if (line._end.y < vaabMin.y)
vaabMin.y = line._end.y;
else if (line._end.y > vaabMax.y)
vaabMax.y = line._end.y;
if (line._end.z < vaabMin.z)
//.........这里部分代码省略.........
示例14:
void CCustomShape::CreateVertexBuffer1()
{
if(0 == m_pointArray.size())
{
return;
}
// 先把上次创建的缓冲区删掉
ClearVertexBuffer1();
size_t nVertexCount = CalcVertexCount1( m_pointArray.size()-1 )*2;
if( m_pUnreachRegion )
{
nVertexCount = 0;
m_Weights = new float[m_pointArray.size()*m_pointArray.size()];
memset( m_Weights, 0, m_pointArray.size()*m_pointArray.size()*sizeof(float) );
size_t s;
for( s = 0; s < m_pointArray.size()-1; s ++ )
{
for( size_t t = s+1; t < m_pointArray.size(); t ++ )
{
Ogre::Vector3& v1 = m_pointArray[s];
Ogre::Vector3& v2 = m_pointArray[t];
UNREACHREGIONMAP::iterator it;
for( it = m_pUnreachRegion->begin(); it != m_pUnreachRegion->end();it ++ )
{
CUnreachRegion* pRe = it->second;
if( pRe->CheckCross( v1, v2 ) )
break;
}
float w = FLT_MAX;
if( it == m_pUnreachRegion->end() )
{
w = (v1.x-v2.x)*(v1.x-v2.x) + (v1.z-v2.z)*(v1.z-v2.z);
nVertexCount ++;
}
m_Weights[(s) + (t)*(m_pointArray.size())] = w;
m_Weights[(t) + (s)*(m_pointArray.size())] = w;
}
m_Weights[(s) + (s)*(m_pointArray.size())] = 0.0f;
}
m_Weights[(s) + (s)*(m_pointArray.size())] = 0.0f;
m_Weights[0] = 0.0f;
nVertexCount *= 2;
}
mRenderOp.vertexData = new Ogre::VertexData;
mRenderOp.vertexData->vertexCount = nVertexCount;
mRenderOp.vertexData->vertexStart = 0;
if( mRenderOp.vertexData->vertexCount == 0 ) return;
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);
}
示例15:
//------------------------------------------------------------------------------
void
Background2D::CreateVertexBuffers()
{
m_AlphaMaxVertexCount = 2048 * TILE_VERTEX_COUNT;
m_AlphaRenderOp.vertexData = new Ogre::VertexData;
m_AlphaRenderOp.vertexData->vertexStart = 0;
Ogre::VertexDeclaration* vDecl = m_AlphaRenderOp.vertexData->vertexDeclaration;
size_t offset = 0;
vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
m_AlphaVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_AlphaMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
m_AlphaRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_AlphaVertexBuffer );
m_AlphaRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
m_AlphaRenderOp.useIndexes = false;
m_AddMaxVertexCount = 256 * TILE_VERTEX_COUNT;
m_AddRenderOp.vertexData = new Ogre::VertexData;
m_AddRenderOp.vertexData->vertexStart = 0;
vDecl = m_AddRenderOp.vertexData->vertexDeclaration;
offset = 0;
vDecl->addElement( 0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT3 );
vDecl->addElement( 0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE );
offset += Ogre::VertexElement::getTypeSize( Ogre::VET_FLOAT4 );
vDecl->addElement( 0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES );
m_AddVertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer( vDecl->getVertexSize( 0 ), m_AddMaxVertexCount, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false );
m_AddRenderOp.vertexData->vertexBufferBinding->setBinding( 0, m_AddVertexBuffer );
m_AddRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
m_AddRenderOp.useIndexes = false;
}