How do I animated the buggy wheels
by Robert Brower · in Torque Game Engine · 08/27/2002 (5:23 pm) · 2 replies
The racing mod contains a buggy with 4 wheels that are programatically rotated and moved up and down based on the physics of the springs and the velocity of the vehicle. The wheel.dts object does not have any animation sequences in it.
I want to simply replace the wheel with a leg. I have an animated Leg.dts file which I exported from Milkshape with seq: walk=1-50 defined as a special material so the exporter can export the animation sequence. For now I only have one sequence called "walk".
I commented out the code that rotates the wheel. I also modified the code that calculates the radius of the wheel such that it is attached at the shoulder not at the hub. My vehicle now drives around quite nicely with unanimated legs.
I want to add code to animate the legs.
I noticed that WheeledVehicle and WheeledVehicleData classes both exist but that WheeledVehicleTire exists but no WheeledVehicleTireData class exists.
What is the relationship between WheeledVehicle and WheeledVehicleData classes? Do i have to define and declare a WheeledVehicleTireData class in order to animate the wheel using the animation sequences found in the dts file?
WheeledVehicleData::preload() sets the following members WheeledVehicleData::wheel::springNode
WheeledVehicleData::wheel::springSequence and WheeledVehicleData::wheel::springLength which are essential elements of the dts animation in WheeledVehicle.
Without a WheeledVehicleTireData class, where can I set node, sequence, and length for the Walk animation?
What are the steps i should take to do this? It seems conceptually easy but I've been unsuccessful in the last 5 days in doing this.
Any help at all would be very much appreciated. Thank you. I really need some guidance here, preferably from someone within the GG organization. I'm not looking for vagueness. I'm more interested in an answer that will lead me towards this simple goal. Thanks again.
Robert Brower
I want to simply replace the wheel with a leg. I have an animated Leg.dts file which I exported from Milkshape with seq: walk=1-50 defined as a special material so the exporter can export the animation sequence. For now I only have one sequence called "walk".
I commented out the code that rotates the wheel. I also modified the code that calculates the radius of the wheel such that it is attached at the shoulder not at the hub. My vehicle now drives around quite nicely with unanimated legs.
I want to add code to animate the legs.
I noticed that WheeledVehicle and WheeledVehicleData classes both exist but that WheeledVehicleTire exists but no WheeledVehicleTireData class exists.
What is the relationship between WheeledVehicle and WheeledVehicleData classes? Do i have to define and declare a WheeledVehicleTireData class in order to animate the wheel using the animation sequences found in the dts file?
WheeledVehicleData::preload() sets the following members WheeledVehicleData::wheel::springNode
WheeledVehicleData::wheel::springSequence and WheeledVehicleData::wheel::springLength which are essential elements of the dts animation in WheeledVehicle.
Without a WheeledVehicleTireData class, where can I set node, sequence, and length for the Walk animation?
What are the steps i should take to do this? It seems conceptually easy but I've been unsuccessful in the last 5 days in doing this.
Any help at all would be very much appreciated. Thank you. I really need some guidance here, preferably from someone within the GG organization. I'm not looking for vagueness. I'm more interested in an answer that will lead me towards this simple goal. Thanks again.
Robert Brower
#2
08/28/2002 (2:51 pm)
In the previous post, replace all instances of WalkingVehicle with WheeledVehicle as I have just made copies of WheeledVehicle.h and .cc and renamed them and the classes within.
Torque Owner Robert Brower
Here's where I am now.... step by step here is what I've done...
1. Added WheeledVehicle::Wheel::TSThread* walkThread
2. Changed the line ->
radius = shape->bounds.len_z() / 2;
in WalkingVehicleTire::preload() to ->
radius = shape->bounds.len_z();
so that the legs are attached at the shoulder.
3. Initialize mWheel[i].walkThread = 0; in WheeledVehicle::WheeledVehicle()
4. Initialize wheel->walkThread = 0; in WalkingVehicle::onNewDataBlock()
5. Added thread creation code to WalkingVehicle::onNewDataBlock()
// RFB 08/28/02, adding walk thread
wheel->walkThread = wheel->shapeInstance->addThread();
wheel->shapeInstance->setSequence(
wheel->walkThread,0,0); // sequence 0 is "walk"
// RFB
6. Added code to WalkingVehicle::updateWheelThreads()
// RFB 08/28/02, adding walk thread
if (wheel->tire && wheel->walkThread) {
wheel->shapeInstance->setPos(wheel->walkThread, pos);
}
// RFB
The line ->
wheel->walkThread = wheel->shapeInstance->addThread();
causes an unhandled exception. I don't know why.
Can anyone please help me?