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.

Attractors?

2 posters

Go down

Attractors? Empty Attractors?

Post  jlperan Tue Oct 21, 2008 9:35 am

Hi!

Is there any way to implement an attractor for some objects? I mean, imagine a 3d world with its own gravity system and a character with a power to attract objects to its own.

I´ve been looking here and in BulletPhysics forum and the only thing I´ve found is this video: https://www.youtube.com/watch?v=pt_n_V_Yl9Y and this forum post: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2683

AFAIK, you can only attach one physics world to SIO2. Perhaps a way to achieve this is to create a subclass of sio2 with two physics world but the problem is objects from different worlds will not collision.

Any idea?

Thanks!

jlperan

Posts : 41
Join date : 2008-10-10

Back to top Go down

Attractors? Empty Re: Attractors?

Post  matt Tue Oct 21, 2008 10:07 am

Is a separate world for a second gravity system really needed? Wouldn't it be sufficient to manually calculate apply a force on all objects towards the direction of the attractor?

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Attractors? Empty Re: Attractors?

Post  jlperan Wed Oct 22, 2008 3:58 am

You´re right but SIO2 has no forces appart from gravity.

Should we make use of Bullet Physics ApplyImpulse?

PD: I know I´m a newby, don´t shoot at me Smile

jlperan

Posts : 41
Join date : 2008-10-10

Back to top Go down

Attractors? Empty Re: Attractors?

Post  jlperan Thu Nov 06, 2008 3:12 am

Ok, i´ve been working on this and I need help with my code.

I´ve used tutorial 06 as a start point. I´ve created a simple blender scene with just 3 objects and set a gravity of 0.0 for testing purposes, no land and no sky. I set the objects as actors and rigid body with the same specs as created int tutorial 02.

I´ve modified the code to allow the user to tap two consecutive objects so the first will be attracted by the second. Selection is working fine but then comes the weird thing.

This is the code (slighty modified) to move an object.

Code:

         SIO2object *_SIO2StickyObject = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, stickyObject );
         SIO2object *_SIO2StuckToObject = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, stuckObject );

         btVector3 _rel_pos = btVector3(_SIO2StuckToObject->pos->x - _SIO2StickyObject->pos->x, _SIO2StuckToObject->pos->y - _SIO2StickyObject->pos->y, _SIO2StuckToObject->pos->z - _SIO2StickyObject->pos->z);

         //_SIO2StickyObject->_btRigidBody->setActivationState( DISABLE_DEACTIVATION );
         //_SIO2StuckToObject->_btRigidBody->setActivationState( DISABLE_DEACTIVATION );
         _SIO2StickyObject->_btRigidBody->setGravity(_rel_pos);         
         _SIO2StickyObject->_btRigidBody->applyGravity();

The thing is if I first select the last added object to the blender scene and then select another object, the last objects gets an impulse but not the first one. Any other combination does not move anything. I don´t know if you understand me, sorry for my english.

I´ve tried setting the activation state to DISABLE_DEACTIVATION, using applyImpulse instead of applyGravity, changing the _rel_pos vector to other values (for example : btVector3 _rel_pos = btVector3(_SIO2StuckToObject->pos->x, _SIO2StuckToObject->pos->y, _SIO2StuckToObject->pos->z); ) but the first object does not move.

Probably it´s there but I don´t see it. Can somebody help me?

Thanks in advance.

jlperan

Posts : 41
Join date : 2008-10-10

Back to top Go down

Attractors? Empty Re: Attractors?

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


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