Sprite setPivotPoint()
by Tim Doty · in Torque Game Builder · 03/06/2005 (1:24 pm) · 9 replies
Unless I'm missing something (entirely possible) you can't set the pivot point for (at least) staticsprites. There is a setPivotPoint() function for particle effects and I decided to try it for grins on the sprite (hoping it existed undocumented) but all I got was an error.
What am I missing? Or can this be added?
What am I missing? Or can this be added?
About the author
#2
So, you make a new fxSceneObject2D, set its size to something moderate, and don't set an image for it so that it is invisible -- then mount the hammer sprite onto it, at the top. Line up the bottom of the hammer with the center of your newly-made object. Set the mounted hammer to track rotation, and boom, when you rotate the parent object, the hammer will tip as if its rotating along the base.
UPDATE: Hmm, maybe this will explain it better:
03/06/2005 (11:53 pm)
As Melv has mentioned, you can "fake" arbitrary rotation points without doing the "make the sprite larger" dealie-- By mounting one object to another. For example, let's assume a hammer sprite, that you want to smash something with. If you just make the sprite normally, then try to rotate it, it will rotate around the exact sprite center -- which in this case would be somwhere around halfway up the handle. Not what we want.So, you make a new fxSceneObject2D, set its size to something moderate, and don't set an image for it so that it is invisible -- then mount the hammer sprite onto it, at the top. Line up the bottom of the hammer with the center of your newly-made object. Set the mounted hammer to track rotation, and boom, when you rotate the parent object, the hammer will tip as if its rotating along the base.
UPDATE: Hmm, maybe this will explain it better:
#3
03/07/2005 (5:51 am)
Thanks for the replies! I'd looked through the thread topics but managed to miss the original one. The idea of making the sprites larger had occured to me, but I don't like it very much. Using an invisible sprite as intermediate is more appealing.
#4
03/12/2005 (12:28 pm)
Setting the Registration point should be implemented. Enlarging the sprite or using an invisible sprite is horrendous. BTW Targa files can store the registration point within the file itself.
#5
Sorry if this causes you problems at the moment. It's already on the list of things to do so you won't be doing it forever.
- Melv.
03/13/2005 (1:35 am)
Horrendous is such a strong word. ;)Sorry if this causes you problems at the moment. It's already on the list of things to do so you won't be doing it forever.
- Melv.
#6
I should have written "an abomination".
;)
03/13/2005 (2:58 am)
Yes, I overreacted, horrendous really is a too strong.I should have written "an abomination".
;)
#8
Does that seem like a good place to change where the pivot point is? Or are there other locations where the C++ code assumes a mid-point?
steve
05/09/2005 (1:56 pm)
I noticed some code on the C++ side for managing the pivot point. Consider this code from "fxSceneObject2D.cc", under ::calculateSpatials:Quote: // Calculate Pivot Offset.
fxVector2D size = getSize();
fxVector2D halfSize = size/2.0f;
fxVector2D pivotOffset = -halfSize;
Does that seem like a good place to change where the pivot point is? Or are there other locations where the C++ code assumes a mid-point?
steve
#9
There's no issue with doing the minor work to change the pivot-point but it has impacts on the rigid-body physics routines.
Just finiishing some other work at the moment, then I can get this one off the list.
- Melv.
05/10/2005 (12:01 am)
Stephen,There's no issue with doing the minor work to change the pivot-point but it has impacts on the rigid-body physics routines.
Just finiishing some other work at the moment, then I can get this one off the list.
- Melv.
Torque Owner Jason Cahill
Default Studio Name