Add/remove object
4 posters
Add/remove object
Hi,
This may be a simple answer, but how I would I go about loading my scene initoally with an object (non-actor) and then when I physicPlay, I wish to remove the object from displaying.
Then on a reset cue, I would like the original object to reappear, and keep the same rotation value it previously held before it was "hidden"?
This may be a simple answer, but how I would I go about loading my scene initoally with an object (non-actor) and then when I physicPlay, I wish to remove the object from displaying.
Then on a reset cue, I would like the original object to reappear, and keep the same rotation value it previously held before it was "hidden"?
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
You have 2 options:
1. sio2EnableState( &_SIO2object->flags, SIO2_OBJECT_GHOST ); from anywhere in your app.
2. _SIO2object->dst = 0.0f after sio2ResourceCull, if your object is a collision object its a little bit more tricky cuz you need to remove the object and then add it again to the physic world. It is definitely possible with SIO2 but require a bit more coding. Lemme know if you need help on this.
Cheers,
1. sio2EnableState( &_SIO2object->flags, SIO2_OBJECT_GHOST ); from anywhere in your app.
2. _SIO2object->dst = 0.0f after sio2ResourceCull, if your object is a collision object its a little bit more tricky cuz you need to remove the object and then add it again to the physic world. It is definitely possible with SIO2 but require a bit more coding. Lemme know if you need help on this.
Cheers,
Re: Add/remove object
What exactly does the "SIO2_OBJECT_GHOST" flag mean? Is such an object also invisible to physics, i.e. it doesn't collide?
Best,
Matt
Best,
Matt
Re: Add/remove object
Check out the tutorial06 video I explain it in detail there, however ghost is used for tagging an invisible collision object, and is used for collision map. Please view the tutorial06 on youtube to get more info.
Re: Add/remove object
sio2interactive wrote:You have 2 options:
1. sio2EnableState( &_SIO2object->flags, SIO2_OBJECT_GHOST ); from anywhere in your app.
2. _SIO2object->dst = 0.0f after sio2ResourceCull, if your object is a collision object its a little bit more tricky cuz you need to remove the object and then add it again to the physic world. It is definitely possible with SIO2 but require a bit more coding. Lemme know if you need help on this.
Cheers,
Hi,
I need a way to remove a collision object from the world. I have a regular object which I can remove by using
sio2EnableState( &_SIO2object->flags, SIO2_OBJECT_GHOST );
but then I have a collision map I would like to remove as well which is set flagged as ghost to use vertices as collision object (but not initally rendered). Could you provide some help with this?
Thanks!
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
I don't have the code at hand, but isn't there something like sio2PhysicsRemove or so?jj wrote:I need a way to remove a collision object from the world.
Best,
Matt
Re: Add/remove object
this doesn't work for a collision ghost object...
sio2interactive said theres a way by removeObject then add it back. I get it to not render, but the ghost vertices are still causing collisions...
sio2interactive said theres a way by removeObject then add it back. I get it to not render, but the ghost vertices are still causing collisions...
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
Before you free (sio2ObjectFree) your dynamic object make sure you call:
sio2PhysicRemoveObject( <your current physic world handle >, _SIO2object );
sio2PhysicRemoveObject( <your current physic world handle >, _SIO2object );
Re: Add/remove object
sio2interactive wrote:Before you free (sio2ObjectFree) your dynamic object make sure you call:
sio2PhysicRemoveObject( <your current physic world handle >, _SIO2object );
They are both static objects.
I get an error in FreeObject.... I'm trying to free several instances depending on which target is hit: a static ghost collision map object and a static actor object for each... no luck. Quite frustrating.
Error here: BAD ACCESS
while( i != _SIO2object->n_vertexgroup )
{
sio2VertexGroupFree( _SIO2object->_SIO2vertexgroup[i] );
_SIO2object->_SIO2vertexgroup[i] = NULL;
++i;
}
You mentioned this earlier:
_SIO2object->dst = 0.0f after sio2ResourceCull, if your object is a collision object its a little bit more tricky cuz you need to remove the object and then add it again to the physic world. It is definitely possible with SIO2 but require a bit more coding. Lemme know if you need help on this.
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
Unfortunately I'm on contract on this one, and can't send the source. Bummer for me, because I'm having a real issue.
Once the template has loaded and I'm in the "game" render loop, where should I be implementing the code to take collision objects out of the world?
What did you mean by "if your object is a collision object...you need to remove the object and then add it again to the physic world."?
It seems that while the I can get the objects to not RENDER, the physic world still sees them there. Do I need to reinitialize or update it somehow? Is this because of the flags?
Does this have anything to do with the way I name my objects? I name them target1, target2, target3 and the collision maps collideTarget1, collideTarget2, collideTarget3... but I still see MESH names as Cylinder, Cylinder.002, etc
The problem is these are static objects, not dynamic.
Could it be because the object THAT WON'T GO AWAY is a static triangle mesh? Do I need to come up with some kind of custom coding to resolve this. The only difference between the problem object and the one that resolves away appropriately is the shape. One is a cylinder and the other is a static concave mesh.
Anyone have any thoughts?
Once the template has loaded and I'm in the "game" render loop, where should I be implementing the code to take collision objects out of the world?
What did you mean by "if your object is a collision object...you need to remove the object and then add it again to the physic world."?
It seems that while the I can get the objects to not RENDER, the physic world still sees them there. Do I need to reinitialize or update it somehow? Is this because of the flags?
Does this have anything to do with the way I name my objects? I name them target1, target2, target3 and the collision maps collideTarget1, collideTarget2, collideTarget3... but I still see MESH names as Cylinder, Cylinder.002, etc
The problem is these are static objects, not dynamic.
Could it be because the object THAT WON'T GO AWAY is a static triangle mesh? Do I need to come up with some kind of custom coding to resolve this. The only difference between the problem object and the one that resolves away appropriately is the shape. One is a cylinder and the other is a static concave mesh.
Anyone have any thoughts?
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
I know that I've made some modification recently on theses functions but they are not part of what is online at the moment,
maybe send me your email address and I send you me current version to see if it get rid of that bug.
maybe send me your email address and I send you me current version to see if it get rid of that bug.
Re: Add/remove object
Could that static triangle concave mesh be sticking around because of a PhysicReset after I've tried to remove it from Physic? or because of the sensor that was set up for triggering a sound when it was still being rendered?
Has anyone else had problems removing an object from the physics world?
Is there some other hack or work around to get a damn collision object out of the scene? Bug?
Has anyone else had problems removing an object from the physics world?
Is there some other hack or work around to get a damn collision object out of the scene? Bug?
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
Maybe try to use directly the Bullet API with the SIO2object->_btRigidBody handle? to check if its an SIO2 bug or Bullet's...
Re: Add/remove object
New quick question. Once I perform
sio2PhysicRemoveObject(sio2->_SIO2physic, _object);
sio2ObjectFree(_object);
Is there a couple calls to bring the object back to its original state?
sio2PhysicRemoveObject(sio2->_SIO2physic, _object);
sio2ObjectFree(_object);
Is there a couple calls to bring the object back to its original state?
jj- Posts : 77
Join date : 2008-09-24
Re: Add/remove object
Not really the object is totally gone, not resident in memory, freed forever... You have to load it back from scratch from the SIO2 file or by other means...
Re: Add/remove object
maybe best way is to add parameters in struct SIO2object as :
int visible , // if sio2ResourceRender will render te object.
int physicable , // if the bullet will affect it
and then in the sio2ResourceRender check if it visible ,
the physic sio2PhysicRemoveObject to remove it from DynamicsWorld .
but this will hack the SIO2 source code
you can try it , and tell me the result .
int visible , // if sio2ResourceRender will render te object.
int physicable , // if the bullet will affect it
and then in the sio2ResourceRender check if it visible ,
the physic sio2PhysicRemoveObject to remove it from DynamicsWorld .
but this will hack the SIO2 source code
you can try it , and tell me the result .
sw- Posts : 73
Join date : 2008-10-12
Similar topics
» Correct way to remove SIO2sensor?
» Use object only for collision
» physics object inside another physics object
» Object with two materials
» how to not rotate around object
» Use object only for collision
» physics object inside another physics object
» Object with two materials
» how to not rotate around object
Permissions in this forum:
You cannot reply to topics in this forum