Tutorial: Orientation Matrix (Update: Up/Down, North/South/East/West)

Hi All

Some questions and comments inspired an update of the orientation matrix tutorial (so the previous version was not the final one, and this one is probably not either!):

  • I have improved the layout. It is now one column, which makes it easier to copy the code.
  • There are a few new sections:[LIST]
  • rotating children and non-children (root objects);
  • determining whether an object is upright or not;
  • determining in which wind direction (North, South, …) an object is facing; and
  • determining on which side of a plane a point lies. [/LIST]The usual disclaimer: it is math and code heavy…
    http://www.luma.co.za/labs/tutorials/rotation.zip (250 KB)


PS If you are interested in image / game programming, you might also check out some of the other items on the luma/labs page!

the PDF its like ancient Greek to me :slight_smile:
But the little demos are great
I’ve added some motion to the targets and it’s still working
Thank you very much

Thanks Herman. The two column format was really bad for copying code. I ended up retyping one of the functions in order to use it. Not that it was particularly hard, but this will be more convienient.

Hey,thats some really great script…much apreciated :wink:

I have one question…in the rotate tutorial if i want to map the left arrow key to make the box rotate to the left and map the right arrow key to make the box rotate to the right how can i change the ‘gamma’ value in the python script without having to make 2 scripts the same but just having the gamma value different?

So when i press left ‘gamma’ should have lets say -10 value and when i press right key ‘gamma’ has +10 value…

Also how can i make the Cube object always point at the target having the same face look at the target as it rotates?

I kinda new to this so i though i`d ask :slight_smile:

There are many ways to do it. One way is to store gamma in a property of the connected object. Then you can use the code like this:

controller = GameLogic.getCurrentController()
owner = controller.getOwner()
gamma = owner.gamma

And then set up the logic bricks:

Key Sensor (Left Arrow)  ---> AND ---> Property (gamma=10)
Key Sensor (Right Arrow) ---> AND ---> Property (gamma=-10)

Awsome…i made it just the way you said and it worked…thanks a lot :wink: