Hi everyone. I must apologise for making my first post a cry for help. I am very new to 3d programming, but not new to programming in general and have tried to solve this myself for a few days with no luck. I will explain what I have done already and describe what I want to do.
I have 2 angles, call them z and x. Thse angles represent the inclination of a slope (or plane if you like). I also have another angle called r, this represents a compass direction. I have a 3D object that I need to render onto the slope, but I am stuck on how to set its rotation correctly. The object is a vehicle, and so it must have its front end pointing in the direction of r, and also be correctly sat on the slope. I would appreciate any help on this. Thanks.
edit: oh yes, the 3d object is out by 16 degrees on its y axis, so I will need angular correction too.
3D rotation problem, object spin AND plane rotation.
Normally vehicles are done with physics engines these days.
From what I gather you have this

Inorder to do what you want I'd start by using proper coordinate labels to ease the confusion. e.g irrlicht uses Y for vertical, X and Z for horizonal.. and R would be a rotation vector.
essentially your car can face any direction, but rotation vector (0,0,0) would be what you want I believe.
the rotations are what you're working with, not angles.. angles are cuboid calculated coordinates. in other words Y axis change will lift your model up and X or Z axis rotation vector change will tilt it up. They are both vectors, or rather components of vectors in irrlicht.
You'll need to first recalculate the matrix for your environment/scene to line everything up. you can make position and scale corrections from your model compared to the node postion, and then you'd rotate the node itself.
X or Z rotation will pitch, and roll, Y rotation will yaw.
There is thread on flight mechanics among many other examples, this should help you get started.
From what I gather you have this

Inorder to do what you want I'd start by using proper coordinate labels to ease the confusion. e.g irrlicht uses Y for vertical, X and Z for horizonal.. and R would be a rotation vector.
essentially your car can face any direction, but rotation vector (0,0,0) would be what you want I believe.
the rotations are what you're working with, not angles.. angles are cuboid calculated coordinates. in other words Y axis change will lift your model up and X or Z axis rotation vector change will tilt it up. They are both vectors, or rather components of vectors in irrlicht.
You'll need to first recalculate the matrix for your environment/scene to line everything up. you can make position and scale corrections from your model compared to the node postion, and then you'd rotate the node itself.
X or Z rotation will pitch, and roll, Y rotation will yaw.
There is thread on flight mechanics among many other examples, this should help you get started.
Hi, thanks for your reply. I will take a look at the flight mechanics like you suggest. I suspect aircraft will have the calculations I need. The frustrating part is that I know the pitch, roll and yaw I want the vehicle to be. At first I tried .setRotation(roll, yaw, pitch) but that only seems to work when one of the values is 0. I thought there may be a simple formula for working out the rotation vector from the roll, yaw and pitch angles, but it seems a bit more complicated than that.
I did try looking at quaternions, but they just muddle me. I thought that they represent an axis and a rotation angle. So (0,1,0,pi) represents a 180 degree rotation around a vertical axis, but, when i convert the quaternion back to euler, i was expecting (0,pi,0) which it wasn't, lol. I also couldn't see any way of applying a quaternion rotation to anything. This aint a simple subject, can be frustrating.
EDIT:
Midnight I'd like to say thanks for the advice on what to search for. Although I didn't find it here, I did some googling on the subject of flight mechanics and found a suggestion that seemed promising, and after some tinkering got it to work. For everyone else who might be interested in how to do this, here goes.
take three 3 angles representing roll, yaw and pitch (from an unrotated object; roll is the x axis, yaw is the y axis and pitch is the z axis). Create 2 matrix4 objects m1 and m2, do:
m1.setRotationDegrees(roll,0,0);
m2.setRotationDegrees(0,yaw,pitch);
m1 *= m2; ( or m1=m1.multiply(m2); )
node.setRotation(m1.getRotationDegrees());
Thanks again,
Marc
I did try looking at quaternions, but they just muddle me. I thought that they represent an axis and a rotation angle. So (0,1,0,pi) represents a 180 degree rotation around a vertical axis, but, when i convert the quaternion back to euler, i was expecting (0,pi,0) which it wasn't, lol. I also couldn't see any way of applying a quaternion rotation to anything. This aint a simple subject, can be frustrating.
EDIT:
Midnight I'd like to say thanks for the advice on what to search for. Although I didn't find it here, I did some googling on the subject of flight mechanics and found a suggestion that seemed promising, and after some tinkering got it to work. For everyone else who might be interested in how to do this, here goes.
take three 3 angles representing roll, yaw and pitch (from an unrotated object; roll is the x axis, yaw is the y axis and pitch is the z axis). Create 2 matrix4 objects m1 and m2, do:
m1.setRotationDegrees(roll,0,0);
m2.setRotationDegrees(0,yaw,pitch);
m1 *= m2; ( or m1=m1.multiply(m2); )
node.setRotation(m1.getRotationDegrees());
Thanks again,
Marc
That's one way to do it, but you might be over complicating things.
First I'll tell you that I have very little actual experience on the subject, most of my programming is in the engine department so I haven't put much time into mechanics just yet.
I have messed around with nodes in the past though, and rotating them never required using an entire matrix array (or whatever the hell they are)
but since I'm bored at the moment I'm going to walk through it step by step.
ACTUALLY better yet.. I'm currently making a tutorial on the subject.
First I'll tell you that I have very little actual experience on the subject, most of my programming is in the engine department so I haven't put much time into mechanics just yet.
I have messed around with nodes in the past though, and rotating them never required using an entire matrix array (or whatever the hell they are)
but since I'm bored at the moment I'm going to walk through it step by step.
ACTUALLY better yet.. I'm currently making a tutorial on the subject.