Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9110 in orxonox.OLD


Ignore:
Timestamp:
Jul 4, 2006, 11:18:41 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the Presentation back

Location:
trunk
Files:
50 edited

Legend:

Unmodified
Added
Removed
  • trunk/config.h.in

    r8293 r9110  
    2424/* Define to 1 if you have the `dl' library (-ldl). */
    2525#undef HAVE_LIBDL
    26 
    27 /* Define to 1 if you have the `m' library (-lm). */
    28 #undef HAVE_LIBM
    2926
    3027/* Define to 1 if you have the `OpenGL' library (-lOpenGL). */
  • trunk/configure.ac

    r8523 r9110  
    621621
    622622# FIXME: Replace `main' with a function in `-lm':
    623  AC_CHECK_LIB([m], [main])
     623 AX_CHECK_REQUIRED_HEADER_LIB([math.h], [m], [sqrt])
    624624 AX_CHECK_REQUIRED_HEADER_LIB([zlib.h], [z], [zlibVersion],,, [http://www.zlib.net])
    625625
  • trunk/src/lib/collision_detection/cd_engine.cc

    r8894 r9110  
    4545
    4646  this->bAbordOnFirstCollision = false;
     47 
     48  this->terrain = NULL;
    4749}
    4850
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r9061 r9110  
    7070
    7171
    72   float CR_MAX_WALK_HEIGHT = 2.0f;
     72  float CR_MAX_WALK_HEIGHT = 15.0f;
    7373  float CR_THRESHOLD = 0.2f;
    7474
    75   float height = 0;
    76   float front = 0;
    77   float side = 0;
    78 
    79   //PRINTF(0)("collision raction======================================\n");
     75  float height = 0.0f;
     76  float front = 0.0f;
     77  float back = 0.0f;
     78  float right = 0.0f;
     79  float left = 0.0f;
     80
    8081
    8182  const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents());
     
    9394    switch( ce->getType())
    9495    {
    95         // collision in the x-axis
     96        /* collision in the X-AXIS */
    9697      case COLLISION_TYPE_AXIS_X:
    97         front = collPos.len() - box->halfLength[0]; // should be [0]
     98        front = collPos.len() - box->halfLength[0];
    9899
    99100        // object is beneath the plane (ground)
    100101        if( front <= 0.0f )
    101102        {
    102           Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     103          Vector dirX = entity->getAbsDirX();
     104          dirX.y = 0.0f;
     105          dirX.normalize();
    103106          Vector backoff = dirX * front;
    104          
    105           entity->setAbsCoor(entity->getLastAbsCoor());
    106          // entity->shiftCoor(backoff);
    107         }
    108         // object is already in the wall
    109         else if( ce->isInWall())
    110         {
    111               entity->setAbsCoor(entity->getLastAbsCoor());
    112         }
    113         break;
    114        
     107
     108          entity->shiftCoor(backoff);
     109        }
     110        else if( ce->isInWall())
     111        {
     112          // object is already in the wall
     113          entity->setAbsCoor(entity->getLastAbsCoor());
     114        }
     115        break;
     116
    115117      case COLLISION_TYPE_AXIS_X_NEG:
    116         front = collPos.len() - box->halfLength[0]; // should be [0]
    117 
    118         // object is beneath the plane (ground)
    119         if( front <= 0.0f )
    120         {
    121           Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
    122           Vector backoff = dirX * front * -1.0f;
    123          
    124           entity->setAbsCoor(entity->getLastAbsCoor());
    125          // entity->shiftCoor(backoff);
    126         }
    127         // object is already in the wall
    128         else if( ce->isInWall())
    129         {
    130           entity->setAbsCoor(entity->getLastAbsCoor());
    131         }
    132         break;
    133 
    134 
    135         // collision in the y-axis
     118        back = collPos.len() - box->halfLength[0];
     119
     120        // object is beneath the plane (ground)
     121        if( back <= 0.0f)
     122        {
     123          Vector dirX = entity->getAbsDirX();
     124          dirX.y = 0.0f;
     125          dirX.normalize();
     126          Vector backoff = dirX * back * -1.0f;
     127
     128          entity->shiftCoor(backoff);
     129        }
     130        else if( ce->isInWall())
     131        {
     132          // object is already in the wall
     133          entity->setAbsCoor(entity->getLastAbsCoor());
     134        }
     135        break;
     136
     137
     138        /* collision in the Y-AXIS */
    136139      case COLLISION_TYPE_AXIS_Y_NEG:
    137140        // calulate the height above ground
    138         height = collPos.y - box->halfLength[1];
    139 
    140 
    141         // object is beneath the plane (ground)
    142         if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
    143         else if( height < 0.0f )
     141        height = collPos.len() - box->halfLength[1];
     142
     143
     144        // object is beneath the plane (ground)
     145        //         if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
     146        if( height < 0.0f && -height < CR_MAX_WALK_HEIGHT)
    144147        {
    145148          entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f));
     
    160163
    161164
     165        /* collision in the Z-AXIS */
     166      case COLLISION_TYPE_AXIS_Z:
     167
     168        right = collPos.len()  - box->halfLength[2];
     169
     170        // object is beneath the plane (ground)
     171        if( right <= 0.0f )
     172        {
     173          Vector dirZ = entity->getAbsDirZ();
     174          dirZ.y = 0.0f;
     175          dirZ.normalize();
     176          Vector backoff = dirZ * right;
     177          entity->shiftCoor(backoff);
     178        }
     179        else if( ce->isInWall())
     180        {
     181          // object is already in the wall
     182          entity->setAbsCoor(entity->getLastAbsCoor());
     183        }
     184        break;
     185
     186
    162187        // collision in the z-axis
    163       case COLLISION_TYPE_AXIS_Z:
    164 
    165         side = collPos.len()  - box->halfLength[2]; // should be [2]
    166 
    167         // object is beneath the plane (ground)
    168         if( side <= 0.0f )
    169         {
    170           entity->setAbsCoor(entity->getAbsCoor());
    171           Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
    172           Vector backoff = dirZ * side;
    173           entity->shiftCoor(backoff);
    174         }
    175         // object is already in the wall
    176         else if( ce->isInWall())
    177         {
    178           entity->setAbsCoor(entity->getLastAbsCoor());
    179         }
    180         break;
    181        
    182        
    183          // collision in the z-axis
    184188      case COLLISION_TYPE_AXIS_Z_NEG:
    185189
    186         side = collPos.len()  - box->halfLength[2]; // should be [2]
    187 
    188         // object is beneath the plane (ground)
    189         if( side <= 0.0f )
    190         {
    191          
    192           Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
    193           Vector backoff = dirZ * side*-1.0f;
     190        left = collPos.len()  - box->halfLength[2];
     191
     192        // object is beneath the plane (ground)
     193        if( left <= 0.0f )
     194        {
     195          Vector dirZ = entity->getAbsDirZ();
     196          dirZ.y = 0.0f;
     197          dirZ.normalize();
     198          Vector backoff = dirZ * left*-1.0f;
    194199          entity->shiftCoor(backoff);
    195200        }
     
    209214
    210215
    211 #if 0
    212   if( box != NULL)
    213     height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
    214   else
    215     height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
    216 
    217 
    218   if( box != NULL)
    219   {
    220 
    221 
    222     if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
    223     {
    224       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    225       return;
    226     }
    227     if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
    228     {
    229       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    230       return;
    231     }
    232 
    233     if(ce->getGroundNormal().len() <= 0.1f)
    234     {
    235       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    236       return;
    237     }
    238 
    239 
    240     if(ce->getGroundNormal().len() >= 1.4f)
    241     {
    242       downspeed++;
    243       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
    244       return;
    245     }
    246 
    247 
    248     if(height.y > box->halfLength[1] + 0.0f ) // Above ground
    249     {
    250       if(height.y < box->halfLength[1] + 2.3f) // Snap in
    251       {
    252         downspeed = 0;
    253         collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() - Vector(0.0,height.y  - box->halfLength[1] - 0.0f,0.0));
    254       } else
    255       {
    256         downspeed++;
    257         collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
    258       }
    259 
    260     }
    261     else
    262     {
    263       if(height.y <  box->halfLength[1] + 0.0f   /* && height.y  >  - 55.0f*/) // below ground
    264       {
    265         //if(downspeed <= 0) downspeed =1;
    266         collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f,0.0));
    267         //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
    268         downspeed = 0;
    269       }
    270 
    271     }
    272 
    273   }// if(box!= NULL)
    274 #endif
    275   /*
    276   PRINTF(0)("Collision with Ground: \n");
    277   collision->getEntityB()->getAbsCoor().debug();
    278   collision->getEntityB()->setVelocity(Vector());
    279   collision->getEntityB()->setAbsCoor(this->lastPositions[1]);
    280 
    281   */
    282216
    283217}
  • trunk/src/lib/graphics/importer/bsp_manager.cc

    r9061 r9110  
    960960  this->outputFraction = 1.0f;
    961961
     962
     963  this->checkCollisionX(worldEntity);
     964  this->checkCollisionY(worldEntity);
     965  this->checkCollisionZ(worldEntity);
     966
     967
     968#if 0
    962969  // Retrieve Bounding box
    963970  AABB* box = worldEntity->getModelAABB();
     
    985992
    986993
     994  plane* testPlane;
     995
     996  bool xCollision = false;
     997  bool zCollision = false;
     998
    987999
    9881000  float height = 40;
     
    9981010    dest1     = worldEntity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
    9991011    dest2     = worldEntity->getAbsCoor() -  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
    1000    
     1012
    10011013    Vector dirZ =  worldEntity->getAbsDirZ(); dirX.y = 0.0f; dirZ.normalize();
    10021014    //position2 = worldEntity->getAbsCoor() +  box->center - dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     
    10091021
    10101022
    1011 //   PRINTF(0)("x and v\n");
    1012 //   worldEntity->getAbsDirX().debug();
    1013 //   worldEntity->getAbsDirV().debug();
    1014 
    1015 
    1016   // 1st Ray
     1023
     1024  // 1st Ray: Y RAY
    10171025  this->inputStart =  position;
    10181026  this->inputEnd =   dest;
     
    10521060      this->out = out;
    10531061    }
    1054 
    1055 
    1056   }
    1057 
    1058   plane* testPlane = this->collPlane;
    1059 
    1060   bool xCollision = false;
    1061   bool zCollision = false;
     1062  }
     1063    testPlane = this->collPlane;
     1064
     1065
    10621066  bool xCollisionNeg = false;
    10631067  bool zCollisionNeg = false;
    1064  
    1065 
    1066 
    1067     // 2nd Collision Detection
     1068
     1069
     1070
     1071    // 2nd Collision Detection X-RAY
    10681072    this->outputStartsOut = true;
    10691073    this->outputAllSolid = false;
     
    10931097
    10941098
    1095       // 3rd Collision Detection
     1099      // 3rd Collision Detection Z-RAY
    10961100      this->outputStartsOut = true;
    10971101      this->outputAllSolid = false;
     
    11211125      }
    11221126
    1123   //end if
    1124   /*
    1125   This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
    1126   out.x = position1.x + (dest.x -position1.x) * this->outputFraction;
    1127   out.z = position1.z + (dest.z -position1.z) * this->outputFraction;
    1128   */
    1129 
    11301127
    11311128  // Return the normal here: Normal's stored in this->collPlane;
    11321129  if( collision) {
    1133     worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1130    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
    11341131}
    11351132  if(xCollision) {
    11361133    worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag);
    11371134  }
    1138  
     1135
    11391136  if(zCollision) {
    11401137    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag);
    11411138  }
    1142 
    1143 
    1144   //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
    1145 
    1146 }
     1139#endif
     1140
     1141}
     1142
     1143
     1144
     1145/**
     1146 * check the collision in the x direction (forward, backward)
     1147 */
     1148void BspManager::checkCollisionX(WorldEntity* entity)
     1149{
     1150  // Retrieve Bounding box
     1151  AABB* box = entity->getModelAABB();
     1152
     1153
     1154  plane*            testPlane          = NULL;  //!< the collision test plane
     1155
     1156  Vector            forward;                    //!< left collision ray
     1157  Vector            backward;                   //!< right collision ray
     1158  Vector            collPos;                    //!< the collision position
     1159
     1160  bool              xCollisionForward  = false; //!< flag true if right collision
     1161  bool              xCollisionBackward = false; //!< flag true if left collision
     1162  bool              SolidFlag          = false; //!< flag set true if solid
     1163
     1164  Vector            position;                   //!< current position of the entity
     1165  Vector            dirX;                       //!< direction x
     1166
     1167  position = entity->getAbsCoor();
     1168  dirX =  entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     1169
     1170  // calculate the rays
     1171  if( box != NULL)
     1172  {
     1173    forward  = entity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     1174    backward = entity->getAbsCoor() +  box->center - dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     1175  }
     1176  else
     1177  {
     1178    forward  = position + dirX * 4.0f;
     1179    backward = position + Vector(0.0, 1.0, 0.0) + dirX * 4.0;
     1180  }
     1181
     1182
     1183  /*   X Ray forward  */
     1184  // init some member variables before collision check
     1185  this->outputStartsOut = true;
     1186  this->outputAllSolid = false;
     1187  this->outputFraction = 1.0f;
     1188  this->inputStart =  position;
     1189  this->inputEnd =   forward;
     1190  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &forward );
     1191
     1192  // collision occured
     1193  if( this->outputFraction < 1.0f)
     1194  {
     1195    collPos = position + (forward - position) * this->outputFraction;
     1196    xCollisionForward = true;
     1197    testPlane = this->collPlane;
     1198  }
     1199  if(this->outputAllSolid )
     1200  {
     1201    this->collPlane = new plane;
     1202    this->collPlane->x = 0.0f;
     1203    this->collPlane->y = 0.0f;
     1204    this->collPlane->z = 0.0f;
     1205    testPlane = this->collPlane;
     1206    SolidFlag = true;
     1207    xCollisionForward = true;
     1208  }
     1209
     1210  // collision registration
     1211  if( xCollisionForward)
     1212  {
     1213    entity->registerCollision(COLLISION_TYPE_AXIS_X ,
     1214                              this->parent, entity,
     1215                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1216                              collPos,
     1217                              SolidFlag);
     1218  }
     1219
     1220
     1221
     1222  /*   X Ray backward  */
     1223  // init some member variables before collision check
     1224  this->outputStartsOut = true;
     1225  this->outputAllSolid = false;
     1226  this->outputFraction = 1.0f;
     1227  this->inputStart =  position;
     1228  this->inputEnd =   backward;
     1229  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &backward );
     1230
     1231  // collision occured
     1232  if( this->outputFraction < 1.0f)
     1233  {
     1234    collPos = position + (backward - position) * this->outputFraction;
     1235    xCollisionBackward = true;
     1236    testPlane = this->collPlane;
     1237  }
     1238  if( this->outputAllSolid)
     1239  {
     1240    this->collPlane = new plane;
     1241    this->collPlane->x = 0.0f;
     1242    this->collPlane->y = 0.0f;
     1243    this->collPlane->z = 0.0f;
     1244    testPlane = this->collPlane;
     1245    SolidFlag = true;
     1246    xCollisionBackward = true;
     1247  }
     1248
     1249  // collision registration
     1250  if( xCollisionBackward)
     1251  {
     1252    entity->registerCollision(COLLISION_TYPE_AXIS_X_NEG ,
     1253                              this->parent, entity,
     1254                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1255                              collPos,
     1256                              SolidFlag);
     1257  }
     1258}
     1259
     1260
     1261/**
     1262 * check the collision in the z direction (up, down)
     1263 */
     1264void BspManager::checkCollisionY(WorldEntity* entity)
     1265{
     1266
     1267  // Retrieve Bounding box
     1268  AABB* box = entity->getModelAABB();
     1269
     1270
     1271  plane*            testPlane          = NULL;  //!< the collision test plane
     1272
     1273  Vector            up;                         //!< up collision ray
     1274  Vector            down;                       //!< down collision ray
     1275  Vector            collPos;                    //!< the collision position
     1276
     1277  bool              yCollisionUp       = false; //!< flag true if right collision
     1278  bool              yCollisionDown     = false; //!< flag true if left collision
     1279  bool              SolidFlag          = false; //!< flag set true if solid
     1280
     1281  Vector            position;                   //!< current position of the entity
     1282  Vector            dirY;                       //!< direction x
     1283
     1284  position = entity->getAbsCoor();
     1285  collPos = position;
     1286  dirY =  Vector(0.0, 1.0, 0.0);
     1287
     1288  // calculate the rays
     1289  if( box != NULL)
     1290  {
     1291    up   = position +  box->center + dirY * (box->halfLength[1]/*  + BSP_Y_OFFSET*/);
     1292    down = position +  box->center - dirY * (box->halfLength[1]  + BSP_Y_OFFSET);
     1293  }
     1294  else
     1295  {
     1296    up   = position + dirY * 4.0f;
     1297    down = position + Vector(0.0, 1.0, 0.0) + dirY * 4.0;
     1298  }
     1299
     1300
     1301
     1302
     1303  /*   Y Ray up */
     1304  // init some member variables before collision check
     1305  this->inputStart = position;
     1306  this->inputEnd   = up;
     1307  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &up );
     1308
     1309  if( !this->outputStartsOut )
     1310  {
     1311    this->collPlane = new plane;
     1312    this->collPlane->x = 0.0f;
     1313    this->collPlane->y = 0.0f;
     1314    this->collPlane->z = 0.0f;
     1315    yCollisionUp = true;
     1316  }
     1317  else
     1318  {
     1319    if( this->outputFraction == 1.0f)
     1320    {
     1321      if( this->outputAllSolid )
     1322      {
     1323        this->collPlane = new plane;
     1324        this->collPlane->x = 0.0f;
     1325        this->collPlane->y = 0.0f;
     1326        this->collPlane->z = 0.0f;
     1327        yCollisionUp = true;
     1328        SolidFlag = true;
     1329      }
     1330      else
     1331      {
     1332        yCollisionUp = false;
     1333        collPos = up;
     1334      }
     1335    }
     1336    else
     1337    {
     1338      yCollisionUp = true;
     1339      collPos = position + (up - position) * this->outputFraction;
     1340      this->out = collPos;        // why this????
     1341    }
     1342  }
     1343  testPlane = this->collPlane;
     1344
     1345  // collision registration
     1346  if( yCollisionUp)
     1347  {
     1348    entity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent,
     1349                              entity,
     1350                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1351                              collPos, SolidFlag);
     1352  }
     1353
     1354
     1355
     1356
     1357  /*   Y Ray down */
     1358  // init some member variables before collision check
     1359  this->inputStart = position;
     1360  this->inputEnd   = down;
     1361  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &down );
     1362
     1363  if( !this->outputStartsOut )
     1364  {
     1365    this->collPlane = new plane;
     1366    this->collPlane->x = 0.0f;
     1367    this->collPlane->y = 0.0f;
     1368    this->collPlane->z = 0.0f;
     1369    yCollisionDown = true;
     1370  }
     1371  else
     1372  {
     1373    if( this->outputFraction == 1.0f)
     1374    {
     1375      if( this->outputAllSolid )
     1376      {
     1377        this->collPlane = new plane;
     1378        this->collPlane->x = 0.0f;
     1379        this->collPlane->y = 0.0f;
     1380        this->collPlane->z = 0.0f;
     1381        yCollisionDown = true;
     1382        SolidFlag = true;
     1383      }
     1384      else
     1385      {
     1386        yCollisionDown = false;
     1387        collPos = down;
     1388      }
     1389    }
     1390    else
     1391    {
     1392      yCollisionDown = true;
     1393      collPos = position + (down - position) * this->outputFraction;
     1394      this->out = collPos;        // why this????
     1395    }
     1396  }
     1397  testPlane = this->collPlane;
     1398
     1399  // collision registration
     1400  if( yCollisionDown)
     1401  {
     1402    entity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent,
     1403                              entity,
     1404                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1405                              collPos, SolidFlag);
     1406  }
     1407
     1408
     1409}
     1410
     1411
     1412
     1413
     1414/**
     1415 * check the collision in the z direction (left, right)
     1416 */
     1417void BspManager::checkCollisionZ(WorldEntity* entity)
     1418{
     1419  // Retrieve Bounding box
     1420  AABB* box = entity->getModelAABB();
     1421
     1422
     1423  plane*            testPlane          = NULL;  //!< the collision test plane
     1424
     1425  Vector            right;                      //!< right collision ray
     1426  Vector            left;                       //!< left collision ray
     1427  Vector            collPos;                    //!< the collision position
     1428
     1429  bool              zCollisionRight    = false; //!< flag true if right collision
     1430  bool              zCollisionLeft     = false; //!< flag true if left collision
     1431  bool              SolidFlag          = false; //!< flag set true if solid
     1432
     1433  Vector            position;                   //!< current position of the entity
     1434  Vector            dirZ;                       //!< direction x
     1435
     1436  position = entity->getAbsCoor();
     1437  dirZ =  entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
     1438
     1439  // calculate the rays
     1440  if( box != NULL)
     1441  {
     1442    right = entity->getAbsCoor() +  box->center + dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     1443    left  = entity->getAbsCoor() +  box->center - dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     1444  }
     1445  else
     1446  {
     1447    right = position + dirZ * 4.0f;
     1448    left  = position + Vector(0.0, 1.0, 0.0) + dirZ * 4.0;
     1449  }
     1450
     1451
     1452  /*   Z Ray right */
     1453  // init some member variables before collision check
     1454  this->outputStartsOut = true;
     1455  this->outputAllSolid = false;
     1456  this->outputFraction = 1.0f;
     1457  this->inputStart =  position;
     1458  this->inputEnd =   right;
     1459  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &right );
     1460
     1461
     1462  // collision occured
     1463  if( this->outputFraction < 1.0f )
     1464  {
     1465    collPos = position + (right - position) * this->outputFraction;
     1466    zCollisionRight = true;
     1467    testPlane = this->collPlane;
     1468  }
     1469  if(this->outputAllSolid )
     1470  {
     1471    this->collPlane = new plane;
     1472    this->collPlane->x = 0.0f;
     1473    this->collPlane->y = 0.0f;
     1474    this->collPlane->z = 0.0f;
     1475    testPlane = this->collPlane;
     1476
     1477    SolidFlag = true;
     1478    zCollisionRight = true;
     1479  }
     1480
     1481
     1482  if( zCollisionRight) {
     1483    entity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent,
     1484                              entity,
     1485                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1486                              collPos , SolidFlag);
     1487  }
     1488
     1489
     1490
     1491  /*   Z Ray left */
     1492  // init some member variables before collision check
     1493  this->outputStartsOut = true;
     1494  this->outputAllSolid = false;
     1495  this->outputFraction = 1.0f;
     1496  this->inputStart =  position;
     1497  this->inputEnd =    left;
     1498  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &left);
     1499
     1500
     1501  // collision occured
     1502  if( this->outputFraction < 1.0f )
     1503  {
     1504    collPos = position + (left - position) * this->outputFraction;
     1505    zCollisionLeft = true;
     1506    testPlane = this->collPlane;
     1507  }
     1508  if(this->outputAllSolid )
     1509  {
     1510    this->collPlane = new plane;
     1511    this->collPlane->x = 0.0f;
     1512    this->collPlane->y = 0.0f;
     1513    this->collPlane->z = 0.0f;
     1514    testPlane = this->collPlane;
     1515
     1516    SolidFlag = true;
     1517    zCollisionLeft = true;
     1518  }
     1519
     1520
     1521  if( zCollisionLeft) {
     1522    entity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this->parent,
     1523                              entity,
     1524                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1525                              collPos , SolidFlag);
     1526  }
     1527
     1528}
     1529
     1530
    11471531
    11481532
  • trunk/src/lib/graphics/importer/bsp_manager.h

    r9061 r9110  
    2828
    2929
    30 #define BSP_X_OFFSET 40.0f
     30#define BSP_X_OFFSET 20.0f
    3131#define BSP_Y_OFFSET 40.0f
    32 #define BSP_Z_OFFSET 40.0f
     32#define BSP_Z_OFFSET 20.0f
    3333
    3434
     
    7979
    8080private:
    81   // Functions
     81  // collision functions
    8282  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
    8383  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
    8484  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
    8585  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
    86   void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
     86
     87  void checkCollisionX(WorldEntity* entity);
     88  void checkCollisionY(WorldEntity* entity);
     89  void checkCollisionZ(WorldEntity* entity);
     90
    8791  void  checkCollisionBox(void);
    8892  void  checkBrushRay(brush* curBrush);
    8993  void  checkBrushRayN(brush* curBrush);
    9094  void  checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
    91   float  checkPatchAltitude(BspTreeNode* node); //! To be implemented...
     95  float checkPatchAltitude(BspTreeNode* node); //! To be implemented...
    9296
     97  void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
     98
     99
     100  // visibility functions
    93101  void drawDebugCube(Vector* cam);
    94102  bool isAlreadyVisible(int Face);
  • trunk/src/lib/graphics/importer/md3/md3_model.cc

    r8724 r9110  
    525525    float  interpolatedMatrix[4][4];
    526526
    527     Quaternion currQuat(currFrameTag->matrix); currQuat.matrix(currRot);
    528     Quaternion nextQuat(nextFrameTag->matrix); nextQuat.matrix(nextRot);
     527    /// TODO CHANGED BY BENSCH TO MATCH NEW QUATERNION FUNCTIONALITY
     528    Quaternion currQuat; currQuat.from3x3(currFrameTag->matrix); currQuat.matrix(currRot);
     529    Quaternion nextQuat; nextQuat.from3x3(nextFrameTag->matrix); nextQuat.matrix(nextRot);
    529530
    530531    Quaternion interpolatedQuat = Quaternion::quatSlerp(currQuat, nextQuat, frac); interpolatedQuat.matrix(interpolatedMatrix);
  • trunk/src/lib/graphics/importer/primitive_model.cc

    r8316 r9110  
    1818#include "primitive_model.h"
    1919
    20 #include <math.h>
    2120#include "vector.h"
    2221#include "debug.h"
  • trunk/src/lib/graphics/spatial_separation/quadtree.cc

    r8293 r9110  
    5252
    5353  /* make an array with access to the leafs of the Quad-Tree */
    54   this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)];
     54  this->nodes = new QuadtreeNode*[(int)pow(4.0, treeDepth)];
    5555  int index = 0; //new int; *index = 0; // !!changed by bensch!!
    56   for(int i = 0; i < (int)pow(2, treeDepth); ++i)
     56  for(int i = 0; i < (int)pow(2.0, treeDepth); ++i)
    5757  {
    5858    this->rootNode->buildHashTable(this->nodes, &index);
     
    7070  this->offset->x = xOff;
    7171  this->offset->z = yOff;
    72   this->maxIndex = (int)pow(2, this->treeDepth);
     72  this->maxIndex = (int)pow(2.0, this->treeDepth);
    7373}
    7474
     
    103103void Quadtree::revertHashTable(QuadtreeNode** nodes)
    104104{
    105   int                  len         = (int)pow(2, this->treeDepth);          //!< the length of a quadtree side
     105  int                  len         = (int)pow(2.0, this->treeDepth);          //!< the length of a quadtree side
    106106  int                  iterator    = 0;                                     //!< iterator used for mapping
    107107  QuadtreeNode*        tmpNode     = NULL;                                  //!< temp saving place
     
    132132void Quadtree::sortHashTable(QuadtreeNode** nodes)
    133133{
    134   int                  len         = (int)pow(2, this->treeDepth);          //!< the length of a quadtree side
     134  int                  len         = (int)pow(2.0, this->treeDepth);          //!< the length of a quadtree side
    135135  float                a;                                                   //!< temp place for float a
    136136  float                b;                                                   //!< temp place for float b
     
    207207{
    208208  //this->rootNode->drawTree();
    209   for(int i = 0; i < (int)pow(4, this->treeDepth); ++i)
     209  for(int i = 0; i < (int)pow(4.0, this->treeDepth); ++i)
    210210  {
    211211    this->nodes[i]->draw();
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r6022 r9110  
    164164
    165165  /*              offset              #of elements in a row            #of rows in a quadtree          */
    166   int threshold = this->nodeIter + (int)pow(2, this->maxDepth) * (int)pow(2, maxDepth - treeDepth - 1);
     166  int threshold = this->nodeIter + (int)pow(2.0, this->maxDepth) * (int)pow(2.0, maxDepth - treeDepth - 1);
    167167  int loopLimit = (*index < threshold)?2:4;
    168168
  • trunk/src/lib/gui/gl/glgui_box.cc

    r8717 r9110  
    5959  void GLGuiBox::unpack(GLGuiWidget* widget)
    6060  {
    61     assert(widget == NULL);
     61    assert(widget != NULL);
    6262
    6363    std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
  • trunk/src/lib/gui/gtk/gui_gtk.cc

    r8145 r9110  
    3030#include <string.h>
    3131#include <stdlib.h>
    32 #include <math.h>
     32#include <cmath>
    3333
    3434using namespace std;
  • trunk/src/lib/math/curve.cc

    r5232 r9110  
    2929#include "debug.h"
    3030
    31 #include <math.h>
     31#include <cmath>
    3232#include <stdio.h>
    3333
  • trunk/src/lib/math/line.h

    r6617 r9110  
    2424#define __LINE_H_
    2525
    26 #include <math.h>
    2726#include "compiler.h"
    2827#include "vector.h"
  • trunk/src/lib/math/matrix.cc

    r7711 r9110  
    1414*/
    1515#include "matrix.h"
    16 #include <math.h>
     16#include <cmath>
    1717
    1818#ifdef DEBUG
  • trunk/src/lib/math/matrix.h

    r5698 r9110  
    44 */
    55
    6 #include <math.h>
    76#include "vector.h"
    87
  • trunk/src/lib/math/plane.h

    r7711 r9110  
    2424#define __PLANE_H_
    2525
    26 #include <math.h>
    2726#include "compiler.h"
    2827#include "vector.h"
  • trunk/src/lib/math/quaternion.cc

    r8731 r9110  
    2828  #define PRINT(x) printf
    2929#endif
    30 
    31 using namespace std;
    3230
    3331/////////////////
     
    5856  m[0][1] = x.y;
    5957  m[0][2] = x.z;
    60   m[0][3] = 0;
     58  m[0][3] = 0.0;
    6159  m[1][0] = y.x;
    6260  m[1][1] = y.y;
    6361  m[1][2] = y.z;
    64   m[1][3] = 0;
     62  m[1][3] = 0.0;
    6563  m[2][0] = z.x;
    6664  m[2][1] = z.y;
    6765  m[2][2] = z.z;
    68   m[2][3] = 0;
    69   m[3][0] = 0;
    70   m[3][1] = 0;
    71   m[3][2] = 0;
    72   m[3][3] = 1;
    73 
    74   *this = Quaternion (m);
     66  m[2][3] = 0.0;
     67  m[3][0] = 0.0;
     68  m[3][1] = 0.0;
     69  m[3][2] = 0.0;
     70  m[3][3] = 1.0;
     71
     72  this->from4x4(m);
    7573}
    7674
     
    279277 * @param m: a 4x4 matrix in glMatrix order
    280278 */
    281 Quaternion::Quaternion (float m[4][4])
     279void Quaternion::from4x4(float m[4][4])
    282280{
    283281
     
    285283  int    i, j, k;
    286284
    287   int nxt[3] = {1, 2, 0};
     285  static int nxt[3] = {1, 2, 0};
    288286
    289287  tr = m[0][0] + m[1][1] + m[2][2];
     
    327325
    328326/**
    329  * Creates a quaternion from a 3x3 rotation matrix.
     327 * applies a quaternion from a 3x3 rotation matrix.
    330328 * @param mat The 3x3 source rotation matrix.
    331329 * @return The equivalent 4 float quaternion.
    332330 */
    333 Quaternion::Quaternion(float mat[3][3])
     331void Quaternion::from3x3(float mat[3][3])
    334332{
    335333  int   NXT[] = {1, 2, 0};
  • trunk/src/lib/math/quaternion.h

    r8894 r9110  
    2424#define __QUATERNION_H_
    2525
    26 #include <math.h>
    2726#include "compiler.h"
    28 //! PI the circle-constant
    29 #define PI 3.14159265359f
    3027#include "vector.h"
    3128
     
    3936  /** creates a Default quaternion (multiplicational identity Quaternion)*/
    4037  inline Quaternion () { w = 1; v = Vector(0,0,0); }
     38  /** Copy constructor @param q the Quaternion to copy. */
     39  inline Quaternion (const Quaternion& q) { w = q.w; v = q.v; };
    4140  /** creates a Quaternion looking into the direction v @param v: the direction @param f: the value */
    4241  inline Quaternion (const Vector& v, float f) { this->w = f; this->v = v; }
    43   Quaternion (float m[4][4]);
    44   Quaternion (float m[3][3]);
    4542  /** turns a rotation along an axis into a Quaternion @param angle: the amount of radians to rotate @param axis: the axis to rotate around */
    4643  inline Quaternion (float angle, const Vector& axis) { w = cos(angle/2.0); v = axis * sin(angle/2.0); }
    4744  Quaternion (const Vector& dir, const Vector& up);
    4845  Quaternion (float roll, float pitch, float yaw);
     46
     47  void from3x3(float m[3][3]);
     48  void from4x4(float m[4][4]);
     49
    4950
    5051  /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */
  • trunk/src/lib/math/vector.cc

    r6617 r9110  
    2929#endif
    3030
    31 using namespace std;
    3231
    3332/////////////
     
    4039Vector Vector::getNormalized() const
    4140{
    42   float l = this->len();
    43   if(unlikely(l == 1.0 || l == 0.0))
     41  float length = this->len();
     42  if (unlikely(length == 0.0))
    4443    return *this;
    4544  else
    46     return (*this / l);
     45    return (*this / length);
    4746}
    4847
  • trunk/src/lib/math/vector.h

    r8894 r9110  
    2424#define __VECTOR_H_
    2525
    26 #include <math.h>
     26#include <cmath>
    2727#include "compiler.h"
    2828//! PI the circle-constant
     
    4242  Vector (float x, float y, float z) : x(x), y(y), z(z) {}  //!< assignment constructor
    4343  Vector () : x(0), y(0), z(0) {}
    44   ~Vector () {}
    4544
    4645  /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */
     
    9089  void scale(const Vector& v) {   x *= v.x;  y *= v.y; z *= v.z; };
    9190  /** @returns the length of the vector */
    92   inline float len() const { return sqrt (x*x+y*y+z*z); }
     91  inline float len() const { return sqrt (x*x + y*y + z*z); }
    9392  /** normalizes the vector */
    9493  inline void normalize() { float l = len(); if( unlikely(l == 0.0))return; this->x=this->x/l; this->y=this->y/l; this->z=this->z/l; };
  • trunk/src/lib/network/network_game_manager.cc

    r9059 r9110  
    9898  ClassID playableClassId = rules.getPlayableClassId( userId, team );
    9999  std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId );
     100  std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId );
    100101 
    101102  BaseObject * bo = Factory::fabricate( playableClassId );
     
    106107  Playable & playable = *(dynamic_cast<Playable*>(bo));
    107108 
    108   if (  playableModel != "" )
     109  if ( playableTexture != "" )
     110    playable.loadMD2Texture( playableTexture );
     111  if ( playableModel != "" )
    109112    playable.loadModel( playableModel );
    110113  playable.setOwner( userId );
  • trunk/src/lib/network/player_stats.cc

    r8708 r9110  
    238238}
    239239
     240
     241
     242ScoreList PlayerStats::getScoreList( )
     243{
     244  ScoreList result;
     245 
     246  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
     247 
     248  if ( !list )
     249  {
     250    return result;
     251  }
     252 
     253  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     254  {
     255    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     256   
     257    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
     258   
     259    while (  it != result[stats.getTeamId()].end() && stats.score > it->score )
     260    {
     261      it++;
     262    }
     263   
     264    PlayerScore score;
     265    score.name = stats.getNickName();
     266    score.score = stats.getScore();
     267   
     268    result[stats.getTeamId()].insert(it, score);
     269  }
     270 
     271  return result;
     272}
  • trunk/src/lib/network/player_stats.h

    r8623 r9110  
    2020  TEAM_SPECTATOR = -1
    2121};
     22
     23struct PlayerScore
     24{
     25  std::string name;
     26  int score;
     27};
     28typedef std::list<PlayerScore> TeamScoreList;
     29typedef std::map<int,TeamScoreList> ScoreList;
    2230
    2331//! A class for storing player information
     
    6270   
    6371    static void deleteAllPlayerStats();
     72   
     73    static ScoreList getScoreList();
    6474
    6575  private:
  • trunk/src/lib/network/shared_network_data.cc

    r6822 r9110  
    4444 */
    4545SharedNetworkData::~SharedNetworkData()
    46 {}
     46{
     47  SharedNetworkData::singletonRef = NULL;
     48}
  • trunk/src/lib/network/synchronizeable.cc

    r8708 r9110  
    6767{
    6868  if ( this->networkStream )
     69  {
    6970    this->networkStream->disconnectSynchronizeable(*this);
    7071 
    71   if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
    72     NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
     72    if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
     73      NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
     74  }
    7375   
    7476  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
  • trunk/src/lib/shell/shell_buffer.cc

    r8350 r9110  
    4141  ShellBuffer* ShellBuffer::singletonRef = NULL;
    4242  std::list<std::string> ShellBuffer::buffer;
    43   char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE];
     43  char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE] = "";
    4444
    4545
  • trunk/src/lib/util/loading/game_loader.cc

    r8717 r9110  
    5757    delete this->currentCampaign;
    5858  this->currentCampaign = NULL;
     59 
     60  GameLoader::singletonRef = NULL;
    5961}
    6062
  • trunk/src/story_entities/game_world.cc

    r9061 r9110  
    6464using namespace std;
    6565
     66#include "script_class.h"
     67CREATE_SCRIPTABLE_CLASS(GameWorld, CL_GAME_WORLD,
     68                        addMethod("setPlaymode", ExecutorLua1<GameWorld,const std::string&>(&GameWorld::setPlaymode))
     69                       );
    6670
    6771SHELL_COMMAND(speed, GameWorld, setSpeed) ->describe("set the Speed of the Level");
     
    336340      this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode))
    337341  {
    338     PRINTF(3)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
     342    PRINTF(4)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
    339343  }
    340344  else
    341345  {
    342     PRINTF(1)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
     346    PRINTF(2)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
    343347  }
    344348}
  • trunk/src/story_entities/menu/game_menu.cc

    r9059 r9110  
    236236  if (this->networkBox == NULL)
    237237  {
    238     this->networkBox = new OrxGui::GLGuiBox();
     238    this->networkBox = new OrxGui::GLGuiBox( OrxGui::Horizontal );
    239239    {
     240      OrxGui::GLGuiBox * box = new OrxGui::GLGuiBox();
     241     
    240242      OrxGui::GLGuiButton* clientButton = new OrxGui::GLGuiPushButton("Client");
    241       networkBox->pack(clientButton);
     243      box->pack(clientButton);
    242244      clientButton->connect(SIGNAL(clientButton, released), this, SLOT(GameMenu, showClientMenu));
    243245
    244246      OrxGui::GLGuiButton* serverButton = new OrxGui::GLGuiPushButton("Server");
    245       networkBox->pack(serverButton);
     247      box->pack(serverButton);
    246248      serverButton->connect(SIGNAL(serverButton, released), this, SLOT(GameMenu, showServerMenu));
    247 
    248 
     249     
     250      networkBox->pack( box );
    249251    }
    250252  }
     
    511513  if ( this->serverNetworkBox )
    512514  {
    513     delete this->serverNetworkBox;
    514     this->serverNetworkBox = NULL;
     515    this->networkBox->unpack( this->serverNetworkBox );
     516    this->serverNetworkBox->hideAll();
     517    //delete this->serverNetworkBox;
     518    //this->serverNetworkBox = NULL;
    515519  }
    516520 
     
    535539  }
    536540 
     541  this->networkBox->pack( this->clientNetworkBox );
     542 
    537543  this->clientNetworkBox->showAll();
    538544 
    539   this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
     545  //this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
    540546}
    541547
     
    547553  if ( this->clientNetworkBox )
    548554  {
    549     delete this->clientNetworkBox;
    550     this->clientNetworkBox = NULL;
     555    this->networkBox->unpack( this->clientNetworkBox );
     556    this->clientNetworkBox->hideAll();
     557    //delete this->clientNetworkBox;
     558    //this->clientNetworkBox = NULL;
    551559  }
    552560 
     
    569577  }
    570578 
     579  this->networkBox->pack( this->serverNetworkBox );
     580 
    571581  this->serverNetworkBox->showAll();
    572582 
    573   this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
     583  //this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
    574584}
    575585
  • trunk/src/story_entities/multi_player_world.cc

    r9059 r9110  
    129129  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
    130130    this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
     131
     132
     133
     134    // ground collision detection: BSP Model
     135  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_00));
     136  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_01));
     137  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_PLAYERS));
    131138}
    132139
     
    153160
    154161  State::setOnline( false );
    155  
     162
    156163  return ErrorMessage();
    157164}
  • trunk/src/subprojects/framework.cc

    r7711 r9110  
    3434  LightManager::getInstance();
    3535
    36   std::string dataPath = //Preferences::getInstance()->getString(CONFIG_SECTION_DATA, CONFIG_NAME_DATADIR, "");
     36  std::string dataPath = //Preferences::getInstance()->getString(CONFIG_SECTION_GENERAL, CONFIG_NAME_DATADIR, "");
    3737      "/home/boenzlip/orxonox/data/trunk/";
    3838  printf("%s\n", dataPath.c_str());
     
    5252    ResourceManager::getInstance()->getDataDir().c_str(),
    5353    DEFAULT_CONFIG_FILE,
    54     CONFIG_SECTION_DATA,
     54    CONFIG_SECTION_GENERAL,
    5555    CONFIG_NAME_DATADIR);
    5656    exit(-1);
     
    317317  delete GraphicsEngine::getInstance();
    318318
     319  Framework::singletonRef = NULL;
    319320}
    320321
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r9059 r9110  
    455455  ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );
    456456  std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
     457  std::string playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );
    457458
    458459  BaseObject * bo = Factory::fabricate( playableClassId );
     
    463464  Playable & playable = *(dynamic_cast<Playable*>(bo));
    464465
    465   playable.loadModel( playableModel );
     466  if ( playableTexture != "" )
     467    playable.loadMD2Texture( playableTexture );
     468  if ( playableModel != "" )
     469    playable.loadModel( playableModel );
    466470  playable.setOwner( userId );
    467471  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
     
    537541      this->hideStats();
    538542    }
    539     if ( !this->statsBox && event.bPressed )
     543    else if ( !this->statsBox && event.bPressed )
    540544    {
    541545      PRINTF(0)("show stats\n");
     
    612616{
    613617  statsBox = new OrxGui::GLGuiBox();
    614   statsBox->setAbsCoor2D( 300, 100 );
    615 
    616   this->table = new OrxGui::GLGuiTable(5,5);
     618  statsBox->setAbsCoor2D( 100, 100 );
     619
     620  this->table = new OrxGui::GLGuiTable(10,5);
    617621
    618622  statsBox->pack( this->table );
     
    642646
    643647  std::vector<std::string> headers;
     648  headers.push_back("Blue Team");
     649  headers.push_back("");
     650  headers.push_back("");
    644651  headers.push_back("Red Team");
    645652  headers.push_back("");
    646   headers.push_back("");
    647   headers.push_back("Blue Team");
    648   headers.push_back("");
    649653  this->table->setHeader(headers);
    650654
    651   std::map<int,std::string> fragsTeam0;
    652   std::map<int,std::string> fragsTeam1;
    653 
    654   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    655 
    656   if ( !list )
    657     return;
    658 
    659   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    660   {
    661     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
    662 
    663     if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 )
    664     {
    665       if ( stats.getTeamId() == 0 )
    666         fragsTeam0[stats.getScore()] = stats.getNickName();
    667       else
    668         fragsTeam1[stats.getScore()] = stats.getNickName();
    669     }
    670   }
     655  ScoreList scoreList = PlayerStats::getScoreList();
    671656
    672657  char st[10];
    673658  int i = 0;
    674 
    675 
     659 
    676660  i = 2;
    677   for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ )
    678   {
    679     this->table->setEntry( 0, i, it->second );
    680     snprintf( st, 10, "%d", it->first );
    681     this->table->setEntry( 1, i, st );
    682     this->table->setEntry( 2, i, "" );
     661  for ( TeamScoreList::const_iterator it = scoreList[0].begin(); it != scoreList[0].end(); it++ )
     662  {
     663    this->table->setEntry( i, 0, it->name );
     664    snprintf( st, 10, "%d", it->score );
     665    this->table->setEntry( i, 1, st );
     666    this->table->setEntry( i, 2, "" );
    683667    i++;
    684668  }
    685669
    686670  i = 2;
    687   for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ )
    688   {
    689     this->table->setEntry( 3, i, it->second );
    690     snprintf( st, 10, "%d", it->first );
    691     this->table->setEntry( 4, i, st );
     671  for ( TeamScoreList::const_iterator it = scoreList[1].begin(); it != scoreList[1].end(); it++ )
     672  {
     673    this->table->setEntry( i, 3, it->name );
     674    snprintf( st, 10, "%d", it->score );
     675    this->table->setEntry( i, 4, st );
    692676    i++;
    693677  }
     678
    694679}
    695680
     
    797782}
    798783
     784std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassID classId )
     785{
     786  if ( classId == CL_FPS_PLAYER )
     787  {
     788    return "maps/doom_guy.png";
     789  }
     790 
     791  return "";
     792}
     793
  • trunk/src/util/multiplayer_team_deathmatch.h

    r9059 r9110  
    3939    virtual int getTeamForNewUser();
    4040    virtual ClassID getPlayableClassId( int userId, int team );
     41    virtual std::string getPlayableModelTextureFileName( int userId, int team, ClassID classId );
    4142    virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId );
    4243
  • trunk/src/util/network_game_rules.cc

    r8623 r9110  
    4040}
    4141
     42
     43std::string NetworkGameRules::getPlayableModelTextureFileName( int userId, int team, ClassID classId )
     44{
     45  return "";
     46}
     47
    4248std::string NetworkGameRules::getPlayableModelFileName( int uesrId, int team, ClassID classId )
    4349{
  • trunk/src/util/network_game_rules.h

    r8623 r9110  
    2323    virtual ClassID getPlayableClassId( int userId, int team );
    2424    virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId );
     25    virtual std::string getPlayableModelTextureFileName( int userId, int team, ClassID classId );
    2526   
    2627    virtual PlayerStats * getNewPlayerStats( int userId ){ return new PlayerStats( userId ); }
  • trunk/src/util/signal_handler.h

    r8623 r9110  
    4444  public:
    4545    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
     46    ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
    4647
    4748    void registerCallback( SignalCallback cb, void * someData );
  • trunk/src/world_entities/creatures/fps_player.cc

    r9003 r9110  
    2121
    2222#include "src/lib/util/loading/factory.h"
     23
     24#include "md2/md2Model.h"
    2325
    2426#include "weapons/weapon_manager.h"
     
    2830#include "weapons/fps_sniper_rifle.h"
    2931
     32#include "aabb.h"
     33
    3034#include "key_mapper.h"
    3135
    3236#include "debug.h"
    3337
     38#include "shared_network_data.h"
    3439
    3540
     
    9297
    9398  this->fallVelocity = 0.0f;
     99  this->jumpForce = 0.0f;
    94100
    95101  this->cameraNode.setParent(this);
     
    123129
    124130  this->getWeaponManager().setSlotCount(2);
    125   this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));
    126131//   this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_2, Vector(0,1,0)));
    127132  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     133  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     134  this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));
    128135  this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0));
    129   this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     136
    130137
    131138  this->getWeaponManager().setParentNode(&this->cameraNode);
     
    141148  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
    142149  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
    143 //  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );
    144 
    145 
    146   // collision reaction registration
    147   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     150  registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) );
     151  registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) );
    148152}
    149153
     
    189193
    190194
    191   State::getCameraNode()->setRelCoor(0,0,0);
    192   State::getCameraTargetNode()->setRelCoor(10,0,0);
     195  AABB* box = this->getModelAABB();
     196  if( box != NULL)
     197  {
     198    State::getCameraNode()->setRelCoor(0, box->halfLength[1] * 2.0f, 0);
     199    State::getCameraTargetNode()->setRelCoor(10, box->halfLength[1] * 2.0f, 0);
     200
     201    this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * 2.0f - 0.7, 1.1));
     202    this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * 2.0f, 0.0));
     203  }
    193204}
    194205
     
    207218void FPSPlayer::tick (float time)
    208219{
    209  
     220
    210221  if( this->bPosBut)
    211222  {
    212223    this->bPosBut = false;
    213     printf("prisoner:walkTo( %f, height, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
    214   }
    215  
     224    printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
     225  }
     226
    216227  Playable::tick( time );
    217228
    218   if( ( xMouse != 0 || yMouse != 0 ) /*&& this->getOwner() == this->getHostID() */)
     229  if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) )
    219230  {
    220231    xMouse *= time ;
     
    230241      attitude = -1.15;
    231242
    232     this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
    233     this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
    234 
    235243    xMouse = yMouse = 0;
    236244  }
    237245
    238  // this->setAbsDir( this->mouseDir );
     246  this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
     247  this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
    239248
    240249  Vector velocity;
     
    262271
    263272  velocity *= 100;
     273
     274  if( this->bJump && likely(this->getModel(0) != NULL))
     275  {
     276    if( this->jumpForce < 1.0f)
     277    {
     278      this->jumpForce = 300.0f;
     279
     280      if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
     281        ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
     282    }
     283  }
     284  else if(velocity.len() != 0.0f)
     285  {
     286    if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
     287      ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
     288  }
     289  else
     290  {
     291    if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
     292      ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
     293  }
     294
     295
     296  velocity.y += this->jumpForce;
     297  if( this->jumpForce > 1.0f)
     298    this->jumpForce *= 0.9f;
    264299
    265300
     
    287322  {
    288323    ((InteractiveModel*)this->getModel(0))->tick(time);
    289 //
    290 //     // handle animations differently
    291 //     if( this->bJump && likely(this->getModel(0) != NULL))
    292 //     {
    293 //       ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
    294 //     }
     324
     325    // handle animations differently
     326
     327
     328
     329
     330
    295331//     else if( this->bFire && likely(this->getModel(0) != NULL))
    296332//     {
     
    347383  }
    348384  else if( event.type == KeyMapper::PEV_JUMP)
     385    this->bJump = event.bPressed;
    349386    this->bPosBut = event.bPressed;
    350387}
  • trunk/src/world_entities/creatures/fps_player.h

    r9003 r9110  
    5454
    5555    float                 fallVelocity;        //!< velocity for falling down
     56    float                 jumpForce;           //!< the jump force
    5657};
    5758
  • trunk/src/world_entities/environments/mapped_water.cc

    r9021 r9110  
    2020#include "state.h"
    2121#include "t_animation.h"
    22 #include "math.h"
     22#include <cmath>
    2323#include "glgui.h"
    2424#include "shell_command.h"
  • trunk/src/world_entities/npcs/door.cc

    r9003 r9110  
    4545
    4646
    47 Door::Door ()
    48 {
    49   this->init();
    50 }
    51 
    52 
    5347Door::Door(const TiXmlElement* root)
    5448{
     
    5650  this->setClassID(CL_DOOR, "Door");
    5751  this->scale = 1.0f;
     52  this->actionRadius = 1.0;
    5853
    5954  if( root != NULL)
     
    6257  this->toList(OM_COMMON);
    6358  this->bLocked = false;
     59  this->bOpen = false;
    6460
    6561  this->loadMD2Texture("maps/doors.jpg");
  • trunk/src/world_entities/npcs/door.h

    r9003 r9110  
    2222{
    2323  public:
    24     Door ();
    25     Door(const TiXmlElement* root);
     24    Door(const TiXmlElement* root = NULL);
    2625    virtual ~Door ();
    2726
     
    4342
    4443  private:
     44    void init();
    4545    bool checkOpen();
    4646    void setAnimation(int animNum, int playbackMode = 0);
  • trunk/src/world_entities/npcs/generic_npc.cc

    r9061 r9110  
    8484  this->toList(OM_GROUP_00);
    8585
    86   if (this->soundBuffer != NULL)
    87     ResourceManager::getInstance()->unload(this->soundBuffer);
    8886  this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    8987
     
    9391
    9492  // collision reaction registration
    95 //   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     93   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    9694}
    9795
     
    186184  this->animationStack.push(this->behaviourList);
    187185  this->behaviourList = new std::list<GenericNPC::Anim>;
     186
     187  if( this->getAnimation() != STAND)
     188    this->setAnimation(STAND, MD2_ANIM_LOOP);
    188189}
    189190
     
    194195void GenericNPC::resume()
    195196{
    196   //if()
     197  if( this->animationStack.size() == 0)
     198    return;
     199
    197200  delete this->behaviourList;
    198201  this->behaviourList = this->animationStack.top();
     
    219222        Vector dir = (currentAnimation.v - this->getAbsCoor());
    220223        dir.y = 0.0f;
    221         dir.getNormalized();
     224        dir.normalize();
    222225        this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
    223226
     
    518521      {
    519522        Vector dest = currentAnimation.v - this->getAbsCoor();
     523        dest.y = 0.0f;
    520524        if (dest.len() < .5)
    521525          this->nextStep();
     
    530534      {
    531535        Vector dest = currentAnimation.v - this->getAbsCoor();
     536        dest.y = 0.0f;
    532537        if (dest.len() < .5)
    533538          this->nextStep();
  • trunk/src/world_entities/playable.cc

    r9061 r9110  
    6767  this->bDead = false;
    6868
     69  //subscribe to collision reaction
    6970  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    7071
  • trunk/src/world_entities/script_trigger.cc

    r9061 r9110  
    115115  LoadParam(root, "invert", this, ScriptTrigger, setInvert)
    116116      .describe("")
    117       .defaultValues("false");
     117      .defaultValues(false);
    118118  LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
    119119      .describe("")
    120       .defaultValues("true");
     120      .defaultValues(true);
    121121  LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    122122      .describe("")
    123       .defaultValues("false");
     123      .defaultValues(false);
    124124  LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
    125125      .describe("True if this scripttrigger should be aviable in the script")
    126       .defaultValues("false");
     126      .defaultValues(false);
    127127}
    128128
  • trunk/src/world_entities/space_ships/space_ship.cc

    r9061 r9110  
    5858CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,
    5959                        addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
     60                       //Coordinates
     61                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     62                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     63                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     64                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    6065                       );
    6166
  • trunk/src/world_entities/space_ships/spacecraft_2d.cc

    r9061 r9110  
    2525
    2626#include "util/loading/factory.h"
     27#include "util/loading/load_param.h"
    2728#include "key_mapper.h"
    2829#include "state.h"
     
    3637CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D);
    3738
     39/**
     40 *  destructs the spacecraft_2d, deletes alocated memory
     41 */
     42Spacecraft2D::~Spacecraft2D ()
     43{
     44  this->setPlayer(NULL);
     45  delete this->toTravelHeight;
     46}
    3847
    3948/**
     
    8695
    8796/**
    88  *  destructs the spacecraft_2d, deletes alocated memory
    89  */
    90 Spacecraft2D::~Spacecraft2D ()
    91 {
    92   this->setPlayer(NULL);
    93 }
    94 
    95 /**
    9697 * @brief initializes a Spacecraft2D
    9798 */
     
    101102  this->setClassID(CL_SPACECRAFT_2D, "Spacecraft2D");
    102103
    103   this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal);
    104 
     104  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal );
    105105
    106106  bForward = bBackward = bLeft = bRight = false;
     
    110110  this->rotation = 0.0f;
    111111  this->acceleration = 10.0f;
    112   this->altitude = 0.0f;
     112  this->airFriction = 2.0f;
     113
    113114
    114115  this->setHealthMax(100);
     
    116117
    117118
     119  /// 2D-MODE
     120  this->toTravelHeight = NULL;
     121  this->travelSpeed = 0.0f;
     122  this->travelNode = new PNode();
     123
     124
    118125  // camera - issue
    119   this->travelNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
     126  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     127  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    120128  //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
    121129  //this->cameraNode.setParent(this);
    122130
    123   // rotors
    124131  // PARTICLES
    125132  this->burstEmitter = new DotEmitter(200, 5.0, .01);
    126133  this->burstEmitter->setParent(this);
    127134  this->burstEmitter->setRelCoor(0, -0.7, 0);
    128   this->burstEmitter->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
     135  this->burstEmitter->setRelDir(Quaternion(-M_PI, Vector(0,0,1)));
    129136  this->burstEmitter->setName("Spacecraft2D_Burst_emitter_Left");
    130 
    131137
    132138  this->burstSystem = new SpriteParticles(1000);
     
    150156  this->registerEvent(KeyMapper::PEV_LEFT);
    151157  this->registerEvent(KeyMapper::PEV_RIGHT);
    152   this->registerEvent(KeyMapper::PEV_UP);
    153   this->registerEvent(KeyMapper::PEV_DOWN);
    154158  this->registerEvent(KeyMapper::PEV_FIRE1);
    155159  this->registerEvent(KeyMapper::PEV_NEXT_WEAPON);
     
    178182  this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
    179183
    180   this->travelNode.setRelCoor(0,0,0);
    181   //this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    182   //this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
     184  this->cameraNode.setRelCoor(1,5,0);
     185  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
     186  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
    183187
    184188  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     
    198202{
    199203  Playable::loadParams(root);
     204
     205  LoadParam(root, "travel-speed", this, Spacecraft2D, setTravelSpeed);
     206  LoadParam(root, "travel-height", this, Spacecraft2D, setTravelHeight);
     207  LoadParam(root, "travel-distance", this, Spacecraft2D, setTravelDistance);
    200208}
    201209
     
    205213}
    206214
    207 void Spacecraft2D::setTravelDirecton(const Quaternion& rot, float speed)
    208 {
    209   this->setPlayDirection(rot, speed);
    210 }
    211 
    212215void Spacecraft2D::setTravelSpeed(float travelSpeed)
    213216{
     
    216219
    217220
     221void Spacecraft2D::setTravelHeight(float travelHeight)
     222{
     223  if (this->toTravelHeight == NULL)
     224    this->toTravelHeight = new float;
     225  *this->toTravelHeight = travelHeight;
     226}
     227
     228
     229void Spacecraft2D::setTravelDistance(const Vector2D& distance)
     230{
     231  this->travelDistance = distance;
     232}
     233
     234void Spacecraft2D::setTravelDistance(float x, float y)
     235{
     236  this->setTravelDistance(Vector2D(x, y));
     237}
     238
     239
    218240
    219241void Spacecraft2D::enter()
    220242{
    221243  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
    222 
    223   if (State::getCameraNode != NULL)
    224   {
    225     State::getCameraNode()->setParentSoft(&this->travelNode);
    226     State::getCameraNode()->setRelCoorSoft(-10, 50,0);
    227     State::getCameraTargetNode()->setParentSoft(&this->travelNode);
    228   }
     244  this->setPlaymode(this->getPlaymode());
    229245}
    230246
     
    235251
    236252}
     253
     254
     255void Spacecraft2D::enterPlaymode(Playable::Playmode playmode)
     256{
     257  switch(playmode)
     258  {
     259    case Playable::Full3D:
     260      if (State::getCameraNode != NULL)
     261      {
     262        Vector absCoor = this->getAbsCoor();
     263        this->setParent(PNode::getNullParent());
     264        this->setAbsCoor(absCoor);
     265        State::getCameraNode()->setParentSoft(&this->cameraNode);
     266        State::getCameraNode()->setRelCoorSoft(-10, 0,0);
     267        State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
     268        State::getCameraTargetNode()->setRelCoorSoft(100, 0,0);
     269
     270      }
     271      break;
     272
     273
     274    case Playable::Horizontal:
     275      if (State::getCameraNode != NULL)
     276      {
     277        this->debugNode(1);
     278        this->travelNode->debugNode(1);
     279
     280        this->travelNode->setAbsCoor(this->getAbsCoor());
     281        this->travelNode->updateNode(0.01f);
     282
     283        this->setParent(this->travelNode);
     284        this->setRelCoor(0,0,0);
     285
     286        State::getCameraNode()->setParentSoft(this->travelNode);
     287        State::getCameraNode()->setRelCoorSoft(-3, 50,0);
     288        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     289        State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     290
     291
     292        this->debugNode(1);
     293        this->travelNode->debugNode(1);
     294      }
     295      break;
     296
     297    default:
     298      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassName());
     299  }
     300}
     301
    237302
    238303
     
    277342
    278343  // TRYING TO FIX PNode.
    279   //this->travelNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
    280   //this->travelNode.setRelDirSoft(this->getAbsDir(), 30.0f);
     344  this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
     345  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
    281346}
    282347
     
    307372    accel += Vector(0, 0, this->acceleration);
    308373  }
    309 
    310374
    311375  switch(this->getPlaymode())
     
    316380
    317381        // this is the air friction (necessary for a smooth control)
    318 
    319         this->velocity += (accelerationDir)* dt;
     382        Vector damping = (this->velocity * this->airFriction);
     383
     384
     385        this->velocity += (accelerationDir - damping)* dt;
    320386        this->shiftCoor (this->velocity * dt);
    321387
     
    332398
    333399        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
    334 
    335400      }
    336401      break;
     
    338403    case Playable::Horizontal:
    339404      {
     405
     406        if (this->toTravelHeight != NULL)
     407        {
     408          this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt, 0));
     409          if (fabsf(this->travelNode->getAbsCoor().y - *this->toTravelHeight) < .1)
     410          {
     411            delete this->toTravelHeight;
     412            this->toTravelHeight = NULL;
     413          }
     414        }
     415        this->travelNode->shiftCoor(Vector(this->travelSpeed * dt, 0, 0));
     416
    340417        accel.y = 0.0;
    341418        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
     
    343420
    344421        // this is the air friction (necessary for a smooth control)
    345 
    346 
    347         this->velocity += (accelerationDir )* dt;
     422        Vector damping = (this->velocity * this->airFriction);
     423
     424
     425        this->velocity += (accelerationDir - damping)* dt;
    348426        this->shiftCoor (this->velocity * dt);
    349 
    350         // limit the maximum rotation speed.
    351         if (this->rotation != 0.0f)
    352         {
    353           float maxRot = 10.0 * dt;
    354           if (unlikely(this->rotation > 0.01 || this->rotation < 0.01)) this->rotation /=1.5;
    355           this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
    356 
    357           this->rotation = 0.0f;
    358         }
    359 
    360         this->setRelDirSoft(this->direction, 5);
     427        this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 1.0f);
    361428      }
    362429      break;
    363430
    364431    default:
    365       PRINTF(2)("Playmode %s Not Implemented\n", Playable::playmodeToString(this->getPlaymode()).c_str());
     432      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassName());
    366433  }
    367434}
     
    390457  else if( event.type == EV_MOUSE_MOTION)
    391458  {
    392     float xMouse, yMouse;
    393     xMouse = event.xRel*mouseSensitivity;
    394     yMouse = event.yRel*mouseSensitivity;
    395 
    396     // rotate the Player around the y-axis
     459
     460
     461
    397462    if (this->getPlaymode() == Playable::Full3D)
     463    {
     464      float xMouse, yMouse;
     465      xMouse = event.xRel*mouseSensitivity;
     466      yMouse = event.yRel*mouseSensitivity;
     467
     468      // rotate the Player around the y-axis
    398469      this->rotation += xMouse;
    399470
    400     this->cameraLook += yMouse;
    401     // rotate the Camera around the z-axis
    402     if (cameraLook > M_PI_4)
    403       cameraLook = M_PI_4;
    404     else if (cameraLook < -M_PI_4)
    405       cameraLook = -M_PI_4;
    406     //this->cameraNode.setRelDirSoft(this->direction,10);
    407   }
    408 }
     471      this->cameraLook += yMouse;
     472      // rotate the Camera around the z-axis
     473      if (cameraLook > M_PI_4)
     474        cameraLook = M_PI_4;
     475      else if (cameraLook < -M_PI_4)
     476        cameraLook = -M_PI_4;
     477      //this->cameraNode.setRelDirSoft(this->direction,10);
     478    }
     479  }
     480}
  • trunk/src/world_entities/space_ships/spacecraft_2d.h

    r9061 r9110  
    2222
    2323    virtual void loadParams(const TiXmlElement* root);
     24
     25    void setTravelSpeed(float travelSpeed);
     26    void setTravelHeight(float travelHeight);
     27    void setTravelDistance(const Vector2D& distance);
     28    void setTravelDistance(float x, float y);
     29
     30
    2431    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
    25     void setTravelDirecton(const Quaternion& rot, float speed = 0.0);
    26     void setTravelSpeed(float travelSpeed);
    27 
    2832    virtual void enter();
    2933    virtual void leave();
    30 
    3134
    3235
     
    3942
    4043    virtual void process(const Event &event);
     44
     45  protected:
     46    virtual void enterPlaymode(Playable::Playmode playmode);
    4147
    4248  private:
     
    5359    float                 mouseSensitivity;   //!< the mouse sensitivity
    5460
     61    /// Normal Movement.
     62    Quaternion            direction;          //!< the direction of the Spacecraft2D.
     63    float                 acceleration;       //!< the acceleration of the Spacecraft2D.
     64    float                 airFriction;        //!< AirFriction.
     65
     66    float                 airViscosity;
    5567
    5668
    57     PNode                 travelNode;
    58     float                 travelSpeed;
     69    /// 2D-traveling
     70    PNode*                travelNode;
     71    float*                toTravelHeight;
     72    float                 travelSpeed;        //!< the current speed of the Hove (to make soft movement)
    5973
     74    Vector2D              travelDistance;     //!< Travel-Distance away from the TravelNode.
     75
     76    /// Camera
     77    PNode                 cameraNode;
    6078    float                 cameraLook;
    6179    float                 rotation;
    6280
    63    // Vector                velocity;           //!< the velocity of the Spacecraft2D.
    64     Quaternion            direction;          //!< the direction of the Spacecraft2D.
    65     float                 acceleration;       //!< the acceleration of the Spacecraft2D.
    66     float                 maxSpeed;           //!< The Maximal speed of the Spacecraft2D.
    67 
    68     float                 altitude;           //!< The height in the Entity.
    6981
    7082    ParticleEmitter*      burstEmitter;
  • trunk/src/world_entities/world_entity.cc

    r9061 r9110  
    8585
    8686  this->toList(OM_NULL);
    87 
     87 
     88  registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) );
    8889  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    8990  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
    9091  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
     92 
     93  health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) );
     94  healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) );
    9195}
    9296
     
    837841    this->toList( (OM_LIST)list_write );
    838842  }
     843 
     844  if ( std::find( id.begin(), id.end(), health_handle ) != id.end() )
     845  {
     846    this->setHealth( health_write );
     847  }
     848 
     849  if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() )
     850  {
     851    this->setHealthMax( healthMax_write );
     852  }
    839853
    840854  PNode::varChangeHandler( id );
  • trunk/src/world_entities/world_entity.h

    r9008 r9110  
    198198  int                     list_write;                      //!< entity's list
    199199  int                     list_handle;                     //!< handle for list changes
     200 
     201  float                   health_write;
     202  int                     health_handle;
     203 
     204  float                   healthMax_write;
     205  int                     healthMax_handle;
    200206
    201207  CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
Note: See TracChangeset for help on using the changeset viewer.