LoginLogin

3D rotation

Root / Programming Questions / [.]

randoCreated:
I have a 3D engine that can render objects, but I have one problem: rotation. Basically, I know nothing about 3D rotation. Would anyone please teach me?

Ok so I found this website: https://petercollingridge.appspot.com/3D-tutorial/rotating-objects And so I translated he code to SB code and got a bendy cube rather than a rotating cube. It kinda just turned into a rhombus prism. EDIT: ID10T It's -+, not -- lol Now it rotates properly

Ok, now I'm trying to make it so that you don't move but everything else moves. This is so that the origin is always on screen and changing. But I need to figure out how to move everything based on stick inputs and which way the player is faced. Just a side note, right now it's in first person if that matters at all.

For 3D rotations, I would recommend you to look up either Euler angles (do this one if you don't mind gimbal lock) or quartenions (do this one if you're prepared for 4-dimensional numbers and the math related with them). There's a good video by 3Blue1Brown which explains very nicely quartenions if you want to implement them.

Man quaternions are confusing. I like euler angles exept for the gimbal lock stuff but ok I guess. EDIT: Ok never mind. Because of the way I have this set up, I just need to increase/decrease the z value of every coordinate. (everything except player moves) EDIT2: Well I guess the new problem now is implementing physics. That's because of how it's set up :D

Man quaternions are confusing.
I can't believe you said that. Jk i know they are confusing at first but if you learn them theyre nice they also allow you to rotate in every axis allowed not only in XYZ axes so thats nice

A: for directional movement, you move X * sin(angle) * speed and Z * cos(angle) * speed For rotation, I recommend the video you used it for that engine and videos in this series(this is video #2): https://youtu.be/XgMWc6LumG4 Also, don't worry about projection matrix. That's just a 2d array of the perspective formulas. If you pay attention you'll understand it.

A: for directional movement, you move X * sin(angle) * speed and Z * cos(angle) * speed
Ok but what is the angle here? Because this is in 3D space and you can have like 3 different angles.

The angle is the 'Y' rotation, looking left/right. Everything rotates around the Y axis for looking left/right. X is up/dow, and Z is wobbley(could be used for dramatic scene or walking)

it's called tilt

Ok thanks