Hi all.
I am trying to learn how to use constraint.
The main objetive is to use a constraint in a car simulation program.
But i cant find how to use a constraint in my aplication.
Can someone help me use a simple constraint?
What is each parameter?
To the my car simulation a good example can be a box and an sphere.
Like:
btCollisionShape* carbody = new btBoxShape(btVector3(2, .5, 5));
btCollisionShape* wheel= new btSphereShape(1);
how to set up a hinge constraint so i can aply torque to the wheel and see it rotate attached to the body
If i can understand this I think that I can put the others 3 wheels and make the car run and change its direction.
Thanks.
Sorry for my bad English.
HingeCanstraint help
-
sosssego
- Posts: 6
- Joined: Sun Nov 29, 2009 2:38 am
Re: HingeCanstraint help
Well, no help until now.
Let me try help you help me.
btHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame, bool useReferenceFrameA = false);
btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA, bool useReferenceFrameA = false);
btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3&
pivotInB, btVector3& axisInA,btVector3& axisInB, bool useReferenceFrameA = false);
btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA = false);
These are the prototypes for a btHingeConstraint
For the first.
rbA is the body a, ok?
what about rbAFrame? and useReferenceFrameA?
How can i have a hinge with only 1 body?
What prototype should i use for the car simulation. (ok i know that i will need more than a hinge to have a good simulation, but if i can understand a btHingeConstraint maybe i can understand all of them. I heard about btHinge2Constraint for car simulation maybe it is very usefull)
Can anyone help me?
Let me try help you help me.
btHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame, bool useReferenceFrameA = false);
btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA, bool useReferenceFrameA = false);
btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3&
pivotInB, btVector3& axisInA,btVector3& axisInB, bool useReferenceFrameA = false);
btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA = false);
These are the prototypes for a btHingeConstraint
For the first.
rbA is the body a, ok?
what about rbAFrame? and useReferenceFrameA?
How can i have a hinge with only 1 body?
What prototype should i use for the car simulation. (ok i know that i will need more than a hinge to have a good simulation, but if i can understand a btHingeConstraint maybe i can understand all of them. I heard about btHinge2Constraint for car simulation maybe it is very usefull)
Can anyone help me?
-
sosssego
- Posts: 6
- Joined: Sun Nov 29, 2009 2:38 am
Re: HingeCanstraint help
Ok, i had understand it a little more.
Not for the prototypes that i had post, but for this one that is pretty good for a car simulation.
I used this btHinge2Constraint (btRigidBody &rbA, btRigidBody &rbB, btVector3 &anchor, btVector3 &axis1, btVector3 &axis2)
If we had some comments on the code that generates the documentation it ill be GREAT for undestand.
And another important thing to make it work.I take to much time to discover it ...
You can find a program with source code with use this hinge2constraint in this forum look for hinge2vehicle.
Now I need some help to know how to apply torque to this hinge.
Can some one help me?
Another doubt is about friction.
Let me explain. The tire had more friction to torque and brake than to hold the trajectory in a curve.
How can I use it in bullet? Is that the function of setAnisotropicFriction? Did I need to choose between regular friction and Anisotropic?
Did I need to activate it?
And more about friction. The static friction (I mean when the tire do not slip)is bigger that the dynamic friction (where the tire slip).
How can I know if the tire is sliding or not so i can set the right value for friction. And how can i know the direction of the sliding?
Hope some one can help me.
Maybe I am trying the wrong place for information... Am I?
Thanks
Best regards
Not for the prototypes that i had post, but for this one that is pretty good for a car simulation.
I used this btHinge2Constraint (btRigidBody &rbA, btRigidBody &rbB, btVector3 &anchor, btVector3 &axis1, btVector3 &axis2)
If we had some comments on the code that generates the documentation it ill be GREAT for undestand.
Code: Select all
rbA //rigid body A in my program it is the car chassis, but i think that there are no difference.
rba //rigid body B in my program it is the wheel, i really don't know yet if swap this to parts make it impossible to work.
anchor // i used the origin of the rbB
axis1 // It is the axis to turn the vehicle, it is not about that axis that the wheel rotate to make the vehicle run. i used the up vector for the chassis
//axis1(chasisRB->getWorldTransform().getBasis().getColumn(1));
axis2 // It is the axis where the wheel rotate to make the car run. The X axis of the chassis
//axis2(chassisRB->getWorldTransform().getBasis().getColumn(0));Code: Select all
dynamicsWorld->addConstraint(Hinge2, true); //add your constraint to the world =)Now I need some help to know how to apply torque to this hinge.
Can some one help me?
Another doubt is about friction.
Let me explain. The tire had more friction to torque and brake than to hold the trajectory in a curve.
How can I use it in bullet? Is that the function of setAnisotropicFriction? Did I need to choose between regular friction and Anisotropic?
Did I need to activate it?
And more about friction. The static friction (I mean when the tire do not slip)is bigger that the dynamic friction (where the tire slip).
How can I know if the tire is sliding or not so i can set the right value for friction. And how can i know the direction of the sliding?
Hope some one can help me.
Maybe I am trying the wrong place for information... Am I?
Thanks
Best regards