Code: Select all
// definition of PointCloudObject::Point
struct Point {
float px, py, pz; //Position
Ogre::ARGB c; //Color
Point() {}
Point( float _px, float _py, float _pz, uint32_t _c ) : px( _px ), py( _py ), pz( _pz ), c( _c ){}
void setColor(Ogre::ColourValue color) {c = color.getAsABGR();}
void setColor(float r, float g, float b, float a) {c = Ogre::ColourValue(r, g, b, a).getAsABGR();}
};
...
Ogre::uint16 *vertexIndices = reinterpret_cast<Ogre::uint16*>( OGRE_MALLOC_SIMD( sizeof(Ogre::uint16) * bufferSize, Ogre::MEMCATEGORY_GEOMETRY ) );
#pragma omp parallel for
for (int i = 0; i < bufferSize; i++) {
vertexIndices[i] = i;
}
Ogre::IndexBufferPacked *indexBuffer = vaoManager->createIndexBuffer( Ogre::IndexBufferPacked::IT_16BIT, bufferSize, Ogre::BT_IMMUTABLE, vertexIndices, true );
//Vertex declaration
Ogre::VertexElement2Vec vertexElements;
vertexElements.push_back( Ogre::VertexElement2( Ogre::VET_FLOAT3, Ogre::VES_POSITION ) );
vertexElements.push_back( Ogre::VertexElement2( Ogre::VET_COLOUR, Ogre::VES_DIFFUSE ) );
PointCloudObject::Point *cloudVertices = reinterpret_cast<PointCloudObject::Point*>( OGRE_MALLOC_SIMD(
sizeof(PointCloudObject::Point) * bufferSize,
Ogre::MEMCATEGORY_GEOMETRY ) );
memcpy( cloudVertices, pointBuffer, sizeof(PointCloudObject::Point) * bufferSize );
Ogre::VertexBufferPacked *vertexBuffer = vaoManager->createVertexBuffer( vertexElements, bufferSize, Ogre::BT_IMMUTABLE, cloudVertices, true );
Ogre::VertexBufferPackedVec vertexBuffers;
vertexBuffers.push_back( vertexBuffer );
Ogre::VertexArrayObject *vao = vaoManager->createVertexArrayObject( vertexBuffers, indexBuffer, Ogre::OT_POINT_LIST );
mVaoPerLod[0].push_back( vao );
...