Replies: 4 comments
-
I suspect the projection matrix messes it up somehow, usually the projection contains also some sort of aspect ratio adjustment (i.e., scaling), and I think this could work better? Matrix4 projection =
inCamera.projectionMatrix() *
Matrix4::translation( { 0.85f, 0.85f, 0.0f } ) *
Matrix4::scaling( { 0.1f, 0.1f, 0.1f } ) *
Matrix4::from(inCamera.cameraMatrix().rotationShear(), {}); For fixing objects relative to camera, parent them to the camera object. The axis indicator is a bit special tho, because it's fixed to the viewport but also needs to rotate based on the actual camera rotation. I don't think there's a way to do that without manually extracting and applying the rotation. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately that made it disappear completely. I think I need an orthographic projection of the object with just the rotation (and nothing else) from the camera. Does that sound right? I've tried a bunch of different things using Do I need to create an orthographic camera and render with it instead? And somehow link its rotation to that of my main camera?
Got it. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Haha. I'm not saying I'm great at matrix math either. Maybe dropping the translation part could make it appear in the center at least, and then you could fiddle with the X/Y offset to place it appropriately? That's what I do even 14 years into this project, flipping signs and the multiplication order until something appears :D
I thought that wouldn't look right, so I didn't even attempt that. A way to achieve that would be dropping the You don't need to create a separate orthographic camera for that, everything the scene graph camera is doing is calculating this one matrix, so if you create it directly, you have everything. |
Beta Was this translation helpful? Give feedback.
-
😆 Well that makes me feel slightly better about not being able to solve what (I think) is a "simple problem". I played around with many different things and can't get what I have in my head onto the screen, so I'm going to leave it for now and continue my experimentation with Magnum as a Qt3D replacement... I'll leave the question open in case someone wants to appear with a solution in the future 😄 Thanks for your help! |
Beta Was this translation helpful? Give feedback.
-
Goal: Add an axis indicator in the upper-right corner of my window.
So after a bunch of head-scratching & fumbling about I have something that seems to be working-ish:
Here's what I did:
Magnum::Primitives::axis3D
andMagnum::MeshTools::generateLines
LineGL3D
shader to use itThis works, but still feels a little bit off. I wonder if it's because I still have shearing from the camera's rotation? Is there a way to eliminate that?
Is there a better approach to this or to fixing UI objects to the camera's viewport?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions