loading and working with .obj file

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
miroslav_karpis
Posts: 12
Joined: Tue Jan 13, 2009 7:12 am

loading and working with .obj file

Post by miroslav_karpis »

Hi, please can you help with this one?

I have created a scene in Blender - let's say 5 objects (5 cubes). I have exported them to .obj file and loaded to irrlicht. I can see the whole scene - that is no problem.

The problem is that how can I 'work' with objects in the scene? For example I want to move only with one cube from the scene (in scene are 5 cubes).

thank you in advance...
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

If you are loading one .obj file containing 5 cubes, then you are loading one single mesh and creating one (animated) mesh scene node from it.

If you want to manipulate each cube independently, then you'll have to save out one cube model, load it as a mesh, and create 5 independent mesh scene nodes from it.

If you look in example 01.HelloWorld/main.cpp, then you'll see this code:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
To create multiple scene nodes using the same mesh, you'd just have to modify it to:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
IAnimatedMeshSceneNode* anotherNode = smgr->addAnimatedMeshSceneNode( mesh );
IAnimatedMeshSceneNode* andYetAnotherNode = smgr->addAnimatedMeshSceneNode( mesh );
Of course, in any real app, you'd use (e.g.) an array of IAnimatedMeshSceneNode pointers.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
miroslav_karpis
Posts: 12
Joined: Tue Jan 13, 2009 7:12 am

Post by miroslav_karpis »

many thanks...

another option would be to export it from blender to irr file. Then I can have one file with several obejcts - that I can than manipulate. Am I right?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Only if you explicitly create multiple scene nodes in IrrEdit. It doesn't (and can't) know that a single .obj file is meant to contain multiple independent meshes.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply