Пример #1
0
/**
 * function to handle mouse movement
 * @param x  the x coordinate of the mouse
 * @param y  the y coordinate of the mouse
 */
void mouseMove(int x, int y)
{
   // TODO
   const double bound = 1.75;
   
   if( options.view_mode == 0 ){

      //Get the current mouse position in world coordinates
      vec4 world_points = window2world( x, y);
      
      //compare axis movement with previous x axis position
      double motion = world_points.x - options.puck_x_axis;
      
      if( options.puck->get_translation().x + motion > bound )
         motion = bound - options.puck->get_translation().x;
      
      if( options.puck->get_translation().x + motion < -bound )
         motion = -bound - options.puck->get_translation().x;
      
      options.puck->adjust_translation(vec3(motion,0,0));
      options.physics.adjPuckTranslation(vec3(motion,0,0));
      options.puck_x_axis = options.physics.getPuckTranslation().x;

   }
}
Пример #2
0
/**
 * function to handle mouse presses
 * @param button  the button pressed
 * @param state  the type of press (up or down)
 * @param x  the x coordinate of the press
 * @param y  the y coordinate of the press
 */
void mouseEvent(int button, int state, int x, int y) 
{
   // TODO
#if 0
   //Get the current mouse position in world coordinates
   vec3 world_points = window2world( x, y);
   
   options.set_paddle2_dest(vec2(world_points.x,world_points.z));
#endif 
}
Пример #3
0
void StickyNoteActor::calculateDialogPoseDims(Mat34& poseOut, Vec3& dimsOut)
{
	POINT windowPos = {0, 0};
	ClientToScreen(winOS->GetWindowsHandle(), &windowPos);
	float dist = 0.0f;
	Vec3 v, w, dir, centroidPt, cornerPt;
	Ray ray;
	NxPlane plane(cam->getDir(), -80.0f);

	// get the centroid point on the plane
	window2world(_editDialog->pos().x() - windowPos.x + _editDialog->width() / 2.0f,
		_editDialog->pos().y() - windowPos.y + _editDialog->height() / 2.0f, v, w);
	dir = w - v;
	dir.normalize();
	ray = Ray(v, dir);
	NxRayPlaneIntersect(ray, plane, dist, centroidPt);

	// get the corner point
	window2world(_editDialog->pos().x() - windowPos.x + _editDialog->width() - _editDialog->getNoteInset(),
		_editDialog->pos().y() - windowPos.y + _editDialog->height() - _editDialog->getNoteInset(), v, w);
	dir = w - v;
	dir.normalize();
	ray = Ray(v, dir);
	NxRayPlaneIntersect(ray, plane, dist, cornerPt);

	// calculate the final dims
	Vec3 diff = centroidPt - cornerPt;
	dimsOut = Vec3 (diff.x, diff.z, getDims().z);
			
	// calculate the final orientation/position
	Mat33 ori;
	Vec3 zaxis = cam->getDir() - cam->getEye();
	zaxis.normalize();
	Vec3 xaxis = cam->getUp().cross(zaxis);
	xaxis.normalize();
	Vec3 yaxis = zaxis.cross(xaxis);
	
	ori.setColumn(0, xaxis);
	ori.setColumn(1, yaxis);
	ori.setColumn(2, zaxis);
	poseOut = Mat34(ori, centroidPt);
}
Пример #4
0
Vec3 TouchPoint::unProject(NxPlane &plane)
{
	Vec3 point;
	NxF32 distance;
	Vec3 closePlane, farPlane, dir;

	window2world(x, y, closePlane, farPlane);
	dir = farPlane - closePlane;
	dir.normalize();
	Ray touchRay(closePlane, dir);

	NxRayPlaneIntersect(touchRay, plane, distance, point);
	return point;
}