CHAI3DCHAI3D

dynamically create and remove objects

More
02 May 2017 15:30 #1

is it possible to dynamically create or to remove objects in the scene?


For example, I have a mesh_sphere created at the beginning.
If I press "2", then two ODE shperes will be created with its imageModel set as mesh_sphere;
Then if I press "1", one of the ODE sphere will be removed from the scene;

Please Log in or Create an account to join the conversation.

More
14 May 2017 21:50 #2

You should be able to remove them from the scene. Since this framework uses the ODE dynamics engine, please check the ODE documentation if you are encountering problems.

Please Log in or Create an account to join the conversation.

More
15 May 2017 16:30 #3

Here is my solution to a similar problem:

// Show an object and activate it (or not)
void activate_object(cODEGenericBody* ODEObject, bool activate)
{
if (activate)
{
ODEObject->setEnabled(true,true);
ODEObject->enableDynamics();
ODEObject->setGhostEnabled(false);
}
else
{
ODEObject->setGhostEnabled(true);
ODEObject->disableDynamics();
ODEObject->setEnabled(false,true);
};
}

Please Log in or Create an account to join the conversation.