Game Development Community

Tire Tracks TGE

by DeVry Online Fall Stdnt 08 (#006 · in Torque Game Engine · 12/10/2009 (12:09 am) · 14 replies

I have a want to create a bunch of tire with different patterns and import them to TGE and see the tracks they make.

I have one tire that I created with blender already http://img704.imageshack.us/i/blendertire.jpg/

and I have imported it into blender, but it is static and I can see that that is bad http://img684.imageshack.us/i/torquetire.jpg/.

So the first thing I need help learning is how to script the movement, so it can roll down the hill, and loose potential going up the hill.

After I need to learn how to leave a tire mark.

I plan on creating snow or rain, as the tire tracks want stay to long.

But where do I start after I added a dts to TGE.
I see TGE come with a moving boulder, and I would like to mimic and adjust that code for what I have, but I have no clue how to do that either, so I might have to start from scratch.

#1
12/11/2009 (7:39 pm)
I have imported a tire into torque, going to do an animation script, can anyone help me, animate a collision between when the tire hits the grounds it create the tire track?
#2
12/11/2009 (7:46 pm)
The best way to figure this one out is to look in "server/scripts/car.cs" in the starter.racing demo.
Tires are added to the car dynamicly and torque takes care of the rest.
If you aren't adding the tires to a car, the script will at least show you how it's done.
#3
12/11/2009 (8:34 pm)
deepscratch? posted somewhere how he got his jeep to lay down 'footprint' decals for tyre tracks
#4
12/12/2009 (6:41 pm)
Great I have some things going great,

I have an object that I want to rotate at the y axis, but I also want it to make it seem like the object is still in the same spot. Using rotate(0 1 0 25) brings some of the objects out of view, but if I used a sequence as such
1.05557 0 1.80411
0 1 0 25.2104

1.23565 0 3.93342
0 1 0 50.9934

0.549822 0 5.80857
0 1 0 75.0576

-0.961562 0 7.31925
0 1 0 100.841

...
The object seems to be staying in place. The first ling is position the second is rotation. What do I need to do to animate 14 sequences in TGE.

Thanks
#5
12/12/2009 (7:05 pm)
I was thinking of %shape.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd); with the hardcoded vaules ex

%shape.setTransform(1.05557 0 1.80411 0 1 0 25.2104);

If i were do that with a
schedule(15,0,FuntionName, %shape);
#6
12/12/2009 (10:29 pm)
complete code:

function rotateShape(%shape, %speed)
{
echo ("MoveShape: shape id: ", %shape);
echo ("MoveShape: animation speed is: ", %speed);
%shape.setTransform("1.05557 0 1.80411 0 1 0 .440004486");
%shape.setTransform("1.23565 0 3.93342 0 1 0 890002727");
%shape.setTransform("0.549822 0 5.80857 0 1 0 1.31000225");
%shape.setTransform("-0.961562 0 7.31925 0 1 0 1.76000747");
%shape.setTransform("-2.88449 0 8.01065 0 1 0 2.19000424");
%shape.setTransform("-4.92059 0 7.8375 0 1 0 2.62000101");
%shape.setTransform("-6.73469 0 6.79921 0 1 0 3.05999851");
%shape.setTransform("-7.95179 0 5.04276 0 1 0 3.50999675");
%shape.setTransform("-8.28938 0 3.02738 0 1 0 3.93999352");
%shape.setTransform("-7.7655 0 1.05515 0 -1 0 1.91319502");
%shape.setTransform("-6.4205 0 -0.544843 0 -1 0 1.47319577");
%shape.setTransform("-4.5221 0 -1.41956 0 -1 0 1.03319652");
%shape.setTransform("-2.47866 0 -1.41296 0 -1 0 0.603196261");
schedule(%speed,0,MoveShape, %shape, %dist, %angle, %scale);
}

Would like to know how to set a pause, break, transition , etc. inbetween each movement.
Thanks
#7
12/13/2009 (9:35 pm)
Can any tell me what SPC means
%shape.setTransform(%pos_x SPC %pos_y SPC %pos_z SPC %rot_x SPC %rot_y SPC %rot_z SPC "1");

I am thinking it means space.
#8
12/13/2009 (10:13 pm)
SPC = Space

%posX Space %posY Space %posZ etc...

I'm trying to get a grasp on what you are trying to do. Making an object rotate in place in code wouldn't be a good idea tho. I would use a custom animation on the object. You can have quite a few animations depending on your needs and it would work a ton better. (performance wise)
#9
12/13/2009 (10:34 pm)
ugh new code crashes tge
function main(%shape)
{
//create a default starting point of object at orgin
%i = 0;
%animation[%i] = %shape.setTransform("0 0 0 0 0 0 1");

// updates the transformations list
moveList();
}

//Picks up new Transform
function moveList()
{
%animation[1] = %shape.setTransform("1.05557 0 1.80411 0 1 0 .440004486");
%animation[2] = %shape.setTransform("1.23565 0 3.93342 0 1 0 .890002727");
%animation[3] = %shape.setTransform("0.549822 0 5.80857 0 1 0 1.31000225");
%animation[4] = %shape.setTransform("-0.961562 0 7.31925 0 1 0 1.76000747");
%animation[5] = %shape.setTransform("-2.88449 0 8.01065 0 1 0 2.19000424");
%animation[6] = %shape.setTransform("-4.92059 0 7.8375 0 1 0 2.62000101");
%animation[7] = %shape.setTransform("-6.73469 0 6.79921 0 1 0 3.05999851");
%animation[8] = %shape.setTransform("-7.95179 0 5.04276 0 1 0 3.50999675");
%animation[9] = %shape.setTransform("-8.28938 0 3.02738 0 1 0 3.93999352");
%animation[10] = %shape.setTransform("-7.7655 0 1.05515 0 -1 0 1.91319502");
%animation[11] = %shape.setTransform("-6.4205 0 -0.544843 0 -1 0 1.47319577");
%animation[12] = %shape.setTransform("-4.5221 0 -1.41956 0 -1 0 1.03319652");
%animation[13] = %shape.setTransform("-2.47866 0 -1.41296 0 -1 0 0.603196261");

//pauses game and transformations
pausegame();
}

//pauses the game and transforamtion
function pausegame()
{
//pauses game
$timescale = 0;

//function that allows shape to rotate
rotateShape(%shape);
}

function rotateShape(%shape)
{
//pints the shape that is movieg
echo ("MoveShape: shape id: ", %shape);

//does the transforming
%shape.setTransform = %animation[%i];

//unpause the game and transforamtions
if($timescale == 0)
{
//unpauses game
unpausegame();
}

counter();
}

function unpausegame()
{
//unpause game
$timescale = 1;

//function that allows shape to rotate
rotateShape(%shape, %speed);
}

function counter()
{
//increments the array
%i = %i + 1;
if(%i == 14)
{
%i=0;
}

pausegame();
}
#10
12/13/2009 (10:39 pm)
Have no idea how do anything, book is cryptic so I am trying to apply what I already know from programming to TGE. If I could learn how to thread, use arrays in TGE I might have something.

i really just want an object to rotate on the Y axis, but stay in the same spot like a Ferris wheel would do.

I started out wanting to do something else, but this seems more like something I want to do at the moment.
#11
12/13/2009 (11:08 pm)
One big problem is your confusion with variables.

%i = %i + 1;
%i is a local variable. It's defined within the scope of the function it's in, and nowhere else. So it looks to me like you're trying to create an array of transforms called %animation. This array is only defined inside the function moveList(), and nowhere else. So in the other spots you're referring to it, %animation[anything] contains "".

To make a global variable (visible to all functions in all scopes) use $ instead of %.

Also:

echo ("MoveShape: shape id: ", %shape);
As far as I know, echo() only takes one parameter, so that should be
echo ("MoveShape: shape id: " @ %shape); //Concatenate strings

%shape.setTransform = %animation[%i];
setTransform is a method, not a property. So this should be
%shape.setTransform(%animation[%i]); //Or $animation[$i]

Also, it's not at all necessary to play with the $timescale. setTransform will happen instantly, you don't need to pause the game while you call it.
#12
12/13/2009 (11:20 pm)
How do you get the code to show up in a nifty box
<p> </p>or is it
<code></code>
I am used to clicking a button for this funtion
#13
12/13/2009 (11:33 pm)
(5) Call to setTransform in main uses result of void function call?

not understanding.
#14
12/14/2009 (1:11 am)
Quote:<code></code>
This, but with square brackets. Same for quotes <quote>, italics <i>, bold <b>, etc. (Just showing with angle brackets so I don't have to worry about the message being formatted :P.)

Quote:(5) Call to setTransform in main uses result of void function call?
Hmm. Probably means that setTransform doesn't return anything, which makes sense.

Huh, another big problem.
Quote:%animation[1] = %shape.setTransform("1.05557 0 1.80411 0 1 0 .440004486");
%shape doesn't exist, and even if it did, why do you need to set the transform of an actual shape to store values in an array? Just do something like
$animation[1] = "1.05557 0 1.80411 0 1 0 .440004486";

%shape.setTransform($animation[1]); //When you want to use it on an actual shape, which you need to define in %shape



EDIT: Phillip, I'm assuming you're the one who started the thread? Just in a different account?