Seg Fault When Realizing Primitive Mesh

kuscotopia

03-04-2013 15:05:28

Hi all. This is my first experience with OgreProcedural and I am getting a seg fault when I attempt to create a set of primitive meshes.

I first initialize ogre manually via:


if( rendering ){
return -EALREADY;
}

//Initialize ogre root
if( !root ){
root = new Root(plugin, config, logFile);
}

if( !log ){
log = Ogre::LogManager::getSingleton().getDefaultLog();
}

//Ensure Ogre is configured
if( !root->restoreConfig() && !root->showConfigDialog() ){
return -ENOTSUP;
}

if( !window ){
window = root->initialise( true, title );
}

root->getRenderSystem()->_initRenderTargets();

Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

//Create primitive meshes
logNormal("Generating primitive meshes...");
createPrimitives();

retrun 0;


Within createPrimitves I am currently attempting to create a sphere and a cube with the following code:


Procedural::BoxGenerator().realizeMesh("box");
Procedural::SphereGenerator().realizeMesh("sphere");


When I execute my program I do not survive the creation of the box. Instead my application segfaults somewhere within realizeMesh.

Any guidance as to what I am doing wrong? Thanks!

kuscotopia

03-04-2013 15:41:11

Well...seems that I have solved my immediate issue.

In order to use OgreProcedural a Scene Manager has to be defined.

My next question, why is that the case?

Transporter

05-04-2013 09:08:07

In order to use OgreProcedural a Scene Manager has to be defined.

My next question, why is that the case?

Because to generate a mesh from a ManualObject you have to setup a scene manager:

Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
Ogre::ManualObject * manual = sceneMgr->createManualObject();
manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
...
manual->end();
Ogre::MeshPtr mesh = manual->convertToMesh(name, group);
sceneMgr->destroyManualObject(manual);

http://docs.ogreprocedural.org/ProceduralTriangleBuffer_8h_source.html#l00116