Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3706 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Mar 31, 2005, 11:29:47 PM (20 years ago)
Author:
dave
Message:

branches/shadows: Ok, das Abbild vom Raumschiff funktioniert schon mal, sieht recht cool aus:)

Location:
orxonox/branches/shadows/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/shadows/src/orxonox.cc

    r3398 r3706  
    133133
    134134  int bpp = 16;
    135   int width = 640;
    136   int height = 480;
     135  int width = 1024;
     136  int height = 768;
    137137  //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
    138138  //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
     
    177177  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
    178178  GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
    179   GLfloat lightPosition[] = {10.0, 10, 19.0, 0.0};
    180 
     179  GLfloat lightPosition[] = {0.0, 10, 19.0, 0.0};
     180  GLfloat lightPosition2[] ={50,10,0,0};
     181 
    181182  glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight);
    182183  glLightfv (GL_LIGHT0, GL_SPECULAR, whiteLight);
     184  glLightfv(GL_LIGHT1,GL_SPECULAR,whiteLight);
    183185  glEnable (GL_LIGHTING);
    184186  glEnable (GL_LIGHT0);
     187  glEnable (GL_LIGHT1);
    185188  glEnable (GL_DEPTH_TEST);
    186189  glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
     190  glLightfv (GL_LIGHT1, GL_POSITION, lightPosition2);
    187191  glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight);
     192  glLightfv (GL_LIGHT1, GL_DIFFUSE, whiteLight);
    188193   
    189194  //glEnable (GL_TEXTURE_2D);
  • orxonox/branches/shadows/src/player.h

    r3698 r3706  
    3131 
    3232  virtual void leftWorld();
    33  
     33  float angle;
    3434 
    3535 private:
     
    4242  float travelSpeed;
    4343  float acceleration;
    44   float angle;
     44 
    4545  GLuint objectList;
    4646 
  • orxonox/branches/shadows/src/shadow.cc

    r3680 r3706  
    3939*/
    4040
    41 Shadow::Shadow(Model* player,float* groundVertexes)
     41Shadow::Shadow(OBJModel* player,Player* playerangle,float groundVertexes[])
    4242{
    4343    this->player=player;
     44    this->playerangle=playerangle;
    4445}
    4546
     
    8889    glNewList(this->player_id,GL_COMPILE);
    8990   
    90     //blabla
     91    this->player->draw();
    9192   
    9293    glEndList();   
     
    9495    this->image=(unsigned char*)malloc(SIZE*SIZE*4);
    9596   
    96     //this->player_id=newList {glNormalefv;glVertex3fv}
    97     //this->ground_id=newList {glTexCoord2fv;glNormal3fv;glVertex3fv}
    98    
    99    
    100     //lightPos[] blabla
     97
    10198}
    10299
     
    117114    glLoadIdentity();
    118115   
    119     //gluLookAt(light0,light1,light2,player0,player1,player2,0,0,1);
     116    gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);
    120117   
    121118    glColor3f(.4,.4,.4);
    122     //glTranslatef(player0,player1,player2);
     119    glTranslatef(this->playerPos[0],this->playerPos[1],this->playerPos[2]);
     120    glRotatef(this->playerangle->angle,1.0,0.0,0.0);
     121   
     122   
    123123    glCallList(this->player_id);
    124124    glColor3f(1,1,1);
     
    134134}
    135135
     136
     137/**
     138    brief updatePosition is used in the same kind as for skysphere, because
     139    the light has got a static orientation(parallel light), we have to always
     140    add the same relative coordinates being 0,10,19 to the players position
     141    in order to receive the lightPosition. This is needed to calculate the Shadow!!
     142
     143*/
     144
     145void Shadow::updatePosition(float x,float y,float z)
     146{
     147    this->playerPos[0]=x;
     148    this->playerPos[1]=y;
     149    this->playerPos[2]=z;
     150   
     151    this->lightPos[0]=this->playerPos[0];
     152    this->lightPos[1]=this->playerPos[1]+10;
     153    this->lightPos[2]=this->playerPos[2]+19;
     154
     155   
     156}
     157/**
     158
     159    brief m_inverse simply inverses the *m matrix and stores the result back
     160    to *out. This is needed further down in the draw() method
     161
     162
     163*/
     164
    136165void Shadow::m_inverse(const float *m,float *out)
    137166{
    138167    float det;
    139     det=m[0]*m[5]*m[10];
     168    det=  m[0]*m[5]*m[10];
    140169    det+= m[4]*m[9]*m[2];
    141170    det+= m[8]*m[1]*m[6];
     
    143172    det-= m[4]*m[1]*m[10];
    144173    det-= m[0]*m[9]*m[6];
    145 }
    146 
     174   
     175    if(det!= 0.0)
     176        det=1.0/det;
     177    out[0]=  (m[5]*m[10]-m[9]*m[6])*det;
     178    out[1]= -(m[1]*m[10]-m[9]*m[2])*det;
     179    out[2]=  (m[1]*m[6]-m[5]*m[2])*det;
     180    out[3]= 0.0;
     181    out[4]= -(m[4]*m[10]-m[8]*m[6])*det;
     182    out[5]=  (m[0]*m[10]-m[8]*m[2])*det;
     183    out[6]= -(m[0]*m[6]-m[4]*m[2])*det;
     184    out[7]= 0.0;
     185    out[8]=  (m[4]*m[9]-m[8]*m[5])*det;
     186    out[9]= -(m[0]*m[9]-m[8]*m[1])*det;
     187    out[10]= (m[0]*m[5]-m[4]*m[1])*det;
     188    out[11]= 0.0;
     189    out[12]=- (m[12]*out[0]+m[13]*out[4]+m[14]*out[8]);
     190    out[13]=- (m[12]*out[1]+m[13]*out[5]+m[14]*out[9]);
     191    out[14]=- (m[12]*out[2]+m[13]*out[6]+m[14]*out[10]);
     192    out[15]= 1.0;
     193
     194
     195}
     196
     197/**
     198    brief Method draw() is called after each tick() from the world.cc class
     199*/
    147200
    148201void Shadow::draw()
     
    151204    createShadow();
    152205   
    153     glClearColor(0,0,0,0);
     206    /*glClearColor(0,0,0,0);
    154207    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    155208    glMatrixMode(GL_PROJECTION);
     
    159212    glLoadIdentity();
    160213   
    161     //gluLookAt(camera0,camera1,camera2,player0,player1,player2,0,0,1);
    162    
     214    gluLookAt(this->cameraPos[0],this->cameraPos[1],this->cameraPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);
     215    */
    163216    glEnable(GL_TEXTURE_GEN_S);
    164217    glEnable(GL_TEXTURE_GEN_T);
     
    166219    glEnable(GL_TEXTURE_GEN_Q);
    167220    glGetFloatv(GL_MODELVIEW_MATRIX,m);
     221    m_inverse(m,im);
     222    glMatrixMode(GL_TEXTURE);
     223    glLoadIdentity();
     224    glTranslatef(0.5,0.5,1.0);
     225    glOrtho(-1,1,-1,1,-1,1);
     226   
     227    gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);
     228   
     229    glMultMatrixf(im);
     230    glEnable(GL_TEXTURE_2D),
     231    glBindTexture(GL_TEXTURE_2D,this->shadow_id);
     232    glEnable(GL_BLEND);
     233    glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR);
     234    glCallList(ground_id);
     235    glDisable(GL_BLEND);
     236   
     237    glLoadIdentity();
     238    glMatrixMode(GL_MODELVIEW);
     239    glDisable(GL_TEXTURE_GEN_S);
     240    glDisable(GL_TEXTURE_GEN_T);
     241    glDisable(GL_TEXTURE_GEN_R);
     242    glDisable(GL_TEXTURE_GEN_Q);
     243   
     244   
    168245   
    169246}
  • orxonox/branches/shadows/src/shadow.h

    r3680 r3706  
    1919
    2020#include "importer/material.h"
    21 #include "importer/model.h"
     21#include "importer/objModel.h"
    2222#include "p_node.h"
    2323#include "world_entity.h"
     24#include "player.h"
    2425
    2526//! A Class to handle the Shadow
     
    2930        int player_id,ground_id; //These are for the glLists!
    3031        int shadow_id;  //this is for the empty shadow texture
    31         int lightPos[3];
     32        float lightPos[3];
     33        float playerPos[3];
     34
    3235       
    3336        unsigned char *image;
    34         Model* player;
     37        OBJModel* player;
     38        //playerangle used to obtain information about the angle of the player
     39        Player* playerangle;
    3540       
    3641        void blur(unsigned char *in,int size);
     
    4045   
    4146    public:
    42         Shadow(Model* player,float* groundVertexes);
     47        Shadow(OBJModel* player,Player* playerangle,float groundVertexes[]);
    4348        ~Shadow();
    4449        void init();
    4550        void draw();
     51        void updatePosition(float x,float y,float z);
    4652
    4753
  • orxonox/branches/shadows/src/skysphere.cc

    r3699 r3706  
    8080   
    8181void Skysphere::draw()
    82 {
     82{   
     83    glEnable(GL_COLOR_MATERIAL);
    8384    sky->select();
    8485    glPushMatrix();
     
    9192    gluSphere(sphereObj,200.0f,20,20);
    9293    glPopMatrix();
     94    glDisable(GL_COLOR_MATERIAL);
    9395
    9496
  • orxonox/branches/shadows/src/world.cc

    r3698 r3706  
    2828#include "helper_parent.h"
    2929#include "glmenu_imagescreen.h"
    30 #include "skysphere.h"
    3130#include "importer/material.h"
    3231
     
    291290           
    292291           
    293             // create skybox
     292            //create shadow
     293            float a[]={1.0,1.0,1.0,4.0};
     294            this->shadow =new Shadow(myPlayer->model,(Player*)myPlayer,a);         
     295            shadow->init();                 
     296           
     297            //create skysphere
    294298            this->skysphere =new Skysphere();
    295                    
    296                    
     299           
     300           
    297301            // bind camera
    298302            this->localCamera = new Camera(this);
     
    583587 
    584588  glEnable(GL_TEXTURE_2D);
    585  
    586589  skysphere->draw();
     590 
     591  shadow->draw();
     592 
    587593 
    588594}
     
    668674 
    669675  skysphere->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z);
    670  
     676  shadow->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z);
    671677  //for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    672678}
  • orxonox/branches/shadows/src/world.h

    r3698 r3706  
    1111#include "story_entity.h"
    1212#include "skysphere.h"
     13#include "shadow.h"
    1314class Material;
    1415
     
    8788  WorldEntity* localPlayer;
    8889  Skysphere* skysphere;
     90  Shadow* shadow;
    8991  PNode* nullParent;
    9092 
Note: See TracChangeset for help on using the changeset viewer.