Page 1 of 1

How to get a 3D scene node's 2D coordinates on the screen?

Posted: Sun Dec 05, 2010 12:59 am
by jerrelDulay
Heya everyone. I've searched through pages of the forum and failed to find a similar topic. What I'm trying to do is get the 2D coordinates of a scene node.

For example, I have a 3rd person game engine, and I want to draw, let's say, an arrow sprite above an NPC that the player can talk to. Also, I'd need to be able to check if that scene node is outside or inside the current viewing frame.
I really just need the X and Y coordinates of where a scene node appears on the screen.

I've been able to do this in Ultimate 3D and Game Maker, I'm not entirely sure how to do this in Irrlicht. Any help would be extremely appreciated!

Cheers!

Posted: Sun Dec 05, 2010 3:11 am
by blAaarg
Don't forget to check the API for ISceneCollisionManager Class Reference
It has several useful methods including the one you want: getScreenCoordinatesFrom3DPosition(). Keep in mind, the position returned is the "local" or "model" coordinates of the mesh and you'll have to figure out how to offset the arrow sprite accordingly.

The scene node will have a method isCulled() which will tell you if its bounding box is completely invisible to the camera, iirc.

Posted: Sun Dec 05, 2010 3:56 am
by jerrelDulay
Thanks mate! I had checked countless other class references in the API, and the last place I expected to find it was in the "ISceneCollisionManager". I really appreciate it! Thanks!