Attractors?
2 posters
Attractors?
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!
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
Re: Attractors?
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
Best,
Matt
Re: Attractors?
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
Should we make use of Bullet Physics ApplyImpulse?
PD: I know I´m a newby, don´t shoot at me
jlperan- Posts : 41
Join date : 2008-10-10
Re: Attractors?
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.
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.
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
Permissions in this forum:
You cannot reply to topics in this forum