STATE_engine_is_movement_possible

 

 


  This function is very important. It checks whether it is possible to move 
   between one point to another in the 3D world without intersecting any polygon.
   If the movement is possible it returns YES else returns NO
   If movement is not possible it returns the blocking polygon 
   and the intersection point.
   Note that the normal of the blocking surface is N=( plane[0], plane[1], plane[2])
   If the return value is NO and blocking_object==NULL
   it means that what blocks us is the static part of the world
   Note that the function will be faster if the distance between the start_location and the end_location is smaller
   Important NOTE:
   Polygons have only one side. 
   So there is a question what to do when we want to
   go through a polygon that is not visible to the camera
   (the camera sees only its back )
   The solution that we chose is that: (can be changed using STATE_engine_ignore_back_faced_polygons_for_collision_detection() )
   In Viewer (STATE_load_world() without EDITOR_MODE) mode we dont care if you see the polygon or not
   you can never go through it !
   In Editor mode we apply the following.
	   If the current camera sees the polygon then it is like
	   a solid wall (nothing can go through the wall and nothing can come from the wall)
	   If the current camera doesn't see the polygon then it is as if
	   the polygon doesn't exist at all.
	   If you didnt get it, we will try again.
	   say A is a point in space in the front of a polygon and B is a point on the back side 
	   of that polygon (The front is the side of the normal where you see the vertex in counterclockwise order)
	   then if the location of the camera is in the side of A then
	   one cant move not from A to B nor form B to A.
	   if the current camera is in the side of B
	   then it is possible to move both from A to B and from
	   B to A.
	   Note that the result is insensitive to the direction
	   of movement ( start_point to end_point or the other way around)
	   IMPORTANT:
	   If you want to move the camera from A to B. Lets say there is a one sided polygon
	   on the way that doesn't allow the movement. Now watch this one, there is a big
	   difference between the following options
	   I- moving the camera to B and then asking STATE_engine_is_movement_possible()
	   II- asking STATE_engine_is_movement_possible() while we are in A
	   In the first case we would get YES (error)
	   In the second case we would get the correct answer - NO
	   The reason for that is that if the camera is at point B then from point
	   B the polygon is not seen (we see only its back side which is invisible)
	   and if the obstacle is not seen then the movement is allowed !
  
   Arguments:
  
  	start_location:
  		The x,y,z coordinate if the starting point
  
  	end_location:
  		The x,y,z coordinate if the end point
  
    intersected_polygon: If the line starting from start_point intersects a polygon in the world then
  						 the handle to this polygon will be returned through this argument
  
    intersection: The x,y,z  coordinate of the intersection point.
  
    blocking_object: If the intersected_polygon belongs to a dynamic object (see the STATE_object API) then
  					 the handle to this object will be returned through this argument.
  
  
  	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:
  		double start_location[3]={10,0,0};
  		double end_location[3]={10,0,1000};
  		double intersection[3];
  		DWORD intersected_polygon;
  		DWORD blocking_object;
  		int rc;
  		rc=STATE_engine_is_movement_possible(start_location, end_location, &intersected_polygon, intersection, &blocking_object);
  		if(rc==NO) ....   Collision
  	    else ....     no collision
  
   See also: STATE_engine_ignore_back_faced_polygons_for_collision_detection(),
  			 STATE_engine_ignore_dynamic_objects_for_collision_detection()
  

 

 

Go to page 1      Select API

 

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