convert world coordinate to screen coordinate
-
oleang
convert world coordinate to screen coordinate
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?
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
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)
-------------------------------------------------------------------------------------
--------------------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)
-------------------------------------------------------------------------------------