Bullet tranformation - proceedToTransform ... btQuaterion
2 posters
Bullet tranformation - proceedToTransform ... btQuaterion
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:
But after all it just doesnt work 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
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 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
Re: Bullet tranformation - proceedToTransform ... btQuaterion
I think you're looking for this https://sio2interactive.forumotion.net/sio2-engine-f3/moving-physic-objects-to-specific-pos-t538.htm
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: Bullet tranformation - proceedToTransform ... btQuaterion
I found that before I asked - it works, but this is not excatly what I'm looking for I want to move object smoothly, not only get/set actual transformation.
Excuse if I am not clear
Excuse if I am not clear
_-MADMAN-_- Posts : 52
Join date : 2009-04-23
Re: Bullet tranformation - proceedToTransform ... btQuaterion
This code form line 61- in tutorial6_1 will move the object smoothly:
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.
- 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
Re: Bullet tranformation - proceedToTransform ... btQuaterion
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
Re: Bullet tranformation - proceedToTransform ... btQuaterion
Just change
( MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->x ) * sio2->_SIO2camera->speed
to something else. I use it this to move my player:
I also have bots in my game, they have a much easier way to handle movement:
Hope this helps you a bit
( 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] ) );
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] ) );
Hope this helps you a bit
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: Bullet tranformation - proceedToTransform ... btQuaterion
thanks a lot!
Playing around, and emulator stuck with that lines (refer to touch direction):
Propably i'm missing some fundamentals.
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
Re: Bullet tranformation - proceedToTransform ... btQuaterion
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:
You should read through most of the tutorials again, at least 2, 4, 6 and maybe 9
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
Re: Bullet tranformation - proceedToTransform ... btQuaterion
I Have already found it - thanks for Your help. I just removed unnecessary sio2 call.
_-MADMAN-_- Posts : 52
Join date : 2009-04-23
Similar topics
» Bullet for 2D
» Upgrading Bullet
» SIO2 Architecture and Bullet Physics integration
» Culling and Bullet
» Bullet Engine
» Upgrading Bullet
» SIO2 Architecture and Bullet Physics integration
» Culling and Bullet
» Bullet Engine
Permissions in this forum:
You cannot reply to topics in this forum