mkandula
11-09-2008 06:59:54
Hi,
I am trying to attach my ogre entity with the NxOgre body.
When I do this,
NxOgre::Body *mBody = mScene->createBody(meshtouse, new NxOgre::Capsule(radius, 2*radius),
NxOgre::Pose(node->getPosition(), node->getOrientation()), "identifier: " + node->getName() + ", usage: use", "mass: 10");
[\code]
I am getting a crash saying:
OGRE_EXCEPTION(ITEM_IDENTITY_EXCEPTION) a scene node with the node's name is already existing in OctreeSceneManager::CreateSceneNode
How should I do what I am trying to do ??
Should Ogre entity node be not attached to the SceneManager ??
Is the NxOgre::Body attached using the node's name ? Can it be not be done with a pointer ? What if the node does not have a name ?
maroxe
12-09-2008 01:13:18
why are you trying to do that? the body class can alredy draw it self
mkandula
12-09-2008 06:58:54
Hi,
I want to have have an object and attach the body so that I can also attach my custom mesh in order to see the physics object...for example..I can attach box as a bounding physics object and visualize the box when i need to.
Also if the its some renderable, how will I animate it ? how to get the renderable's entity pointer ?
Caphalor
12-09-2008 14:02:05
NxOgre::Body *mBody = mScene->createBody(meshtouse, new NxOgre::Capsule(radius, 2*radius),
NxOgre::Pose(node->getPosition(), node->getOrientation()), "identifier: " + node->getName() + ", usage: use", "mass: 10");
I think that should be:
NxOgre::Body *mBody = mScene->createBody(meshtouse, new NxOgre::Capsule(radius, 2*radius),
NxOgre::Pose(node->getPosition(), node->getOrientation()), "identifier: " + node->getName() + ", identifier-type: r", "mass: 10");
see NodeRenderableParams::parse(Parameters params):
if (parameter->i == "identifier-type") {
if (parameter->j.substr(0,1) == "c" || parameter->j.substr(0,1) == "C") {
mIdentifierUsage = IU_Create;
}
else if (parameter->j.substr(0,1) == "r" || parameter->j.substr(0,1) == "R") {
mIdentifierUsage = IU_Use;
}
else {
mIdentifierUsage = IU_Create;
}
}
The most secure way is to use the param class directly instead of passing a string:
NxOgre::NodeRenderableParams nrp;
nrp.setToDefault();
nrp.mIdentifier = node->getName();
nrp.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
NxOgre::Body *mBody = mScene->createBody(meshtouse, new NxOgre::Capsule(radius, 2*radius),
NxOgre::Pose(node->getPosition(), node->getOrientation()), nrp, "mass: 10");
mkandula
14-09-2008 16:16:53
hey that works !!
But now I have another problem...how can I "unattach" the Ogre::Node back.
In my code, I am having all entities cleared and then I am clearing the physics system. I think the NxOgre::Body does not like this.
It looks I need some function to remove the link and let the physics object die by itself seperately.
Prophet
15-09-2008 09:13:16
destroyActor/Body? (I guess it's depending on what you destroy first)
mkandula
15-09-2008 09:27:55
destroyActor/body will leave me with a dangling pointer. I want to avoid this, but removing the link with the Ogre::Node so that my node does not get deleted.
Prophet
15-09-2008 09:48:33
Ah, I misunderstood you. Sorry.