Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

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

File:
1 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 
Note: See TracChangeset for help on using the changeset viewer.