STATE_engine_2D_point_to_3D

 

 


   *** Very useful. one of the most important functions
   Gets a two dimensional point (x,y) which is a point in the rendered window
   Usually we get this point from events like OnLButtonDown()
   The function returns the corresponding three dimensional point
   in the 3D world. Note that if the 2D point that is given is located where there is no 
   polygon then the function will return VR_ERROR. This is because the point
   in 3D is in infinity ... in that case the 3d point retrieved (result[] )
   will hold a point in that direction that is one million units away
   from the camera.
  
   Arguments:
  	x,y   -  A two dimensional point in the rendered window (client area)
    result - a point x,y,z in the 3D world which corresponds to the given 2D point.
  			 When calling the function to content of this argument is not relevant.
  			 The function calculate the 3D point and returns it through this argument.
  
    selected_object_handle - If the pixel X,Y (the 2D point) on the rendered window is taken from
  							 a dynamic object then this argument will hold the handle to this object.
  			 
  
    selected_polygon_handle - a handle to a polygon that corresponds with the given 2D point.

   Return Value: OK or VR_ERROR
  
   See also STATE_engine_2D_point_to_3D_point_on_plane(), STATE_engine_2D_point_to_3D_point_on_sphere()
  			STATE_polygon_get_bitmap_pixel_rgba()
  
  
  	Remark:
  		Note that this function doesn't take a camera handle as one of its parameters.
  		Note also that the result of the operation is dependent on the current camera that is used.
  		The engine will use the current camera (The camera that was used in the last render)
  		In most of the cases this is the right thing to do. In the case when you want
  		to use a different camera for the calculation then use STATE_camera_set_current()
  		Before calling this function.
  
   Example:
  		int x=10, y=20;
  		double result[3];
  		DWORD selected_object_handle;
  		DWORD selected_polygon_handle;
  		int return_code;
  		return_code=STATE_engine_2D_point_to_3D(x,y,result, &selected_object_handle, &selected_polygon_handle);

 

 

Go to page 1      Select API

 

Copyright © 2007 3DSTATE Corporation. www.3dstate.com