Difference between revisions of "Tutorial - Picking"
m |
(Updated the code to work with Beta4 and SVN trunk.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 33: | Line 33: | ||
</source> | </source> | ||
}} | }} | ||
+ | To activate that listener we have to add the following code to the '''setupWindow''' method: | ||
+ | |||
+ | {{CppSourceCode|description=Activate mouse button listener|code=<source lang="cpp" line="1"> | ||
+ | glfwSetMouseButtonCallback( mouseButtonListener ); | ||
+ | </source> | ||
+ | }} | ||
+ | |||
+ | |||
For the use of [http://www.horde3d.org/docs/_utils.html#pickNode Horde3DUtils::pickNode] we have to normalize the window coordinates received by ''glfwGetMousePos''. That's why we need to call ''glfwGetWindowSize'' additionally. Another conversion has to be made, since GLFW has it's origin in the upper left corner while Horde3D requires the origin to be in the lower left corner. | For the use of [http://www.horde3d.org/docs/_utils.html#pickNode Horde3DUtils::pickNode] we have to normalize the window coordinates received by ''glfwGetMousePos''. That's why we need to call ''glfwGetWindowSize'' additionally. Another conversion has to be made, since GLFW has it's origin in the upper left corner while Horde3D requires the origin to be in the lower left corner. | ||
− | Then in the '''app.cpp''' we implement a call to the | + | Then in the '''app.cpp''' we implement a call to the h3dutPickNode utility function. |
{{CppSourceCode| | {{CppSourceCode| | ||
Line 44: | Line 52: | ||
void Application::pick( float dX, float dY ) | void Application::pick( float dX, float dY ) | ||
{ | { | ||
− | + | H3DNode node = h3dutPickNode(_cam, dX, dY); | |
} | } | ||
</source> | </source> | ||
Line 52: | Line 60: | ||
name = Picking Tutorial| | name = Picking Tutorial| | ||
screenshot = H3DPlaceHolder.png| | screenshot = H3DPlaceHolder.png| | ||
− | description = This tutorial present how to pick an object| | + | description = This tutorial present how to pick an object in a 3D scene.| |
version = 1.0| | version = 1.0| | ||
horde3dversion = 1.0 beta| | horde3dversion = 1.0 beta| |
Latest revision as of 15:19, 28 June 2010
|
|