Simple 3D rotation

This should be very simple, but I cannot seem to figure it out. Here is what I want to do:

Imagine an airplane sitting on the xy plane pointing in the y direction.

I adjust the airplane’s roll using setR(90).

Now the airplane is still pointing in the y direction, but it is sitting on the yz plane (it’s left wing is pointing up in the positive z direction, and it’s right wing down in the negative z direction).

Now I gradually increase the pitch of the airplane. What I want to happen is for it to rotate around the z axis, as you would expect a plane to do. What it actually does it roates around the x axis, so that the nose of the plane starts to move in the positive Z direction.

I tried adjusing the pitch and the heading according to the roll like so:

self.airplane.setP(self.airplane.getP() + someconstant * cos(self.airplane.getR())

self.airplane.setH(self.airplane.getH() + someconstant * sin(self.airplane.getR())

This works to a degree. When the plane is rolled to a factor of 90 degress it works just fine. If it is rolled to 45 degrees however, it rotates crazily.

I am sure this is really simple and I have been hacking away at it for a while now but I just can’t figure it out. Any help is really appreciated.

oh man I have no idea I could pass a node as an argument.

self.airplane.setP(self.airplane, self.airplane.getP() + someconstant)

sort of works but sort of does not.

it seems to work at R = 0 and R = 90 like before, but again like before it makes it roll crazily at any angle in between

Edit- okay okay okay I am pretty sure I have got it now.

        # Change roll
        self.plane.setR(self.plane, self.ailerons)   
        # Change pitch
        self.plane.setP(self.plane, self.elevators)

is all i needed :smiley:

i’m not 100% shure what you need but maybe you could use a node-tree like
render->dummy1->dummy2->airplane (or just one dummy)
try to rotate the dummy-node for pitch and the airplane-node for roll.
or something like this^^
good luck anyway=)