Author Topic: object on screen using interact2d  (Read 991 times)

Offline dutch_delight

  • int
  • **
  • Posts: 58
    • View Profile
object on screen using interact2d
« on: March 07, 2012, 09:31:51 pm »
Hey all,

can anyone help me or explain to me the interact2d function? I'm trying to put an object on screen but I cant get it in the right place.

this is sort of what i want to do: A 2 polygon plane that fits nicely into a radar frame. (radar frame is blitted on screen)
for example using a screen size of 800x480, the radar frame is always an 8th of the size of the frame buffer width (100 x 100) so the middle point where the radar object should be positioned is half of that (50 x50)
It's not a pivot problem but the radar object is a child of the player object and the camera is offset from the player

Code: [Select]
ui_frame_pos_x = (fb.height/16);// gives us the middle of the radar frame
ui_frame_pos_y = (fb.heigth/16);

SimpleVector dir=Interact2D.reproject2D3D(camera, fb, ui_frame_pos_x,ui_frame_pos_y).normalize();
RadarObject.clearTranslation();
RadarObject.translate(dir);
but that doesnt work, the radar object appears to be positioned at (150x0)


this does work (sort of) it's roughly in the right place but I cant accept that this is right:
Code: [Select]
SimpleVector dir=Interact2D.reproject2D3D(cam, fb, (-ui_frame_size_x+(ui_frame_size_x/2))+8, (ui_frame_size_y+ui_frame_size_x/2));
also, when my screen is 1024 wide, the above formula doesnt work and I need to do this, which is absolutely crazy:
Code: [Select]
SimpleVector dir=Interact2D.reproject2D3D(cam, fb, (-ui_frame_size_x)-(ui_frame_size_x/2)-(ui_frame_size_x/16), ui_frame_size_y+(ui_frame_size_y/2)-(ui_frame_size_y/16)).normalize();


So I dont think i'm doing it right. I have considered doing a lookup table for screen sizes but that's my last resort.
Any help much appreciated

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: object on screen using interact2d
« Reply #1 on: March 07, 2012, 10:21:38 pm »
Wouldn't it be better to put the radar object in a separate world, decouple it from the player, position it once and leave it alone? Or isn't that an option for some reason?

Offline dutch_delight

  • int
  • **
  • Posts: 58
    • View Profile
Re: object on screen using interact2d
« Reply #2 on: March 08, 2012, 09:22:11 pm »
Never even considered doing it like that. works perfectly. thanks