示例#1
0
//
// Move Backwards
//
void MoveBackward(void)
{

	float heading=0;
	float xpos, zpos;

	float speed = camera_speed;
	float new_speed;

	if (CAMERA->type == CAMERA_WALKING)
	{

		heading = CAMERA->angle[1];


		heading = CAMERA->angle[1];
		new_speed = fTime * speed;

		xpos = (float)sin(heading*PI_180) * new_speed;
		zpos = (float)cos(heading*PI_180) * new_speed;

		TranslateCamera(xpos, 0.0f, -zpos);

	} else {
		TranslateCamera(0.0f, 0.0f, -camera_speed);
	} // end of if 

} // end of the functino 
示例#2
0
	void SetupCamera()
	{
		glEnable(GL_DEPTH_TEST);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluOrtho2D(-1.0,1.0,-1.0,1.0);// i'm not sure about these 1.0 values
		glViewport(0,0,800,600);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		RotateY(45.0f);
		TranslateCamera(0,0,0);
		
	}
示例#3
0
//
// MoveLeft
//
void MoveLeft(void)
{	

	float angle;


	if (CAMERA->type == CAMERA_WALKING)
	{
		angle = fTime * turning_speed;
		TurnCamera(0.0f, angle, 0.0f);
		
	} else {
		angle = fTime * camera_speed;
		TranslateCamera(camera_speed, 0.0f, 0.0f);
	} // end of if 

} // end of the functino 
示例#4
0
/*
   Deal with plain key strokes
*/
void HandleKeyboard(unsigned char key,int x, int y)
{
   switch (key) {
   case ESC:                            /* Quit */
   case 'Q':
   case 'q': 
      exit(0); 
      break;
   case 'h':                           /* Go home     */
   case 'H':
      CameraHome(0);
      break;
   case '[':                           /* Roll anti clockwise */
      RotateCamera(0,0,-1);
      break;
   case ']':                           /* Roll clockwise */
      RotateCamera(0,0,1);
      break;
   case 'i':                           /* Translate camera up */
   case 'I':
      TranslateCamera(0,1);
      break;
   case 'k':                           /* Translate camera down */
   case 'K':
      TranslateCamera(0,-1);
      break;
   case 'j':                           /* Translate camera left */
   case 'J':
      TranslateCamera(-1,0);
      break;
   case 'l':                           /* Translate camera right */
   case 'L':
      TranslateCamera(1,0);
      break;
   case '=':
   case '+':
      FlyCamera(1);
      break;
   case '-':
   case '_':
      FlyCamera(-1);
      break;
   case 'w':                           /* Write the image to disk */
   case 'W':
      windowdump = !windowdump;
      break;
   case 'r':
   case 'R':
      record = !record;
      break;
   case '<':
   case ',':
      iterationdepth--;
      if (iterationdepth < 0)
         iterationdepth = 0;
      geometrydirty = REALDIRTY;
      break;
   case '>':
   case '.':
      iterationdepth++;
      geometrydirty = REALDIRTY;
      break;
   }
}
void CNuGenDimensionView::OnMouseMove(UINT nFlags, CPoint point)
{
    CChildFrame* pFrame = static_cast<CChildFrame*>(GetParentFrame());
    SetFocus();
    if (!pFrame->m_commander)
    {
        switch (m_hand_action )
        {
        case HA_ROTATE:
            if (nFlags & MK_LBUTTON)
            {
                SG_VECTOR downPnt;
                SG_VECTOR curPnt;
                // Convert the mouse left button down position to world
                m_Camera.GetWorldCoord(m_ScreenLeftButtonDownPoint.x,
                                       m_ScreenLeftButtonDownPoint.y,
                                       0.0,
                                       downPnt);
                // Convert the mouse point into world coordinates
                m_Camera.GetWorldCoord(point.x,	point.y, 0.0,curPnt);
                //VecSubf(curPnt, downPnt, curPnt);
                curPnt = sgSpaceMath::VectorsSub(curPnt, downPnt);
                CSize deltaPos;
                deltaPos = m_ScreenLeftButtonDownPoint - point;
                m_ScreenLeftButtonDownPoint = point;
                RotateCamera(deltaPos);
                Invalidate(FALSE);
            }
            break;
        case HA_MOVE:
            if (nFlags & MK_LBUTTON)
            {
                SG_VECTOR downPnt;
                SG_VECTOR curPnt;
                // Convert the mouse left button down position to world
                m_Camera.GetWorldCoord(m_ScreenLeftButtonDownPoint.x,
                                       m_ScreenLeftButtonDownPoint.y,
                                       0.0,
                                       downPnt);
                // Convert the mouse point into world coordinates
                m_Camera.GetWorldCoord(point.x,	point.y, 0.0,curPnt);
                //VecSubf(curPnt, downPnt, curPnt);
                curPnt = sgSpaceMath::VectorsSub(curPnt, downPnt);
                m_ScreenLeftButtonDownPoint = point;
                TranslateCamera(curPnt);
                Invalidate(FALSE);
            }
            break;
        case HA_ZOOM:
            if (nFlags & MK_LBUTTON)
            {
                SG_VECTOR downPnt;
                SG_VECTOR curPnt;
                // Convert the mouse left button down position to world
                m_Camera.GetWorldCoord(m_ScreenLeftButtonDownPoint.x,
                                       m_ScreenLeftButtonDownPoint.y,
                                       0.0,
                                       downPnt);
                // Convert the mouse point into world coordinates
                m_Camera.GetWorldCoord(point.x,	point.y, 0.0,curPnt);
                //VecSubf(curPnt, downPnt, curPnt);
                curPnt = sgSpaceMath::VectorsSub(curPnt, downPnt);
                CSize deltaPos;
                deltaPos = m_ScreenLeftButtonDownPoint - point;
                m_ScreenLeftButtonDownPoint = point;
                ZoomCamera(deltaPos);
                Invalidate(FALSE);
            }
            break;
        default:
            break;
        }
    }

    if (!pFrame->m_commander)
        /*pFrame->m_commander->MouseMove(nFlags,point.x,point.y);
        else*/
        if (!(nFlags & MK_LBUTTON))
        {
            int snapSz = pFrame->GetSnapSize();
            const sgCObject* oldHotObj = Drawer::CurrentHotObject;

            Drawer::CurrentHotObject = GetTopObject(GetHitsInRect(CRect(point.x-snapSz, point.y-snapSz,
                                                    point.x+snapSz, point.y+snapSz),true));
            Drawer::TopParentOfHotObject = GetObjectTopParent(Drawer::CurrentHotObject);
            if (Drawer::TopParentOfHotObject)
                Drawer::CurrentHotObject = Drawer::TopParentOfHotObject;
            /**************************************/
            if (Drawer::CurrentHotObject &&
                    (Drawer::CurrentHotObject->GetType()==SG_OT_LINE ||
                     Drawer::CurrentHotObject->GetType()==SG_OT_CIRCLE ||
                     Drawer::CurrentHotObject->GetType()==SG_OT_SPLINE ||
                     Drawer::CurrentHotObject->GetType()==SG_OT_ARC ||
                     Drawer::CurrentHotObject->GetType()==SG_OT_CONTOUR)
               )
            {
                sgC2DObject* spl = reinterpret_cast<sgC2DObject*>(Drawer::CurrentHotObject);
                CString messs = "2DObject ";
                if (spl->IsClosed())
                    messs += " Closed; ";
                else
                    messs += " No closed; ";
                if (spl->IsLinear())
                {
                    messs += " Linear;";
                }
                else
                {
                    messs += " No linear - ";
                    SG_VECTOR plN;
                    double    plD;
                    if (spl->IsPlane(&plN,&plD))
                    {
                        CString aaaa;
                        aaaa.Format("Normal: X=%f,Y=%f,Z=%f D: %f",plN.x,plN.y,plN.z,plD);
                        messs += " Plane; ";
                        messs+=aaaa;
                    }
                    else
                        messs += " No Plane; ";
                }

                if (spl->IsSelfIntersecting())
                    messs += "Self intersecing; ";
                else
                    messs += "No Self intersecing; ";

                pFrame->PutMessage(IApplicationInterface::MT_MESSAGE,
                                   messs);

            }
            else if (Drawer::CurrentHotObject &&	(Drawer::CurrentHotObject->GetType()==SG_OT_3D))
            {
                sgC3DObject* ddd = reinterpret_cast<sgC3DObject*>(Drawer::CurrentHotObject);
                CString messs;
                messs.Format("Volume = %f",ddd->GetVolume());
                messs+="  Square = ";
                CString aaaa;
                aaaa.Format("%f",ddd->GetSquare());
                messs+=aaaa;
                pFrame->PutMessage(IApplicationInterface::MT_MESSAGE,
                                   messs);
            }
            else
                pFrame->PutMessage(IApplicationInterface::MT_MESSAGE,
                                   "                        ");
            /**************************************/

            if (oldHotObj!=Drawer::CurrentHotObject)
                Invalidate();
        }

    COpenGLView::OnMouseMove(nFlags, point);
}