Mesh from an ISceneNode
Mesh from an ISceneNode
Hi all!!!
I've created my scene on IrrEdit and
loaded with loadscene(), but now i have
to take the mesh of an ISceneNode
(grabbed with getSceneNodeFromId).
Is that possible?
Here:
http://www.irrlicht3d.org/wiki/index.ph ... gCollision
He serialize the node and then
take the name of the mesh.
Is the only way?
Thanks and sorry but i really an
Irrlicht newbie.
I've created my scene on IrrEdit and
loaded with loadscene(), but now i have
to take the mesh of an ISceneNode
(grabbed with getSceneNodeFromId).
Is that possible?
Here:
http://www.irrlicht3d.org/wiki/index.ph ... gCollision
He serialize the node and then
take the name of the mesh.
Is the only way?
Thanks and sorry but i really an
Irrlicht newbie.
if you have the node, can't you get the mesh with node->getMesh() ?!?!?
(maybe a type cast to IMeshSceneNode needed)
(maybe a type cast to IMeshSceneNode needed)
Code: Select all
IMesh* m = ((IMeshSceneNode*)node)->getMesh();
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Sometimes Sometimes you go node->getMesh()->getMesh(0)... i think?Acki wrote:if you have the node, can't you get the mesh with node->getMesh() ?!?!?
(maybe a type cast to IMeshSceneNode needed)Code: Select all
IMesh* m = ((IMeshSceneNode*)node)->getMesh();
I think you are thinking of an animated scene node:lovloss wrote:Sometimes Sometimes you go node->getMesh()->getMesh(0)... i think?Acki wrote:if you have the node, can't you get the mesh with node->getMesh() ?!?!?
(maybe a type cast to IMeshSceneNode needed)Code: Select all
IMesh* m = ((IMeshSceneNode*)node)->getMesh();
Code: Select all
IMesh* m = ((IAnimatedMeshSceneNode*)node)->getMesh(0);
TheQuestion = 2B || !2B
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
First, call ISceneNode::getType(), then cast to the appropriate type based on the result.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
read rogerborg's post above
something like :
if mesh still 0. check console messages. any model missing?
something like :
Code: Select all
IMesh* mesh = 0;
switch(node->getType()){
case(ESNT_ANIMATED_MESH):{
mesh = ((IAnimatedMeshSceneNode*)node)->getMesh();
}
case(ESNT_MESH):{
mesh = ((IMeshSceneNode*)node)->getMesh();
}
//etc.............................. other cast
}
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Well, you shouldn't simply use a dynamic_cast when all you want to do is going down the inheritance hierarchy. That's what static cast is meant for, in the worst case you'd use a reinterpret_cast. dynamic_cast is for navigating across different inheritance branches. RTTI needs to be activated in the project settings, but remember that there's a major runtime penalty related to dynamic_casts.
Not true. The dynamic_cast<> operator is there to ensure that object is a complete object of the requested type. Given an ISceneNode* you don't know if you can safely cast down the inheritance heirarchy to IMeshSceneNode*.hybrid wrote:Well, you shouldn't simply use a dynamic_cast when all you want to do is going down the inheritance hierarchy.
As mentioned above, you can use getType() to find the actual type before doing a static_cast<>. That would be safe. This is essentially the same as a dynamic_cast<> because of the virtual dispatch that happens.
A reinterpret_cast<> would be dangerous, as it might give wrong results in the face of multiple inheritance.hybrid wrote:That's what static cast is meant for, in the worst case you'd use a reinterpret_cast.
Have you ever profiled the use of RTTI? The runtime cost of RTTI depends on the implementation and the inheritance heirarchy. For a simple heirarchy like that used by ISceneNode*, the runtime cost should be minimal.hybrid wrote:dynamic_cast is for navigating across different inheritance branches. RTTI needs to be activated in the project settings, but remember that there's a major runtime penalty related to dynamic_casts.
Travis
Last edited by vitek on Thu Oct 09, 2008 3:48 pm, edited 1 time in total.
I quote this because there's a big difference.vitek wrote: As mentioned above, you can use getType() to find the actual type before doing a static_cast<>. That would be safe. This is essentially the same as a dynamic_cast<> because of the virtual dispatch that happens.
A reinterpret_cast<> would be dangerous, as it might give wrong results in the face of multiple inheritance.
The getType() + static_cast is the same theorically
of the dynamic_cast...i don't know the profiling,
i will test it.
Don't bother. I wrote up some code and the results were in-line with what hybrid had posted...
The static_cast<> tests used a call to getType() followed by a static_cast<>, while the dynamic_cast<> tests just did a dynamic_cast<>. Each test was 500,000,000 iterations. I'm open to posting the code if anyone wants to see it.
Travis
Code: Select all
static_cast<IMeshSceneNode>: 2.37s
static_cast<IAnimatedMeshSceneNode>: 2.29s
dynamic_cast<IMeshSceneNode>: 21.35s
dynamic_cast<IAnimatedMeshSceneNode>: 34.97s
Travis