|
Post by sbdjazz on Apr 2, 2017 18:52:14 GMT
How do I rotate a sprite about an user defined axis of rotation? (Using Script Of course)
|
|
|
Post by Power Supersport on Apr 2, 2017 19:58:33 GMT
float rotation = 0; // your rotation Quaternion Rotation; void Main () { iQuaternionFromEulerAngles (Rotation, 0, 0, rotation, "xyz"); iObjectOrientationSet (OBJ_0, Rotation); // OBJ_0 is your sprite }
|
|
|
Post by sbdjazz on Apr 3, 2017 7:47:22 GMT
I mean I need to change the center of rotation. For example if I want to rotate the sprite about its end instead of its center. And so that I can specify which point of rotation to choose.
|
|
|
Post by Power Supersport on Apr 3, 2017 17:57:45 GMT
Could you give more detailed explanation next time? The thing that you want is anchored orientation, not a "custom axis" as you call it...
I've done some attempts the last 2 hours trying to figure out a way and I only get close... Can you please tell me which corner do you want as an anchor: Top left, top right, bottom left, bottom right, left, right, top, bottom... These are the anchors I was able to achieve, but nothing else...
|
|
|
Post by sbdjazz on Apr 4, 2017 14:58:35 GMT
I need to move the anchor point also. That's what I meant. And can you share your code?
|
|
|
Post by Power Supersport on Apr 5, 2017 16:21:13 GMT
The script is too complicated... And it requires ArcSin, which 3D Rad doesn't have... It isn't even a proper script, so it doesn't worth it...
|
|
|
Post by sbdjazz on Apr 5, 2017 18:54:51 GMT
OK, I will try some other way. Anyways, Thanks!
|
|
|
Post by cypermethrin on Apr 5, 2017 20:12:09 GMT
Just as an out of the box thought - make the object you want to rotate the child of another object, move the parent object to the desired anchor point, offset the child object back to original position, rotate the parent object - not tried but it works in my head
|
|
|
Post by Power Supersport on Apr 6, 2017 16:20:18 GMT
The 3D Rad pro called, and everything went just as needed... Here's the code: void Main() { RotateByAnchor (OBJ_X, OBJ_Y, Vector3 (x, y, 0), angle); }
void RotateByAnchor (int TARGET, int ANCHOR, Vector3 Offset, float angle) { // Target - The object to rotate // Anchor - The parent object (anchor), which will act as the "axis" // Offset - The x/y coordinates of the offset // angle - the rotation angle (0 - 360) Quaternion Rotation; iQuaternionFromEulerAngles (Rotation, 0, 0, angle, "xyz"); iObjectOrientationSet (ANCHOR, Rotation); iObjectChildTransform (ANCHOR, TARGET, Vector3 (0, 0, 0), Offset); } I've attached a demo for ya too... Attachments:demo.3dr (113.48 KB)
|
|
|
Post by cypermethrin on Apr 6, 2017 18:55:21 GMT
Glad to be of service. Nice function - very clean and simple.
|
|