Posted: Mon Oct 24, 2005 10:49 am
@ hike
To obtain a first person driver we need to attach the camera to some joint inside body of the car. The problem is the render distance of the engine so actually, inside the body, the chasssis is transparent. However we can try.
________
NEW CAR DEMO.
DOWNLOAD: http://realityfactory.altervista.org/do ... t_Room.zip
There are new arising problems but new steps beyond done.
a) Test Room and rigid car..
b) Mechanic suspension test.
a) Test Room 1. Drive the car in a empty driving school square. Note that the 2 front wheels are auto-aligned and the force is applied long the actual driving wheel rotation axis. This is possible in virtue of a script that calculate the relative absolute rotation of the wheels and turns that variable in a relative fraction to be applied to the Torque_Force generated by the (virtual) motor.
this is the pawn script:
the result in the Physics Script will be:
The auto-alignement script is obtained in a similar way, calculating the difference between the wheels alignement.
You can turn on stencil shadows and see them in action on the Car Body. This will show up the limit of the script because the left wheel will lose his capability to auto-align properly. Too much scripts at the same time and too much pawn entities to track the physic object (attached using PositionTPAwn). So Nout, some help is welcome to put all the script in one and track object yaw without pawn entities.
Brake and Handbrake are scripted in a brutal wa, don't think about it. In the same way I had to use a simpliied torque increasing method to test the torque/rotation alignement but an acceleration/gear system has to be scripted to have different gear ratio and torque responses.
Probaly there is better way to have the front wheels aligned. Can Nout explain in a detailed way, wich methos has been used in the Vehicle Entity (sensor and callbacks? but what exactly are "sensor and callbacks"? please teach me!)
I think that the behavious of the car is, all things considered, quite good. The problem is stability.
b) Little example to have "mechanic suspension" using only joint and force trying to simulate the suspension real mechanic. The result is a quite interesting interesing as case study.
There are additional bodies jointed between the chassis and the wheels. These bodies create am hinge the chassis and the wheels in the Z axis. This joint have a llittle up/down limit so the chassis can move up and down in respect the wheels. A constant force in applied to these bodies to partially invert the gravity such a suspension that force up a body. This isn't probably a good method to create a suspension but is interesting to see that it can be done.
DOWNLOAD: http://realityfactory.altervista.org/do ... t_Room.zip
Probably you have to wait some day to have the last Nout executables...
To obtain a first person driver we need to attach the camera to some joint inside body of the car. The problem is the render distance of the engine so actually, inside the body, the chasssis is transparent. However we can try.
________
NEW CAR DEMO.
DOWNLOAD: http://realityfactory.altervista.org/do ... t_Room.zip
There are new arising problems but new steps beyond done.
a) Test Room and rigid car..
b) Mechanic suspension test.
a) Test Room 1. Drive the car in a empty driving school square. Note that the 2 front wheels are auto-aligned and the force is applied long the actual driving wheel rotation axis. This is possible in virtue of a script that calculate the relative absolute rotation of the wheels and turns that variable in a relative fraction to be applied to the Torque_Force generated by the (virtual) motor.
this is the pawn script:
to have patial percentual output of the torque (X Z axis).debug("Torque Direction - Debug");
debug(self.key_pressed);
debug("Torque on Z Axis :" # A_PERC # " %");
debug("Torque on X Axis :" # B_PERC # " %");
debug("Overrall steer Wheel: " # OVERRALL_STEER # " %");
debug("Overrall steer Chassis: " # OVERRALL_STEER_CHASSIS # " %");
debug("Left Wheel steer: " # LEFT_STEER # " %");
debug("Right Wheel steer: " # RIGHT_STEER # " %");
debug("Left Mouse Button = accelerate");
debug("Right Mouse Button = decelerate / retro");
debug("Keyboard Arrows = Left/Right");
debug("8 = Change Camera");
debug("J = Apply an Upward Impulse");
debug("SPACE = HANDBRAKE");
//calculemus 1 - For the torque forcfe applied on Z axis on the motor wheel
MY_YAW = Integer(LEFT_WHEEL_ATTACH.current_yaw / 0.0174532925199433);
MY_YAW_CHASSIS = Integer(self.current_yaw / 0.0174532925199433);
if((MY_YAW > 0)and(MY_YAW <= 90))
{
B_PERC = Integer(100 /(90/(MY_YAW)));
A_PERC = Integer(100 - B_PERC);
}
if((MY_YAW > 90)and(MY_YAW <= 180))
{
A_PERC = -(Integer(100 /(90/(MY_YAW-90))));
B_PERC = Integer(100 + A_PERC);
}
if((MY_YAW > 180)and(MY_YAW <= 270))
{
B_PERC = -(Integer(100 /(90/(MY_YAW-180))));
A_PERC = -(Integer(100 + B_PERC));
}
if((MY_YAW > 270)and(MY_YAW <= 360))
{
A_PERC = Integer(100 /(90/(MY_YAW-270)));
B_PERC = -(Integer(100 - A_PERC));
}
if(MY_YAW = 0)
{
B_PERC=0;
A_PERC=100;
}
the result in the Physics Script will be:
Now i'm trying to migrate it inside the PhysicsScript of the car but something doesn't work good.SetTorque(Body[3], X_FINAL_TORQUE, 0, Z_FINAL_TORQUE, true);
SetTorque(Body[4], X_FINAL_TORQUE, 0, Z_FINAL_TORQUE, true);
Z_PERC = GetGlobal(1, "Int");
X_PERC = GetGlobal(2, "Int");
if(((self.leftmousekey_pressed=true)and((self.key_pressed=46)=false)and((self.key_pressed=33)=false))and(((self.key_pressed=58)=true)or((self.key_pressed=58)=false))and(((self.key_pressed=57)=true)or((self.key_pressed=57)=false)))
{
TORQUE_REAR=240;
X_FINAL_TORQUE = TORQUE_REAR*(X_PERC/100);
Z_FINAL_TORQUE = TORQUE_REAR*(Z_PERC/100);
}
else
{
X_FINAL_TORQUE = -TORQUE_REAR*(X_PERC/100);
Z_FINAL_TORQUE = -TORQUE_REAR*(Z_PERC/100);
if(((self.rightmousekey_pressed)and((self.key_pressed=46)=false)and((self.key_pressed=33)=false))and(((self.key_pressed=58)=true)or((self.key_pressed=58)=false))and(((self.key_pressed=57)=true)or((self.key_pressed=57)=false)))
{
TORQUE_REAR=240;
}
else
{
TORQUE_REAR=1;
}
The auto-alignement script is obtained in a similar way, calculating the difference between the wheels alignement.
You can turn on stencil shadows and see them in action on the Car Body. This will show up the limit of the script because the left wheel will lose his capability to auto-align properly. Too much scripts at the same time and too much pawn entities to track the physic object (attached using PositionTPAwn). So Nout, some help is welcome to put all the script in one and track object yaw without pawn entities.
Brake and Handbrake are scripted in a brutal wa, don't think about it. In the same way I had to use a simpliied torque increasing method to test the torque/rotation alignement but an acceleration/gear system has to be scripted to have different gear ratio and torque responses.
Probaly there is better way to have the front wheels aligned. Can Nout explain in a detailed way, wich methos has been used in the Vehicle Entity (sensor and callbacks? but what exactly are "sensor and callbacks"? please teach me!)
I think that the behavious of the car is, all things considered, quite good. The problem is stability.
b) Little example to have "mechanic suspension" using only joint and force trying to simulate the suspension real mechanic. The result is a quite interesting interesing as case study.
There are additional bodies jointed between the chassis and the wheels. These bodies create am hinge the chassis and the wheels in the Z axis. This joint have a llittle up/down limit so the chassis can move up and down in respect the wheels. A constant force in applied to these bodies to partially invert the gravity such a suspension that force up a body. This isn't probably a good method to create a suspension but is interesting to see that it can be done.
DOWNLOAD: http://realityfactory.altervista.org/do ... t_Room.zip
Probably you have to wait some day to have the last Nout executables...