- Timestamp:
- Jan 28, 2007, 11:22:33 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/scrolling_screen.cc
r10467 r10468 26 26 #include "camera.h" 27 27 28 #include "script_class.h" 29 30 28 31 ObjectListDefinition(ScrollingScreen); 29 32 CREATE_FACTORY(ScrollingScreen); 30 33 34 CREATE_SCRIPTABLE_CLASS(ScrollingScreen, 35 addMethod("start", Executor0<ScrollingScreen, lua_State*>(&ScrollingScreen::start)) 36 ); 31 37 32 38 … … 58 64 {} 59 65 66 void ScrollingScreen::start() 67 { 68 this->bRun = true; 69 } 60 70 61 71 /** … … 78 88 this->ySize = 0.; 79 89 this->mode = SCSC_VIEW; 90 this->bRun = false; 80 91 } 81 92 … … 119 130 void ScrollingScreen::draw() const 120 131 { 132 133 if( this->offset - this->ratio > 1.|| this->offset < -1. || !this->bRun) 134 return; 121 135 122 136 if( this->mode == SCSC_FULL) … … 147 161 glBegin(GL_QUADS); 148 162 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 163 // unten links 164 glTexCoord2f(0., 1.); 165 glVertex3f(0., -this->xSize*0.5, -this->ySize*0.5); 166 167 // unten rechts 168 glTexCoord2f(1., 1.); 169 glVertex3f(0., -this->xSize*0.5, this->ySize*0.5); 170 171 // oben rechts 172 glTexCoord2f(1., 0.); 173 glVertex3f(0., this->xSize*0.5, this->ySize*0.5); 174 175 // oben links 176 glTexCoord2f(0., 0.); 177 glVertex3f(0., this->xSize*0.5, -this->ySize*0.5); 164 178 165 179 glEnd(); … … 201 215 } 202 216 217 float ratShift = 0.; 203 218 float borderTex = this->offset + ratio; 204 219 // we are above/below … … 206 221 { 207 222 borderTex = 1.0; 223 ratShift = 1. - (1.-offset)/ratio; 208 224 } 209 225 210 226 glBegin(GL_QUADS); 211 212 213 glVertex3f(0., -x*0.5, -y*0.5);214 215 216 217 glVertex3f(0., -x*0.5, y*0.5);218 219 220 221 222 223 224 225 227 // unten links 228 glTexCoord2f(0., borderTex); 229 glVertex3f(0., -(x*0.5 - x*ratShift), -y*0.5); 230 231 // unten rechts 232 glTexCoord2f(1., borderTex); 233 glVertex3f(0., -(x*0.5 - x*ratShift), y*0.5); 234 235 // oben rechts 236 glTexCoord2f(1., this->offset); 237 glVertex3f(0., x*0.5, y*0.5); 238 239 // oben links 240 glTexCoord2f(0., this->offset); 241 glVertex3f(0., x*0.5, -y*0.5); 226 242 227 243 glEnd(); … … 238 254 { 239 255 240 CameraMan* cm = State::getCameraman(); 241 const Camera* cam = cm->getCurrentCam(); 242 PNode* tar = cam->getTargetNode(); 243 244 Vector dir = tar->getAbsCoor() - cam->getAbsCoor(); 245 dir = dir.getNormalized(); 246 247 float offset = 4.; 248 249 this->setAbsCoor( cam->getAbsCoor() + dir * offset); 250 251 252 Vector ddir = dir.cross( cam->getAbsDirV()); 253 Quaternion q(ddir, cam->getAbsDirY()); 254 this->setAbsDir( q); 255 256 // scroll the texture 257 this->offset += time * this->scrollingSpeed; 258 if( this->offset > 1.|| this->offset < -1.) 259 this->offset = 0.; 260 261 /* PRINTF(0)("offset %f, offset: %f\n", this->offset, time * this->scrollingSpeed);*/ 262 263 // if( this->getParent() != cam) 264 // { 265 // this->setParent( cam); 266 // this->setRelCoor( 4.0, 0., 0.); 267 // this->setRelDir(); 268 // } 269 256 if( !this->bRun) 257 return; 258 259 CameraMan* cm = State::getCameraman(); 260 const Camera* cam = cm->getCurrentCam(); 261 PNode* tar = cam->getTargetNode(); 262 263 Vector dir = tar->getAbsCoor() - cam->getAbsCoor(); 264 dir = dir.getNormalized(); 265 266 float offset = 6.; 267 268 this->setAbsCoor( cam->getAbsCoor() + dir * offset); 269 270 271 Vector ddir = dir.cross( cam->getAbsDirV()); 272 Quaternion q(ddir, cam->getAbsDirY()); 273 this->setAbsDir( q); 274 275 // scroll the texture 276 this->offset += time * this->scrollingSpeed; 277 // if( this->offset - this->ratio > 1.|| this->offset < -1.) 278 // this->offset = 0.; 270 279 271 280 } … … 273 282 void ScrollingScreen::fadeIn(float speed) 274 283 { 275 276 284 } 277 285 278 286 void ScrollingScreen::fadeOut(float speed) 279 287 { 280 281 } 288 } -
trunk/src/world_entities/scrolling_screen.h
r10466 r10468 27 27 void init(); 28 28 virtual void loadParams(const TiXmlElement* root); 29 30 void start(); 29 31 30 32 void fadeIn(float speed); … … 61 63 int mode; 62 64 65 bool bRun; 63 66 }; 64 67
Note: See TracChangeset
for help on using the changeset viewer.