?
Solved

Camera Movement in OPENGL

Posted on 2005-05-10
6
Medium Priority
?
4,622 Views
Last Modified: 2013-12-04
Hi Auqa,

Below is my code for creation of walls and apply texture to it.All the methods below in the class are used to create the walls in a polygon grid (10 X 10) format.And also create a ambient light for Day and Night effect.Now the only thing i need to do i put in a camera so that the user can move only inside the room.

Sorry for my silly question.As i am not programmer basically and i am working in networking feild.And this is the first time i am using C++ and opengl.


#ifndef WIN32
#define WIN32
#endif
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>


// included to enable using of images
#include "textureclass.cpp"
#include "Camera.h"

    Camera view;

    // The below 2 vriables are for the rotation
    static GLfloat spin = 0.0;
    int ifFound=0;

       // Variable to enable and disable night mode.
   // nightMode - false, enables global ambient
   // nightMode - true, disables global ambient
   static bool nightMode = false;

   GLUquadric* quad;

   float xtmp;


   // The viewing position of the camera
   static GLdouble xPos = 0.0;
   static GLdouble yPos = 0.0;  
   static GLdouble zPos = 5.0;

   // Texture Maps are declared
   static Texture_Image wall_bmp;
   static Texture_Image bathRug_bmp;
   static Texture_Image bathDoor_bmp;
   static Texture_Image bathwalls_bmp;
   static Texture_Image bathceiling_bmp;


void draw_backwall(void)
{
      // Store all the Values of the vertices x,y,z and the diffenrce between the
        // first and the consecutive polygon.
      float x= 0.978024;
        float y= 1.00523;
        float z = 0;
      float diffy = 0.197046;
      float diffx = 0.196046;
      

      
       for(int i=1;i<=10;i++)
      {
            x= 0.978024;
            for(int j=1;j<=10;j++)
            {
                  glBegin (GL_POLYGON);
                  glVertex3f(x,y,z);
                  glVertex3f(x,y-diffy,z);
                  glVertex3f(x-diffx,y-diffy,z);
                  glVertex3f(x-diffx,y,z);
                  glEnd();
                  x=x-diffx;
            }
                        y=y-diffy;
      }
            
}


void draw_ceilingwall(void)
{
      // Store all the Values of the vertices x,y,z and the diffenrce between the
        // first and the consecutive polygon.
      float x= -0.982438;
        float y= 1.005;
        float z =  0.206816;
      float diffz = 0.197046;
      float diffx = -0.196046;

                      glBindTexture( GL_TEXTURE_2D, bathceiling_bmp.Get_Texture() );
                      float fwidth, fheight;            
                        int width, height;
                        bathceiling_bmp.Get_Fraction_Used ( &fwidth, &fheight);
                        glEnable(GL_TEXTURE_2D);
      
       for(int i=1;i<=10;i++)
      {
            x= -0.982438;
            for(int j=1;j<=10;j++)
            {
                                    
                  glBegin (GL_POLYGON);
                  glTexCoord2f(1.0f, 0.0f); glVertex3f(x-diffx,y,z);
                  glTexCoord2f(1.0f, 1.0f); glVertex3f(x-diffx,y,z-diffz);
                  glTexCoord2f(0.0f, 1.0f); glVertex3f(x,y,z-diffz);
                  glTexCoord2f(0.0f, 0.0f); glVertex3f(x,y,z);
                  glEnd();
                  x=x-diffx;
      
            }
                        z=z+diffz;
      }
                  glDisable(GL_TEXTURE_2D);            
}


void draw_floorwall(void)
{
      // Store all the Values of the vertices x,y,z and the diffenrce between the
        // first and the consecutive polygon.
 
      float x= -0.786392;
        float y= -0.97277;
        float z = 1.765194;
      float diffz = 0.197046;
      float diffx = 0.196046;
      


       for(int i=1;i<=10;i++)
      {
                  glBindTexture( GL_TEXTURE_2D, wall_bmp.Get_Texture() );
                      float fwidth, fheight;            
                        int width, height;
                        wall_bmp.Get_Fraction_Used ( &fwidth, &fheight);
                        glEnable(GL_TEXTURE_2D);      
            x= -0.786392;
            for(int j=1;j<=10;j++)
            {
                                    
                  glBegin (GL_POLYGON);
                  glTexCoord2f(1.0f, 0.0f); glVertex3f(x,y,z);
                  glTexCoord2f(1.0f, 1.0f); glVertex3f(x,y,z+diffz);
                  glTexCoord2f(0.0f, 1.0f); glVertex3f(x-diffx,y,z+diffz);
                  glTexCoord2f(0.0f, 0.0f); glVertex3f(x-diffx,y,z);
                  glEnd();
                  x=x+diffx;
      
            }
                        z=z-diffz;
            
      }
                  glDisable(GL_TEXTURE_2D);                  
}



void draw_rightwall(void)
{
      // Store all the Values of the vertices x,y,z and the diffenrce between the
        // first and the consecutive polygon.
   
      float x= 0.979804;
        float y= -0.768184;
        float z = 1.76026;
      float diffy = 0.197046;
      float diffz = -0.19605;
      
      glBindTexture( GL_TEXTURE_2D, bathwalls_bmp.Get_Texture() );
          float fwidth, fheight;
            int width, height;
            bathwalls_bmp.Get_Fraction_Used ( &fwidth, &fheight);
      glEnable(GL_TEXTURE_2D);
      
       for(int i=1;i<=10;i++)
      {
            z= 1.76026;
            for(int j=1;j<=10;j++)
            {
                                    
                  glBegin (GL_POLYGON);
                  glTexCoord2f(1.0f, 0.0f); glVertex3f(x,y,z);
                  glTexCoord2f(1.0f, 1.0f); glVertex3f(x,y-diffy,z);
                  glTexCoord2f(0.0f, 1.0f); glVertex3f(x,y-diffy,z-diffz);
                  glTexCoord2f(0.0f, 0.0f); glVertex3f(x,y,z-diffz);
                  glEnd();
                  z=z+diffz;
      
            }
                        y=y+diffy;
                  
      }
                  glDisable(GL_TEXTURE_2D);
}

void draw_leftwall(void)
{
      // Store all the Values of the vertices x,y,z and the diffenrce between the
        // first and the consecutive polygon.

      glBindTexture( GL_TEXTURE_2D, bathwalls_bmp.Get_Texture() );
          float fwidth, fheight;
            int width, height;
            bathwalls_bmp.Get_Fraction_Used ( &fwidth, &fheight);
      glEnable(GL_TEXTURE_2D);
 
   
      float x= -0.990528;
        float y= 1.00523;
        float z = -0.0160207;
      float diffy = 0.197046;
      float diffz = -0.1960457;
      
       for(int i=1;i<=10;i++)
      {
            z= -0.0160207;
            for(int j=1;j<=10;j++)
            {
                                    
                  glBegin (GL_POLYGON);
                  glTexCoord2f(1.0f, 0.0f); glVertex3f(x,y,z);
                  glTexCoord2f(1.0f, 1.0f); glVertex3f(x,y-diffy,z);
                  glTexCoord2f(0.0f, 1.0f); glVertex3f(x,y-diffy,z-diffz);
                  glTexCoord2f(0.0f, 0.0f); glVertex3f(x,y,z-diffz);
                  glEnd();
                  z=z-diffz;
      
            }
                        y=y-diffy;
      }
      glDisable(GL_TEXTURE_2D);
}

void draw_mat(void)
{

                        glBindTexture( GL_TEXTURE_2D, bathRug_bmp.Get_Texture() );
          float fwidth, fheight;
            int width, height;
            bathRug_bmp.Get_Fraction_Used ( &fwidth, &fheight);
                  glEnable(GL_TEXTURE_2D);
                  glBegin (GL_POLYGON);
                  glTexCoord2f(1.0f, 0.0f); glVertex3f(0.41,-0.96,0.05);
                  glTexCoord2f(1.0f, 1.0f); glVertex3f(0.95,-0.96,0.05);
                  glTexCoord2f(0.0f, 1.0f); glVertex3f(0.95,-0.96,0.38);
                  glTexCoord2f(0.0f, 0.0f); glVertex3f(0.41,-0.96,0.38);
                  glEnd();
                  glDisable(GL_TEXTURE_2D);
}

void draw_door(void)
{

                        glBindTexture( GL_TEXTURE_2D, bathDoor_bmp.Get_Texture() );
                            float fwidth, fheight;
                              int width, height;
                              bathDoor_bmp.Get_Fraction_Used ( &fwidth, &fheight);
                              glEnable(GL_TEXTURE_2D);
                  glBegin (GL_POLYGON);
                  glTexCoord2f(1.0f, 0.0f); glVertex3f(0.25,0.86,0.01);
                  glTexCoord2f(1.0f, 1.0f); glVertex3f(0.95,0.86,0.01);
                  glTexCoord2f(0.0f, 1.0f); glVertex3f(0.95,-0.96,0.01);
                  glTexCoord2f(0.0f, 0.0f); glVertex3f(0.25,-0.96,0.01);
                  glEnd();
                  glDisable(GL_TEXTURE_2D);
}

// method to setup the lighting
   void set_light ( void)
   {


        // controlling the ambient light
        GLfloat ambientVal;
        if(!nightMode)
              ambientVal = 2.0;
        else
                ambientVal = 0.2;

        GLfloat lmodel_ambient[] = {ambientVal,ambientVal,ambientVal, 1.0 };
        glClearColor(0.0,0.0,0.0,1.0);
        glShadeModel(GL_SMOOTH);

      // enable ambient light
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);

            glLightModeli ( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE );
      glLightModeli ( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );

       // enable all the lighting
        glEnable ( GL_LIGHTING ); // ambient
        glEnable (GL_DEPTH_TEST);
        glEnable(GL_COLOR_MATERIAL); // to enable proper transparency and color after the lighting
   }

void control(unsigned char key, int x, int y){
               Camera temp(view);
               Point a;
               
               //Point blah = temp.getLooking();
               switch(key){
                    //Strafe Left
                    case '7':
                         temp.strafe(1);
                         a.copy(temp.getLooking());
                         
                         break;
                    //Strafe Right
                    case '9':
                         temp.strafe(-1);
                         a.copy(temp.getLooking());
                         
                         break;
                    //Look up
                    case '8':
                         temp.pitch(1);
                         a.copy(temp.getLooking());              
                         break;
                    //Look down
                    case '5':
                         temp.pitch(-1);
                         a.copy(temp.getLooking());
                         break;
                    //Turn left
                    case '4':
                         temp.turn(1);
                         a.copy(temp.getLooking());
                         break;
                    //Turn right
                    case '6':
                         temp.turn(-1);
                         a.copy(temp.getLooking());
                         break;
                    //Move foreward
                    case '0':
                         temp.walk(1);
                         a.copy(temp.getLooking());
                         break;
                    //Move backward
                    case '1':
                         temp.walk(-1);
                         a.copy(temp.getLooking());
                         break;
                    case 'q':
                         temp.altitude(1);
                         break;
                    case 'a':
                         temp.altitude(-1);
                         break;
                    default:
                         break;
             }

                    bool x1 = false;
                temp.atLoc.setY(Collision::checkScene(temp.getAt()));
                    view.upd(temp,a,x1);
                    view.setStatic();
             glutPostRedisplay();
          }



void init(void)
{
     //glClearColor (.5,1,1,1); // Black is the Background
     glShadeModel (GL_SMOOTH); // The Shade Model is smooth , to create the reality.

      glClearColor (1,1,1, 1.0);
      glClearDepth (1.0);

     // set all the textures
      wall_bmp.Make_Std_Texture("wall_back.bmp",true,GL_BLEND);
      bathRug_bmp.Make_Std_Texture("bath_rug.bmp",true,GL_DECAL);
      bathDoor_bmp.Make_Std_Texture("bath_door.bmp",true,GL_DECAL);
      bathwalls_bmp.Make_Std_Texture("bath_walls.bmp",true,GL_DECAL);
      bathceiling_bmp.Make_Std_Texture("bath_walls.bmp",true,GL_DECAL);

      glShadeModel (GL_FLAT);
      quad = gluNewQuadric();
      glShadeModel (GL_SMOOTH);
}


void display(void)
{
      
     set_light(); // Call the light
      // clear colour and depth buffer(window)
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glLoadIdentity();
      glPushMatrix();
         

      // current position of viewer x,y,z
       gluLookAt ( xPos, yPos, zPos, 0., 0., 0., 0., 1.0, 0. );


      // Enabling depth testing
      glEnable (GL_DEPTH_TEST);
      
      
            glScalef(1.55,1.55,1.55);
      // Draw the Back Wall
      draw_backwall();

      // Draw the roof of the room.
      draw_ceilingwall();

      // Draw the floor of the wall
      draw_floorwall();

      // Draw the right Wall
      draw_rightwall();

      
        // Draw the left Wall
      draw_leftwall();
      
      // Draw the mat at the entrance
      draw_mat();
      
      // Draw the door the bathrroom
      draw_door();

   glutSwapBuffers();

}

   void reshape(int width, int height)
   {


           // Viewport is set to the same size of the window.
      glViewport (0, 0, (GLsizei) width, (GLsizei) height);

           // Sets the Matrix mode to Projection
      glMatrixMode(GL_PROJECTION);

      glLoadIdentity();

           // Program uses a perspective projection
      // Parameters: field of view (in angle degrees), aspect ratio, distance to near clipping plane,
      // distance to far cutoff plane

      gluPerspective(75.0, 1.0, 0.5, 1500.0);

           // Sets the Matrix mode to Modelview
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();

   }


   
  void keyboard(unsigned char key, int x, int y)
  {
      switch (key) {

       case 'o':
          nightMode = false;
          break;

       case 'O':
          nightMode = true;
          break;

           default:
            return;
            break;
       }
          glutPostRedisplay ();
  }

   int main(int argc, char** argv)
   {
      glutInit(&argc, argv);
      glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);            //set up window (double buffering, colour setup)
      glutInitWindowSize (700, 700);            // Set initial window size to 700 x 700
      glutInitWindowPosition (10, 10);      // Set initial window position of project
      glutCreateWindow (argv[0]);            // Create the application window

      init();

      glutDisplayFunc(display);

      glutKeyboardFunc(keyboard);
      glutReshapeFunc(reshape);

      glutMainLoop();
      return 0;
   }


Regards
Hari
0
Comment
Question by:srihari1986
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Andrew Beers
ID: 13987356
Ok... in your display you have this:

      // current position of viewer x,y,z
       gluLookAt ( xPos, yPos, zPos, 0., 0., 0., 0., 1.0, 0. );


Here is your explination of this... *winks*

gluLookAt(x_at_location, y_at_location, z_at_location,
0
 
LVL 10

Expert Comment

by:Andrew Beers
ID: 13987403
whoops... heh....  Lets try that one again.

gluLookAt(x_at_location, y_at_location, z_at_location,
               x_looking_at_location, y_looking_at_location, z_looking_at_location,
               x_direction_of_up, y_direction_of_up, z_direction_of_up);

The direction of up is around a 3d unit sphere, meaning 1.0 in a single direction means that is the direction of the camera's up.  Meaning you can twist the camera having a up direction of -1.0 of Y would mean having an upside down world.  Heh...  kinda cool and fun but... *shrugs* ...unless you are doing some racing or space game there is no point of using this.  Keep possative Y as the up direction for logical purposes.

Your camera class is following, then I'll give you the updates for everything else as well.

Post back in a second,

~Aqua
0
 
LVL 10

Accepted Solution

by:
Andrew Beers earned 2000 total points
ID: 13987726
Ok:  The camera class:

#include <glut.h>
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
//#include "Points.h"

//using namespace std;

class Camera{
   private:
            
            float currentLook;
            float currentPitch;

            static const float moveBy = 1.;
            static const float lookRadius = .5;
            static const float cameraHeight = 1.5;
            static const float PI = 3.1416;
            static const float yawn = PI / 32.0;
            static const float turnVal = PI / 32.0;
            static const float pitchMax = PI / 4.0;
            static const float pitchMin = -1.0 * PI / 4.0;

      public:

              Point atLoc;
            Point looking;

            //Default class constructor sets the camera position at
            //      0, cameraHeight, 0
            //      Sets the looking position to
            //      0 PI along the distance lookRadius
            Camera()
            {
                  float x, y, z;
                  currentLook = 0.0;
                  currentPitch = 0.0;

                  Point tLoc(0.0, cameraHeight, 0.0);
                  atLoc.copy(tLoc);
                  x = atLoc.getX() + cos(currentLook) * lookRadius;
                  y = atLoc.getY();
                  z = atLoc.getZ() + sin(currentLook) * lookRadius;
                  
                  Point tLook(x, y, z);
                  looking.copy(tLook);
            }

            //Class constructor takes in tempAt for camera location
            //      and the looking angle.
            //      +X Axis is 0 PI
            //      +Z Axis is 1/2 PI
            //      -X Axis is PI
            //      -Z Axis is 3/2 PI
            Camera(Point tempAt, float angle)
            {
                  float x, y, z;
                  currentLook = angle;
                  currentPitch = 0.0;

                  atLoc.copy(tempAt);
                  x = atLoc.getX() + cos(currentLook) * lookRadius;
                  y = atLoc.getY();
                  z = atLoc.getZ() + sin(currentLook) * lookRadius;
                  
                  Point tLook(x, y, z);
                  looking.copy(tLook);
            }

            //Copy Constructor
            //      Takes in a camera and assigns a new camera
            //      to be an identical copy of the camera passed in
            Camera(Camera &a)
            {
                  currentLook = a.currentLook;
                  currentPitch = a.currentPitch;
                  
                  atLoc.copy(a.atLoc);
                  looking.copy(a.looking);      
            }

            //Takes in a direction:
            //      1 - Increases the angle (aka CCW)
            //      -1 - Decreases the angle (aka CW)
            //      value of change is turn
            void turn(int dir){
                  float x, y, z;
                  if(dir == 1){
                        currentLook += turnVal;
                  }
                  else{
                        currentLook -= turnVal;
                  }

                  x = atLoc.getX() + sin(currentLook) * lookRadius;
                  y = looking.getY();
                  z = atLoc.getZ() + cos(currentLook) * lookRadius;
                  
                  Point tLook(x, y, z);
                  looking.copy(tLook);
            }

            //Takes in a direction:
            //      1 - Increases the angle - Y Axis (aka Up)
            //      -1 - Decreases the angle (aka down)
            //      value of change is pitch
            //      Constraints:      pitchMin <= currentPitch <= pitchMax
            void pitch(int dir){
                  float x, y, z;
                  if(dir == 1){
                        if(currentPitch <= pitchMax){
                              currentPitch += yawn;
                        }
                  }
                  else{
                        if(currentPitch >= pitchMin){
                              currentPitch -= yawn;
                        }
                  }
                  
                  y = atLoc.getY() + sin(currentPitch) * lookRadius;
                  looking.setY(y);
            }

            //Sets glu Camera with values stored in this instantiation
            void updateCamera()
            {
                  gluLookAt(atLoc.getX(), atLoc.getY(), atLoc.getZ(),
                        looking.getX(), looking.getY(), looking.getZ(),
                        0.0, 1.0, 0.0);

                  if(currentLook >= (2.0 * PI) ){
                        currentLook -= (2.0 * PI);
                  }
            }

            //Takes in a direction:
            //      1 is left
            //      -1 is right
            //      Moves by moveBy units
            void strafe(int dir){
                  Point strafeDir;
                  float x, y, z;
                  float dist;
                  if(dir == 1){
                  //Strafe left
                        x = atLoc.getX() + sin(currentLook + (PI / 2.0) ) * lookRadius;
                        z = atLoc.getZ() + cos(currentLook + (PI / 2.0) ) * lookRadius;
                        dist = moveBy;
                  }
                  else{
                  //Strafe right
                        x = atLoc.getX() + sin(currentLook + (PI / -2.0) ) * lookRadius;
                        z = atLoc.getZ() + cos(currentLook + (PI / -2.0) ) * lookRadius;
                        dist = moveBy;
                  }
                  Point sDir(x, y, z);
                  strafeDir.copy(sDir);
                  atLoc.setX(atLoc.getX() + dist * (strafeDir.getX() - atLoc.getX()) );
                  atLoc.setZ(atLoc.getZ() + dist * (strafeDir.getZ() - atLoc.getZ()) );

                  x = atLoc.getX() + sin(currentLook) * lookRadius;
                  y = looking.getY();
                  z = atLoc.getZ() + cos(currentLook) * lookRadius;

                  Point tLook(x, y, z);
                  looking.copy(tLook);
            }

            void altitude(int dir){
                  if(dir == 1){
                        looking.setY(looking.getY() + 1.0);
                        atLoc.setY(atLoc.getY() +1.0);
                  }
                  else{
                        looking.setY(looking.getY() - 1.0);
                        atLoc.setY(atLoc.getY() - 1.0);
                  }
            }      

      
            //Takes in a direction:
            //      1 is forward
            //      -1 is reverse
            //      Moves by moveBy units
            void walk(int dir){
                  float x, y, z;
                  float dist;
                  if(dir == 1){
                        dist = moveBy * 1.0;
                  }
                  else{
                        dist = moveBy * -1.0;
                  }

                  atLoc.setX(atLoc.getX() + dist * (looking.getX() - atLoc.getX()) );
                  atLoc.setZ(atLoc.getZ() + dist * (looking.getZ() - atLoc.getZ()) );

                  x = atLoc.getX() + sin(currentLook) * lookRadius;
                  y = looking.getY();
                  z = atLoc.getZ() + cos(currentLook) * lookRadius;

                  Point tLook(x, y, z);
                  looking.copy(tLook);
            }

            //Accessor for At Location
            //Stored in a Point class
            Point getAt(){ return atLoc; }

            //Accessor for Looking Location
            //Stored in a Point class
            Point getLooking() { return looking; }

            float getLookAngle() {return currentLook; }

            void setLook(Point a)
            {
                  looking.copy(a);
            }
            void setAt(Point a)
            {
                  atLoc.copy(a);
            }

};



You DO need my points class which is this:

class Point{
   private:
      float x;
      float y;
      float z;
   public:
      float pt[3];
      Point():x(0), y(0), z(0){/*Empty*/};
      Point(float xT, float yT, float zT):x(xT), y(yT), z(zT)
      {
         pt[0] = x;
         pt[1] = y;
         pt[2] = z;  
      }
        Point(const Point &a){
             x = a.x;
             y = a.y;
             z = a.z;
        }
      float getX(){return x;};
      float getY(){return y;};
      float getZ(){return z;};
      void setX(float xT){x = xT;};
      void setY(float yT){y = yT;};
      void setZ(float zT){z = zT;};
      void copy(Point a);      
};

void Point::copy(Point a)
{
   x = a.x;
   y = a.y;
   z = a.z;    
}

Then you need to add this into your keyboard switch case:

//Strafe Left
                        case '7':
                              view.strafe(1);
                              break;
                        //Strafe Right
                        case '9':
                              view.strafe(-1);                              
                              break;
                        //Look up
                        case '8':
                              view.pitch(1);                                                                                              break;
                        //Look down
                        case '5':
                              view.pitch(-1);
                              break;
                        //Turn left
                        case '4':
                              view.turn(1);
                              break;
                        //Turn right
                        case '6':
                              view.turn(-1);
                              break;
                        //Move foreward
                        case '0':
                              view.walk(1);
                              break;
                        //Move backward
                        case '1':
                              view.walk(-1);
                              break;
                        case 'q':
                              view.altitude(1);
                              break;
                        case 'a':
                              view.altitude(-1);
                              break;

Do away with that control function you copied from my player class, it doesn't work that way.  Then instead of your gluLookAt call in your display function you want view.updateCamera();

;-)

That should be everything you need, possibly some minor debugging to do because I dont have time to actually try to compile this and do it for you but that is the general idea.  For a networking guy never before using C++ and OpenGL you did pretty good.  :-P

If you have any problems ask away.

~Aqua
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:srihari1986
ID: 13992364
Aqua,

Really thanks for your help.will go home and do it.


Thanks
Hari
0
 

Author Comment

by:srihari1986
ID: 13997708
Hi Aqua,

Thanks for your wonderful timely help.Can you just tell me some info..How do i like make the camra default to center of the room.And also write a IF loop so that the user does not leave the room....

And how and where should  i write the IF loop and how should the i loop contructor be.

Regards
Hari
0
 
LVL 10

Expert Comment

by:Andrew Beers
ID: 13999896
Hari that is getting into a subject and topic called collision detection...  ;-)   ...You can use the distance from the line to the player can not become .5 or such... OR you can use your camera look at and the camera location within the camera class and make sure that those points never intersect a bounding line.  Feel free to ask about collision detection... although dave may just beat me to this one... he has a fair amount of knowledge on the subject...  You can also make it so you cannot intersect your objects either.  :-D

Plus you write your intersection equations before you update the camera or within the camera.

~Aqua
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question