Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2242 in orxonox.OLD for orxonox/branches/dave/core


Ignore:
Timestamp:
Jul 25, 2004, 10:00:08 PM (20 years ago)
Author:
dave
Message:

orxonox/branches/dave: habe wieder mal was gemacht:)

Location:
orxonox/branches/dave/core
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/dave/core/environment.cc

    r1994 r2242  
    1818
    1919#include "environment.h"
     20#include <ostream>
    2021#include <iostream>
    2122
     
    2526//Sorry Bensch
    2627#define LEVEL_LENGTH 500
     28dVector V1V2,V1V3,Kreuz;
     29dVector V1,V2,V3;
    2730
    2831Environment::Environment ()
    2932{
    3033
    31   //Sorry Bensch: x,y = 10
     34 //Sorry Bensch: x,y = 10
    3235  for (int x = 0; x < 50; x++)
    3336    {
     
    4346      for (int y = 1; y < LEVEL_LENGTH; y++)
    4447        {
    45           //mountainTest[x][y] = (float)random() / 900000000;
    46           mountainTest[x][y] = (float)(random() % 4);                                       
     48         //mountainTest[x][y] = (float)random() / 900000000;
     49         mountainTest[x][y] = (float)(random() % 2);                                       
    4750        }
     51       
    4852    }
    4953}
     
    5963  glPushMatrix();
    6064  glEnable(GL_DEPTH_TEST);
     65  glEnable(GL_LIGHTING);
     66 
    6167  //glScalef(0.5, 0.5, 1.0);
    6268  //glTranslatef(xCor, yCor, zCor);
    63   glTranslatef( -100.0, -50.0, 0.0);
     69  glTranslatef( -25.0, -10.0, 0.0);
    6470 
    65   glColor4f(0.0, 0.3, 0.4,1.0);
     71  glColor3f(0.6, 0.6, 0.4);
     72  glNormal3d(0,0,1);
     73  glBegin(GL_TRIANGLES);
    6674 
    67   glBegin(GL_LINES);
    68   for (int x = 0; x < LEVEL_LENGTH; x += 1)
    69     {
    70       for (int y = 0; y < 190; y += 1)
    71         {
    72           glVertex3f((float)(2*x), (float)(2*y), mountainTest[x][y]);
    73           glVertex3f((float)(2*x), (float)(2*(y+1)), mountainTest[x][y+1]);
    74         }
    75     }
     75  for (int x=0;x<60;x+=1)
     76  {
     77    for(int y=-30+DataTank::yOffset;y<40+DataTank::yOffset;y+=1)
     78    {
     79     if((int)DataTank::yOffset%2==1)
     80      {
     81      V1.x=x;V1.y=y;V1.z=mountainTest[x][y];
     82      V2.x=x;V2.y=y+1;V2.z=mountainTest[x][y+1];
     83      V3.x=x+1;V3.y=y;V3.z=mountainTest[x+1][y];
     84      glNormal3d(-(Environment::CalcNormale(&V1,&V2,&V3)).x,-(Environment::CalcNormale(&V1,&V2,&V3)).y,-(Environment::CalcNormale(&V1,&V2,&V3).z));
     85     
     86      glVertex3f((float)(x),(float)(y),mountainTest[x][y]);
     87      glVertex3f((float)(x),(float)(y+1),mountainTest[x][y+1]);
     88      glVertex3f((float)(x+1),(float)(y),mountainTest[x+1][y]);
     89     
     90      V1.x=x;V1.y=y+1;V1.z=mountainTest[x][y+1];
     91      V2.x=x+1;V2.y=y+1;V2.z=mountainTest[x+1][y+1];
     92      V3.x=x+1;V3.y=y;V3.z=mountainTest[x+1][y];
     93      glNormal3d(-(Environment::CalcNormale(&V1,&V2,&V3)).x,-(Environment::CalcNormale(&V1,&V2,&V3)).y,-(Environment::CalcNormale(&V1,&V2,&V3).z));
     94     
     95      glVertex3f((float)(x),(float)(y+1),mountainTest[x][y+1]);
     96      glVertex3f((float)(x+1),(float)(y+1),mountainTest[x+1][y+1]);
     97      glVertex3f((float)(x+1),(float)(y),mountainTest[x+1][y]);
     98      }
     99     else
     100     {
     101     V1.x=x;V1.y=y+1;V1.z=mountainTest[x][y+1];
     102     V2.x=x;V2.y=y+2;V2.z=mountainTest[x][y+2];
     103     V3.x=x+1;V3.y=y+1;V3.z=mountainTest[x+1][y+1];
     104     glNormal3d(-(Environment::CalcNormale(&V1,&V2,&V3).x),-(Environment::CalcNormale(&V1,&V2,&V3).y),-(Environment::CalcNormale(&V1,&V2,&V3).z));
     105     
     106     glVertex3f((float)(x),(float)(y+1),mountainTest[x][y+1]);
     107     glVertex3f((float)(x),(float)(y+2),mountainTest[x][y+2]);
     108     glVertex3f((float)(x+1),(float)(y+1),mountainTest[x+1][y+1]);
     109   
     110     
     111     V1.x=x;V1.y=y+2;V1.z=mountainTest[x][y+2];
     112     V2.x=x+1;V2.y=y+2;V2.z=mountainTest[x+1][y+2];
     113     V3.x=x+1;V3.y=y+1;V3.z=mountainTest[x+1][y+1];
     114     
     115     glNormal3d(-(Environment::CalcNormale(&V1,&V2,&V3).x),-(Environment::CalcNormale(&V1,&V2,&V3).y),-(Environment::CalcNormale(&V1,&V2,&V3).z));
     116     
     117     glVertex3f((float)(x),(float)(y+2),mountainTest[x][y+2]);
     118     glVertex3f((float)(x+1),(float)(y+2),mountainTest[x+1][y+2]);
     119     glVertex3f((float)(x+1),(float)(y+1),mountainTest[x+1][y+1]);
     120    }}
     121   
     122   
     123  }
    76124  glEnd();
     125  /*glBegin(GL_LINES);
     126  for(int y=0+DataTank::yOffset/2;y<25+DataTank::yOffset/2;y+=1)
     127  {
     128    for(int x=0;x<25;x+=1)
     129     {
     130     glVertex3f((float)(2*x),(float)(2*y),mountainTest[x][y]);
     131     glVertex3f((float)(2*(x+1)),(float)(2*y),mountainTest[x+1][y]);
     132     }
     133     }
    77134 
    78  
    79   glBegin(GL_LINES);
    80   for (int y = 0; y < LEVEL_LENGTH; y += 1)
    81     {
    82       for (int x = 0; x < 90; x += 1)
    83         {
    84           glVertex3f((float)(2*x), (float)(2*y), mountainTest[x][y]);
    85           glVertex3f((float)(2*(x+1)), (float)(2*y), mountainTest[x+1][y]);
    86         }
    87     }
    88135  glEnd();
    89  
     136  */
    90137  glPopMatrix();
    91138}
    92139
     140
     141
     142dVector Environment::CalcNormale(dVector *V1, dVector *V2, dVector *V3){
     143 GLdouble Betrag;
     144 V1V2.x = V2->x - V1->x;
     145 V1V2.y = V2->y -V1->y;
     146 V1V2.z = V2->z -V1->z;
     147 V1V3.x = V3->x -V1->x;
     148 V1V3.y = V3->y -V1->y;
     149 V1V3.z = V3->z -V1->z;
     150 
     151 Kreuz.x =+((V1V2.y * V1V3.z) -(V1V2.z * V1V3.y));
     152 Kreuz.y =-((V1V2.x *V1V3.z) -(V1V2.z * V1V3.x));
     153 Kreuz.z =+((V1V2.x * V1V3.y) - (V1V2.y * V1V3.x));
     154 
     155 Betrag =sqrt(pow(Kreuz.x, 2) + pow(Kreuz.y,2) +pow(Kreuz.z,2));
     156 return Kreuz;
     157 }
     158 
     159 
     160 
     161 
  • orxonox/branches/dave/core/environment.h

    r1994 r2242  
    77
    88#include "data_tank.h"
     9typedef struct dVektor{
     10GLdouble x;
     11GLdouble y;
     12GLdouble z;
     13
     14
     15}dVector;
    916
    1017class Environment {
     
    1623
    1724  float mountainTest[10][10];
    18 
     25 
     26 
     27 
     28 
    1929 public:
    2030  Environment ();
     
    2434  void setEnvPosition(void);
    2535  void getEnvPosition(void);
     36  dVector CalcNormale(dVector *V1, dVector *V2, dVector *V3);
    2637
    2738};
  • orxonox/branches/dave/core/orxonox.cc

    r1994 r2242  
    7373int Orxonox::globalInit (int argc, char** argv)
    7474{
    75   glEnable(GL_DEPTH_TEST);
     75  //glEnable(GL_DEPTH_TEST);
    7676  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    7777  glutInit(&argc, argv);
    7878  glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB | GLUT_DEPTH);
    7979  glEnable(GL_NORMALIZE);
    80   glEnable(GL_COLOR_MATERIAL);
     80 
     81 
     82  //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1);
     83 
     84 
     85 
     86 
     87 
     88 
    8189  /*glEnable(GL_LIGHT0);
    8290  glEnable(GL_LIGHTING);
     
    137145  npc->setCollisionRadius(1.0);
    138146  world->addNPC(npc);
    139 
    140   NPC* npc2 = new NPC;
    141   npc2->setPosition(-2.0, 10.0, 3.0);
    142   npc2->setCollisionRadius(1.0);
     147 
     148  NPC* npc2=new NPC;
     149  npc2->setPosition(3,10,3);
     150  npc2->setCollisionRadius(1);
    143151  world->addNPC(npc2);
    144  
    145   NPC* npc3 = new NPC;
    146   npc3->setPosition(3.0, 30.0, 3.0);
    147   npc3->setCollisionRadius(1.0);
    148   world->addNPC(npc3);
    149  
    150   NPC* npc4 = new NPC;
    151   npc4->setPosition(-2.0, 35.0, 3.0);
    152   npc4->setCollisionRadius(1.0);
    153   world->addNPC(npc4);
    154  
    155   NPC* npc5 = new NPC;
    156   npc5->setPosition(5.0, 45.0, 3.0);
    157   npc5->setCollisionRadius(1.0);
    158   world->addNPC(npc5);
    159152
    160153  glutSpecialFunc(specFunc);
     
    173166  /* this is very very unsafe: io could be uninit */
    174167  io->setPlayerStep(19.0/fps); /* set player to propper speed */
    175   localPlayer->shootLaser->setShootStep(20.0/fps); /* set shoot speed */
    176   world->setWorldStep(7.0/fps); /* set the speed of the terrain moving away */
     168  localPlayer->shootLaser->setShootStep(400.0/fps); /* set shoot speed */
     169  world->setWorldStep(5.0/fps); /* set the speed of the terrain moving away */
    177170  fps = 0;
    178171  inputEnabled = true;
  • orxonox/branches/dave/core/player.cc

    r1994 r2242  
    7676{
    7777    shootLaser->addShoot(xCor,yCor+1.0,5);
    78     //shootLaser->addShootExt(xCor,yCor,zCor,.1,.4,.0);
     78    shootLaser->addShootExt(xCor,yCor,zCor,.1,.4,.0);
     79    shootLaser->addShootExt(xCor,yCor,zCor,-.1,.4,.0);
    7980    //shootLaser->addShootdExt(xCor,yCor,zCor,-.1,.4,.0);
    80     shootRocket->addBackParable(xCor,yCor,zCor);
     81    //shootRocket->addBackParable(xCor,yCor,zCor);
    8182
    8283
     
    9697  glPopMatrix();*/
    9798  glPushMatrix();
    98   //glEnable(GL_DEPTH_TEST);
     99  glEnable(GL_NORMALIZE);
     100  glEnable(GL_COLOR_MATERIAL);
     101  glEnable(GL_LIGHTING);
     102  glEnable(GL_LIGHT0);
     103  GLfloat LPosition[4]={0,20,30,1};
     104  glLightfv(GL_LIGHT0,GL_POSITION,&LPosition[0]);
     105  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
     106 
    99107  glTranslatef(xCor,yCor,5.0);
    100108  glRotatef(3*a,1.0,0.0,0.0);
     
    102110  //glTranslatef(xCor,yCor,3.0);
    103111  glBegin(GL_QUADS);
    104   glColor3f(1.0,0.0,0.0);
     112  glColor3f(.2,0.5,0.5);
    105113  glNormal3f(-1.0,0.0,0.0);
    106114  glVertex3f(-1.0,-1.0,-1.0);
    107115  glVertex3f(-1.0,-1.0,1.0);
    108   glVertex3f(-.6,1.0,0.4);
    109   glVertex3f(-.6,1.0,-0.4);
     116  glVertex3f(-1,1.0,0.4);
     117  glVertex3f(-1,1.0,-0.4);
    110118 
    111   glNormal3f(0.0,-1.0,0.0);
    112   glColor3f(0.0,1.0,0.0);
    113   glVertex3f(-.6,1.0,.4);
    114   glVertex3f(-.6,1.0,-.4);
    115   glVertex3f(.6,1.0,-.4);
    116   glVertex3f(.6,1.0,.4);
     119  glNormal3f(1,0,0);
     120  glVertex3f(-.99,-1,-1);
     121  glVertex3f(-.99,-1,1);
     122  glVertex3f(-.99,1,.4);
     123  glVertex3f(-.99,1,-.4);
    117124 
    118   glNormal3f(-1.0,0.0,0.0);
    119   glColor3f(0.0,0.0,1.0);
    120   glVertex3f(.6,1.0,.4);
    121   glVertex3f(.6,1.0,-.4);
     125  glNormal3f(0.0,1.0,0.0);
     126  glVertex3f(-1,1.0,.4);
     127  glVertex3f(-1,1.0,-.4);
     128  glVertex3f(1,1.0,-.4);
     129  glVertex3f(1,1.0,.4);
     130 
     131  glNormal3f(0,-1,0);
     132  glVertex3f(-1,.99,.4);
     133  glVertex3f(-1,.99,-.4);
     134  glVertex3f(1,.99,-.4);
     135  glVertex3f(1,.99,.4);
     136 
     137  glNormal3f(1.0,0.0,0.0);
     138  glVertex3f(1,1,.4);
     139  glVertex3f(1,1,-.4);
    122140  glVertex3f(1.0,-1.0,-1.0);
    123141  glVertex3f(1.0,-1.0,1.0);
     142 
     143  glNormal3f(-1,0,0);
     144  glVertex3f(.99,1,.4);
     145  glVertex3f(.99,1,-.4);
     146  glVertex3f(.99,-1,-1);
     147  glVertex3f(.99,-1,1);
    124148 
    125149 
     
    133157 
    134158  /* draw all the shoots additionaly */
     159  glColor3f(0,0,1);
    135160  shootLaser->drawShoot();
    136161  shootRocket->drawShoot();
  • orxonox/branches/dave/core/shoot_laser.cc

    r1995 r2242  
    2929{
    3030  lastShoot = null;
    31   step = 1.0;
     31  step = .01;
    3232  inhibitor = 0;
    3333}
  • orxonox/branches/dave/core/world.cc

    r1994 r2242  
    206206  /* draw the ground grid  */
    207207  glColor3f(0.3, 0.3, 0.0);
    208   glBegin(GL_LINES);
     208 // glBegin(GL_LINES);
    209209  /* for the moment, we've got only pseudo moving ground
    210210  for (int y = 0; y < 60; y += 2)
Note: See TracChangeset for help on using the changeset viewer.