orxObject_GetPosition & orxObject_GetWorldPosition

Hello everyone
I'm new to orx. I got a little puzzle when I read the 3rd tutorial (Frame).
Somewhere call a function called orxObject_GetWorldPositon, and there is another function called orxObject_Position in orx, what's the difference between them, anybody can help me?

Comments

  • edited February 2012
    Hi and welcome here!

    orxObject_GetWorldPosition() get object position in the world instead of orxObject_GetPosition that get object position relatively to its parent (in the parent coord space).

    If your object has no parent, the result is the same.

    To understand, maybe take a look at the file CreationTemplate.ini.

    In the section ObjectTemplate, you will see that orx manage a properties called "ChildList".

    Look at this example (here is a stupid example of a head with two eyes ..., sorry, I don't want to take time to search a better one ^^) :
    ; This is your head
    [HeadObject]
    ; The head has two child objects for his eyes
    ChildList = LeftEyesObject # RightEyesObject
    ; Initial position in the world
    Position = (0,100,0)
    
    ; We define the two eyes
    [LeftEyesObject]
    ; The position is relative to its parent (the head)
    Position = (-20,-10,0)
    ; I don't write some Graphics and other properties ...
    [RightEyesObject]
    ; The position is relative to its parent (the head)
    Position = (20,-10,0)
    

    So, if you call orxObject_GetPosition() on the left eyes object, you will get a vector like (-20,-10,0) => it is the position in its parent space. If you call orxObject_GetWorldPosition() on the left eyes, you will have (-20,90,0) => it is its position in the world.

    Note: the orx's frame (one by object), contains informations like scale/rotation/position. If you move an object, all its child will be automatically moved. In my example, if you move the head then the eyes will follow the same move.

    Hope this can help ! ;)
  • edited February 2012
    Hi Movement617!

    As faistoiplaisir already replied with all details and a nice example, I'll simply write this post to welcome you here. :)

    Don't hesitate to ask if you have any other questions!
  • edited February 2012
    Thanks for your help, faistoiplaisir and iarwain. I now understander it completely - the one gets the absolute coordinate and the other one gets the relative. Thank you again :silly:
Sign In or Register to comment.