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.

rotate a physics object?

2 posters

Go down

rotate a physics object? Empty rotate a physics object?

Post  arrogantb Sun Aug 02, 2009 3:30 am

I'm trying to duplicate - and then both scale and rotate a "static" physics object with box bounds.

(The larger scale goal is to define some basic objects in blender - then programatically create a new scene using them)

The following code seems to work for me as far as scaling the duplicate object:

Code:


      SIO2object *selection = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource,
                                                SIO2_OBJECT,
                                                "object/floor1" );
      

      selection->_SIO2transform->loc->x += 180.0f;

      selection->_SIO2transform->scl->x = .6f;


      btRigidBody            *_btRigidBody;
      btCollisionShape      *_btCollisionShape;
      btDefaultMotionState  *_btDefaultMotionState;
      btTransform            _btTransform;
      btMatrix3x3            _btMatrix3x3;
      
      btVector3            inertia( 0.0, 0.0, 0.0 );
      
      _btCollisionShape = new btBoxShape( btVector3( selection->dim->x * selection->_SIO2transform->scl->x,
       selection->dim->y * selection->_SIO2transform->scl->y,
       selection->dim->z * selection->_SIO2transform->scl->z ) );
      
      _btTransform.setIdentity();
      
      _btTransform.setOrigin( btVector3( selection->_SIO2transform->loc->x,
                                selection->_SIO2transform->loc->y,
                                selection->_SIO2transform->loc->z ) );
      
      _btDefaultMotionState = new btDefaultMotionState( _btTransform );
      
      _btCollisionShape->calculateLocalInertia( (btScalar)selection->mass, inertia );
      
      _btRigidBody = new btRigidBody( (btScalar)selection->mass,
                             _btDefaultMotionState,
                             _btCollisionShape,
                             inertia );
      
      _btRigidBody->setAngularFactor( (btScalar)0.0 );
            
      sio2->_SIO2physic->_btSoftRigidDynamicsWorld->addRigidBody( _btRigidBody );

      selection->_btRigidBody = _btRigidBody;
      
      selection = sio2ObjectDuplicate( selection,
                              selection->_SIO2transform,
                              new_object, 1 );


But whenever I try to introduce rotation - I get strange results. It seems I can get the rotation - or the scaling to work in physics - but not both.

Is there a "right" way to do this? Am I barking up the wrong tree? Any help appreciated.

Currently using sio2 1.35.

arrogantb

Posts : 5
Join date : 2009-02-05

Back to top Go down

rotate a physics object? Empty Re: rotate a physics object?

Post  sio2interactive Sun Aug 02, 2009 7:41 am

Check tutorial061...
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Back to top

- Similar topics

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