Jump to content

[SOLVED] How do we get the pick ray?


photo

Recommended Posts

Is there any way to get the pick ray in world space given the mouse coordinates? We plan to use this ray with world.getIntersection() to determine which object is currently under the mouse.

Couldn't find any function that did this in world or Player classes.

An old forum post mentions getPlayerMouseDirection() but that doesn't seem to be available anymore.

It'd be convenient if Unigine offered this instead of us having to construct it from the projection matrix.

 

Thanks,

Ashwin.

Link to comment

Is there any way to get the pick ray in world space given the mouse coordinates?

 

Have a look into <UNIGINE-SDK-root>/data/core/scripts/utils.h for Unigine::getPlayerMouseDirection(vec3 &p0,vec3 &p1). This should be exactly what you need. Also there is a sample for mouse based object picking using this function. Start <UNIGINE-SDK-root>/demos/system_d3d9.bat. Code can be found in <UNIGINE-SDK-root>/data/selection_00.cpp

 

post-82-0-46822700-1307604135_thumb.jpg

Link to comment

Thanks ulf!

My only complaint is that this is not discoverable enough. Most engines have this built into the Camera (or equivalent) class. And since this looks like a util script, the documentation does not mention it either (that's where I looked).

Link to comment

the documentation does not mention it either (that's where I looked).

 

From my experience having a detailed look at ALL provided demos/examples gives you best/fastest overview on function set

Link to comment
  • silent changed the title to [SOLVED] How do we get the pick ray?
×
×
  • Create New...