inteja

Testing & compensating for lookAt() gimbal lock at zenith?

Recommended Posts

I know I can't stop gimbal lock but I'd like to avoid the circumstances where it occurs in my application i.e. when a lookAt() call returns a vector close to the zenith.

Basically I'd like to clamp the rotational pitch from 0 to 85 degrees, rather than allowing it to ever reach 90 degrees.

I see the lookAt method has an optional parameter for pitchCor (pitch correction) but that doesn't seem to do what I want. What I'm thinking at the moment is I need to test the lookAt result to see of it's >= 85 degrees pitch and if so then clamp the pitch back to 85 degrees (without altering yaw) before applying the rotation to my mesh, but I'm a bit lost how to achieve that or if there's a better way.

EDIT

Here's a PG http://www.babylonjs-playground.com/#NM5LIX

Basically as the lookAt() approaches the zenith I want to clamp the pitch input (even though it's not accurate this way) in order to eliminate the unnaturally fast spin.

I hope this makes sense. 

Share this post


Link to post
Share on other sites

Trs-80, -> c64 -> c128 -> A500  :)  weird. 

Didjall see my #1 PG?    I tried using a dummy camera... etc, etc.  Embarrassing Wing-nutty-ness.

Anyone remember forum buddy "Alby"?  He and his campfire team would fight-with unwanted spin from lookAt() and billboardMode... DAILY. 

I think he's in an institution or something, now.  :o  Rumor has it... he just mumbles "camera epsilon"  and "poles" and "gimbal lock" all day long, and drools a lot.

But but but but... doesn't it "feel" like... there is a transformNormal() or some other Matrix transformation that can be done, here (avoiding lookAt)? 

mesh. bake[Something], perhaps?  Or, maybe re-scale the plane at some point... causing it to change its forward() vector?  What the heck?

In #1 PG, line 15:  camera2.noRotationConstraint = true;

There, what I really wanted was... .allowUpsideDown, but that is an ARC cam thing (allows arcCam to behave differently... at beta = 0)

So, yeah, not only did I contribute NOTHING in this post, but I might have made us all... a little stupider.  sorry.  heh

Share this post


Link to post
Share on other sites

I was young and poor and only drooled over the TRS-80. Used Spectrum ZX and BBC Micros at school though.

VIC20 > C64 > A500 > A1200 (sadly skipped the C128 and A4000). I jumped to the PC dark side when Doom came out with a 486 DX 266.

There was nothing like 8-bit computing. Long gone are the days when you could know a system inside-out, unless you count Arduino, Raspberry Pi etc...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.