Looping Rotating Model
by Michael Shah · in Torque Game Engine Advanced · 08/10/2009 (12:01 pm) · 2 replies
Hello,
I am trying to figure out how to rotate a shape continuously if a button is clicked. I am looking into the schedule events, and have tried something like this.
myShape.schedule(ms,"rotateModel");
I have written a method for myShape as
myShape::rotateModel(%this,%client)
{
$rotation = $rotation +1;
setTransform("0 0 0 0 0 1 "@$rotation);
}
Is this the correct way to go about doing this?
So to make an analogy, imagine how cars at a car show slowly rotate and viewers can get a 360 degree angle of the vechicle. This is what I'm trying to recreate in my torque script.
Thanks for any help
I am trying to figure out how to rotate a shape continuously if a button is clicked. I am looking into the schedule events, and have tried something like this.
myShape.schedule(ms,"rotateModel");
I have written a method for myShape as
myShape::rotateModel(%this,%client)
{
$rotation = $rotation +1;
setTransform("0 0 0 0 0 1 "@$rotation);
}
Is this the correct way to go about doing this?
So to make an analogy, imagine how cars at a car show slowly rotate and viewers can get a 360 degree angle of the vechicle. This is what I'm trying to recreate in my torque script.
Thanks for any help
About the author
Uses Torque for Research
#2
I'm currently swapping in a lot of models by using the setDataBlock command.
This function alone will work, if I explicitly set my shape.
function rotateModel()
{
$rotation = $rotation +1;
myShape.setTransform("0 0 0 0 0 1 "@$rotation);
}
However, I need to figure out how to schedule an event, so that this function is constantly called in a loop. I was thinking the way to do so, would be schedule an event as I described above.
Imagine something like this (watch the first minute or so)
http://www.youtube.com/watch?v=x6tyyVmugLk&feature=PlayList&p=F4EDF733C31A5C63&playnext=1&playnext_from=PL&index=14
(The difference in what I want to achieve is that the car rotates, and not the camera)
08/11/2009 (10:56 am)
Thanks for the advice, but unfortuantely animating the models isn't an option.I'm currently swapping in a lot of models by using the setDataBlock command.
This function alone will work, if I explicitly set my shape.
function rotateModel()
{
$rotation = $rotation +1;
myShape.setTransform("0 0 0 0 0 1 "@$rotation);
}
However, I need to figure out how to schedule an event, so that this function is constantly called in a loop. I was thinking the way to do so, would be schedule an event as I described above.
Imagine something like this (watch the first minute or so)
http://www.youtube.com/watch?v=x6tyyVmugLk&feature=PlayList&p=F4EDF733C31A5C63&playnext=1&playnext_from=PL&index=14
(The difference in what I want to achieve is that the car rotates, and not the camera)
Torque Owner Rex
BrokeAss Games
This will perhaps take an artist to get going...but:
I would use a 'cyclic' animation[on the shape]to accomplish this effect. You can then use playThread, pauseThread, and stopThread to affect some kind of control of the object. This would simulate the starting and stopping of the motor on the auto's turntable.
There are 4 separate Animation Threads to work with...so you could also throw in some other animations if you wish....;).
Good luck, don't give up! Post back with progress...
Rex