Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4597 in orxonox.OLD for orxonox/trunk/src/world_entities


Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

Location:
orxonox/trunk/src/world_entities
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/environment.cc

    r4490 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616*/
    1717
     
    3131Environment::Environment () : WorldEntity()
    3232{
    33 
     33  this->setClassID(CL_ENVIRONMENT, "Environment");
    3434}
    3535
     
    3838   \brief deletes an environment
    3939*/
    40 Environment::~Environment () 
     40Environment::~Environment ()
    4141{
    4242
     
    6767   \brief draws the Environment
    6868*/
    69 void Environment::draw () 
     69void Environment::draw ()
    7070{
    7171  //this->getRelCoor().debug();
     
    7474  glPushMatrix();
    7575  float matrix[4][4];
    76  
     76
    7777  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    7878  //rotate
    7979  this->getAbsDir().matrix (matrix);
    8080  glMultMatrixf((float*)matrix);
    81  
     81
    8282  this->model->draw();
    8383
  • orxonox/trunk/src/world_entities/npc.cc

    r3472 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    2727
    2828
    29 NPC::NPC()
    30   : WorldEntity()
     29NPC::NPC() : WorldEntity()
    3130{
     31  this->setClassID(CL_NPC, "NPC");
    3232  hasDied = 0;
    3333}
     
    4141}
    4242
    43 void NPC::getPosition(float* x, float* y, float* z) 
     43void NPC::getPosition(float* x, float* y, float* z)
    4444{
    45   *x = xCor; 
    46   *y = yCor; 
     45  *x = xCor;
     46  *y = yCor;
    4747  *z = zCor;
    4848}
    4949
    50 void NPC::setCollisionRadius(float r) 
     50void NPC::setCollisionRadius(float r)
    5151{
    5252  collisionRadius = r;
    5353}
    5454
    55 float NPC::getCollisionRadius() 
     55float NPC::getCollisionRadius()
    5656{
    5757  return collisionRadius;
     
    6464void NPC::paint()
    6565{
    66   //cout << "WorldEntity::WorldEntity();" << endl; 
     66  //cout << "WorldEntity::WorldEntity();" << endl;
    6767  /* fix: died flag approach is very stupid, just to show @ convention */
    6868  if( hasDied == 0 ) {
     
    7575}
    7676
    77 void NPC::drawNPC() 
     77void NPC::drawNPC()
    7878{
    7979
  • orxonox/trunk/src/world_entities/player.cc

    r4592 r4597  
    4949  */
    5050  this->setClassID(CL_PLAYER, "Player");
     51
    5152  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
    5253  travelSpeed = 15.0;
     
    9091{
    9192  this->setClassID(CL_PLAYER, "Player");
     93
    9294  this->weapons = new tList<Weapon>();
    9395  this->activeWeapon = NULL;
  • orxonox/trunk/src/world_entities/power_up.cc

    r3483 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    2424
    2525
    26 PowerUp::PowerUp () {}
     26PowerUp::PowerUp ()
     27{
     28  this->setClassID(CL_POWER_UP, "PowerUp");
     29}
    2730
    2831
  • orxonox/trunk/src/world_entities/projectile.cc

    r4464 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616*/
    1717
     
    3434{
    3535  this->setClassID(CL_PROJECTILE, "Projectile");
     36
    3637  this->weapon = weapon;
    3738  this->flightDirection = NULL;
     
    4546   \brief standard deconstructor
    4647*/
    47 Projectile::~Projectile () 
     48Projectile::~Projectile ()
    4849{
    49   /* 
    50      do not delete the test projectModel, since it is pnode 
    51      and will be cleaned out by world 
     50  /*
     51     do not delete the test projectModel, since it is pnode
     52     and will be cleaned out by world
    5253  */
    5354  //delete this->projectileModel;
     
    110111   \param time since last tick
    111112*/
    112 void Projectile::tick (float time) 
     113void Projectile::tick (float time)
    113114{
    114115  Vector v = this->velocity * (time);
     
    131132   \param place where it is hit
    132133*/
    133 void Projectile::hit (WorldEntity* entity, Vector* place) 
     134void Projectile::hit (WorldEntity* entity, Vector* place)
    134135{}
    135136
     
    138139   \brief the function gets called, when the projectile is destroyed
    139140*/
    140 void Projectile::destroy () 
     141void Projectile::destroy ()
    141142{}
    142143
    143144
    144 void Projectile::draw () 
     145void Projectile::draw ()
    145146{
    146147  glMatrixMode(GL_MODELVIEW);
    147148  glPushMatrix();
    148149
    149   float matrix[4][4]; 
     150  float matrix[4][4];
    150151  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    151152  this->getAbsDir().matrix (matrix);
    152   glMultMatrixf((float*)matrix); 
     153  glMultMatrixf((float*)matrix);
    153154  this->model->draw();
    154155
  • orxonox/trunk/src/world_entities/projectile.h

    r4464 r4597  
    1 /*! 
     1/*!
    22    \projectile.h
    33    \brief a projectile, that is been shooted by a weapon
    44
    55    You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the
    6     shooting funcions work, use the Projectile class. But if you want to implement your own shoots its 
     6    shooting funcions work, use the Projectile class. But if you want to implement your own shoots its
    77    different:<br>
    88    Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions
     
    1010    - void draw()
    1111    - void hit() (only if you have working collision detection)
    12     When you have implemented these functions you have just to add the projectiles to your weapon. You ll want 
    13     to make this by looking into the function 
     12    When you have implemented these functions you have just to add the projectiles to your weapon. You ll want
     13    to make this by looking into the function
    1414    - Weapon::fire()
    1515    there you just change the line:
     
    2727class Weapon;
    2828
    29 class Projectile : public WorldEntity 
     29class Projectile : public WorldEntity
    3030{
    3131  friend class World;
     
    4848 protected:
    4949  //physical attriutes like: force, speed, acceleration etc.
    50   float speed;                         //!< this is the speed of the projectile
    51   float currentLifeTime;               //!< this is the time, the projectile exists in this world (incremented by tick)
    52   float ttl;                           //!< time to life, after this time, the projectile will garbage collect itself
    53   Vector* flightDirection;             //!< direction in which the shoot flights
    54   Weapon* weapon;                      //!< weapon the shoot belongs to
    55  
    56   Vector velocity;                     //!< velocity of the projectile
    57   Vector offsetVel;                    //!< offset velocity TEMP
     50  float          speed;                     //!< this is the speed of the projectile
     51  float          currentLifeTime;           //!< this is the time, the projectile exists in this world (incremented by tick)
     52  float          ttl;                       //!< time to life, after this time, the projectile will garbage collect itself
     53  Vector*        flightDirection;           //!< direction in which the shoot flights
     54  Weapon*        weapon;                    //!< weapon the shoot belongs to
     55
     56  Vector         velocity;                  //!< velocity of the projectile
     57  Vector         offsetVel;                 //!< offset velocity TEMP
    5858};
    5959
  • orxonox/trunk/src/world_entities/satellite.cc

    r4320 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616*/
    1717
     
    3232{
    3333  this->setClassID(CL_SATELLITE, "Satellite");
     34
    3435  this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);
    3536  this->speed = speed;
     
    5253   \brief this method is called every frame
    5354   \param time: the time in seconds that has passed since the last tick
    54    
     55
    5556   Handle all stuff that should update with time inside this method (movement, animation, etc.)
    5657*/
    57 void Satellite::tick(float time) 
     58void Satellite::tick(float time)
    5859{
    5960  float w = this->speed * M_PI;
    6061
    61   Quaternion rotation(w * time, *this->axis); 
     62  Quaternion rotation(w * time, *this->axis);
    6263  Quaternion v = this->getRelDir();
    63  
     64
    6465  this->setRelDir(v * rotation);
    6566}
     
    6869/**
    6970   \brief the entity is drawn onto the screen with this function
    70    
     71
    7172   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    7273*/
    73 void Satellite::draw() 
     74void Satellite::draw()
    7475{
    7576  glMatrixMode(GL_MODELVIEW);
    7677  glPushMatrix();
    7778  float matrix[4][4];
    78  
     79
    7980  /* translate */
    80   glTranslatef (this->getAbsCoor ().x, 
    81                 this->getAbsCoor ().y,
    82                 this->getAbsCoor ().z);
     81  glTranslatef (this->getAbsCoor ().x,
     82                this->getAbsCoor ().y,
     83                this->getAbsCoor ().z);
    8384  /* rotate */
    8485  this->getAbsDir ().matrix (matrix);
    8586  glMultMatrixf((float*)matrix);
    86  
     87
    8788  this->model->draw();
    8889  glPopMatrix();
  • orxonox/trunk/src/world_entities/satellite.h

    r3750 r4597  
    1 /*! 
     1/*!
    22    \file world_entity.h
    33    \brief Definition of the basic WorldEntity
     
    1818//! Basic class from which all interactive stuff in the world is derived from
    1919class Satellite : public WorldEntity
    20 {       
     20{
    2121  friend class World;
    2222
     
    2727  virtual void draw ();
    2828  virtual void tick (float time);
    29  
     29
    3030 private:
    31   Vector* axis;
    32   float speed;
    33  
     31  Vector*       axis;
     32  float         speed;
     33
    3434
    3535};
  • orxonox/trunk/src/world_entities/skybox.cc

    r4444 r4597  
    11
    2 /* 
     2/*
    33   orxonox - the future of 3D-vertical-scrollers
    44
     
    6868{
    6969  this->setClassID(CL_SKYBOX, "SkyBox");
     70
    7071  this->skyModel = NULL;
    7172  this->material = new Material*[6];
    72   for (int i = 0; i < 6; i++) 
     73  for (int i = 0; i < 6; i++)
    7374    {
    7475      this->material[i] = new Material();
     
    104105   usage: give this function an argument like
    105106   setTexture("skybox", "jpg");
    106    and it will convert this to 
     107   and it will convert this to
    107108   setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg",
    108109               "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg");
     
    123124  sprintf(front, "%s_front.%s", name, extension);
    124125  sprintf(back, "%s_back.%s", name, extension);
    125  
     126
    126127  this->setTextures(top, bottom, left, right, front, back);
    127128
     
    180181/**
    181182   \brief rebuilds the SkyBox
    182    
     183
    183184   this must be done, when changing the Size of the Skybox (runtime-efficency)
    184185*/
     
    189190  skyModel = new Model();
    190191
    191   this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 
     192  this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size);
    192193  this->skyModel->addVertex (0.5*size, -0.5*size, 0.5*size);
    193194  this->skyModel->addVertex (-0.5*size, 0.5*size, 0.5*size);
     
    222223  this->skyModel->setMaterial(material[5]);
    223224  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
    224  
     225
    225226  this->skyModel->finalize();
    226227}
  • orxonox/trunk/src/world_entities/skybox.h

    r4261 r4597  
    1 /*! 
     1/*!
    22    \file skybox.h
    33    \brief Definition of the SkyBox, that handles the Display of an atmosphere for orxonox.
     
    4343  void rebuild();
    4444
    45   Model* skyModel;        //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.
    46   Material **material;    //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
    47   float size;             //!< Size of the SkyBox. This should match the frustum maximum range.
    48    
     45  Model*          skyModel;        //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.
     46  Material**      material;        //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
     47  float           size;            //!< Size of the SkyBox. This should match the frustum maximum range.
     48
    4949};
    5050
  • orxonox/trunk/src/world_entities/skysphere.cc

    r4444 r4597  
    11
    2 /* 
     2/*
    33   orxonox - the future of 3D-vertical-scrollers
    44
     
    1313   main-programmer: David Gruetter
    1414   co-programmer: Benjamin Grauer
    15    
    16    Created by Dave: this file is actually quite similar to player.cc and so is 
     15
     16   Created by Dave: this file is actually quite similar to player.cc and so is
    1717   skybox.h similar to player.h
    1818   With that said, things should be clear:)
    19    
     19
    2020   Edited:
    2121   Bensch: more constructors, changeability, comments...
     
    4343Skysphere::Skysphere(char* fileName)
    4444{
     45  this->setClassID(CL_SKYSPHERE, "SkySphere");
     46
    4547  if (fileName == NULL)
    4648    this->initialize("pictures/sky-replace.jpg");
     
    9294/**
    9395   \brief draws the Skysphere
    94    
     96
    9597   This part is normally precessed in the "Painting Phase".
    9698*/
     
    105107  //glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
    106108  //glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
    107  
     109
    108110  skyMaterial->select();
    109111  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
  • orxonox/trunk/src/world_entities/skysphere.h

    r3763 r4597  
    1 /*! 
     1/*!
    22    \file skysphere.h
    33    \brief Definition of the Skysphere, that handles the Display of an atmosphere of orxonox.
     
    3434  virtual void draw();
    3535
    36  private:
    37   GLUquadricObj *sphereObj; //!< A Placeholder for the SkySphere.
    38   Material *skyMaterial;    //!< A Material for the SkySphere.
    39   float sphereRadius;       //!< Radius of the SkySphere. This should match the frustum maximum range.
    40    
    41   void initialize(char* fileName); 
     36  private:
     37    void initialize(char* fileName);
     38
     39 private:
     40  GLUquadricObj*    sphereObj;           //!< A Placeholder for the SkySphere.
     41  Material*         skyMaterial;         //!< A Material for the SkySphere.
     42  float             sphereRadius;        //!< Radius of the SkySphere. This should match the frustum maximum range.
    4243};
    4344
  • orxonox/trunk/src/world_entities/terrain.cc

    r4320 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2828
    2929*/
    30 Terrain::Terrain () 
     30Terrain::Terrain ()
    3131{
    3232  this->init();
     
    3636   \brief Constructor for loading a Terrain out of a file
    3737   \param fileName The file to load data from.
    38  
     38
    3939   this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found.
    4040*/
    41 Terrain::Terrain(char* fileName)
     41Terrain::Terrain(const char* fileName)
    4242{
    4343  this->init();
     
    6868
    6969*/
    70 Terrain::~Terrain () 
     70Terrain::~Terrain ()
    7171{
    7272  if (objectList)
     
    7878{
    7979  this->setClassID(CL_TERRAIN, "Terrain");
     80
    8081  this->objectList = 0;
    8182}
     
    8485
    8586void Terrain::draw ()
    86 { 
     87{
    8788  glMatrixMode(GL_MODELVIEW);
    8889  glPushMatrix();
    8990  float matrix[4][4];
    90  
     91
    9192  /* translate */
    92   glTranslatef (this->getAbsCoor ().x, 
    93                 this->getAbsCoor ().y,
    94                 this->getAbsCoor ().z);
     93  glTranslatef (this->getAbsCoor ().x,
     94                this->getAbsCoor ().y,
     95                this->getAbsCoor ().z);
    9596  /* rotate */
    9697  this->getAbsDir ().matrix (matrix);
     
    112113      objectList = glGenLists(1);
    113114      glNewList (objectList, GL_COMPILE);
    114      
     115
    115116      glColor3f(1.0,0,0);
    116      
     117
    117118      int sizeX = 100;
    118119      int sizeZ = 80;
     
    121122      float widthX = float (length /sizeX);
    122123      float widthZ = float (width /sizeZ);
    123      
     124
    124125      float height [sizeX][sizeZ];
    125126      Vector normal_vectors[sizeX][sizeZ];
    126      
    127      
     127
     128
    128129      for ( int i = 0; i<sizeX-1; i+=1)
    129         for (int j = 0; j<sizeZ-1;j+=1)
    130           //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
     130        for (int j = 0; j<sizeZ-1;j+=1)
     131          //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
    131132#ifdef __WIN32__
    132           height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
     133          height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
    133134#else
    134135      height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
    135136#endif
    136      
     137
    137138      //Die Huegel ein wenig glaetten
    138139      for (int h=1; h<2;h++)
    139         for (int i=1;i<sizeX-2 ;i+=1 )
    140           for(int j=1;j<sizeZ-2;j+=1)
    141             height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
    142      
     140        for (int i=1;i<sizeX-2 ;i+=1 )
     141          for(int j=1;j<sizeZ-2;j+=1)
     142            height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
     143
    143144      //Berechnung von normalen Vektoren
    144145      for(int i=1;i<sizeX-2;i+=1)
    145         for(int j=1;j<sizeZ-2 ;j+=1)
    146           {
    147             Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
    148             Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
    149             Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
    150             Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
    151             Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
    152            
    153             Vector c1 = v2 - v1;
    154             Vector c2 = v3 - v1;
    155             Vector c3=  v4 - v1;
    156             Vector c4 = v5 - v1;
    157             Vector zero = Vector (0,0,0);
    158             normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
    159             normal_vectors[i][j].normalize();
    160           }
    161      
     146        for(int j=1;j<sizeZ-2 ;j+=1)
     147          {
     148            Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
     149            Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
     150            Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
     151            Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
     152            Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
     153
     154            Vector c1 = v2 - v1;
     155            Vector c2 = v3 - v1;
     156            Vector c3=  v4 - v1;
     157            Vector c4 = v5 - v1;
     158            Vector zero = Vector (0,0,0);
     159            normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
     160            normal_vectors[i][j].normalize();
     161          }
     162
    162163      glBegin(GL_QUADS);
    163164      int snowheight=3;
    164165      for ( int i = 0; i<sizeX; i+=1)
    165         for (int j = 0; j<sizeZ;j+=1)
    166           {       
    167             Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
    168             Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
    169             Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
    170             Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
    171             float a[3];
    172             if(height[i][j]<snowheight){
    173               a[0]=0;
    174               a[1]=1.0-height[i][j]/10-.3;
    175               a[2]=0;
    176               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    177             }
    178             else{
    179               a[0]=1.0;
    180               a[1]=1.0;
    181               a[2]=1.0;
    182               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    183              
    184             }
    185             glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
    186             glVertex3f(v1.x, v1.y, v1.z);
    187             if(height[i+1][j]<snowheight){
    188               a[0]=0;
    189               a[1] =1.0-height[i+1][j]/10-.3;
    190               a[2]=0;
    191               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    192             }
    193             else{
    194               a[0]=1.0;
    195               a[1]=1.0;
    196               a[2]=1.0;
    197               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    198              
    199             }
    200             glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
    201             glVertex3f(v2.x, v2.y, v2.z);
    202             if(height[i+1][j+1]<snowheight){
    203               a[0]=0;
    204               a[1] =1.0-height[i+1][j+1]/10-.3;
    205               a[2]=0;
    206               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    207             }
    208             else{
    209               a[0]=1.0;
    210               a[1]=1.0;
    211               a[2]=1.0;
    212               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    213              
    214              
    215             }
    216             glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
    217             glVertex3f(v3.x, v3.y, v3.z);
    218             if(height[i][j+1]<snowheight){
    219               a[0]=0;
    220               a[1] =1.0-height[i+1][j+1]/10-.3;
    221               a[2]=0;
    222               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    223             }
    224             else{
    225               a[0]=1.0;
    226               a[1]=1.0;
    227               a[2]=1.0;
    228               glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
    229             }
    230             glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
    231             glVertex3f(v4.x, v4.y, v4.z);
    232            
    233           }
     166        for (int j = 0; j<sizeZ;j+=1)
     167          {
     168            Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
     169            Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
     170            Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
     171            Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
     172            float a[3];
     173            if(height[i][j]<snowheight){
     174              a[0]=0;
     175              a[1]=1.0-height[i][j]/10-.3;
     176              a[2]=0;
     177              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     178            }
     179            else{
     180              a[0]=1.0;
     181              a[1]=1.0;
     182              a[2]=1.0;
     183              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     184
     185            }
     186            glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
     187            glVertex3f(v1.x, v1.y, v1.z);
     188            if(height[i+1][j]<snowheight){
     189              a[0]=0;
     190              a[1] =1.0-height[i+1][j]/10-.3;
     191              a[2]=0;
     192              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     193            }
     194            else{
     195              a[0]=1.0;
     196              a[1]=1.0;
     197              a[2]=1.0;
     198              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     199
     200            }
     201            glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
     202            glVertex3f(v2.x, v2.y, v2.z);
     203            if(height[i+1][j+1]<snowheight){
     204              a[0]=0;
     205              a[1] =1.0-height[i+1][j+1]/10-.3;
     206              a[2]=0;
     207              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     208            }
     209            else{
     210              a[0]=1.0;
     211              a[1]=1.0;
     212              a[2]=1.0;
     213              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     214
     215
     216            }
     217            glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
     218            glVertex3f(v3.x, v3.y, v3.z);
     219            if(height[i][j+1]<snowheight){
     220              a[0]=0;
     221              a[1] =1.0-height[i+1][j+1]/10-.3;
     222              a[2]=0;
     223              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     224            }
     225            else{
     226              a[0]=1.0;
     227              a[1]=1.0;
     228              a[2]=1.0;
     229              glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
     230            }
     231            glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
     232            glVertex3f(v4.x, v4.y, v4.z);
     233
     234          }
    234235      glEnd();
    235236      glEndList();
     
    239240    {
    240241      /*
    241         this->model = (OBJModel*) new Model();
     242        this->model = (OBJModel*) new Model();
    242243      this->model->setName("CUBE");
    243244      this->model->addVertex (-0.5, -0.5, 0.5);
     
    249250      this->model->addVertex (-0.5, -0.5, -0.5);
    250251      this->model->addVertex (0.5, -0.5, -0.5);
    251      
     252
    252253      this->model->addVertexTexture (0.0, 0.0);
    253254      this->model->addVertexTexture (1.0, 0.0);
     
    268269      */
    269270    }
    270  
    271 }
     271
     272}
  • orxonox/trunk/src/world_entities/terrain.h

    r3566 r4597  
    1 /*! 
     1/*!
    22    \file terrain.h
    33    \brief Defines and handles the terrain of the World
     
    2020
    2121//! A Class to handle Terrain of orxonox
    22 class Terrain : public WorldEntity 
     22class Terrain : public WorldEntity
    2323{
    2424
    2525 public:
    2626  Terrain();
    27   Terrain(char* fileName);
     27  Terrain(const char* fileName);
    2828  Terrain(DebugTerrain debugTerrain);
    2929  virtual ~Terrain();
    3030  void init();
    31  
     31
    3232  void buildDebugTerrain(DebugTerrain debugTerrain);
    3333  virtual void draw();
  • orxonox/trunk/src/world_entities/test_bullet.cc

    r4593 r4597  
    3434{
    3535  this->setClassID(CL_TEST_BULLET, "TestBullet");
     36
    3637  float modelSize = .5;
    3738  this->model = (Model*)ResourceManager::getInstance()->load("models/Rocket1.obj", OBJ, RP_LEVEL, (void*) &modelSize);
  • orxonox/trunk/src/world_entities/test_gun.cc

    r4592 r4597  
    4343   creates a new weapon
    4444*/
    45 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight)
     45TestGun::TestGun (PNode* parent, const Vector& coordinate,
     46                  const Quaternion& direction, int leftRight)
    4647  :  Weapon (parent, coordinate, direction)
    4748{
    4849  this->setClassID(CL_TEST_GUN, "TestGun");
     50
    4951  this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    5052  this->idleTime = 0.2f;
  • orxonox/trunk/src/world_entities/weapon.cc

    r4000 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616*/
    1717
     
    3535   \param number of weapon slots of the model/ship <= 8 (limitied)
    3636*/
    37 WeaponManager::WeaponManager(int nrOfSlots)
    38 {
     37WeaponManager::WeaponManager(int nrOfSlots)
     38{
     39  this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
     40
    3941  for(int i = 0; i < W_MAX_CONFIGS; ++i)
    4042    {
    4143      this->configs[i].bUsed = false;
    4244      for(int j = 0; j < W_MAX_SLOTS; ++j)
    43         this->configs[i].slots[j] = NULL;
     45        this->configs[i].slots[j] = NULL;
    4446    }
    4547  this->nrOfSlots = nrOfSlots;
     
    4850
    4951
    50 WeaponManager::~WeaponManager() 
    51 {
    52   /* 
    53      i dont have to delete the weapons itself, because they are 
     52WeaponManager::~WeaponManager()
     53{
     54  /*
     55     i dont have to delete the weapons itself, because they are
    5456     worldentities and therefore in the entities list of the world.
    5557     world will clean them up for me
     
    5961      this->configs[i].bUsed = false;
    6062      for(int j = 0; j < W_MAX_SLOTS; ++j)
    61         this->configs[i].slots[j] = NULL;
     63        this->configs[i].slots[j] = NULL;
    6264    }
    6365}
     
    7274   if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be
    7375   replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free
    74    slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 
     76   slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be
    7577   a error message.
    7678*/
    77 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 
     79void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    7880{
    7981  if( slotID == W_FREE_SLOT)
     
    8183      int freeSlot = this->getNextFreeSlot( configID);
    8284      if( freeSlot < 0 || freeSlot >= this->nrOfSlots)
    83         {
    84           PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
    85           return;
    86         }
     85        {
     86          PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
     87          return;
     88        }
    8789      PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot);
    8890      this->configs[configID].bUsed = true;
     
    108110   this function will deactivate the weapons first, change the config and reactivate them later
    109111*/
    110 void WeaponManager::nextWeaponConf() 
     112void WeaponManager::nextWeaponConf()
    111113{
    112114  PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID);
     
    116118  for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
    117119  if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0;
    118   else this->currConfID = i; 
    119 
    120  
     120  else this->currConfID = i;
     121
     122
    121123  Weapon *w1, *w2;
    122124  for(int j = 0; j < W_MAX_SLOTS; ++j)
     
    124126      w1 = this->configs[lastConfID].slots[j];
    125127      w2 = this->configs[this->currConfID].slots[j];
    126      
     128
    127129      if( w1 == w2)
    128         {
    129           printf("no need for change\n");
    130         }
     130        {
     131          printf("no need for change\n");
     132        }
    131133      else
    132         {
    133         if( w1 != NULL )
    134           {
    135             w1->deactivate();
    136             printf("deactivating %i,%i\n", j,lastConfID);
    137           }
    138         if( w2 != NULL)
    139           {
    140             w2->activate();
    141             printf("activating %i,%i\n", j, this->currConfID);
    142           }
    143         }
     134        {
     135        if( w1 != NULL )
     136          {
     137            w1->deactivate();
     138            printf("deactivating %i,%i\n", j,lastConfID);
     139          }
     140        if( w2 != NULL)
     141          {
     142            w2->activate();
     143            printf("activating %i,%i\n", j, this->currConfID);
     144          }
     145        }
    144146    }
    145147}
     
    199201    {
    200202      if( this->configs[configID].slots[i] == NULL)
    201         return i;
     203        return i;
    202204    }
    203205  return -1;
     
    214216   creates a new weapon
    215217*/
    216 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 
     218Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction)
    217219  : WorldEntity()
    218220{
     
    236238   \brief standard deconstructor
    237239*/
    238 Weapon::~Weapon () 
     240Weapon::~Weapon ()
    239241{
    240242  // model will be deleted from WorldEntity-destructor
    241243  //this->worldEntities = NULL;
    242  
     244
    243245  /* dont delete objectComponentsX here, they will be killed when the pnodes are cleaned out */
    244246
     
    247249
    248250
    249 /** 
     251/**
    250252    \brief enables the weapon
    251253
    252     a weapon can be enabled/disabled because of various reasons. if a weapon is 
     254    a weapon can be enabled/disabled because of various reasons. if a weapon is
    253255    been enabled, it can interact in a world. elswhere it wont react to any
    254256    action.
     
    260262
    261263
    262 /** 
     264/**
    263265    \brief disables the weapon
    264266
    265     a weapon can be enabled/disabled because of various reasons. if a weapon is 
     267    a weapon can be enabled/disabled because of various reasons. if a weapon is
    266268    been enabled, it can interact in a world. elswhere it wont react to any
    267269    action.
     
    273275
    274276
    275 /** 
     277/**
    276278    \brief checks if the weapon is enabled
    277279    \returns true if enabled
    278280
    279     a weapon can be ebabled/disabled because of various reasons. if a weapon is 
     281    a weapon can be ebabled/disabled because of various reasons. if a weapon is
    280282    been enabled, it can interact in a world. elswhere it wont react to any
    281283    action.
     
    314316   \brief this activates the weapon
    315317
    316    This is needed, since there can be more than one weapon on a ship. the 
    317    activation can be connected with an animation. for example the weapon is 
    318    been armed out. 
     318   This is needed, since there can be more than one weapon on a ship. the
     319   activation can be connected with an animation. for example the weapon is
     320   been armed out.
    319321*/
    320322void Weapon::activate()
     
    325327   \brief this deactivates the weapon
    326328
    327    This is needed, since there can be more than one weapon on a ship. the 
    328    activation can be connected with an animation. for example the weapon is 
     329   This is needed, since there can be more than one weapon on a ship. the
     330   activation can be connected with an animation. for example the weapon is
    329331   been armed out.
    330332*/
     
    352354   can destroy the weapons of enemies or vice versa.
    353355*/
    354 void Weapon::hit (WorldEntity* entity, Vector* position) 
     356void Weapon::hit (WorldEntity* entity, Vector* position)
    355357{}
    356358
     
    362364   hit, it can also be destoryed.
    363365*/
    364 void Weapon::destroy () 
     366void Weapon::destroy ()
    365367{}
    366368
     
    369371   \brief tick signal for time dependent/driven stuff
    370372*/
    371 void Weapon::tick (float time) 
     373void Weapon::tick (float time)
    372374{}
    373375
     
    383385   \brief this will draw the weapon
    384386*/
    385 void Weapon::draw () 
    386 {}
    387 
     387void Weapon::draw ()
     388{}
     389
  • orxonox/trunk/src/world_entities/weapon.h

    r4504 r4597  
    1 /*! 
     1/*!
    22    \file weapon.h
    33    \brief a weapon that a player can use
     
    1212     o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down!
    1313     o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile
    14    
     14
    1515    Furthermore there are some other attributes, that will help to represent a firing
    1616    weapon in this world:
    1717     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
    1818     o shooting animation
    19      
     19
    2020
    2121     a player defines one or more weapon configurations. a player has got one to eight
     
    3131#define _WEAPON_H
    3232
     33#include "base_object.h"
    3334#include "world_entity.h"
    3435
     
    7475//! this is a weapon Configuration: it has up to 8 slots
    7576typedef struct weaponConfig {
    76   bool bUsed;                       //<! is set to true, if this configuration is 
     77  bool bUsed;                       //<! is set to true, if this configuration is
    7778  Weapon* slots[8];
    7879};
    7980
    8081
    81 class WeaponManager {
     82class WeaponManager : public BaseObject {
    8283 public:
    8384  WeaponManager(int nrOfSlots = 2);
    8485  ~WeaponManager();
    85  
     86
    8687  void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT);
    8788  void removeWeapon(Weapon* weapon, int configID = W_CONFIG0);
     
    9697  int currConfID;                       //<! the currently selected config
    9798  weaponConfig configs[4];              //<! a list of four configurations
    98  
     99
    99100  int getNextFreeSlot(int configID);
    100101};
    101102
    102 class Weapon : public WorldEntity 
     103class Weapon : public WorldEntity
    103104{
    104105  friend class World;
     
    107108  Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction);
    108109  virtual ~Weapon ();
    109  
     110
    110111  void enable(void);
    111112  void disable(void);
     
    123124     \brief sets a weapon idle time
    124125     \param idle time in ms
    125      
     126
    126127     a weapon idle time is the time spend after a shoot until the weapon can
    127128     shoot again
     
    131132     \brief gets the weapon idle time
    132133     \returns idle time in ms
    133      
     134
    134135     a weapon idle time is the time spend after a shoot until the weapon can
    135136     shoot again
     
    139140     \brief checks if the idle time is elapsed
    140141     \return true if time is elapsed
    141      
     142
    142143     a weapon idle time is the time spend after a shoot until the weapon can
    143144   shoot again
     
    147148  /**
    148149     \brief fires the weapon
    149      
     150
    150151     this is called from the player.cc, when fire-button is been pushed
    151152  */
     
    153154  virtual void hit (WorldEntity* weapon, Vector* loc);
    154155  virtual void destroy(void);
    155  
     156
    156157  virtual void tick(float time);
    157158  virtual void weaponIdle(void);
  • orxonox/trunk/src/world_entities/world_entity.cc

    r4570 r4597  
    3131{
    3232  this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
     33
    3334  this->model = NULL;
    3435
Note: See TracChangeset for help on using the changeset viewer.