Aply the same vertexbuffer to multi-meshbuffers

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Aply the same vertexbuffer to multi-meshbuffers

Post by kaos »

Code: Select all

 
 
for( unsigned int indexGroupVertex = 0; indexGroupVertex < numMeshBuffer; indexGroupVertex++ )
{
if(  )
{
dmb->getVertexBuffer().reallocate( meshbuffer->getVertexCount() );
video::S3DVertex* vertex = (video::S3DVertex*)meshbuffer->getVertices();
for( unsigned int cont = 0; cont < meshbuffer->getVertexCount(); cont++ )
        dmb->getVertexBuffer().push_back( vertex[cont] );
}
else
{
// crash here
dmb->setVertexBuffer( (scene::IVertexBuffer*)meshbuffer->getIndices() );
}
}
 
 
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Aply the same vertexbuffer to multi-meshbuffers

Post by smso »

Code: Select all

meshbuffer->getIndices()
cannot be cast to:

Code: Select all

scene::IVertexBuffer*
Regards
smso
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Re: Aply the same vertexbuffer to multi-meshbuffers

Post by kaos »

Sorry I want to say

Code: Select all

 
 
dmb->setVertexBuffer( (scene::IVertexBuffer*)meshbuffer->getVertices() );
 
 
arrival
Posts: 8
Joined: Mon Feb 27, 2012 9:50 am
Location: Poland

Re: Aply the same vertexbuffer to multi-meshbuffers

Post by arrival »

Not sure about types you used but as far as I know inside the SMeshBuffer and CMeshBuffer vertices are stored as an array of Vertex objects (S3DVertex for example). getVertices() returns an array - pointer to its firs element, so now you are probably trying to cast S3DVertex* to IVertexBuffer*. I think it's not going to work. :)

Sorry, I dont know what IVertexBuffer are used for, cuz Im using Irrlicht for about 2 weeks.

Oh and its better to use c++ style casting (****_cast) if you deal with something else than built in types.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Aply the same vertexbuffer to multi-meshbuffers

Post by Nadro »

This isn't possible in current Irrlicht implementation, but You can use this Irrlicht branch for it:
https://irrlicht.svn.sourceforge.net/sv ... -pipeline/
in this way:
IMeshBuffer_Object->setVertexBuffer(IMeshBuffer_OtherObject->getVertexBuffer());

But, remember that FVF support (branch from a link) for Irrlicht is in testing phase, so some bugs may appear.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Post Reply