FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Add/remove object

4 posters

Go down

Add/remove object Empty Add/remove object

Post  jj Thu Oct 02, 2008 5:14 pm

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"?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Thu Oct 02, 2008 6:49 pm

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,
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  matt Tue Oct 14, 2008 3:54 pm

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

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Tue Oct 14, 2008 4:39 pm

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.
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  jj Tue Oct 21, 2008 3:28 am

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

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  matt Tue Oct 21, 2008 9:15 am

jj wrote:I need a way to remove a collision object from the world.
I don't have the code at hand, but isn't there something like sio2PhysicsRemove or so?

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  jj Tue Oct 21, 2008 10:56 am

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...

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Tue Oct 21, 2008 5:20 pm

Before you free (sio2ObjectFree) your dynamic object make sure you call:

sio2PhysicRemoveObject( <your current physic world handle >, _SIO2object );
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  jj Tue Oct 21, 2008 5:31 pm

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

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Tue Oct 21, 2008 5:53 pm

If you can send me a test project that reproduce the error, I can debug it...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  jj Tue Oct 21, 2008 8:00 pm

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?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Tue Oct 21, 2008 10:29 pm

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.
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  jj Tue Oct 21, 2008 10:56 pm

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?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Wed Oct 22, 2008 12:28 am

Maybe try to use directly the Bullet API with the SIO2object->_btRigidBody handle? to check if its an SIO2 bug or Bullet's...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  jj Tue Oct 28, 2008 1:46 am

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?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sio2interactive Tue Oct 28, 2008 2:06 am

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...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  sw Tue Oct 28, 2008 2:39 am

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 Smile

you can try it , and tell me the result .
sw
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

Add/remove object Empty Re: Add/remove object

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum