Game Development Community

Offset, Mounted Rotation...

by Melv May · in Torque Game Builder · 03/03/2005 (10:17 am) · 7 replies

There seems to be a little confusion over mounting objects and having the object rotate around another point other than its center. I've mentioned before that I'll be looking at that feature and the problems it causes for the physics/angular collision physics.

I've kinda gone over this a few too many times and perhaps I've not explained the situation very well so here's a graphical example of how to achieve it.

If you've got an object like this public.garagegames.com/melvm/centerMount.jpg and you mount it, it would rotate around the center of the object (marked with a yellow cross) which isn't what you'd want as you want it to rotate around the little dark-grey disk so you'd simply organise your graphic like this public.garagegames.com/melvm/offsetMount.jpg and it would rotate around the correct point.

If you've got a single image and you want to rotate it around lots of different points on the image (cannot think of a reason to do this), only then would you need seperate art.

Until this is changed, stuff rotates around the images center. You can mount it to any point on the target object but it will always rotate around its center. As I've mentioned in other posts, rotating around any point other than the center adds complexity to the physics routines and I'll be looking at efficient methods to get around this. I won't just leave it as it is. It's EA guys. ;)

If this is totally unacceptable then there's an alternative but it involves an extra object. Don't forget that you can generate a fxSceneObject2D as these don't render anything but have all the core capabilities. You can mount this to the position on the target object and mount your object to this offset by a constant like "1 0" or whatever you like. The size of the invisible fxSceneObject2D then determines the offset from the center of the image.

Here's a code example...
// Show the bounding-boxes.
t2dSceneGraph.setDebugOn( BIT(1) );

// Create base sprite we want to mount to.	
new fxStaticSprite2D(testSprite1) { scenegraph = t2dSceneGraph; };
testSprite1.setSize( 10 );
testSprite1.setImageMap(tileMapImageMap);
// Move it so we can show we're mounted and not faking it.
testSprite1.setLinearVelocityX( 1 );

// Create hidden mount (articulation frame).
new fxSceneObject2D(hiddenMount) { scenegraph = t2dSceneGraph; };
// Use this size to control the offset.
hiddenMount.setSize( 10 );
hiddenMount.setAutoRotation( 90 );
hiddenMount.mount( testSprite1, "0 0", 0, false );

// Create our object we want to mount.	
new fxStaticSprite2D(testSprite2) { scenegraph = t2dSceneGraph; };
testSprite2.setSize( 10 );
testSprite2.setImageMap(tileMapImageMap,1);
testSprite2.mount( hiddenMount, "0 1" );

Here's an example of that working...
public.garagegames.com/melvm/offsetMountExample.jpg
Hope this helps,

- Melv.

#1
03/30/2005 (9:15 am)
I don't know if it is just me, but the images are not working in your post melv. I realise that there probably not important but it would be cool if we could see them.

If you need some hosting space for pics let me know, I have plenty of space/bandwith available.
#2
03/30/2005 (9:18 am)
Charlie,

Thanks for the offer but there seems to be a problem with the server. I'll see what I can do to get it back again.

Thanks. :)

- Melv.
#3
03/30/2005 (9:21 am)
Edit due to being forced to type by child
#4
03/30/2005 (9:23 am)
Edit due to child
#5
03/30/2005 (9:27 am)
Your little girl again?

:)

- Melv.
#6
03/30/2005 (10:07 am)
I'd like to see the pics on this too. I have a similiar issue but i'm not sure its the same without seeing the pics.

I have an issue with the fact that when trackign rotation of the parent on a mounted object, the mounted object gets set to the parent's rotation, but I would like to add/subtract from that rotation. So the mounted object would follow the parents rotation + some amount.
#7
04/08/2005 (6:08 am)
Yea it's fixed! Bumpage.