Bullet tranformation - proceedToTransform ... btQuaterion

View previous topic View next topic Go down

Bullet tranformation - proceedToTransform ... btQuaterion

Post  _-MADMAN-_ on Thu Apr 23, 2009 7:47 am

I'm new, so: hello.

I'm stucked with using bullet in SIO2. Geting tranformation from rigid bodies works, but I can't find the way to apply any transform/ force to it. I tried to use quaterion:

Code:
{(sio2->_SIO2object->_btRigidBody->proceedToTransform(btTransform(btQuaternion(0.0, 0.0, 0.0))) );}

But after all it just doesnt work Smile Whole scene works well - dynamic objects, ground etc. No errors and warnings while building.

What is the best way to manipulate physic objects in SIO2?

PS - I'm totally newbe... at all

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  oioioi on Thu Apr 23, 2009 7:58 am


oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  _-MADMAN-_ on Thu Apr 23, 2009 12:04 pm

I found that before I asked - it works, but this is not excatly what I'm looking for Smile I want to move object smoothly, not only get/set actual transformation.

Excuse if I am not clear Smile

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  oioioi on Thu Apr 23, 2009 12:26 pm

This code form line 61- in tutorial6_1 will move the object smoothly:
Code:
// Activate the state of the rigid body, in case the camera
         // didn't move for a while. This is necessary in order to
         // apply the linear velocity. Objects that are "sleeping" cannot
         // receive no new physic "inputs".
         sio2->_SIO2camera->_btRigidBody->setActivationState( ACTIVE_TAG );
         
         // Give a little push in the back to our camera. If you've notice
         // in the video i modify the material property Restitution and
         // friction. Using theses values will avoid our camera to "slide"
         // when it is on a slope or ramp or? If you want the camera to
         // respond in this type of scenarios, just leave the default blender
         // value and the camera will slowly go down the hill or whatever.
         sio2->_SIO2camera->_btRigidBody->setLinearVelocity( btVector3( ( MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->x ) * sio2->_SIO2camera->speed,
                                                        ( MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->y ) * sio2->_SIO2camera->speed,
                                                         sio2->_SIO2camera->_btRigidBody->getLinearVelocity()[2] ) );

However this doesn't move it to a given position but in a given direction. If you want the first one you can easily calculate the direction your object have to go and the push it in that direction until it reaches the position.

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  _-MADMAN-_ on Thu Apr 23, 2009 12:35 pm

Yeah, this is it. But i had a problem with differences between camera and object - object doesn't have speed. I changed that to location in x axis - there started the problem with transformation dynamic mesh with rigid body depending on bullet.

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  oioioi on Thu Apr 23, 2009 1:04 pm

Just change
( MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->x ) * sio2->_SIO2camera->speed
to something else. I use it this to move my player:
Code:
vec3 v;
player.playerObj->_btRigidBody->setActivationState( ACTIVE_TAG );
memcpy( &v, player.playerObj->_SIO2transform->loc, 12 );
               
v.x -= float(player.playerObj->_SIO2transform->loc->x +  sio2->_SIO2camera->_SIO2transform->dir->y * player.moveLR);
v.y -= float(player.playerObj->_SIO2transform->loc->y + -sio2->_SIO2camera->_SIO2transform->dir->x * player.moveLR);
               
player.playerObj->_btRigidBody->setLinearVelocity(btVector3(
            ((-v.x * player.speedLR) + (( player.moveDir * sio2->_SIO2camera->_SIO2transform->dir->x ) * player.speed)) * 2,
            ((-v.y * player.speedLR) + (( player.moveDir * sio2->_SIO2camera->_SIO2transform->dir->y ) * player.speed)) * 2,
            player.playerObj->_btRigidBody->getLinearVelocity()[2] ) );
vec3 v is used in tutorial 9 or in SIO2CamerStrafe() I think, to calculate which direction is sideways. speed, speedLR and moveDir is set by using the accelerometer.

I also have bots in my game, they have a much easier way to handle movement:
Code:
bots[i].botObj->_btRigidBody->setActivationState( ACTIVE_TAG );
         bots[i].botObj->_btRigidBody->setLinearVelocity( btVector3( bots[i].speed.x,
                                                     bots[i].speed.y,
                                                     bots[i].botObj->_btRigidBody->getLinearVelocity()[2] ) );
speed.x and speed.y is set by easy math using waypoint.

Hope this helps you a bit

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  _-MADMAN-_ on Thu Apr 23, 2009 1:43 pm

thanks a lot!

Playing around, and emulator stuck with that lines (refer to touch direction):

Code:
sio2->_SIO2object->_SIO2transform->loc->x = (d.x*0.025f);


Code:
   if(ROT_Z)
   {   
      SIO2object *_SIO2object = (SIO2object*)sio2ResourceGet(sio2->_SIO2resource, SIO2_OBJECT, "object/bolid");
      
      if(_SIO2object)
      {
         {sio2TransformRotateZ(sio2->_SIO2object->_SIO2transform, ROT_Z);}
      }
      sio2TransformBindMatrix(_SIO2object->_SIO2transform);
   }

Propably i'm missing some fundamentals.

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  oioioi on Thu Apr 23, 2009 3:21 pm

You should move this line:
SIO2object *_SIO2object = (SIO2object*)sio2ResourceGet(sio2->_SIO2resource, SIO2_OBJECT, "object/bolid");
to the top of your render function, at least before:
sio2->_SIO2object->_SIO2transform->loc->x = (d.x*0.025f);
which should be changed to
_SIO2object->_SIO2transform->loc->x = (d.x*0.025f);
_SIO2object is here referring to the first line(sio2RecourceGet())

sio2->_SIO2object is an array of objects(I think), if you look at the sio2ResourceGet() code you can see that you can access all the objects with sio2->_SIO2object[some number]. your line of code to modify the position is something like this:
Code:
int number[20];
number[0] = 2; //ok
number = 5; //not ok

You should read through most of the tutorials again, at least 2, 4, 6 and maybe 9

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  _-MADMAN-_ on Thu Apr 23, 2009 3:50 pm

I Have already found it - thanks for Your help. I just removed unnecessary sio2 call.

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Bullet tranformation - proceedToTransform ... btQuaterion

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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