Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3679 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Mar 30, 2005, 8:01:06 PM (20 years ago)
Author:
dave
Message:

branches/shadows: another try

Location:
orxonox/branches/dave/src
Files:
3 edited

Legend:

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

    r3659 r3679  
    132132
    133133  int bpp = 16;
    134   int width = 400;
    135   int height = 300;
     134  int width = 1024;
     135  int height = 768;
    136136  //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
    137137  //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
     
    177177  GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
    178178  GLfloat brightLight[]={2.0,2.0,2.0,1.0};
    179   GLfloat lightPosition[] = {10.0, 10, 19.0, 0.0};
     179  GLfloat lightPosition[] = {0.0, 4, 4, 0.0};
    180180  GLfloat lightPosition2[]={ 180.0,-20.0,-30.0,0.0};
    181181
  • orxonox/branches/dave/src/shadow.cc

    r3674 r3679  
    3939*/
    4040
    41 Shadow::Shadow()
    42 {
     41Shadow::Shadow(Model* player,float* groundVertexes)
     42{
     43    this->player=player;
    4344}
    4445
     
    5152{
    5253}
     54
     55void Shadow::init()
     56{
     57   
     58    float plane_s[] ={1.0f,0.0f,0.0f,0.0f};
     59    float plane_t[] ={0.0f,1.0f,0.0f,0.0f};
     60    float plane_r[] ={0.0f,0.0f,1.0f,0.0f};
     61    float plane_q[] ={0.0f,0.0f,0.0f,1.0f};
     62   
     63    glClearDepth(1);
     64    glDepthFunc(GL_LEQUAL);
     65    glTexGenfv(GL_S,GL_EYE_PLANE,plane_s);
     66    glTexGenfv(GL_T,GL_EYE_PLANE,plane_t);
     67    glTexGenfv(GL_R,GL_EYE_PLANE,plane_r);
     68    glTexGenfv(GL_Q,GL_EYE_PLANE,plane_q);
     69    glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
     70    glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
     71    glTexGeni(GL_R,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
     72    glTexGeni(GL_Q,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
     73   
     74    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
     75    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
     76    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE_EXT);
     77    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE_EXT);
     78    glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,SIZE,SIZE,0,GL_RGB,GL_UNSIGNED_BYTE,NULL);
     79
     80    this->ground_id=glGenLists(1);
     81    glNewList(this->ground_id,GL_COMPILE);
     82   
     83    //blabla
     84   
     85    glEndList();
     86   
     87    this->player_id=glGenLists(1);
     88    glNewList(this->player_id,GL_COMPILE);
     89   
     90    //blabla
     91   
     92    glEndList();   
     93   
     94    this->image=(unsigned char*)malloc(SIZE*SIZE*4);
     95   
     96    //this->player_id=newList {glNormalefv;glVertex3fv}
     97    //this->ground_id=newList {glTexCoord2fv;glNormal3fv;glVertex3fv}
     98   
     99   
     100    //lightPos[] blabla
     101}
     102
     103
     104void Shadow::createShadow()
     105{
     106    glViewport(0,0,SIZE,SIZE);
     107    glScissor(0,0,SIZE,SIZE);
     108    glEnable(GL_SCISSOR_TEST);
     109    glBindTexture(GL_TEXTURE_2D,this->shadow_id);
     110   
     111    glClearColor(1,1,1,1);
     112    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     113    glMatrixMode(GL_PROJECTION);
     114    glLoadIdentity();
     115    glOrtho(-1,1,-1,1,-100,100);
     116    glMatrixMode(GL_MODELVIEW);
     117    glLoadIdentity();
     118   
     119    //gluLookAt(light0,light1,light2,player0,player1,player2,0,0,1);
     120   
     121    glColor3f(.4,.4,.4);
     122    //glTranslatef(player0,player1,player2);
     123    glCallList(this->player_id);
     124    glColor3f(1,1,1);
     125    glReadPixels(0,0,SIZE,SIZE,GL_RGB,GL_UNSIGNED_BYTE,this->image);
     126    blur(this->image,SIZE);
     127    glTexSubImage2D(GL_TEXTURE_2D,0,0,0,SIZE,SIZE,GL_RGB,GL_UNSIGNED_BYTE,this->image);
     128   
     129    glDisable(GL_SCISSOR_TEST);
     130    glViewport(0,0,1024,768); //Achtung: hier Aufloesung von Orxonox einstellen!
     131     
     132   
     133   
     134}
     135
     136void Shadow::m_inverse(const float *m,float *out)
     137{
     138    float det;
     139    det=m[0]*m[5]*m[10];
     140    det+= m[4]*m[9]*m[2];
     141    det+= m[8]*m[1]*m[6];
     142    det-= m[8]*m[5]*m[2];
     143    det-= m[4]*m[1]*m[10];
     144    det-= m[0]*m[9]*[6];
     145   
     146   
     147}
     148
     149
     150void Shadow::draw()
     151{
     152    float m[16],im[16];
     153    createShadow();
     154   
     155    glClearColor(0,0,0,0);
     156    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     157    glMatrixMode(GL_PROJECTION);
     158    glLoadIdentity();
     159    gluPerspective(45,4.0/3.0,.5,100);
     160    glMatrixMode(GL_MODELVIEW);
     161    glLoadIdentity();
     162   
     163    //gluLookAt(camera0,camera1,camera2,player0,player1,player2,0,0,1);
     164   
     165    glEnable(GL_TEXTURE_GEN_S);
     166    glEnable(GL_TEXTURE_GEN_T);
     167    glEnable(GL_TEXTURE_GEN_R);
     168    glEnable(GL_TEXTURE_GEN_Q);
     169    glGetFloatv(GL_MODELVIEW_MATRIX,m);
     170   
     171}
     172
    53173
    54174
  • orxonox/branches/dave/src/shadow.h

    r3674 r3679  
    1919
    2020#include "importer/material.h"
     21#include "importer/model.h"
    2122#include "p_node.h"
    2223#include "world_entity.h"
     
    2627{
    2728    private:
     29        int player_id,ground_id; //These are for the glLists!
     30        int shadow_id;  //this is for the empty shadow texture
     31        int lightPos[3];
     32       
     33        unsigned char *image;
     34        Model* player;
     35       
    2836        void blur(unsigned char *in,int size);
     37        void createShadow();
     38        void m_inverse(const float *m,float *out);
     39       
     40   
    2941    public:
    30         Shadow();
     42        Shadow(Model* player,float* groundVertexes);
    3143        ~Shadow();
     44        void init();
     45        void draw();
    3246
    3347
Note: See TracChangeset for help on using the changeset viewer.