Removing roll from camera matrix
I have a camera class which is just this:
and it works, but I want to eliminate the roll from the matrix somehow.
107 Replies
⌛
This post has been reserved for your question.
Hey @𝓐pothicon! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
(roll as in the tilting of the camera from left to right as shown here)
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
/reopen
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
open seasame
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Then don't rotate it
Does the default constructor of Matrix4f return an identity matrix?
Yes (but not sure why that matters)
but i need to rotate the matrix so that i can well.. rotate the camera around, just need to somehow eliminate the roll aspect immediately afterwards
I don't understand
Just don't rotate on the roll axis
what do you do to not rotate on the roll axis tho
ive tried everything i can think of
its not like their seperate numbers
im getting three axis of rotation just by rotating x and y
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
That's euler rotation, those are done by first rotating x then y
What you want is another rotation completely
Or rotate in a different order
pitch yaw roll is a different rotation definition from euler xyz
ive tried doing both orders
either way i get roll
and i dont think its euler rotation cuz if it was then why would i be getting roll from just two axis
also im not sure what you mean by "another rotation"
do you mean a different rotate() method?
i tried many different ones
i just want some kind of equation to remove the roll
cant find one anywhere
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
There's axis-angle, quaternion, ...
Isnt axis-angle just euler which should never be used
And im pretty sure what im using is a quaternion just inside of a matrix
no axis angle is not the same
and quaternions have to be converted to matrix form, you can't "use a quaternion in a matrix"
https://www.andre-gaschler.com/rotationconverter/
the quaternion is the matrix3 inside of the matrix4
also not sure why this would be helpful
Under some very specific conditions only
i mean its always the matrix3
i never store it anywhere else
and then add scale...
scale?
what would that do
multiply the numbers in the diagonal
but i dont want scale
its a camera
lol
cant have a big camera or a small camera
size isnt a thing
I'm just saying that a 3by3 affine transormation matrix isn't always JUST rotation
what else would it be
It's called an affine transformation for a reason
Like I literally just said, it could also have scale built in
oh
And if you go to 4x4 you can also have translation built in
im not seeing how that would be possible tbh
but it doesnt matter
For a camera you don't need it
But for transforming your objects in the world you'd need it
give me some angles you set in that rotation method you have
wdym?
x and y are just the x and y the mouse moved
ok, so let's say 45 degrees x and y
type those in on the left side in rotationconverter
and set both sides to degrees
You get
{ [ 0.6785983, 0.6785983, 0.2810846 ], 62.7994296 }
as an axis angle resultwhere
euler angles
ah yeah i do get that result
but why
so axis angle is pretty easy to reason about
basically it's a vector pointing in a certain direction (your axis) and the angle you rotate around that vector (the angle)
See that by using euler angles, you're rotating around your own axis as well?
So you won't get a level horizon this way
https://dugas.ch/transform_viewer/index.html
This one has some visualization built in
i didnt even know i was using euler angles lol
That's what rotateXYZ does
well i tried pretty much every rotate method
https://javadoc.io/doc/org.joml/joml/latest/org/joml/Matrix4f.html#rotateXYZ(float,float,float)
you want pitch/yaw/roll
you need something like the lookAt methods
but i dont want it to look at anything specific
Doesn't matter, you can set your look at point to a coordinate in front of you
if i knew what "in front of me" was i wouldnt be having this problem
lol
I suggest this then
LearnOpenGL - Camera
Learn OpenGL . com provides good and clear modern 3.3+ OpenGL tutorials with clear examples. A great resource to learn modern OpenGL aimed at beginners.
There's math involved
oh yeah, and probably read the chapter on coordinate systems as well
The one right before
Because your camera shouldn't move 🙂
yes it should
no, the camera stays at 0,0,0 and you rotate/move the world around it
read the articles
horrible idea
ok, go tell the video game industry you know better than them
updating millions of objects a frame
instead of one
no, update one matrix per frame
thats what im doing
Read the articles
Then you'll understand
i read em a few times before
i dont agree with them
Well, it seems like you're the smarty pants that knows everything, so you don't need any help. Good luck figuring out your completely custom camera system
i just need some help on removing the roll from my existing already figured out camera system
or changing the way i rotate to not add roll in the first place
i dont need to change the entire structure of the game to account for "moving the world"
and i DEFINITELY dont need to convert the camera to use euler angles like you suggested by linking this
euler = bad
it even says in the article
dont see why you care if i store the position in the camera matrix anyways
its the same result
that part is fully working
"viewMatrix.rotateXYZ(x, y, 0);" <- euler
yeah i didnt know that was euler so I need other rotate method
been weeks trying to find the right one
although its weird how thats euler yet im not getting any gimbal lock
the camera works flawlessly aside from having roll
if only there was a way to like rotate it globally instead of locally
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
148 messages is crazy
anyway
idk much about cameras in java
but u could just not use the axis for roll
i think its y
that should technically fix it lol
or it was z
not sure now
try both of these
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Im already only rotating with two axis
It just ends up rotating on 3 because the 2nd rotation is relative to the 1st or smth like that
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
.
are u sure ur using the right parameters
degrees not radians or vice versa
try to use degrees instead of radians
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Someone else verified that I was using euler angles
The problem is just the rotate methods are all relative to existing rotations so you cant rotate on two axes without rotating on three
And idk how to make a method to either rotate non-relatively or remove the roll after-the-fact
what you could also do is
apply the rotation twice
in separate methods
you might have to use some other method than the one that sets stuff itself btw
so it sets only 1 value regardless
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
yeah ive tried that
tried basically every rotation method thats built-in
in the rotate method set the rotate angle in just one axis. If Z is up set the up vector to (0, 0, 1) and rotate by an angle (are you using OpenGL ?) And if there is a translation do it after the rotation
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
setting the up vector doesnt prevent roll sadly
it just makes the camera controls very weird
(And im already rotating by angles)
have you thought of doing this
finalrotation = rotationx * rotationy
that should work
or x and z i forgot which one is for roll
Stack Overflow
Quaternion-based camera unwanted roll
I created a camera based on quaternions, but when I turn the camera, an unwanted roll appears. I would not like to lose my freedom of movement using, for example, Euler angles, since there is a ne...
check here
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
it doesnt introduce any weird issues, but it doesnt actually change any behavior either (theres still roll)
OHHH I GOT IT
after 21 days
this was the solution:
the camera matrix stores position & yaw
and theres a seperate pitch quaternion that is rotated with the matrix when you do getViewMatrix()
peak camera class
Post Closed
This post has been closed by <@465515365108154380>.