Changeset 3706 in orxonox.OLD for orxonox/branches
- Timestamp:
- Mar 31, 2005, 11:29:47 PM (20 years ago)
- Location:
- orxonox/branches/shadows/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/shadows/src/orxonox.cc
r3398 r3706 133 133 134 134 int bpp = 16; 135 int width = 640;136 int height = 480;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; … … 177 177 GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0}; 178 178 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 181 182 glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight); 182 183 glLightfv (GL_LIGHT0, GL_SPECULAR, whiteLight); 184 glLightfv(GL_LIGHT1,GL_SPECULAR,whiteLight); 183 185 glEnable (GL_LIGHTING); 184 186 glEnable (GL_LIGHT0); 187 glEnable (GL_LIGHT1); 185 188 glEnable (GL_DEPTH_TEST); 186 189 glLightfv (GL_LIGHT0, GL_POSITION, lightPosition); 190 glLightfv (GL_LIGHT1, GL_POSITION, lightPosition2); 187 191 glLightfv (GL_LIGHT0, GL_DIFFUSE, whiteLight); 192 glLightfv (GL_LIGHT1, GL_DIFFUSE, whiteLight); 188 193 189 194 //glEnable (GL_TEXTURE_2D); -
orxonox/branches/shadows/src/player.h
r3698 r3706 31 31 32 32 virtual void leftWorld(); 33 33 float angle; 34 34 35 35 private: … … 42 42 float travelSpeed; 43 43 float acceleration; 44 float angle;44 45 45 GLuint objectList; 46 46 -
orxonox/branches/shadows/src/shadow.cc
r3680 r3706 39 39 */ 40 40 41 Shadow::Shadow( Model* player,float* groundVertexes)41 Shadow::Shadow(OBJModel* player,Player* playerangle,float groundVertexes[]) 42 42 { 43 43 this->player=player; 44 this->playerangle=playerangle; 44 45 } 45 46 … … 88 89 glNewList(this->player_id,GL_COMPILE); 89 90 90 //blabla91 this->player->draw(); 91 92 92 93 glEndList(); … … 94 95 this->image=(unsigned char*)malloc(SIZE*SIZE*4); 95 96 96 //this->player_id=newList {glNormalefv;glVertex3fv} 97 //this->ground_id=newList {glTexCoord2fv;glNormal3fv;glVertex3fv} 98 99 100 //lightPos[] blabla 97 101 98 } 102 99 … … 117 114 glLoadIdentity(); 118 115 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); 120 117 121 118 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 123 123 glCallList(this->player_id); 124 124 glColor3f(1,1,1); … … 134 134 } 135 135 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 145 void 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 136 165 void Shadow::m_inverse(const float *m,float *out) 137 166 { 138 167 float det; 139 det= m[0]*m[5]*m[10];168 det= m[0]*m[5]*m[10]; 140 169 det+= m[4]*m[9]*m[2]; 141 170 det+= m[8]*m[1]*m[6]; … … 143 172 det-= m[4]*m[1]*m[10]; 144 173 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 */ 147 200 148 201 void Shadow::draw() … … 151 204 createShadow(); 152 205 153 glClearColor(0,0,0,0);206 /*glClearColor(0,0,0,0); 154 207 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 155 208 glMatrixMode(GL_PROJECTION); … … 159 212 glLoadIdentity(); 160 213 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 */ 163 216 glEnable(GL_TEXTURE_GEN_S); 164 217 glEnable(GL_TEXTURE_GEN_T); … … 166 219 glEnable(GL_TEXTURE_GEN_Q); 167 220 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 168 245 169 246 } -
orxonox/branches/shadows/src/shadow.h
r3680 r3706 19 19 20 20 #include "importer/material.h" 21 #include "importer/ model.h"21 #include "importer/objModel.h" 22 22 #include "p_node.h" 23 23 #include "world_entity.h" 24 #include "player.h" 24 25 25 26 //! A Class to handle the Shadow … … 29 30 int player_id,ground_id; //These are for the glLists! 30 31 int shadow_id; //this is for the empty shadow texture 31 int lightPos[3]; 32 float lightPos[3]; 33 float playerPos[3]; 34 32 35 33 36 unsigned char *image; 34 Model* player; 37 OBJModel* player; 38 //playerangle used to obtain information about the angle of the player 39 Player* playerangle; 35 40 36 41 void blur(unsigned char *in,int size); … … 40 45 41 46 public: 42 Shadow( Model* player,float* groundVertexes);47 Shadow(OBJModel* player,Player* playerangle,float groundVertexes[]); 43 48 ~Shadow(); 44 49 void init(); 45 50 void draw(); 51 void updatePosition(float x,float y,float z); 46 52 47 53 -
orxonox/branches/shadows/src/skysphere.cc
r3699 r3706 80 80 81 81 void Skysphere::draw() 82 { 82 { 83 glEnable(GL_COLOR_MATERIAL); 83 84 sky->select(); 84 85 glPushMatrix(); … … 91 92 gluSphere(sphereObj,200.0f,20,20); 92 93 glPopMatrix(); 94 glDisable(GL_COLOR_MATERIAL); 93 95 94 96 -
orxonox/branches/shadows/src/world.cc
r3698 r3706 28 28 #include "helper_parent.h" 29 29 #include "glmenu_imagescreen.h" 30 #include "skysphere.h"31 30 #include "importer/material.h" 32 31 … … 291 290 292 291 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 294 298 this->skysphere =new Skysphere(); 295 296 299 300 297 301 // bind camera 298 302 this->localCamera = new Camera(this); … … 583 587 584 588 glEnable(GL_TEXTURE_2D); 585 586 589 skysphere->draw(); 590 591 shadow->draw(); 592 587 593 588 594 } … … 668 674 669 675 skysphere->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z); 670 676 shadow->updatePosition(localPlayer->absCoordinate.x,localPlayer->absCoordinate.y,localPlayer->absCoordinate.z); 671 677 //for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 672 678 } -
orxonox/branches/shadows/src/world.h
r3698 r3706 11 11 #include "story_entity.h" 12 12 #include "skysphere.h" 13 #include "shadow.h" 13 14 class Material; 14 15 … … 87 88 WorldEntity* localPlayer; 88 89 Skysphere* skysphere; 90 Shadow* shadow; 89 91 PNode* nullParent; 90 92
Note: See TracChangeset
for help on using the changeset viewer.