Changeset 10710 in orxonox.OLD for branches/presentation/src/world_entities/weapons
- Timestamp:
- Jun 17, 2007, 2:25:20 PM (17 years ago)
- Location:
- branches/presentation/src/world_entities/weapons
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/world_entities/weapons/bsp_weapon.cc
r10709 r10710 133 133 //gunFirExpl.explode(gunFire2,Vector(2,2,2)); 134 134 135 for ( std::list<MuzzleFlash*>::iterator it = gunFire.begin(); it!=gunFire.end(); it++) 136 { 137 (*it)->explode( 0.2 ); 138 } 139 140 std::list<WorldEntity*>::iterator entityIterator; 141 // for all bsp managers check all entities 142 Vector pos = this->getAbsCoor(); 143 Vector dir = pos + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*range; 144 145 146 float shortestDist = range; 147 for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin(); 148 bspIterator != BspEntity::objectList().end(); 149 bspIterator++) { 150 float res = (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollisionRay( pos, dir, dir.len() + 1 ); 151 152 if ( res < shortestDist ) 153 shortestDist = res; 154 } 155 156 WorldEntity* target = aimingSystem->getNearestTarget(); 157 aimingSystem->flushList(); 158 159 if ( target != NULL ) 160 { 161 if (!alwaysHits){ 162 float r = rand(); 163 r = r/RAND_MAX; 164 float res = (target->getAbsCoor() - this->getAbsCoor()).len(); 165 float p = 1 - res*res/range/range; 166 if (r < p ){ 167 printf( "HIT %s\n", target->getClassName().c_str() ); 168 target->hit( this->damage, this ); 169 } 170 else 171 printf( "MISHIT %s\n", target->getClassName().c_str() ); 172 173 } 174 else 175 { 176 printf( "HIT %s\n", target->getClassName().c_str() ); 177 target->hit( this->damage, this ); 178 } 179 } 180 181 182 135 for ( std::list<MuzzleFlash*>::iterator it = gunFire.begin(); it!=gunFire.end(); it++) 136 { 137 (*it)->explode( 0.2 ); 138 } 139 140 std::list<WorldEntity*>::iterator entityIterator; 141 // for all bsp managers check all entities 142 Vector pos = this->getAbsCoor(); 143 Vector dir = pos + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*range; 144 145 146 float shortestDist = range; 147 for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin(); 148 bspIterator != BspEntity::objectList().end(); 149 bspIterator++) 150 { 151 float res = (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollisionRay( pos, dir, dir.len() + 1 ); 152 153 if ( res < shortestDist ) 154 shortestDist = res; 155 } 156 157 WorldEntity* target = aimingSystem->getNearestTarget(); 158 aimingSystem->flushList(); 159 160 if ( target != NULL ) 161 { 162 if ( shortestDist < (pos - target->getAbsCoor()).len() ) 163 { 164 printf("HIT WALL\n"); 165 return; 166 } 167 if (!alwaysHits) 168 { 169 float r = rand(); 170 r = r/RAND_MAX; 171 float res = (target->getAbsCoor() - this->getAbsCoor()).len(); 172 float p = 1 - res*res/range/range; 173 if (r < p ) 174 { 175 printf( "HIT %s\n", target->getClassName().c_str() ); 176 target->hit( this->damage, this ); 177 } 178 else 179 printf( "MISHIT %s\n", target->getClassName().c_str() ); 180 181 } 182 else 183 { 184 printf( "HIT %s\n", target->getClassName().c_str() ); 185 target->hit( this->damage, this ); 186 } 187 } 188 189 190 183 191 184 192 } -
branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc
r10705 r10710 81 81 this->registerObject(this, FPSSniperRifle::_objectList); 82 82 83 this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2); 83 this->setAbsDir( this->getAbsDir() * Quaternion( -PI/2, Vector(1, 0, 0) ) ); 84 this->loadModel("models/guns/fps_sniper_rifle.obj", 1.5); 84 85 this->material = new Material(); 85 86 this->material->setIllum(3); 86 87 this->material->setAmbient(1.0, 1.0, 1.0); 87 this->material->setDiffuseMap("textures/ rifle01tex.jpg");88 this->material->setDiffuseMap("textures/fps_sniper_rifle.jpg"); 88 89 89 90 this->setStateDuration(WS_SHOOTING, .1); … … 169 170 glPushMatrix(); 170 171 171 Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 2, 0, 0 ) );172 Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) ); 172 173 glTranslatef (pos.x, 173 174 pos.y,
Note: See TracChangeset
for help on using the changeset viewer.