Getting mesh from node
-
- Posts: 6
- Joined: Fri Oct 27, 2006 9:39 pm
Getting mesh from node
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?
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?
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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.
[UPDATE]
Patch submitted.
Last edited by rogerborg on Fri Nov 03, 2006 1:40 pm, edited 1 time in total.
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
-
- Posts: 6
- Joined: Fri Oct 27, 2006 9:39 pm
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.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
What do you mean 'add it to the main code base'? It's there - he was giving you the answer!!!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.
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
#irrlicht on irc.freenode.net
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
hey guys, what I wrote down is not even a code ,
a will try so know, as exact as it gets
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...
-
- Posts: 6
- Joined: Fri Oct 27, 2006 9:39 pm
Yes, that's the sort of method I'm looking for. Sadly, it doesn't exist.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!
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?
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.Sadly, SceneNode does not have a getMesh() method. The TerrainSceneNode does, but not SceneNode.
-
- Posts: 6
- Joined: Fri Oct 27, 2006 9:39 pm
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()?vitek wrote: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.Sadly, SceneNode does not have a getMesh() method. The TerrainSceneNode does, but not SceneNode.
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
Code: Select all
scene::ISceneNode* sphere = smgr->addMeshSceneNode(earthMesh);
If following was possible
Code: Select all
scene::IMeshLessSceneNode* sphere = smgr->addMeshSceneNode(earthMesh);
what is this thing...