convert world coordinate to screen coordinate

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
oleang

convert world coordinate to screen coordinate

Post by oleang »

I need to convert world coordinates (x,y,z) in the world to the screen coordinate (x, y) for show messagebox overhead of a player. I cant find in the docs any idea about how to do it. Can somebody point me in the right direction?
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

The collision manager has a method called getScreenCoordinatesFrom3DPosition which does what you want. You can get the collision manager from the Scene Manager. Once you get the screen coordinates, you can use the setRelativePosition method of the message box to update its location. eg:

Code: Select all

ISceneCollisionManager *colMan = smgr->getSceneCollisionManager();
dimension2d<s32> size(100,20);
position2d<s32> pos = colMan->getScreenCoordinatesFrom3DPosition(worldPos,camera);
messageBox->setRelativePosition(rect<s32>(pos,size));
oleang

Post by oleang »

i have one errors from this method. Please help me again. Thank you.

--------------------Configuration: Collision - Win32 Debug--------------------
Compiling...
main.cpp
C:\EngineIrrlicht\examples\7.Collision\main.cpp(253) : error C2039: 'getScreenCoordinatesFrom3DPosition' : is not a member of 'ISceneCollisionManager'
c:\engineirrlicht\include\iscenecollisionmanager.h(25) : see declaration of 'ISceneCollisionManager'
Error executing cl.exe.

Collision.exe - 1 error(s), 0 warning(s)
-------------------------------------------------------------------------------------
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

I have no idea.. it is both in the ICollisionManager in the source, in the include folder, and in the documentation. Are you using version 0.4.1 or 0.4.2? (the two versions I have tested it with)
Post Reply