Attractors?

View previous topic View next topic Go down

Attractors?

Post  jlperan on 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.

Ive been looking here and in BulletPhysics forum and the only thing Ive found is this video: http://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

View user profile

Back to top Go down

Re: Attractors?

Post  matt on 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

View user profile http://elfrun.net

Back to top Go down

Re: Attractors?

Post  jlperan on Wed Oct 22, 2008 3:58 am

Youre right but SIO2 has no forces appart from gravity.

Should we make use of Bullet Physics ApplyImpulse?

PD: I know Im a newby, dont shoot at me Smile

jlperan

Posts : 41
Join date : 2008-10-10

View user profile

Back to top Go down

Re: Attractors?

Post  jlperan on Thu Nov 06, 2008 3:12 am

Ok, ive been working on this and I need help with my code.

Ive used tutorial 06 as a start point. Ive 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.

Ive 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 dont know if you understand me, sorry for my english.

Ive 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 its there but I dont see it. Can somebody help me?

Thanks in advance.

jlperan

Posts : 41
Join date : 2008-10-10

View user profile

Back to top Go down

Re: Attractors?

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


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