Hi,
I have a question about scripting in irrEdit (I know it would be better to ask at irrEdit Forum, but I have no account there for now).
I'm trying to get type of node:
local nodeType = irrGetSceneNodeProperty(node, "Type");
but it is not working. I get an error: "Property does not exist: Type" Why?
Documentation says, there is such property of node.
When I try:
irrGetSceneNodeMaterialProperty(node, 0, "Type");
everything is ok, but for node it doesn't work.
[IrrEdit] Script
-
- Posts: 62
- Joined: Fri Aug 22, 2008 7:22 am
first: you don't need to register at the irredit forum afaiik. you can post there as "guest"
second:
check out the load .irr file tutorial or maybe ths code here can help you
second:
check out the load .irr file tutorial or maybe ths code here can help you
Code: Select all
// load irr scene
smgr->loadScene( "media/stage1.irr" );
scene::ISceneNode* startloc = smgr->getSceneNodeFromName( "StartLocation" );
core::vector3df startlocvec = startloc->getAbsolutePosition();
startlocvec.Y += 80;
camera->setPosition( startlocvec );
scene::IParticleSystemSceneNode* windup = static_cast<IParticleSystemSceneNode*>(smgr->getSceneNodeFromName( "WindUp" ));
// Create a meta triangle selector to hold several triangle selectors.
scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
// find all meshes
core::array<scene::ISceneNode*> nodes;
smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes);
for (u32 i=0; i < nodes.size(); ++i)
{
scene::ISceneNode* node = nodes[i];
scene::ITriangleSelector* selector = 0;
switch(node->getType())
{
case scene::ESNT_CUBE:
case scene::ESNT_ANIMATED_MESH:
// Because the selector won't animate with the mesh,
// and is only being used for camera collision, we'll just use an approximate
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
selector = smgr->createTriangleSelectorFromBoundingBox(node);
break;
case scene::ESNT_MESH:
case scene::ESNT_SPHERE: // Derived from IMeshSceneNode
selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
case scene::ESNT_TERRAIN:
selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
break;
case scene::ESNT_OCT_TREE:
selector = smgr->createOctTreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
default:
// Don't create a selector for this node type
break;
}
if(selector)
{
// Add it to the meta selector, which will take a reference to it
meta->addTriangleSelector(selector);
// And drop my reference to it, so that the meta selector owns it.
selector->drop();
}
}
The documentation for irrGetSceneNodeProperty() says that you can retrieve the node type, but it is wrong. It is just a documentation bug.
The reason that this doesn't work is that scene nodes don't have a property named Type. The properties that you have access to are the ones that can be modified inside IrrEdit (the ones that would be serialized in a call to serializeAttributes() for a given scene node). I'm fairly certain that you cannot change the node type property for an existing node, so this property name is not valid.
If you want to get the type of a scene node, use irrGetSceneNodeType() instead.
Travis
The reason that this doesn't work is that scene nodes don't have a property named Type. The properties that you have access to are the ones that can be modified inside IrrEdit (the ones that would be serialized in a call to serializeAttributes() for a given scene node). I'm fairly certain that you cannot change the node type property for an existing node, so this property name is not valid.
If you want to get the type of a scene node, use irrGetSceneNodeType() instead.
Travis
-
- Posts: 11
- Joined: Sat May 23, 2009 11:39 am
- Location: Poland