moss-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Moss-devel] CVS: moss/3Dsia/client/3Dcf/src World.cxx,1.6,1.7 main.cxx


From: Felix Morgner <address@hidden>
Subject: [Moss-devel] CVS: moss/3Dsia/client/3Dcf/src World.cxx,1.6,1.7 main.cxx,1.5,1.6
Date: Sun, 02 Feb 2003 11:11:16 -0500

Update of /cvsroot/moss/moss/3Dsia/client/3Dcf/src
In directory subversions:/tmp/cvs-serv27253

Modified Files:
        World.cxx main.cxx 
Log Message:
Zooming doesn't work really


Index: World.cxx
===================================================================
RCS file: /cvsroot/moss/moss/3Dsia/client/3Dcf/src/World.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** World.cxx   10 Nov 2002 16:38:15 -0000      1.6
--- World.cxx   2 Feb 2003 16:11:13 -0000       1.7
***************
*** 39,51 ****
  CWorld::CWorld(int nParams, char* aszParams[])
    {
!   GLfloat afLP[] = {.0, .0, .0, 1.};     // light posiiton
    GLfloat afWL[] = {1.0, 1.0, 1.0, 1.0}; // withe light
    GLfloat afMA[] = {0.2,0.2,0.2,1};      // ambient material
    GLfloat afMP[] = {0.2, 0.2, 0.2, 1.0}; // specular material
  
!   m_afLightPosition    = afLP;
!   m_afWhiteLight       = afWL;
!   m_afMaterialAmbient  = afMA;
!   m_afMaterialSpecular = afMP;
  
    m_dXrot = .0;
--- 39,52 ----
  CWorld::CWorld(int nParams, char* aszParams[])
    {
! 
!   GLfloat afLP[] = {.0, .0, .0, 1.};     // light position
    GLfloat afWL[] = {1.0, 1.0, 1.0, 1.0}; // withe light
    GLfloat afMA[] = {0.2,0.2,0.2,1};      // ambient material
    GLfloat afMP[] = {0.2, 0.2, 0.2, 1.0}; // specular material
  
!   memcpy(m_afLightPosition, afLP, sizeof(afLP));
!   memcpy(m_afWhiteLight, afWL, sizeof(afWL));
!   memcpy(m_afMaterialAmbient, afMA, sizeof(afMA));
!   memcpy(m_afMaterialSpecular, afMP, sizeof(afMP));
  
    m_dXrot = .0;
***************
*** 127,131 ****
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
!   gluPerspective(45.0f,(GLfloat)nWidth/(GLfloat)nHeight,0.1f,100.0f);
    glMatrixMode(GL_MODELVIEW);
    } // void CWorld::ReSizeGLScene(int nWidht, int nHeight)
--- 128,132 ----
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
!   gluPerspective(45.0f,(GLfloat)m_nWidth/(GLfloat)m_nHeight,0.1f,100.0f);
    glMatrixMode(GL_MODELVIEW);
    } // void CWorld::ReSizeGLScene(int nWidht, int nHeight)
***************
*** 160,163 ****
--- 161,165 ----
    glPopMatrix();
  
+     DrawLabel(1, "Welcome to 3Dcf");
    // Creating the world cube
    // all entities have to be in them
***************
*** 245,250 ****
--- 247,335 ----
    } // void CWorld::KeyPressed(unsigned char key, int x, int y)
  
+ void CWorld::DrawLabel(int row, string sLabel)
+   {
+   double scalefactor = 0.003;
+   GLfloat z = (row * 30.0/20) + .8;
+   
+   glPushMatrix();
+   glTranslatef(-1.5, 1.5, z);
+   glScalef(scalefactor, scalefactor, 1);
+   glColor3f(1.0f, .3f, 0.2f);
+   for(string::const_iterator i = sLabel.begin(); i != sLabel.end(); i++)
+     {
+     glutStrokeCharacter(GLUT_STROKE_ROMAN, *i);
+     glTranslatef(glutStrokeWidth(GLUT_STROKE_ROMAN, *i) * 1.1 *scalefactor, 
0, 0);
+     }
+   glPopMatrix();
+   } // void CWorld::DrawLabel(int row, string label)
+ 
  void CWorld::MouseFunction(int nButton, int nStatus, int x, int y)
    {
+ 
+   if(nButton == GLUT_LEFT_BUTTON && nStatus == GLUT_DOWN)
+     {
+     nFirst = 1;
+     glutSetCursor(GLUT_CURSOR_CYCLE);
+     nMouseX = x;
+     nMouseY = y;
+     }
+   else if(nButton == GLUT_LEFT_BUTTON && nStatus == GLUT_UP)
+     {
+     glutSetCursor(GLUT_CURSOR_INHERIT);
+     }
+   
+   if(nButton == GLUT_MIDDLE_BUTTON && nStatus == GLUT_DOWN)
+     {
+     glutSetCursor(GLUT_CURSOR_UP_DOWN);
+     nZooming = 1;
+     nMouseZ = y - 3 * 9;
+     }
+   else if(nButton == GLUT_MIDDLE_BUTTON && nStatus == GLUT_UP)
+     {
+     glutSetCursor(GLUT_CURSOR_INHERIT);
+     }
+ 
+ /*  else if(nButton == 0 && nStatus == 1)
+     {
+     nDragging = 0;
+     glutSetCursor(GLUT_CURSOR_INHERIT);
+     }
+   if(nButton == 1 && nStatus == 0)
+     {
+     nFirst = nZooming = 1;
+     glutSetCursor(GLUT_CURSOR_UP_DOWN);
+     }
+   else if(nButton == 1 && nStatus  == 1)
+     {
+     nZooming = 0;
+     glutSetCursor(GLUT_CURSOR_INHERIT);
+     }
+ */
+     
    glutPostRedisplay();
    } // void CWorld::MouseFunction(int nButton, int nStatus, int x, int y)
+ 
+ void CWorld::MouseMotion(int x, int y)
+   {
+   if(nFirst == 1)
+     {
+     m_dXrot = m_dXrot - (y - nMouseY);
+     m_dYrot = m_dYrot - (x - nMouseX);
+     
+     nMouseX = x;
+     nMouseY = y;
+     
+     glutPostRedisplay();
+     }
+     
+   if(nZooming == 1)
+     {
+     glMatrixMode(GL_PROJECTION);
+     glLoadIdentity();
+     gluPerspective(45.f, (GLfloat)m_nWidth/(GLfloat)m_nHeight, .1f, 100.f);
+     gluLookAt(2, 2, nMouseZ/6, 0, 0, 0, 0, 1, 0);
+     glMatrixMode(GL_MODELVIEW);
+     
+     glutPostRedisplay();
+     }
+   } // void CWorld::MouseMotion(int x, int y)

Index: main.cxx
===================================================================
RCS file: /cvsroot/moss/moss/3Dsia/client/3Dcf/src/main.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** main.cxx    10 Nov 2002 16:38:15 -0000      1.5
--- main.cxx    2 Feb 2003 16:11:13 -0000       1.6
***************
*** 39,43 ****
  CWorld* g_poWorld = 0;
  
- 
  void DrawScene()
    {
--- 39,42 ----
***************
*** 65,68 ****
--- 64,73 ----
    }
  
+ void MouseMotion(int x, int y)
+   {
+   if (g_poWorld == 0) return;
+   g_poWorld->MouseMotion(x, y);
+   }
+ 
  int main(int nParams, char* aszParams[])
    {
***************
*** 77,81 ****
    glutIdleFunc(Idle);
    glutKeyboardFunc(KeyPressed);
! //  glutMouseFunc(MouseFunction);
  
    g_poWorld->InitGL(800, 600, true);
--- 82,87 ----
    glutIdleFunc(Idle);
    glutKeyboardFunc(KeyPressed);
!   glutMouseFunc(MouseFunction);
!   glutMotionFunc(MouseMotion);
  
    g_poWorld->InitGL(800, 600, true);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]