getScreenCoordinates returning 0.000

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
headfonez
Posts: 12
Joined: Wed Oct 31, 2007 2:04 pm

getScreenCoordinates returning 0.000

Post by headfonez »

Hello, I'm using the getScreenCoordinatesFrom3DPosition() for a camera and each time I use the printf function to display the 2d coordinates, it always returns 0.00000. Any ideas why this happening?

Code: Select all

b = smgr->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(vector3df(80,50,-70));
printf("%f\n", b.Y);
No matter where I move or rotate the camera, it returns 0.000. Any help is appreciated.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Are you positive that those world coordinates are on the screen at any time, it's possible that you miss them...

Maybe you should test it with a static camera (non FPS) and set the target to the same position that you're passing to that function and then i guess you should get something like 0.5,0.5 returned.
Image Image Image
headfonez
Posts: 12
Joined: Wed Oct 31, 2007 2:04 pm

Post by headfonez »

Thanks for your reply. I used a static camera and had it point to the coordinates of a node. Then I used the getScreenCoordinatesFrom3DPosition(node->getPosition()) to read the node's coordinates and translate them to 2d Screen Coordinates. Alas, it again returned 0.000 when doing a printf("%f",coord.X);

Note, I dont know if this could be a problem, but I'm using a windowed mode. Any help is appreciated. Thanks.
headfonez
Posts: 12
Joined: Wed Oct 31, 2007 2:04 pm

Post by headfonez »

I am having the same problem with the cursor position. It also returns 0.000, regardless of where I move the cursor.

Code: Select all

position2d<s32> pos;
pos = cursor->getPosition(); 
printf("%f\n", pos.Y );
Any help is appreciated.
headfonez
Posts: 12
Joined: Wed Oct 31, 2007 2:04 pm

Post by headfonez »

THe coordinates are being read, I'm able to move a node based on the mouse position, however, I just can't display it using printf(). But the get2d position function does work.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Both getScreenCoordinatesFrom3DPosition() and cursor->getPosition() return a position2d<s32>. That means that the type of b.X is s32, not f32, so you need to use the correct printf() format specifier [use %d or %i instead of %f].

Travis
headfonez
Posts: 12
Joined: Wed Oct 31, 2007 2:04 pm

Post by headfonez »

Thanks!
Post Reply