setting object coordinates

edited May 2013 in Help request
I am trying to draw a diagnoal line of squares going from roughly left upper corner to right bottom corner. However, I only see the second half of the diagonal line (lower rh). And 0,0 is supposed to be in the center of the screen, is that correct?
orxOBJECT* tile;

for (orxU32 i = 0; i < 6; i++) {
tile = orxObject_CreateFromConfig("TileObject");

// -- assign position
orxVECTOR tilePos = {-240+i*80, -240+i*80, 0};
orxObject_SetPosition(tile, &tilePos);

ScreenWidth = 480
ScreenHeight = 800

Camera = Camera

FrustumWidth = @Display.ScreenWidth
FrustumHeight = @Display.ScreenHeight
FrustumFar = 1.0
FrustumNear = 0.0
Position = (0.0, 0.0, -1.0)


Graphic = TileGraphic

Texture = tutorial-tiles.png
TextureSize = (80,80,0)
TextureOrigin = (0,0,0)


  • edited May 2013
    a bit of an update, here's the log of what happens when setting the negative coordinates:
    [LOG] tilePos: 4294967040.0, 4294967040.0, status: SUCCESS
    [LOG] tilePos: 4294967040.0, 4294967040.0, status: SUCCESS
    [LOG] tilePos: 4294967296.0, 4294967296.0, status: SUCCESS
    [LOG] tilePos: 0.0, 0.0, status: SUCCESS
    [LOG] tilePos: 80.0, 80.0, status: SUCCESS
    [LOG] tilePos: 160.0, 160.0, status: SUCCESS
  • edited May 2013
    ok, i know the problem

    int i = 2;
    float x = -240+80*i;
    x -> -80

    unsigned int i = 2;
    float x = -240+80*i;
    x -> INT_MAX

    somehow this has never bothered me before, heh
  • edited May 2013
    I made a few notes on how coordinate system works, angles, rotation direction. This may help:

    Snippets for orxObject's Functions
  • edited May 2013
    Glad you found your issue.

    A small note though: the world coordinates are *not* directly correlated to screen position, it all depends on the viewport/camera couple that renders that portion of the world and where it's display on the target surface.

    In your example, your camera points to x,y = 0,0.
    As your associated viewport covers the whole display surface, that will then map the (0,0) world coordinate to the middle of the screen.
    However if your camera were in (240, 400), the (0,0) of the world would then be rendered in the top left corner of your screen.

    Of course, in addition to position, one has to account for the camera zoom and rotation as well.

    There are functions in the orxRender API to convert coordinates between screen and world spaces. They'll also let you know if the input coordinates maps outside the destination (for ex, if the world coordinates you pass to orxRender_GetScreenPosition() isn't actually on screen).
Sign In or Register to comment.