StaticGeometry in Ogre 2.0

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
rogual
Gnoblar
Posts: 21
Joined: Sun Mar 01, 2015 9:33 pm
x 4

StaticGeometry in Ogre 2.0

Post by rogual »

Hi, I've recently ported my app from Ogre 1.8 to 2.0, and I can't seem to get StaticGeometry working again.

I'm trying to initialize a StaticGeometry with the contents of a SceneNode. Here is what I'm doing:

Code: Select all

    Ogre::SceneNode *temp = scene->createSceneNode();
    Ogre::Entity *oe = scene->createEntity(Ogre::SceneManager::PT_PLANE);
    temp->attachObject(oe);

    temp->_getDerivedPositionUpdated();

    Ogre::StaticGeometry *sg = scene->createStaticGeometry("blah");

    sg->reset();
    sg->addSceneNode(temp);
    sg->build();
I added the line with _getDerivedPositionUpdated because without it, StaticGeometry::addSceneNode crashes with this assertion failure:

Code: Select all

    Assertion failed: (!mCachedTransformOutOfDate), function _getDerivedPosition
But, with that fixed, I now get a different exception in StaticGeometry::build:

Code: Select all

frame #1: 0x0000000100016812 Ogre`Ogre::ExceptionFactory::throwException(code=ERR_ITEM_NOT_FOUND, number=5, desc=0x00007fff5fbfd5b8, src=0x00007fff5fbfd588, file=0x0000000100a7aa51, line=1071) + 674 at OgreException.h:272
frame #2: 0x00000001007c0fb2 Ogre`Ogre::StaticGeometry::MaterialBucket::build(this=0x0000000108d00778) + 482 at OgreStaticGeometry.cpp:1069
frame #3: 0x00000001007be4da Ogre`Ogre::StaticGeometry::LODBucket::build(this=0x0000000107b44808) + 746 at OgreStaticGeometry.cpp:958
frame #4: 0x00000001007b9678 Ogre`Ogre::StaticGeometry::Region::build(this=0x0000000107a81838, parentVisible=true) + 1352 at OgreStaticGeometry.cpp:800
frame #5: 0x00000001007b8bee Ogre`Ogre::StaticGeometry::build(this=0x0000000107b0b588) + 1262 at OgreStaticGeometry.cpp:564
Is there a new correct way to use StaticGeometry in 2.0? I saw it is used in the Grass sample but that didn't help me because that's all about adding individual Entities to a SG, and I need to add an entire SceneNode.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: StaticGeometry in Ogre 2.0

Post by dark_sylinc »

A simple look at the source where the crash is being pointed to reveals the code is complaining the Material wasn't found.
Perhaps the material name is spelled wrong or was not loaded from the resource scripts, or isn't even defined. Or somehow the original material name was lost.

Remember to catch exceptions at the top of the scene and log them somewhere. Or check the logs if you're already doing that. Can save you a lot of time.
rogual
Gnoblar
Posts: 21
Joined: Sun Mar 01, 2015 9:33 pm
x 4

Re: StaticGeometry in Ogre 2.0

Post by rogual »

The object has no material assigned to it; is that a requirement for putting it into a StaticGeometry?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: StaticGeometry in Ogre 2.0

Post by dark_sylinc »

Apparently yes because it's complaining about it.
rogual
Gnoblar
Posts: 21
Joined: Sun Mar 01, 2015 9:33 pm
x 4

Re: StaticGeometry in Ogre 2.0

Post by rogual »

Thanks for your help.
Post Reply