Changeset 3839 in orxonox.OLD for orxonox/branches/shadows
- Timestamp:
- Apr 15, 2005, 6:59:34 PM (20 years ago)
- Location:
- orxonox/branches/shadows/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/shadows/src/orxonox.cc
r3728 r3839 133 133 134 134 int bpp = 16; 135 int width = 400;136 int height = 300;135 int width = 1024; 136 int height = 768; 137 137 //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/ 138 138 //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER; -
orxonox/branches/shadows/src/shadow.cc
r3760 r3839 56 56 } 57 57 58 void Shadow::init( )58 void Shadow::init(GLuint ground_id_imported) 59 59 { 60 60 … … 63 63 float plane_r[] ={0.0f,0.0f,1.0f,0.0f}; 64 64 float plane_q[] ={0.0f,0.0f,0.0f,1.0f}; 65 66 67 this->mat=new Material("Ground"); 68 this->mat->setDiffuseMap("../data/pictures/ground.tga"); 69 this->mat->setIllum(3); 65 70 66 71 glClearDepth(1); … … 91 96 92 97 this->image=(unsigned char*)malloc(SIZE*SIZE*4); 93 94 95 } 96 void Shadow::createGroundList(){ 97 this->ground_id=glGenLists(1); 98 glNewList(this->ground_id,GL_COMPILE); 99 100 setGround(); 101 102 glEndList(); 103 104 } 98 this->ground_id=ground_id_imported; 99 100 } 101 105 102 106 103 void Shadow::createShadow() … … 111 108 glBindTexture(GL_TEXTURE_2D,this->shadow_id); 112 109 113 glClearColor(1,1,1,1); 114 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 115 glMatrixMode(GL_PROJECTION); 116 glLoadIdentity(); 117 glOrtho(-4.2,4.2,-4.2,4.2,-100,100); 118 glMatrixMode(GL_MODELVIEW); 119 glLoadIdentity(); 120 110 121 111 gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1); 122 112 … … 132 122 glEnable(GL_LIGHTING); 133 123 134 glColor3f(1,1,1);135 136 glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,SIZE,SIZE);137 //glReadPixels(0,0,SIZE,SIZE,GL_RGB,GL_UNSIGNED_BYTE,this->image);138 //blur(this->image,SIZE);139 //glTexSubImage2D(GL_TEXTURE_2D,0,0,0,SIZE,SIZE,GL_RGB,GL_UNSIGNED_BYTE,this->image);124 125 126 //glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,SIZE,SIZE); 127 glReadPixels(0,0,SIZE,SIZE,GL_RGB,GL_UNSIGNED_BYTE,this->image); 128 blur(this->image,SIZE); 129 glTexSubImage2D(GL_TEXTURE_2D,0,0,0,SIZE,SIZE,GL_RGB,GL_UNSIGNED_BYTE,this->image); 140 130 141 131 glDisable(GL_SCISSOR_TEST); 142 glViewport(0,0, 400,300); //Achtung: hier Aufloesung von Orxonox einstellen!132 glViewport(0,0,1024,768); //Achtung: hier Aufloesung von Orxonox einstellen! 143 133 144 134 … … 146 136 } 147 137 138 void Shadow::draw() 139 { 140 float m[16],im[16]; 141 142 createShadow(); 143 //glClearColor(0,0,0,1); 144 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 145 //glMatrixMode(GL_PROJECTION); 146 //glLoadIdentity(); 147 //gluPerspective(45,4.0/3.0,.5,100); 148 //glMatrixMode(GL_MODELVIEW); 149 //glLoadIdentity(); 150 151 this->mat->select(); 152 glCallList(this->ground_id); 153 154 //glDisable(GL_TEXTURE_2D); 155 156 glEnable(GL_TEXTURE_GEN_S); 157 glEnable(GL_TEXTURE_GEN_T); 158 glEnable(GL_TEXTURE_GEN_R); 159 glEnable(GL_TEXTURE_GEN_Q); 160 glGetFloatv(GL_MODELVIEW_MATRIX,m); 161 m_inverse(m,im); 162 glMatrixMode(GL_TEXTURE); 163 glLoadIdentity(); 164 //glTranslatef(.5,.5,0); 165 //glScalef(.5,.5,1.0); 166 //glOrtho(-1,1,-1,1,-1,1); 167 168 gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1); 169 170 glMultMatrixf(im); 171 glEnable(GL_TEXTURE_2D), 172 glBindTexture(GL_TEXTURE_2D,this->shadow_id); 173 glEnable(GL_BLEND); 174 glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR); 175 //glCallList(this->ground_id); 176 glDisable(GL_BLEND); 177 glDisable(GL_TEXTURE_2D); 178 179 glLoadIdentity(); 180 glMatrixMode(GL_MODELVIEW); 181 glDisable(GL_TEXTURE_GEN_S); 182 glDisable(GL_TEXTURE_GEN_T); 183 glDisable(GL_TEXTURE_GEN_R); 184 glDisable(GL_TEXTURE_GEN_Q); 185 186 187 188 189 190 } 148 191 149 192 /** … … 168 211 } 169 212 170 /** 171 brief takes the ground data from the world.cc class and passes it to shadow.cc 172 173 */ 174 175 void Shadow::setGround() 176 { 177 178 179 glBegin(GL_QUADS); 180 for(int i=0;i<100;i+=1) 181 for(int j=0;j<80;j+=1) 182 { 183 glNormal3f(normal_vectors[i][j].x,normal_vectors[i][j].y,normal_vectors[i][j].z); 184 glTexCoord2f(0.0f,0.0f); 185 glVertex3f(vertexes[0][i][j].x,vertexes[0][i][j].y,vertexes[0][i][j].z); 186 glNormal3f(normal_vectors[i+1][j].x,normal_vectors[i+1][j].y,normal_vectors[i+1][j].z); 187 glTexCoord2f(1.0f,0.0f); 188 glVertex3f(vertexes[1][i][j].x,vertexes[1][i][j].y,vertexes[1][i][j].z); 189 glNormal3f(normal_vectors[i+1][j+1].x,normal_vectors[i+1][j+1].y,normal_vectors[i+1][j+1].z); 190 glTexCoord2f(1.0f,1.0f); 191 glVertex3f(vertexes[2][i][j].x,vertexes[2][i][j].y,vertexes[2][i][j].z); 192 glNormal3f(normal_vectors[i][j+1].x,normal_vectors[i][j+1].y,normal_vectors[i][j+1].z); 193 glTexCoord2f(0.0f,1.0f); 194 glVertex3f(vertexes[3][i][j].x,vertexes[3][i][j].y,vertexes[3][i][j].z); 195 } 196 glEnd(); 197 198 199 200 201 } 202 203 void Shadow::setNormal(Vector a,int i,int j) 204 { 205 normal_vectors[i][j]=a; 206 207 } 208 209 void Shadow::setVertexNum(Vector a,int i,int j,int num) 210 { 211 vertexes[num][i][j]=a; 212 213 } 213 214 215 216 214 217 /** 215 218 … … 256 259 */ 257 260 258 void Shadow::draw()259 {260 float m[16],im[16];261 262 createShadow();263 //glClearColor(0,0,0,0);264 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);265 //glMatrixMode(GL_PROJECTION);266 //glLoadIdentity();267 //gluPerspective(45,4.0/3.0,.5,100);268 //glMatrixMode(GL_MODELVIEW);269 //glLoadIdentity();270 271 272 273 glEnable(GL_TEXTURE_GEN_S);274 glEnable(GL_TEXTURE_GEN_T);275 glEnable(GL_TEXTURE_GEN_R);276 glEnable(GL_TEXTURE_GEN_Q);277 glGetFloatv(GL_MODELVIEW_MATRIX,m);278 m_inverse(m,im);279 glMatrixMode(GL_TEXTURE);280 glLoadIdentity();281 glTranslatef(-.5,.5,0);282 glScalef(0.3,0.3,1.0);283 glOrtho(-1,1,-1,1,-1,1);284 285 gluLookAt(this->lightPos[0],this->lightPos[1],this->lightPos[2],this->playerPos[0],this->playerPos[1],this->playerPos[2],0,0,1);286 287 glMultMatrixf(im);288 glEnable(GL_TEXTURE_2D),289 glBindTexture(GL_TEXTURE_2D,this->shadow_id);290 glEnable(GL_BLEND);291 glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR);292 glCallList(this->ground_id);293 glDisable(GL_BLEND);294 glDisable(GL_TEXTURE_2D);295 296 glLoadIdentity();297 glMatrixMode(GL_MODELVIEW);298 glDisable(GL_TEXTURE_GEN_S);299 glDisable(GL_TEXTURE_GEN_T);300 glDisable(GL_TEXTURE_GEN_R);301 glDisable(GL_TEXTURE_GEN_Q);302 303 304 305 }306 261 307 262 -
orxonox/branches/shadows/src/shadow.h
r3760 r3839 33 33 float lightPos[3]; 34 34 float playerPos[3]; 35 35 Material* mat; 36 36 37 37 unsigned char *image; … … 51 51 Shadow(OBJModel* player,Player* playerangle); 52 52 ~Shadow(); 53 void init( );53 void init(GLuint ground_id); 54 54 void createShadow(); 55 void createGroundList();56 55 void draw(); 57 void setGround();58 void setNormal(Vector a,int i,int j);59 void setVertexNum(Vector a,int i,int j,int num);60 56 void updatePosition(float x,float y,float z); 61 57 -
orxonox/branches/shadows/src/skysphere.cc
r3706 r3839 90 90 glRotatef(-250.0f,0.0,1.0f,0.0f); 91 91 92 gluSphere(sphereObj, 200.0f,20,20);92 gluSphere(sphereObj,150.0f,20,20); 93 93 glPopMatrix(); 94 94 glDisable(GL_COLOR_MATERIAL); -
orxonox/branches/shadows/src/world.cc
r3760 r3839 453 453 normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); 454 454 normal_vectors[i][j].normalize(); 455 shadow->setNormal(normal_vectors[i][j],i,j); 455 456 456 } 457 457 … … 470 470 a[2]=.8; 471 471 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 472 shadow->setVertexNum(v1,i,j,0); 473 shadow->setVertexNum(v2,i,j,1); 474 shadow->setVertexNum(v3,i,j,2); 475 shadow->setVertexNum(v4,i,j,3); 476 472 477 473 478 474 … … 498 494 499 495 } 500 if(first){496 /*if(first){ 501 497 shadow->createGroundList(); 502 498 first=false; 503 } 499 }*/ 504 500 505 501 glEnd(); … … 528 524 529 525 glEndList(); 530 shadow->init( );526 shadow->init(objectList); 531 527 532 528 } … … 583 579 // draw entities 584 580 585 581 586 582 WorldEntity* entity; 587 583 entity = this->entities->enumerate(); 584 588 585 while( entity != NULL ) 589 586 { … … 598 595 //glLoadIdentity(); 599 596 600 glCallList (objectList);597 601 598 602 599 … … 604 601 605 602 glEnable(GL_TEXTURE_2D); 603 606 604 skysphere->draw(); 607 608 shadow->draw();605 shadow->draw(); 606 609 607 610 608
Note: See TracChangeset
for help on using the changeset viewer.