void YsClassSample::Motion(int x,int y) { double dx,dy; YsVec3 vec; dx=double(x-lastX); dy=double(lastY-y); switch(mouseMode) { case 0: eyeAtt.NoseUp(dy/300.0); eyeAtt.YawLeft(-dx/300.0); break; case 1: vec.Set(-dx/30.0,-dy/30.0,0.0); vec=eyeAtt.GetMatrix()*vec; eyeLookAt=eyeLookAt+vec; break; case 2: RotatePolygon(dy/300.0,-dx/300.0); break; case 3: vec.Set(dx/30.0,dy/30.0,0.0); vec=eyeAtt.GetMatrix()*vec; pointOfInterest=pointOfInterest+vec; break; } lastX=x; lastY=y; }
void Motion(int x,int y) { if(button==GLUT_DOWN) { double dx,dy; YsVec3 vec; dx=double(x-lastX); dy=double(lastY-y); switch(mouseMode) { case 0: eyeAtt.NoseUp(dy/300.0); eyeAtt.YawLeft(-dx/300.0); break; case 1: vec.Set(-dx/30.0,-dy/30.0,0.0); vec=eyeAtt.GetMatrix()*vec; eyeLookAt=eyeLookAt+vec; break; } glutPostRedisplay(); } lastX=x; lastY=y; }
void YsClassSample::Display(void) { BIPOSATT biEyePos; BIPOINT cursor; eyePos.Set(0.0,0.0,-eyeDistance); eyePos=eyeAtt.GetMatrix()*eyePos; eyePos=eyeLookAt+eyePos; BiSetPoint(&biEyePos.p,eyePos.x(),eyePos.y(),eyePos.z()); BiSetAngleDeg(&biEyePos.a, YsRadToDeg(eyeAtt.h()), YsRadToDeg(eyeAtt.p()), YsRadToDeg(eyeAtt.b())); BiClearScreen(); BiStartBuffer(&biEyePos); BiSetPoint(&cursor, pointOfInterest.x(), pointOfInterest.y(), pointOfInterest.z()); BiInsMarker(&cursor,&BiWhite,BIMK_CROSS); DrawSlashedPolygon(); DrawPolygon(4,q,blu,YSFALSE); DrawPolygon(4,r,blu,YSFALSE); DrawAxis(5.0); BiFlushBuffer(); BiSwapBuffers(); }
void Display(void) { double matBuf[4*4]; YsVec3 eyePos; YsMatrix4x4 eyeTfm; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); eyePos.Set(0.0,0.0,eyeDistance); eyePos=eyeAtt.GetMatrix()*eyePos; eyeTfm.Initialize(); eyeTfm.Translate(eyePos); eyeTfm.Rotate(eyeAtt); eyeTfm.Invert(); eyeTfm.Translate(-eyeLookAt); eyeTfm.GetArray(matBuf); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixd(matBuf); DrawSeparatablePair(nVtx,vtx); glFlush(); glutSwapBuffers(); }
void Display(void) { double matBuf[4*4]; YsVec3 eyePos; YsMatrix4x4 eyeTfm; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); eyePos.Set(0.0,0.0,eyeDistance); eyePos=eyeAtt.GetMatrix()*eyePos; eyeTfm.Initialize(); eyeTfm.Translate(eyePos); eyeTfm.Rotate(eyeAtt); eyeTfm.Invert(); eyeTfm.Translate(-eyeLookAt); eyeTfm.GetArray(matBuf); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixd(matBuf); DrawShell(sh1,blu,drawInPolygon); DrawShell(sh2,grn,drawInPolygon); DrawAxis(5.0); glFlush(); glutSwapBuffers(); }
void MoveShell(YsShell &sh,YsVec3 &mov) { YsMatrix4x4 mat,trn,viw,iViw; sh.GetMatrix(mat); viw=eyeAtt.GetMatrix(); iViw=viw; iViw.Invert(); trn.Initialize(); trn.Translate(mov); mat=viw*trn*iViw*mat; sh.SetMatrix(mat); }
void RotateShell(YsShell &sh,double pitch,double yaw) { YsMatrix4x4 mat,rot,viw,iViw; sh.GetMatrix(mat); viw=eyeAtt.GetMatrix(); iViw=viw; iViw.Invert(); rot.Initialize(); rot.RotateZY(pitch); rot.RotateXZ(yaw); mat=viw*rot*iViw*mat; sh.SetMatrix(mat); }
void Display(void) { double matBuf[4*4]; YsVec3 eyePos; YsMatrix4x4 eyeTfm; YsVec3 p; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); eyePos.Set(0.0,0.0,eyeDistance); eyePos=eyeAtt.GetMatrix()*eyePos; eyeTfm.Initialize(); eyeTfm.Translate(eyePos); eyeTfm.Rotate(eyeAtt); eyeTfm.Invert(); eyeTfm.Translate(-eyeLookAt); eyeTfm.GetArray(matBuf); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixd(matBuf); DrawAxis(5.0); glDisable(GL_LIGHTING); glColor3d(1.0,1.0,1.0); glBegin(GL_LINES); glVertex3d(0.0,0.0,0.0); glVertex3d(axisOfOrbit.x()*5.0,axisOfOrbit.y()*5.0,axisOfOrbit.z()*5.0); glEnd(); rot.RotatePositive(p,orbiter); glPushMatrix(); glTranslatef(p.x()*5.0,p.y()*5.0,p.z()*5.0); DrawCursor(); glPopMatrix(); glFlush(); glutSwapBuffers(); }