Getting mesh from node

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!
BernieRoehl
Posts: 6
Joined: Fri Oct 27, 2006 9:39 pm

Getting mesh from node

Post by BernieRoehl »

How do I get a mesh from a scenenode?

I've loaded a .irr file using sceneMnager->loadScene(). Some of the meshes in the scene are things I want the user to collide with, and other meshes shouldn't affect the user's movement through the scene.

I think to myself, "this is easy -- I'll just have a userdata entry to indicate which objects should be colliders". So I add the userdata to my .irr file, and create a subclass of scene::ISceneUserDataSerializer whose OnReadUserData method looks for my "isCollider" attribute. It finds it okay, so my next step is to add the parent node's mesh to the MetaTriangleSelector for collision obstacles in the scene.

But wait! I can't get the mesh! Even though I have a reference to the node, the mesh is protected!

What should I do? Am I missing something?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I can't for the life of me understand why IMeshSceneNode and IAnimatedMeshSceneNode don't provide accessors for their meshes. I just went ahead and added them locally, which took about 5 minutes. Perhaps bitplane or one of the other maintainers can shed light on this curious omission.

[UPDATE]
Patch submitted.
Last edited by rogerborg on Fri Nov 03, 2006 1:40 pm, edited 1 time in total.
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

IMesh node->GetMesh(0) ;
the parameter number is the identifier of the mesh. Only in IAnimatedmeshscenennode class you can use some higher value than 0, so u get mesh on appropriate frame :idea:
what is this thing...
BernieRoehl
Posts: 6
Joined: Fri Oct 27, 2006 9:39 pm

Post by BernieRoehl »

needforhint wrote:IMesh node->GetMesh(0) ;
the parameter number is the identifier of the mesh. Only in IAnimatedmeshscenennode class you can use some higher value than 0, so u get mesh on appropriate frame :idea:
Yes, something like that would be perfect. Is there any chance this could be added to the main code base? I'm trying to avoid having to modify the engine.
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post by sgt_pinky »

BernieRoehl wrote:Yes, something like that would be perfect. Is there any chance this could be added to the main code base? I'm trying to avoid having to modify the engine.
What do you mean 'add it to the main code base'? It's there - he was giving you the answer!!!
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

It's not there :?

He wants to get a mesh from a scene node, what that code does is get a mesh from a mesh, or a specific frame from an animated mesh.
Image Image Image
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post by sgt_pinky »

Ah, you're right. Sorry, my mistake.
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

hey guys, what I wrote down is not even a code :wink: ,
a will try so know, as exact as it gets

Code: Select all

scene::IMesh* earthMesh = smgr->getMesh( "earth.x");

scene::ISceneNode* sphere = smgr->addMeshSceneNode(earthMesh);

scene::IMesh* copyfromnodeMesh = NULL;

copyfromnodeMesh = sphere->getMesh(0); // AHA!




what is this thing...
BernieRoehl
Posts: 6
Joined: Fri Oct 27, 2006 9:39 pm

Post by BernieRoehl »

needforhint wrote:

Code: Select all

scene::IMesh* earthMesh = smgr->getMesh( "earth.x");

scene::ISceneNode* sphere = smgr->addMeshSceneNode(earthMesh);

scene::IMesh* copyfromnodeMesh = NULL;

copyfromnodeMesh = sphere->getMesh(0); // AHA!

Yes, that's the sort of method I'm looking for. Sadly, it doesn't exist.

I've checked the 1.1 help file (not the 1.0 API ref that's online), and I've even checked the .h files in case the help file was out of date.

Sadly, SceneNode does not have a getMesh() method. The TerrainSceneNode does, but not SceneNode.

Is it possible that you're running a modified version of the code?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This method has been requested very often. I never checked if there are any things wrong with it, but I think it's worth adding it and fixing problems later on in case they appear...
dloomis
Posts: 8
Joined: Mon Aug 14, 2006 5:00 pm
Location: TN

Post by dloomis »

Really how else is there to add collision to a mesh loaded via .IRR?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Sadly, SceneNode does not have a getMesh() method. The TerrainSceneNode does, but not SceneNode.
It is perfectly acceptable to request the IMeshSceneNode get a getMesh() and the IAnimatedMeshSceneNode get a getAnimatedMesh(). That said, the scene node class ISceneNode should NOT have a getMesh() method.
BernieRoehl
Posts: 6
Joined: Fri Oct 27, 2006 9:39 pm

Post by BernieRoehl »

vitek wrote:
Sadly, SceneNode does not have a getMesh() method. The TerrainSceneNode does, but not SceneNode.
It is perfectly acceptable to request the IMeshSceneNode get a getMesh() and the IAnimatedMeshSceneNode get a getAnimatedMesh(). That said, the scene node class ISceneNode should NOT have a getMesh() method.
Yes, fair enough. Of course, it's a little bit odd that SceneNode has a getMaterial() method -- shouldn't that really be on MeshSceneNode as well, like getMesh()?
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

Code: Select all

scene::ISceneNode* sphere = smgr->addMeshSceneNode(earthMesh); 
If that is possible it means ISceneNode has a member of IMesh* type.

If following was possible

Code: Select all

scene::IMeshLessSceneNode* sphere = smgr->addMeshSceneNode(earthMesh); 
then IMeshLessSceneNode node has a IMesh* member . So function that returns this IMesh* member is I think appropriate.
what is this thing...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, needforhint, it is a question of 'all objects' and 'some objects'. In both cases you have 'one object' which means it is only a special case and thus you are overgeneralizing here.
Post Reply