Object rotations and translations
by Rob Van Gulik · in Torque Game Engine · 06/10/2008 (7:06 am) · 7 replies
Ok so I just started playing with the TGE1.5 and it's scripting language, and
so far I've been able to place objects and let them play animations that were
exported to the dts files. I also tried the RigidShape for objects that need
physics, but somehow I can't manage to find a way to do something that
should probably be very easy;
How do you make an object move, without physics or animation?
An example; a powerup object that slowly spins around. It seems silly to
go through all the trouble to create an animation clip (or 'thread') and export
it to a dts file, only to let an object spin around. Isn't there a way to give a
simple object an 'angular velocity' or 'rotation animation' without the object
falling down due to gravity, or having to export an animation clip?
so far I've been able to place objects and let them play animations that were
exported to the dts files. I also tried the RigidShape for objects that need
physics, but somehow I can't manage to find a way to do something that
should probably be very easy;
How do you make an object move, without physics or animation?
An example; a powerup object that slowly spins around. It seems silly to
go through all the trouble to create an animation clip (or 'thread') and export
it to a dts file, only to let an object spin around. Isn't there a way to give a
simple object an 'angular velocity' or 'rotation animation' without the object
falling down due to gravity, or having to export an animation clip?
#2
Okay, when I follow the tutorial in the "Getting Started.pdf" that accompanies
the TGE1.5.2, I place Torque Logo items using the editor, and implement the
possibility to pick up those items by walking into them. I guess these items
classify as objects of type "item", right?
When I look at the engine source, I find a class "Item" which contains a
member variable 'mRotate' that probably keeps track of whether this item
is rotating. When I use the World Editor Creator, and I create an object
under Shapes-Items, I suppose this object will be created as an object of
this "Item" class. However, when I use the World Editor Inspector, I don't
see any fields that allow me to let the object rotate. I can set its position,
orientation and scaling without problems, but I can't let the object move,
rotate or scale over time using the available fields.
So how would you make objects ("items") rotate over time?
edit: I just got one step closer; I noticed I can create an "item" by using
datablock ItemData instead of StaticShapeData. Objects created using
the ItemData datablock are actual items and have more fields in the
World Editor Inspector. However, I still didn't find a way to actually make
such an item rotate over time. I just need one more push in the right
direction :)
06/11/2008 (4:41 am)
Thanks for your reply, Orion. But I still can't figure it out.Okay, when I follow the tutorial in the "Getting Started.pdf" that accompanies
the TGE1.5.2, I place Torque Logo items using the editor, and implement the
possibility to pick up those items by walking into them. I guess these items
classify as objects of type "item", right?
When I look at the engine source, I find a class "Item" which contains a
member variable 'mRotate' that probably keeps track of whether this item
is rotating. When I use the World Editor Creator, and I create an object
under Shapes-Items, I suppose this object will be created as an object of
this "Item" class. However, when I use the World Editor Inspector, I don't
see any fields that allow me to let the object rotate. I can set its position,
orientation and scaling without problems, but I can't let the object move,
rotate or scale over time using the available fields.
So how would you make objects ("items") rotate over time?
edit: I just got one step closer; I noticed I can create an "item" by using
datablock ItemData instead of StaticShapeData. Objects created using
the ItemData datablock are actual items and have more fields in the
World Editor Inspector. However, I still didn't find a way to actually make
such an item rotate over time. I just need one more push in the right
direction :)
#3
it can be confusing, for sure.
you're on the right track with "ItemData".
okay, just experimented a little w/ the stock tge 1.5.2 demo.
once you've got the FPS demo running and are in the world editor in the creator mode,
create an object via "Shapes | Weapon | Crossbow".
this will add a spinning crossbow to the world.
you can find the datablock defining this item in demo/server/scripts/crossbow.cs:
if you inspect the item with the world editor inspector,
you can see that it has a field "rotate".
unfortunately, this field will only take effect after you save & reload the mission,
unless you implement this resource which i happened to write just a couple weeks ago.
if you save the mission out, and load the corresponding .mis file into your favorite text editor,
you would see a block similar to this:
06/11/2008 (7:36 am)
Hi Rob -it can be confusing, for sure.
you're on the right track with "ItemData".
okay, just experimented a little w/ the stock tge 1.5.2 demo.
once you've got the FPS demo running and are in the world editor in the creator mode,
create an object via "Shapes | Weapon | Crossbow".
this will add a spinning crossbow to the world.
you can find the datablock defining this item in demo/server/scripts/crossbow.cs:
datablock ItemData(Crossbow)
{
// Mission editor category
category = "Weapon";
// Hook into Item Weapon class hierarchy. The weapon namespace
// provides common weapon handling functions in addition to hooks
// into the inventory system.
className = "Weapon";
// Basic Item properties
shapeFile = "~/data/shapes/crossbow/weapon.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
emap = true;
// Dynamic properties defined by the scripts
pickUpName = "a crossbow";
image = CrossbowImage;
};if you inspect the item with the world editor inspector,
you can see that it has a field "rotate".
unfortunately, this field will only take effect after you save & reload the mission,
unless you implement this resource which i happened to write just a couple weeks ago.
if you save the mission out, and load the corresponding .mis file into your favorite text editor,
you would see a block similar to this:
new Item() {
position = "309.268 -37.4882 196.434";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Crossbow";
collidable = "0";
static = "1";
rotate = "1";
};
#4
own objects spin as well! So far, so good :)
Now for the next step. It's cool that objects either rotate or stand still. But
how would I let the crossbow, for example, rotate twice as fast? Of course
rotating twice as fast is not the important point, I just think it would be cool
to have the freedom to determine the actual movement from the Torque script.
Say I'd like my powerups to move similar to Quake III Arena powerups. I think
those powerups rotated, and moved up and down as well. For other objects
it might be more appropriate to let them scale up and down. Maybe even
change their transparency over time. Are those things possible from script?
Thanks again!
06/11/2008 (8:32 am)
Nice, thanks for the link to that resource. Saving and reloading made myown objects spin as well! So far, so good :)
Now for the next step. It's cool that objects either rotate or stand still. But
how would I let the crossbow, for example, rotate twice as fast? Of course
rotating twice as fast is not the important point, I just think it would be cool
to have the freedom to determine the actual movement from the Torque script.
Say I'd like my powerups to move similar to Quake III Arena powerups. I think
those powerups rotated, and moved up and down as well. For other objects
it might be more appropriate to let them scale up and down. Maybe even
change their transparency over time. Are those things possible from script?
Thanks again!
#5
> Are those things possible from script?
not so much, i think.
you could assign an animation to the object, but you've already mentioned you'd like to avoid that.
you could certainly expand the Item class to include parameters such as bobbing and scaling as well as rotation speed and axis, but you'd need to open up the engine.
.. that would be a cool project for getting familiar with TGE networking and client/server stuff,
but that might not be where you want to be focusing your time just now, i dunno.
it would also make a cool resource ;)
anyhow,
if you do feel like opening that guy up,
in item.cc,
you can see the rotation speed is a global static: sRotationSpeed = 3.0,
which would need to be changed into a member field such as mRotate:
06/11/2008 (8:42 am)
Hah, glad you got things going!> Are those things possible from script?
not so much, i think.
you could assign an animation to the object, but you've already mentioned you'd like to avoid that.
you could certainly expand the Item class to include parameters such as bobbing and scaling as well as rotation speed and axis, but you'd need to open up the engine.
.. that would be a cool project for getting familiar with TGE networking and client/server stuff,
but that might not be where you want to be focusing your time just now, i dunno.
it would also make a cool resource ;)
anyhow,
if you do feel like opening that guy up,
in item.cc,
you can see the rotation speed is a global static: sRotationSpeed = 3.0,
which would need to be changed into a member field such as mRotate:
addField("rotate", TypeBool, Offset(mRotate, Item));and then networkified similar to mRotate, in packUpdate().
#6
I'll see if I can extend the interface a bit to get the functionality I need!
06/11/2008 (8:53 am)
Cool, thanks for the insight and the quick replies :DI'll see if I can extend the interface a bit to get the functionality I need!
#7
thank
12/10/2009 (12:51 pm)
Hi Dude, This is really nice to see this post , I am working on the customization to make bowling game from starter.fps ,Is this will add effect like Bowling Ball??Or how i can customize so the effects come like bowling ball and collied with pins .thank
Associate Orion Elenzil
Real Life Plus