Jump to content

[SOLVED] Vehicle design


photo

Recommended Posts

Hello

 

Can you add a little toutorial to create a Car ?

 

If I use the "sunspension" Joint my tire always roll in any axes... I don´t understud the way to freeze the rotation of the axes.

 

Thank you

Link to comment

I´m Sorry... I resolved this problem (wrong mass setup.. ) Anyway I don´t undertund the right workfolw to create a simple veicle whit the control, this is very important because we are looking for a little race car game

Link to comment

Have you looked at the Passage demo and its source code? This demo could definitely shed some light :) There you can find a car (it is one of the switchable players) under "flurry" name. Controls handling is also implemented there.

Link to comment

Hello manguste

 

no I have an error message if I try to open this demo.

 

joint.setCurrentLineraDistance(0.0f);

demos/passage/flurry/flurry_player.h:99 Interpreter::parse_extern_class_begin(): unknown "JointWheel"class member "setCurrentLinearDistance"

 

 

Also I find this code

 

 

 

void update() {

 

float ifps = engine.game.getIFps();

 

float torque = 0.0f;

if(engine.controls.getState(CONTROLS_STATE_FORWARD) || engine.controls.getState(CONTROLS_STATE_TURN_UP)) {

velocity = max(velocity,0);

velocity += ifps * 15.0f;

torque = 50.0f;

} else if(engine.controls.getState(CONTROLS_STATE_BACKWARD) || engine.controls.getState(CONTROLS_STATE_TURN_DOWN)) {

velocity = min(velocity,0);

velocity -= ifps * 15.0f;

torque = 50.0f;

} else {

velocity *= exp(-ifps);

}

velocity = clamp(velocity,-90.0f,90.0f);

 

if(engine.controls.getState(CONTROLS_STATE_MOVE_LEFT) || engine.controls.getState(CONTROLS_STATE_TURN_LEFT)) {

angle += ifps * 100.0f;

} else if(engine.controls.getState(CONTROLS_STATE_MOVE_RIGHT) || engine.controls.getState(CONTROLS_STATE_TURN_RIGHT)) {

angle -= ifps * 100.0f;

} else {

if(abs(angle) < 0.25f) angle = 0.0f;

else angle -= sign(angle) * ifps * 45.0f;

}

angle = clamp(angle,-40.0f,40.0f);

 

float base = 3.3f;

float width = 3.0f;

float angle_0 = angle;

float angle_1 = angle;

if(abs(angle) > EPSILON) {

float radius = base / tan(angle * DEG2RAD);

angle_0 = atan(base / (radius + width / 2.0f)) * RAD2DEG;

angle_1 = atan(base / (radius - width / 2.0f)) * RAD2DEG;

}

 

joints[2].setAngularVelocity(velocity);

joints[3].setAngularVelocity(velocity);

 

joints[2].setAngularTorque(torque);

joints[3].setAngularTorque(torque);

 

joints[0].setAxis10(rotateZ(angle_0) * vec3(0.0f,1.0f,0.0f));

joints[1].setAxis10(rotateZ(angle_1) * vec3(0.0f,1.0f,0.0f));

 

if(engine.controls.getState(CONTROLS_STATE_USE)) {

joints[0].setAngularDamping(20000.0f);

joints[1].setAngularDamping(20000.0f);

joints[2].setAngularDamping(20000.0f);

joints[3].setAngularDamping(20000.0f);

velocity = 0.0f;

} else {

joints[0].setAngularDamping(0.0f);

joints[1].setAngularDamping(0.0f);

joints[2].setAngularDamping(0.0f);

joints[3].setAngularDamping(0.0f);

}

}

};

 

 

I Dont undestud the way to associate my wheels to the kayboard direction Like thiss :

 

if(engine.controls.getState(CONTROLS_STATE_FORWARD) || engine.controls.getState(CONTROLS_STATE_TURN_UP)) {

velocity = max(velocity,0);

velocity += ifps * 15.0f;

torque = 50.0f;

} else if(engine.controls.getState(CONTROLS_STATE_BACKWARD) || engine.controls.getState(CONTROLS_STATE_TURN_DOWN)) {

velocity = min(velocity,0);

velocity -= ifps * 15.0f;

torque = 50.0f;

I´m sorry but Im a 3D Artist and not a programmer. i Need to create this simple control to move the car and go on on the next step.

 

Tenks for the Reply

Link to comment
I have an error message if I try to open this demo.

The demo will work in the next update.

 

I Dont undestud the way to associate my wheels to the kayboard direction Like thiss :

Take a look at Controls class, there you find description of all states of controls. Handling input can be done only via scripting, I'm afraid.

Good news is you can use samples as templates; they do not require much modification, because controls are already handled there. You can use the following:

* JointSuspension to create ray-cast wheels (see data/samples/physics/car_00) or

* JointWheel for proper physical wheels (see data/samples/physics/car_02, which basically does the same as in code snippet above).

Link to comment
  • 2 years later...

Manguste you said JointSuspension is ray-cast wheel and JointWheel is physical wheel. Is that true or is it the other way around? It is recommended in the documentations to assign rigid bodies to suspension joints, but dummy bodies to wheel joints. That gave me the impression that suspension joint is the one with the physical calculations. 

Link to comment
×
×
  • Create New...