john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.18k stars 63 forks source link

Question: Weird plane orientation #59

Closed jiannanya closed 2 years ago

jiannanya commented 2 years ago

Hi, I setupped the gizmo in osg drawImplementation but got a problem, the orientation of planes are not correct and I didnt know why and what caused that, appreciating for any help. The wird orientation planes are showed like below:
planes

john-chapman commented 2 years ago

Hi - can you share your code? I'd like to see how you're calling Im3d::Gizmo() and also how the AppData struct is being set up.

jiannanya commented 2 years ago

Okay finnally I fixed it buy changing the appdata ad.m_worldUp = Im3d::Vec3(0.0f, 0.0f, 1.0f); , about which I had set to ad.m_worldUp = Im3d::Vec3(camUp.x(), camUp.y(), camUp.z()); and of which the variable camUp was my real camera up direction that leaded to the weird plane orientation.

I think it is the OSG screen coordinate system that confuse me and cause the problem, of which the z axis is up and the y axis is forward into the screen.

It goes well now, thanks very much.

jiannanya commented 2 years ago

So this issue can be closed as you wish, thanks anyway.

john-chapman commented 2 years ago

Ah right- AppData::m_worldUp is basically a reference vector which Im3d uses for some internal operations. It's usually fixed as the cardinal Y or Z axis so setting it as your camera up vector would certainly cause a lot of strange issues. Glad you were able to fix it.