Jump to content

[Resolved] Getting a mesh to rotate above 360' degree's


aWeirdo
 Share

Recommended Posts

Hi guys,

i'm working on a right-click to move mesh system and within that, a rotation of the mesh first, (mesh rotates slowly towards destination, and then start moving.)

Got it working "ok", it uses the lowest angle of rotation, except, when going from high rotation point to a low, and vice versa,

if the mesh.rotation.y is at 350 degree's and you want to rotate towards lets say 5 degree's, instead of jumping 350 -> 360 -> 5. it starts turning the long way around (350-) and i'm not sure how to handle it best.

which is why i'm posting this topic, hoping someone can help me out while i'm having a brainfart.. :D

PG: http://www.babylonjs-playground.com/#CZRC0#0 
rotation is controlled by right-clicks, the sphere to the left of the box is around 360 / 0 degree's, try clicking below it, then above it to see the issue.
then try doing the same on the right side of the box to see how it's supposed to act^^

Cheers.

Link to comment
Share on other sites

@adam Thank you :D that was bugging me so bad..

really apreciate the help :) one minor error though, notised when i put it together with my movement, (hard to spot with a square box lol). 
it was using the wrong angle^^

Quote

var ang = -Math.atan2(rt1.z, rt1.x) - Math.PI / 2;

updated PG for anyone who might be doing something simular in the future. http://www.babylonjs-playground.com/#CZRC0#2

Link to comment
Share on other sites

Cool subject, guys.  Nice troubleshooting, Adam.  Would one or both of you... please test our mesh.lookAt(somemesh.position) and make sure it uses "shortest rotation direction", too?

Oh wait... that is instantaneous, so I guess it doesn't apply.  Nevermind.  :)  As long as we don't accidentally invent animateToLookAt(), we're fine.

What's that you say?  Weirdo just now invented it?  On no!  Way to go, aW!   Now we're all screwed.  @iiceman is dirty-hands in this, also.  He did some animate-rotation-to-click-spot back in the 40's... on a little space ship.  Yeah, you thought we had forgotten about that, eh Ice?  ;)

Link to comment
Share on other sites

Seems like you already found a solution :)

@WingnutYeah, I remember that... I think that was my latest result: http://p215008.mittwaldserver.info/space/

There is a playground somewhere where I tried a lot of stuff. I think it all works well as long as you stick to rotating around 1 axis. As soon as I tried to rotate simultaneously around a second axis everything fell apart.

Link to comment
Share on other sites

Oh yeah, that's right.  Good memory, Ice! 

Yuh yuh yuh, rotation... maybe the #1 forum topic.  Oh how I wish we had "The Ultimate Interactive Rotation WorkLab".  Upper 2/3 screen has the renderCanvas, lower 1/3 has nothing but knobs and dials... to learn localSpace, worldSpace, maybe even teach matrix transforms.  It'd be like our rotation tutorials/overviews... coming alive. 

*sigh*  What a dream-come-true that would be.  But oh, how to design and implement.  Erf.

Everything is fine... until we add a camera to the scene.  I have a difficult time maintaining an orientation in REAL LIFE, speak nothing of doing it in projective geometry:D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...