Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8894 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jun 29, 2006, 12:19:48 AM (18 years ago)
Author:
patrick
Message:

merged the branche single_player_map with the trunk

Location:
trunk/src
Files:
33 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r8793 r8894  
    187187  CL_BSP_ENTITY                 =    0x00000312,
    188188  CL_SKYDOME                    =    0x00000313,
     189  CL_DOOR                       =    0x00000314,
    189190
    190191  // Playables
     
    212213  CL_TARGETING_TURRET           =    0x000003a4,
    213214  CL_HYPERBLASTER               =    0x000003a5,
     215  CL_FPS_SNIPER_RIFLE           =    0x000003a6,
     216  CL_FPS_LASER_RIFLE            =    0x000003a7,
    214217
    215218  // Projectiles
  • trunk/src/lib/collision_detection/cd_engine.cc

    r8490 r8894  
    8484        if( likely((*entity2) != this->terrain))
    8585        {
    86           PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName());
     86          PRINTF(5)("checking object %s (%s) against %s (%s)\n", (*entity1)->getClassName(), (*entity1)->getName(), (*entity2)->getClassName(), (*entity2)->getName());
    8787          tree = (*entity1)->getOBBTree();
    8888          if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL)
  • trunk/src/lib/collision_reaction/collision_event.h

    r8490 r8894  
    99#include "vector.h"
    1010
     11#include "cr_defs.h"
     12
     13
    1114class WorldEntity;
    1215class BoundingVolume;
    1316class Plane;
     17
    1418
    1519
     
    2226
    2327  /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
    24   inline void collide(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    25   { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
     28  inline void collide(int type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
     29  { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
    2630  /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
    27   inline void collide(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)
    28   { this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; }
     31  inline void collide(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
     32  { this->collisionType = type; this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; this->bInWall = bInWall; }
    2933
    3034
     
    4448  inline Vector getCollisionPosition() { return this->position; }
    4549
     50  /** @return the type of the collision */
     51  inline int getType() { return this->collisionType; }
     52
     53  /** @return true if the entity is in the wall */
     54  inline bool isInWall() { return this->bInWall; }
     55
     56
    4657 private:
    4758  WorldEntity*      entityA;                       //!< the collision body A
     
    5364  Vector            groundNormal;                  //!< the ground plane with which it collides (only for bsp-model collisions
    5465  Vector            position;                      //!< position of the collision on the ground plane
     66
     67  bool              bInWall;                       //!< true if is in wall
     68  int               collisionType;                 //!< collision type
    5569};
    5670
  • trunk/src/lib/collision_reaction/cr_defs.h

    r8190 r8894  
    2828
    2929
     30//!< the collision axis x collision event
     31#define COLLISION_TYPE_AXIS_X   1
     32//!< the collision axis y collision event
     33#define COLLISION_TYPE_AXIS_Y   2
     34//!< the collision axis z collision event
     35#define COLLISION_TYPE_AXIS_Z   4
     36//!< the collision is a obb collision
     37#define COLLISION_TYPE_OBB      8
     38
    3039
    3140#endif /* _NETWORK_MANAGER */
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8796 r8894  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44   Copyright (C) 2004 orx
    5  
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10  
     10
    1111   ### File Specific:
    1212   main-programmer: Patrick Boenzli
     
    2626#include <vector>
    2727
     28#include "debug.h"
     29
    2830#include "aabb.h"
     31
     32#include "cr_defs.h"
    2933
    3034using namespace std;
     
    6468  //   collision->getEntityB()->getAbsCoor().debug();
    6569
    66   Vector height;
     70  float height;
    6771  AABB* box = collision->getEntityB()->getModelAABB();
    68  
    69  
    70  
    71   if(box!=NULL)
     72  WorldEntity* entity = collision->getEntityB();
     73
     74  // collision position maths
     75  Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     76
     77  float CR_MAX_WALK_HEIGHT = 2.0f;
     78  float CR_THRESHOLD = 0.2f;
     79
     80  if( box == NULL)
     81  {
     82    PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n");
     83    return;
     84  }
     85
     86
     87  switch( ce->getType())
     88  {
     89    case COLLISION_TYPE_AXIS_Y:
     90
     91      height = collPos.y - box->halfLength[1];
     92     // PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
     93     // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
     94
     95      // object is beneath the plane (ground)
     96      if( height <= 0.0f )
     97      {
     98        entity->shiftCoor(Vector(0, -height, 0));
     99      }
     100      // object is already in the wall
     101      else if( ce->isInWall())
     102      {
     103        entity->setAbsCoor(entity->getLastAbsCoor());
     104      }
     105      break;
     106
     107
     108    case COLLISION_TYPE_AXIS_X:
     109    case COLLISION_TYPE_AXIS_Z:
     110      break;
     111
     112    }
     113
     114
     115
     116
     117
     118
     119
     120
     121#if 0
     122  if( box != NULL)
    72123    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
    73124  else
    74125    height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
    75126
    76   if(box!=NULL) {
     127
     128  if( box != NULL) {
    77129
    78130
     
    90142      return;
    91143    }
    92    
    93    
     144
     145
    94146    if(ce->getGroundNormal().len() >= 1.4f) {
    95147      downspeed++;
     
    101153    if(height.y > box->halfLength[1] + 0.0f ) // Above ground
    102154    {
    103       if(height.y < box->halfLength[1] + 1.3f) // Snap in
     155      if(height.y < box->halfLength[1] + 2.3f) // Snap in
    104156      {
    105157        downspeed = 0;
     
    116168      {
    117169        //if(downspeed <= 0) downspeed =1;
    118         collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f/* 0.00001 *//*height.y+3.500005 + 10.0*/,0.0));
     170        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f,0.0));
    119171        //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
    120172        downspeed = 0;
     
    124176
    125177  }// if(box!= NULL)
     178#endif
    126179  /*
    127180  PRINTF(0)("Collision with Ground: \n");
     
    131184
    132185  */
     186
    133187}
    134188
     
    141195void CRPhysicsGroundWalk::update(WorldEntity* owner)
    142196{
    143   for( int i = 9; i > 0; i--) {
    144     this->lastPositions[i] = this->lastPositions[i-1];
    145     //     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
    146   }
    147   this->lastPositions[0] = owner->getAbsCoor();
     197
    148198}
    149199
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.h

    r8724 r8894  
    2323    virtual void update(WorldEntity* entity);
    2424
     25
    2526  private:
    26     Vector       lastPosition;                //!< vector with the last valid position
    27     Vector       afterLastPosition;           //!< vector for the after last
    28     Quaternion   lastDirection;               //!< quat with the last valid direction
    29 
    30     Vector       lastPositions[10];           //!< last 10 positions
    3127    float        downspeed;
    3228};
  • trunk/src/lib/event/event_handler.cc

    r8743 r8894  
    357357  else
    358358  {
    359     SDL_WM_GrabInput(SDL_GRAB_ON);
    360     SDL_ShowCursor(SDL_DISABLE);
     359//     SDL_WM_GrabInput(SDL_GRAB_ON);
     360//     SDL_ShowCursor(SDL_DISABLE);
    361361  }
    362362}
  • trunk/src/lib/graphics/importer/bsp_file.cc

    r8490 r8894  
    214214    bspFile.read(this->visData, size);
    215215
    216     PRINTF(0)("BSP FILE: VisDataSize: %i Bytes. \n", size);
    217     PRINTF(0)("BSP FILE: NumVisData: %i. \n", size /1 - 8);
    218     PRINTF(0)("BSP FILE: Remainder: %i. \n", size % 1);
    219     PRINTF(0)("BSP FILE: VisDataOffset: %i. \n", offset);
     216    PRINTF(4)("BSP FILE: VisDataSize: %i Bytes. \n", size);
     217    PRINTF(4)("BSP FILE: NumVisData: %i. \n", size /1 - 8);
     218    PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 1);
     219    PRINTF(4)("BSP FILE: VisDataOffset: %i. \n", offset);
    220220
    221221    // Get the Textures
     
    298298    this->VertexArrayModels  = new VertexArrayModel*[this->numPatches];
    299299
    300     PRINTF(0)("BSP FILE:NumberOfPatches: %i . \n", numPatches);
     300    PRINTF(4)("BSP FILE:NumberOfPatches: %i . \n", numPatches);
    301301
    302302    this->swapAllBspCoordinates();
     
    308308    }
    309309
    310     PRINTF(0)("BSP FILE:PatchOffset: %i . \n", this->patchOffset);
     310    PRINTF(4)("BSP FILE:PatchOffset: %i . \n", this->patchOffset);
    311311
    312312    return  1;
    313313  } else {
    314     PRINTF(0)("BSP FILE: Datei nicht gefunden. \n");
     314    PRINTF(4)("BSP FILE: Datei nicht gefunden. \n");
    315315    return -1;
    316316  }
     
    323323{
    324324
    325   PRINTF(0)("BSP FILE:\n");
    326   PRINTF(0)("BSP FILE: Building Tree...\n");
     325  PRINTF(4)("BSP FILE:\n");
     326  PRINTF(4)("BSP FILE: Building Tree...\n");
    327327  root = this->build_tree_rec(0);
    328   PRINTF(0)("BSP FILE: ...done. \n");
    329   PRINTF(0)("BSP FILE:  \n");
    330   PRINTF(0)("BSP FILE: Node #0: \n");
    331   PRINTF(0)("BSP FILE:  x: %f \n",root->plane.x);
    332   PRINTF(0)("BSP FILE:  y: %f\n",root->plane.y);
    333   PRINTF(0)("BSP FILE:  z: %f\n",root->plane.z);
     328  PRINTF(4)("BSP FILE: ...done. \n");
     329  PRINTF(4)("BSP FILE:  \n");
     330  PRINTF(4)("BSP FILE: Node #0: \n");
     331  PRINTF(4)("BSP FILE:  x: %f \n",root->plane.x);
     332  PRINTF(4)("BSP FILE:  y: %f\n",root->plane.y);
     333  PRINTF(4)("BSP FILE:  z: %f\n",root->plane.z);
    334334}
    335335
     
    400400  this->Materials = new AMat[this->numTextures];
    401401  for(int i = 0 ; i < this->numTextures; i++) {
    402     PRINTF(0)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]);
     402    PRINTF(4)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]);
    403403
    404404
     
    429429    strncat (fileName, ext, strlen(fileName) );
    430430
    431     PRINTF(0)("BSP FILE: Name %s . \n", fileName);
     431    PRINTF(4)("BSP FILE: Name %s . \n", fileName);
    432432
    433433    absFileName = ResourceManager::getFullName(fileName);
    434434
    435435    if(File(absFileName).exists()) {
    436       PRINTF(0)("BSP FILE: gefunden . \n");
     436      PRINTF(4)("BSP FILE: gefunden . \n");
    437437      this->Materials[i] = this->loadAVI(fileName);
    438438      continue;
     
    449449
    450450    if(File(absFileName).exists()) {
    451       PRINTF(0)("BSP FILE: gefunden . \n");
     451      PRINTF(4)("BSP FILE: gefunden . \n");
    452452      this->Materials[i] = this->loadAVI(fileName);
    453453      continue;
     
    479479
    480480    if(File(absFileName).exists()) {
    481       PRINTF(0)("BSP FILE: gefunden . \n");
     481      PRINTF(4)("BSP FILE: gefunden . \n");
    482482      this->Materials[i] = this->loadMat(fileName);
    483483      continue;
     
    492492
    493493    if(File(absFileName).exists()/*stat( absFileName.c_str() , &results) == 0*/) {
    494       PRINTF(0)("BSP FILE: gefunden . \n");
     494      PRINTF(4)("BSP FILE: gefunden . \n");
    495495      this->Materials[i] = this->loadMat(fileName);
    496496      continue;
     
    504504    absFileName = ResourceManager::getFullName(fileName);
    505505    if(File(absFileName).exists()) {
    506       PRINTF(0)("BSP FILE: gefunden . \n");
     506      PRINTF(4)("BSP FILE: gefunden . \n");
    507507      this->Materials[i] =this->loadMat(fileName);
    508508      continue;
     
    518518    absFileName = ResourceManager::getFullName(fileName);
    519519    if(File(absFileName).exists()) {
    520       PRINTF(0)("BSP FILE: gefunden . \n");
     520      PRINTF(4)("BSP FILE: gefunden . \n");
    521521      this->Materials[i] =this->loadMat(fileName);
    522522      continue;
     
    534534
    535535    if(File(absFileName).exists()) {
    536       PRINTF(0)("BSP FILE: gefunden . \n");
     536      PRINTF(4)("BSP FILE: gefunden . \n");
    537537      this->Materials[i] =this->loadMat(fileName);
    538538      continue;
     
    548548
    549549    if(File(absFileName).exists()) {
    550       PRINTF(0)("BSP FILE: gefunden . \n");
     550      PRINTF(4)("BSP FILE: gefunden . \n");
    551551      this->Materials[i] = this->loadMat(fileName);
    552552      continue;
    553553    }
    554554
    555 
     555    PRINTF(0)("BSP FILE: Textur %s nicht  gefunden . \n", &this->textures[8+72*i]);
    556556    //  Default Material
    557557    this->Materials[i].mat = new Material();
     
    10121012  Face->meshvert = patchOffset -sz;  //3*(patchOffset-sz)*level1*level1;
    10131013  Face->n_meshverts = sz;
    1014   PRINTF(0)("BSP FILE: sz: %i. \n", sz);
    1015   PRINTF(0)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
     1014  PRINTF(4)("BSP FILE: sz: %i. \n", sz);
     1015  PRINTF(4)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
    10161016
    10171017  //Face->n_meshverts = sz;
  • trunk/src/lib/graphics/importer/bsp_manager.cc

    r8796 r8894  
    4545
    4646#include "aabb.h"
    47 
     47#include "cr_defs.h"
    4848
    4949
     
    912912{
    913913  leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
    914   for(int i = 0; i < curLeaf.n_leaffaces ; i++) {
    915   }
     914  for(int i = 0; i < curLeaf.n_leaffaces ; i++) {}
    916915  return 10.0f;
    917916}
    918917
    919918void BspManager::checkCollisionBox(void)
    920 {
    921 }
    922 ;
     919{}
     920
    923921
    924922void BspManager::TraceBox( Vector& inputStart, Vector& inputEnd,
     
    954952
    955953
    956   Vector forwardDir = worldEntity->getAbsDirX();
    957 
    958 
    959   Vector upDir = worldEntity->getAbsDirY();
    960   upDir.x = 0.0;
    961   upDir.y = 1.0;
    962   upDir.z = 0.0;
    963   Vector dest;
    964    
    965 
    966   Vector position = worldEntity->getAbsCoor();       //+ upDir*10.0f ;
    967   dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    968   Vector out = dest;
    969 
    970 
     954  Vector forwardDir = Vector(0.0,0.0,1.0);
     955  Vector upDir = Vector(0.0,1.0,0.0);
     956  Vector position = worldEntity->getAbsCoor();
     957
     958  bool SolidFlag = false;
    971959  bool collision = false;
    972960  Vector position1 = position;
    973961  Vector position2 = position + Vector(0.0,1.0,0.0);
     962  Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    974963  Vector dest1 = position + forwardDir*4.0f;
    975964  Vector dest2 = position2 + forwardDir;
    976965  dest = position - Vector(0.0, 40.0,0.0);
     966  Vector out = dest;
    977967  Vector out1;
    978968  Vector out2;
    979969
    980  
     970
    981971
    982972  float height = 40;
    983  
    984  
    985   if( box != NULL)
    986   {
     973
     974
     975  if( box != NULL) {
    987976    position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
    988977    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
    989    
     978
    990979    position1 = worldEntity->getAbsCoor() +  box->center + box->axis[0] * box->halfLength[0] * 2.0f;
    991980    dest1     = worldEntity->getAbsCoor() +  box->center - box->axis[0] * box->halfLength[0] *2.0f;
    992    
    993        
     981
     982
    994983    position2 = worldEntity->getAbsCoor() +  box->center + box->axis[2] * box->halfLength[2] * 2.0f;
    995984    dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
    996    
    997   }
    998   else
    999   {
    1000    
    1001   }
    1002 
    1003  
    1004  
    1005   //
     985
     986  } else {
     987    // Init positions and destinations to anything useful!
     988
     989  }
     990
     991
     992
     993  // 1st Ray
    1006994  this->inputStart =  position;
    1007995  this->inputEnd =   dest;
     
    10251013        this->collPlane->z = 0.0f;
    10261014        collision = true;
    1027       } else
     1015        SolidFlag = true;
     1016      } else
    10281017        collision = false;
    1029        
    1030        
    1031         out = dest;
    1032      
     1018
     1019
     1020      out = dest;
     1021
    10331022    } else {
    10341023      collision = true;
     
    10461035  plane* testPlane = this->collPlane;
    10471036
    1048  
    1049   // 2nd Collision Detection
    1050   this->outputStartsOut = true;
    1051   this->outputAllSolid = false;
    1052   this->outputFraction = 1.0f;
    1053   this->inputStart =  position1;
    1054   this->inputEnd =   dest1;
    1055   this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
    1056   out.x = this->outputFraction;
    1057   //out.z = this->outputFraction;
    1058  
    1059  
    1060     // 3rd Collision Detection
    1061   this->outputStartsOut = true;
    1062   this->outputAllSolid = false;
    1063   this->outputFraction = 1.0f;
    1064   this->inputStart =  position2;
    1065   this->inputEnd =   dest2;
    1066   this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    1067   //out.x = this->outputFraction;
    1068   out.z = this->outputFraction;
    1069  
    1070 
     1037
     1038  bool xCollision = false;
     1039  bool zCollision = false;
     1040  if(!SolidFlag) {
     1041
     1042    // 2nd Collision Detection
     1043    this->outputStartsOut = true;
     1044    this->outputAllSolid = false;
     1045    this->outputFraction = 1.0f;
     1046    this->inputStart =  position1;
     1047    this->inputEnd =   dest1;
     1048    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
     1049
     1050    if(!this->outputAllSolid != 1.0f) {
     1051      out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction;
     1052      xCollision = true;
     1053      testPlane = this->collPlane;
     1054    }
     1055    if(this->outputAllSolid) {
     1056      SolidFlag = true;
     1057      xCollision = true; 
     1058    }
     1059    //out.z = this->outputFraction;
     1060
     1061    if(!SolidFlag) {
     1062
     1063      // 3rd Collision Detection
     1064      this->outputStartsOut = true;
     1065      this->outputAllSolid = false;
     1066      this->outputFraction = 1.0f;
     1067      this->inputStart =  position2;
     1068      this->inputEnd =   dest2;
     1069      this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
     1070      //out.x = this->outputFraction;
     1071
     1072      if(this->outputFraction != 1.0f ) {
     1073        out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction;
     1074        zCollision = true;
     1075        testPlane = this->collPlane;
     1076
     1077      }
     1078      if(this->outputAllSolid) {
     1079          SolidFlag = true;
     1080          zCollision = true;   
     1081      }
     1082    }
     1083  }//end if
    10711084  /*
    10721085  This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
     
    10771090
    10781091  // Return the normal here: Normal's stored in this->collPlane;
    1079   if( collision)
    1080   {
     1092  if( collision) {
    10811093    PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    1082     worldEntity->registerCollision(this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);
    1083   }
    1084   else  worldEntity->registerCollision(this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);
     1094    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y || (xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0), this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1095  } else {
     1096    if(xCollision || zCollision) {
     1097
     1098      worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1099    }
     1100
     1101  }
     1102  //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
    10851103
    10861104}
  • trunk/src/lib/graphics/importer/interactive_model.h

    r8724 r8894  
    3737
    3838    virtual void setAnimation(int animNum, int playbackMode = 0) = 0;
     39    virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback) {}
    3940    virtual int getAnimation() = 0;
     41
     42    virtual void setAnimationSpeed(float speed) {}
    4043};
    4144
  • trunk/src/lib/graphics/importer/md2/md2Model.cc

    r8490 r8894  
    103103  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
    104104
     105  this->animationSpeed = 1.0f;
     106
    105107  // triangle conversion
    106108  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
     
    159161
    160162/**
     163 * sets the animation type
     164 * @param firstFrame: index of the first frame
     165 * @param lastFrame: index of the last frame
     166 * @param fps: frames per second
     167 * @param bStoppable: is 1 if so, 0 else
     168 */
     169void MD2Model::setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback)
     170{
     171  this->animationState.startFrame = firstFrame;
     172  this->animationState.endFrame = lastFrame;
     173  this->animationState.nextFrame = firstFrame + 1;
     174  this->animationState.fps = fps;
     175  this->animationState.type = 0;
     176  this->animationState.numPlays = 0;
     177  this->animationState.animPlaybackMode = animPlayback;
     178
     179  this->animationState.interpolationState = 0.0f;
     180  this->animationState.localTime = 0.0f;
     181  this->animationState.lastTime = 0.0f;
     182  this->animationState.currentFrame = firstFrame;
     183}
     184
     185/**
    161186  \brief sets the animation type
    162187* @param type: animation type
     
    196221void MD2Model::tick(float time)
    197222{
    198   this->animate(time);
     223  this->animate(time * this->animationSpeed);
    199224  this->processLighting();
    200225  this->interpolate(/*this->verticesList*/);
  • trunk/src/lib/graphics/importer/md2/md2Model.h

    r8724 r8894  
    6969
    7070//! animation names enumeration
    71 typedef enum animType
     71typedef enum MD2animType
    7272  {
    7373    STAND,                       //0
     
    156156  void renderFrameTriangles() const;
    157157
    158 
    159158  virtual void setAnimation(int type, int animPlayback = MD2_ANIM_LOOP);
     159  virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback);
    160160  /**  returns the current animation @returns animation type */
    161161  inline int MD2Model::getAnimation() { return this->animationState.type; }
     162  virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
    162163  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
    163164  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
     
    186187 private:
    187188  float               scaleFactor;                      //!< the scale factor (individual)
     189  float               animationSpeed;                   //!< the speed of the animation (factor for the time)
    188190  sAnimState          animationState;                   //!< animation state of the model
    189191  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
  • trunk/src/lib/math/quaternion.h

    r8802 r8894  
    5151  inline bool operator== (const Quaternion& q) const { return (unlikely(this->v==q.v&&this->w==q.w))?true:false; };
    5252  /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */
    53   inline bool operator!= (const Quaternion& q) const { return (unlikely(this->v!=q.v&&this->w!=q.w))?true:false; };
     53  inline bool operator!= (const Quaternion& q) const { return (unlikely(this->v!=q.v||this->w!=q.w))?true:false; };
    5454  /** @param f: a real value @return a Quaternion containing the quotient */
    5555  inline Quaternion operator/ (const float& f) const { return (unlikely(f==0.0)) ? Quaternion() : Quaternion(this->v/f, this->w/f); };
  • trunk/src/lib/math/vector.h

    r8490 r8894  
    4747  inline bool operator== (const Vector& v) const { return (this->x==v.x&&this->y==v.y&&this->z==v.z)?true:false; };
    4848  /** @param v: the Vecor to compare with this one @returns true, if the Vecors are different, false otherwise */
    49   inline bool operator!= (const Vector& v) const { return (this->x!=v.x&&this->y!=v.y&&this->z!=v.z)?true:false; };
     49  inline bool operator!= (const Vector& v) const { return (this->x!=v.x||this->y!=v.y||this->z!=v.z)?true:false; };
    5050  /** @param index The index of the "array" @returns the x/y/z coordinate */
    5151  inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; }
  • trunk/src/lib/script_engine/script_manager.h

    r8711 r8894  
    11/*!
    2  * @file scrip_manager.h
     2 * @file script_manager.h
    33 *  manages the scripts
    44 */
  • trunk/src/lib/shell/shell_command.cc

    r8350 r8894  
    373373    else
    374374    {
    375       delete this->completors[parameter];
     375      if(this->completors[parameter] == NULL)
     376      //delete this->completors[parameter];
    376377      this->completors[parameter] = completorPlugin.clone();
    377378    }
  • trunk/src/lib/util/executor/executor.cc

    r7742 r8894  
    3131                   const MultiType& param2,
    3232                   const MultiType& param3,
    33                    const MultiType& param4)
     33                   const MultiType& param4,
     34                   const MultiType& param5,
     35                   const MultiType& param6)
    3436{
    3537  this->setClassID(CL_EXECUTOR, "Executor");
     
    4143  this->defaultValue[3] = param3;
    4244  this->defaultValue[4] = param4;
     45  this->defaultValue[5] = param5;
     46  this->defaultValue[6] = param6;
    4347
    4448  this->paramCount = 0;
     
    8387                                  const MultiType& value2,
    8488                                  const MultiType& value3,
    85                                   const MultiType& value4)
     89                                  const MultiType& value4,
     90                                  const MultiType& value5,
     91                                  const MultiType& value6)
    8692{
    8793  if (this == NULL)
     
    94100  value[3] = &value3;
    95101  value[4] = &value4;
    96 
     102  value[5] = &value5;
     103  value[6] = &value6;
    97104  for (unsigned int i = 0; i < this->paramCount; i++)
    98105  {
  • trunk/src/lib/util/executor/executor.h

    r8408 r8894  
    4747    Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    4848                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    49                             const MultiType& value4 = MT_NULL);
     49                            const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL,
     50                            const MultiType& param6 = MT_NULL);
    5051    /** @param i the i'th defaultValue, @returns reference to the MultiType */
    5152    inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
     
    6869    Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
    6970             const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    70              const MultiType& param4 = MT_NULL);
     71             const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
     72             const MultiType& param6 = MT_NULL);
    7173
    7274    void cloning(Executor* executor) const;
     
    7577    short                       functorType;      //!< The type of Function we've got (either static or objective).
    7678    unsigned int                paramCount;       //!< the count of parameters.
    77     MultiType                   defaultValue[5];  //!< Default Values.
     79    MultiType                   defaultValue[7];  //!< Default Values.
    7880};
    7981
  • trunk/src/lib/util/executor/executor_functional.cc

    r8408 r8894  
    1515
    1616#include "executor.h"
    17 std::string ExecutorFunctional_returningString_from[5];
     17std::string ExecutorFunctional_returningString_from[7];
    1818
    1919
  • trunk/src/lib/util/executor/executor_lua.cc

    r8527 r8894  
    2020#include "lunar.h"
    2121
    22 std::string temp[5];
     22std::string temp[7];
    2323
    2424template<typename type> type fromLua(lua_State* state, int index) { type *obj = Lunar<type>::check(state, 1); lua_remove(state, 1); return obj;};
  • trunk/src/lib/util/executor/executor_lua.h

    r8711 r8894  
    233233
    234234
     235///////////
     236//// 4 ////
     237///////////
     238//! Executes a Function with a lua_State* parameter.
     239template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor
     240{
     241  public:
     242    /**
     243   * @brief Constructor of a ExecutorXML
     244   * @param function a Function to call
     245     */
     246    ExecutorLua4(void(T::*function)(type0, type1, type2, type3))
     247  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     248    {
     249      this->functionPointer = function;
     250      this->functorType = Executor_Objective | Executor_NoLoadString;
     251    }
     252
     253    /**
     254     * @brief executes the Command on BaseObject
     255     * @param object the BaseObject to execute this Executor on
     256     * @param loadString ignored in this case
     257     */
     258    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     259    {
     260      PRINTF(1)("no usefull executor\n");
     261    }
     262
     263    virtual void operator()(BaseObject* object, int& count, void* values) const
     264    {
     265      lua_State* state = (lua_State*)values;
     266      count = 0;
     267
     268      (dynamic_cast<T*>(object)->*(functionPointer))(
     269          fromLua<type0>(state, 1),
     270          fromLua<type1>(state, 2),
     271          fromLua<type2>(state, 3),
     272          fromLua<type3>(state, 4) );
     273    }
     274
     275    /**
     276     * @returns a _new_ Copy of this Executor
     277     */
     278    virtual Executor* clone () const
     279    {
     280      return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer);
     281    }
     282  private:
     283    void          (T::*functionPointer)(type0, type1, type2, type3);
     284};
    235285
    236286
     
    388438};
    389439
     440
     441///////////
     442//// 3 ////
     443///////////
     444//! Executes a Function with a lua_State* parameter.
     445template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor
     446{
     447  public:
     448    /**
     449   * @brief Constructor of a ExecutorXML
     450   * @param function a Function to call
     451     */
     452    ExecutorLua3ret(ret (T::*function)(type0, type1, type2))
     453  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
     454    {
     455      this->functionPointer = function;
     456      this->functorType = Executor_Objective | Executor_NoLoadString;
     457    }
     458
     459    /**
     460     * @brief executes the Command on BaseObject
     461     * @param object the BaseObject to execute this Executor on
     462     * @param loadString ignored in this case
     463     */
     464    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     465    {
     466      PRINTF(1)("no usefull executor\n");
     467    }
     468
     469    virtual void operator()(BaseObject* object, int& count, void* values) const
     470    {
     471      lua_State* state = (lua_State*)values;
     472      count = 1;
     473
     474      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     475          fromLua<type0>(state, 1),
     476          fromLua<type1>(state, 2),
     477          fromLua<type2>(state, 3) ));
     478    }
     479
     480    /**
     481     * @returns a _new_ Copy of this Executor
     482     */
     483    virtual Executor* clone () const
     484    {
     485      return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer);
     486    }
     487  private:
     488    ret          (T::*functionPointer)(type0, type1, type2);
     489};
     490
     491
     492///////////
     493//// 4 ////
     494///////////
     495//! Executes a Function with a lua_State* parameter.
     496template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor
     497{
     498  public:
     499    /**
     500   * @brief Constructor of a ExecutorXML
     501   * @param function a Function to call
     502     */
     503    ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3))
     504  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     505    {
     506      this->functionPointer = function;
     507      this->functorType = Executor_Objective | Executor_NoLoadString;
     508    }
     509
     510    /**
     511     * @brief executes the Command on BaseObject
     512     * @param object the BaseObject to execute this Executor on
     513     * @param loadString ignored in this case
     514     */
     515    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     516    {
     517      PRINTF(1)("no usefull executor\n");
     518    }
     519
     520    virtual void operator()(BaseObject* object, int& count, void* values) const
     521    {
     522      lua_State* state = (lua_State*)values;
     523      count = 1;
     524
     525      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     526          fromLua<type0>(state, 1),
     527          fromLua<type1>(state, 2),
     528          fromLua<type2>(state, 3),
     529          fromLua<type3>(state, 4) ));
     530    }
     531
     532    /**
     533     * @returns a _new_ Copy of this Executor
     534     */
     535    virtual Executor* clone () const
     536    {
     537      return new ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer);
     538    }
     539  private:
     540    ret          (T::*functionPointer)(type0, type1, type2, type3);
     541};
     542
     543///////////
     544//// 5 ////
     545///////////
     546//! Executes a Function with a lua_State* parameter.
     547template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor
     548{
     549  public:
     550    /**
     551   * @brief Constructor of a ExecutorXML
     552   * @param function a Function to call
     553     */
     554    ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4))
     555  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
     556    {
     557      this->functionPointer = function;
     558      this->functorType = Executor_Objective | Executor_NoLoadString;
     559    }
     560
     561    /**
     562     * @brief executes the Command on BaseObject
     563     * @param object the BaseObject to execute this Executor on
     564     * @param loadString ignored in this case
     565     */
     566    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     567    {
     568      PRINTF(1)("no usefull executor\n");
     569    }
     570
     571    virtual void operator()(BaseObject* object, int& count, void* values) const
     572    {
     573      lua_State* state = (lua_State*)values;
     574      count = 1;
     575
     576      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     577          fromLua<type0>(state, 1),
     578          fromLua<type1>(state, 2),
     579          fromLua<type2>(state, 3),
     580          fromLua<type3>(state, 4),
     581          fromLua<type4>(state, 5) ));
     582    }
     583
     584    /**
     585     * @returns a _new_ Copy of this Executor
     586     */
     587    virtual Executor* clone () const
     588    {
     589      return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer);
     590    }
     591  private:
     592    ret          (T::*functionPointer)(type0, type1, type2, type3, type4);
     593};
     594
     595///////////
     596//// 6 ////
     597///////////
     598//! Executes a Function with a lua_State* parameter.
     599template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor
     600{
     601  public:
     602    /**
     603   * @brief Constructor of a ExecutorXML
     604   * @param function a Function to call
     605     */
     606    ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5))
     607  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     608             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     609             ExecutorParamType<type4>(), ExecutorParamType<type5>())
     610    {
     611      this->functionPointer = function;
     612      this->functorType = Executor_Objective | Executor_NoLoadString;
     613    }
     614
     615    /**
     616     * @brief executes the Command on BaseObject
     617     * @param object the BaseObject to execute this Executor on
     618     * @param loadString ignored in this case
     619     */
     620    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     621    {
     622      PRINTF(1)("no usefull executor\n");
     623    }
     624
     625    virtual void operator()(BaseObject* object, int& count, void* values) const
     626    {
     627      lua_State* state = (lua_State*)values;
     628      count = 1;
     629
     630      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     631          fromLua<type0>(state, 1),
     632          fromLua<type1>(state, 2),
     633          fromLua<type2>(state, 3),
     634          fromLua<type3>(state, 4),
     635          fromLua<type4>(state, 5),
     636          fromLua<type5>(state, 6) ));
     637    }
     638
     639    /**
     640     * @returns a _new_ Copy of this Executor
     641     */
     642    virtual Executor* clone () const
     643    {
     644      return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer);
     645    }
     646  private:
     647    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5);
     648};
     649
     650///////////
     651//// 7 ////
     652///////////
     653//! Executes a Function with a lua_State* parameter.
     654template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor
     655{
     656  public:
     657    /**
     658   * @brief Constructor of a ExecutorXML
     659   * @param function a Function to call
     660     */
     661    ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6))
     662  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     663             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     664             ExecutorParamType<type4>(), ExecutorParamType<type5>(),
     665             ExecutorParamType<type6>())
     666             {
     667               this->functionPointer = function;
     668               this->functorType = Executor_Objective | Executor_NoLoadString;
     669             }
     670
     671    /**
     672              * @brief executes the Command on BaseObject
     673              * @param object the BaseObject to execute this Executor on
     674              * @param loadString ignored in this case
     675     */
     676             virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     677             {
     678               PRINTF(1)("no usefull executor\n");
     679             }
     680
     681             virtual void operator()(BaseObject* object, int& count, void* values) const
     682             {
     683               lua_State* state = (lua_State*)values;
     684               count = 1;
     685
     686               toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     687                   fromLua<type0>(state, 1),
     688                   fromLua<type1>(state, 2),
     689                   fromLua<type2>(state, 3),
     690                   fromLua<type3>(state, 4),
     691                   fromLua<type4>(state, 5),
     692                   fromLua<type5>(state, 6),
     693                   fromLua<type6>(state, 7) ));
     694             }
     695
     696    /**
     697              * @returns a _new_ Copy of this Executor
     698     */
     699             virtual Executor* clone () const
     700             {
     701               return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer);
     702             }
     703  private:
     704    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6);
     705};
     706
     707
    390708#endif /* _EXECUTOR_LUA_H */
  • trunk/src/lib/util/executor/functor_list.h

    r8619 r8894  
    2929
    3030//! defines the maximum count of arguments function pointers might have
    31 #define FUNCTOR_MAX_ARGUMENTS                5
     31#define FUNCTOR_MAX_ARGUMENTS                7
    3232#include "multi_type.h"
    3333
  • trunk/src/story_entities/game_world.cc

    r8740 r8894  
    308308    /* update the state */
    309309    //this->update (); /// LESS REDUNDANCY.
    310     PNode::getNullParent()->updateNode(this->dtS);
     310//     PNode::getNullParent()->updateNode(this->dtS);
    311311
    312312
  • trunk/src/story_entities/multi_player_world.cc

    r8717 r8894  
    9898    this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
    9999
     100  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
     101  this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
     102  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS),
     103  this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
     104
    100105  CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),
    101106    this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
  • trunk/src/world_entities/WorldEntities.am

    r8793 r8894  
    1616                world_entities/character_attributes.cc \
    1717                world_entities/test_entity.cc \
     18                world_entities/door.cc \
    1819                world_entities/planet.cc \
    1920                world_entities/bsp_entity.cc \
     
    2627                world_entities/weapons/hyperblaster.cc \
    2728                world_entities/weapons/aim.cc \
     29                world_entities/weapons/fps_sniper_rifle.cc \
    2830                \
    2931                world_entities/projectiles/bomb.cc \
     
    7476                character_attributes.h \
    7577                test_entity.h \
     78                door.h \
    7679                planet.h \
    7780                bsp_entity.h \
     
    8487                weapons/targeting_turret.h \
    8588                weapons/aim.h \
     89                weapons/fps_sniper_rifle.h \
    8690                \
    8791                projectiles/bomb.h \
  • trunk/src/world_entities/creatures/fps_player.cc

    r8846 r8894  
    2626#include "weapons/turret.h"
    2727#include "weapons/cannon.h"
     28#include "weapons/fps_sniper_rifle.h"
    2829
    2930#include "key_mapper.h"
     
    3536
    3637CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER);
     38
     39#include "script_class.h"
     40CREATE_SCRIPTABLE_CLASS(FPSPlayer, CL_FPS_PLAYER,
     41                        addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     42                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     43                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     44                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     45                       );
    3746
    3847
     
    101110  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
    102111
    103   Weapon* wpRight = new TestGun(0);
     112  Weapon* wpRight = new FPSSniperRifle(0);
    104113  wpRight->setName("testGun Right");
    105   Weapon* wpLeft = new TestGun(1);
     114/*  Weapon* wpLeft = new TestGun(1);*/
    106115//   Weapon* wpLeft = new Turret();
    107   wpLeft->setName("testGun Left");
    108 
    109   this->addWeapon(wpLeft, 1, 0);
    110   this->addWeapon(wpRight,1 ,1);
     116//   wpLeft->setName("testGun Left");
     117
     118//   this->addWeapon(wpLeft, 1, 0);
     119  this->addWeapon(wpRight,1, 0);
    111120  this->getWeaponManager().changeWeaponConfig(1);
    112121
    113122  this->getWeaponManager().setSlotCount(2);
    114   this->getWeaponManager().setSlotPosition(0, Vector(-0.5, .2, -1.9));
     123  this->getWeaponManager().setSlotPosition(0, Vector(0.0, 5.0, 0.0));
     124  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(0,1,0)));
    115125  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    116126  this->getWeaponManager().setSlotPosition(1, Vector(-0.5, .2, 1.9));
  • trunk/src/world_entities/npcs/generic_npc.cc

    r8805 r8894  
    3838CREATE_FACTORY(GenericNPC, CL_GENERIC_NPC);
    3939
     40#include "script_class.h"
     41CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,
     42                       // Move
     43                        addMethod("walkTo", ExecutorLua3ret<GenericNPC,float,float,float,float>(&GenericNPC::walkTo))
     44                        ->addMethod("setTime", ExecutorLua1<GenericNPC,float>(&GenericNPC::setTime))
     45                        ->addMethod("turnTo", ExecutorLua4ret<GenericNPC,bool,float,float,float,float>(&GenericNPC::turnTo))
     46                       // Display
     47                        ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
     48                        ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
     49                       // Coordinates
     50                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     51                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     52                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     53                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     54                        ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir))
     55                           
     56                       );
     57
    4058
    4159
     
    5270}
    5371
     72
     73GenericNPC::GenericNPC()
     74  : NPC(NULL)
     75{
     76
     77}
    5478
    5579/**
     
    7599  this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    76100
     101  time = 30.0f;
    77102  // collision reaction registration
    78103//   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     
    136161
    137162  // check if this is the current goal
    138   if( this->destCoor != destCoor && this->destDir != destDir)
     163  if( this->destCoor != destCoor || this->destDir != destDir)
    139164  {
    140     this->destCoor = Vector(x, y, 0.0f);
    141     this->destDir = Quaternion(Vector(qx, qy, qz), qu);
    142 
    143     float time = 5.0f;
     165    this->destCoor = destCoor;
     166    this->destDir = destDir;
     167
     168    //float time = 100.0f;
    144169
    145170    if( this->currentAnim != NULL)
     
    147172
    148173    this->currentAnim = new Animation3D(this);
    149     this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f);
    150     this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time);
     174    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f, ANIM_LINEAR, ANIM_LINEAR);
     175    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     176    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     177
     178    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
     179    this->currentAnim->play();
     180
     181    this->setAnimation(RUN, MD2_ANIM_LOOP);
    151182  }
    152183
     
    157188
    158189
     190/**
     191 * walk to a specific place with direction
     192 *
     193 * @param x: x coordinate to go to
     194 * @param y: y coordinate to go to
     195 * @param z: z coordinate to go to
     196 *
     197 * without turning itself
     198 */
     199float GenericNPC::walkTo(float x, float y, float z)
     200{
     201  Quaternion q = this->getAbsDir();
     202
     203  //printf("%s moving to %f, %f, %f \n",this->getName(),x,y,z);
     204
     205  return this->walkTo(x, y, z, q.w, q.v.x, q.v.y, q.v.z);
     206}
    159207
    160208/**
     
    188236
    189237
     238
     239/**
     240 * run to a specific place with direction
     241 *
     242 * @param x: x coordinate to go to
     243 * @param y: y coordinate to go to
     244 * @param z: z coordinate to go to
     245 * @param qu: angle to rotate
     246 * @param qx: x coordinate of rotation vector
     247 * @param qy: y coordinate of rotation vector
     248 * @param qz: z coordinate of rotation vector
     249 *
     250 */
     251float GenericNPC::runTo(float x, float y, float z, float qu, float qx, float qy, float qz)
     252{
     253  Vector destCoor = Vector(x, y, z);
     254  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
     255
     256  // check if this is the current goal
     257  if( this->destCoor != destCoor || this->destDir != destDir)
     258  {
     259    this->destCoor = destCoor;
     260    this->destDir = destDir;
     261
     262    float time = 5.0f;
     263
     264    if( this->currentAnim != NULL)
     265      delete this->currentAnim;
     266
     267    this->currentAnim = new Animation3D(this);
     268    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     269    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     270
     271
     272    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
     273    this->currentAnim->play();
     274
     275    this->setAnimation(RUN, MD2_ANIM_LOOP);
     276  }
     277
     278  // calculate the distance
     279  Vector distance = this->getAbsCoor() - this->destCoor;
     280  return distance.len();
     281}
     282
     283
     284/**
     285 * run to a specific place with direction
     286 *
     287 * @param x: x coordinate to go to
     288 * @param y: y coordinate to go to
     289 * @param qu: angle to rotate
     290 * @param qx: x coordinate of rotation vector
     291 * @param qy: y coordinate of rotation vector
     292 * @param qz: z coordinate of rotation vector
     293 *
     294 */
     295float GenericNPC::runTo(float x, float y, float qu, float qx, float qy, float qz)
     296{
     297  this->runTo(x, y, 0.0f, qu, qx, qy, qz);
     298}
     299
     300
     301/**
     302 * run to a specific place with direction
     303 *
     304 * @param coor: vector place
     305 * @param dir: direction
     306 *
     307 */
     308float GenericNPC::runTo(const Vector& coordinate, const Quaternion& dir)
     309{
     310  this->runTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
     311}
     312
     313
     314/**
     315 * crouch to a specific place with direction
     316 *
     317 * @param x: x coordinate to go to
     318 * @param y: y coordinate to go to
     319 * @param z: z coordinate to go to
     320 * @param qu: angle to rotate
     321 * @param qx: x coordinate of rotation vector
     322 * @param qy: y coordinate of rotation vector
     323 * @param qz: z coordinate of rotation vector
     324 *
     325 */
     326float GenericNPC::crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz)
     327{
     328  Vector destCoor = Vector(x, y, z);
     329  Quaternion destDir = Quaternion(Vector(qx, qy, qz), qu);
     330
     331  // check if this is the current goal
     332  if( this->destCoor != destCoor || this->destDir != destDir)
     333  {
     334    this->destCoor = destCoor;
     335    this->destDir = destDir;
     336
     337
     338    if( this->currentAnim != NULL)
     339      delete this->currentAnim;
     340
     341    this->currentAnim = new Animation3D(this);
     342    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     343    this->currentAnim->addKeyFrame(this->destCoor, this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     344
     345
     346    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
     347    this->currentAnim->play();
     348
     349    this->setAnimation(CROUCH_WALK, MD2_ANIM_LOOP);
     350  }
     351
     352  // calculate the distance
     353  Vector distance = this->getAbsCoor() - this->destCoor;
     354  return distance.len();
     355}
     356
     357
     358/**
     359 * couch to a specific place with direction
     360 *
     361 * @param x: x coordinate to go to
     362 * @param y: y coordinate to go to
     363 * @param qu: angle to rotate
     364 * @param qx: x coordinate of rotation vector
     365 * @param qy: y coordinate of rotation vector
     366 * @param qz: z coordinate of rotation vector
     367 *
     368 */
     369float GenericNPC::crouchTo(float x, float y, float qu, float qx, float qy, float qz)
     370{
     371  this->crouchTo(x, y, 0.0f, qu, qx, qy, qz);
     372}
     373
     374
     375
     376/**
     377 * crouch to a specific place with direction
     378 *
     379 * @param coor: vector place
     380 * @param dir: direction
     381 *
     382 */
     383float GenericNPC::crouchTo(const Vector& coordinate, const Quaternion& dir)
     384{
     385  this->crouchTo(coordinate.x, coordinate.y, coordinate.z, dir.w, dir.v.x, dir.v.y, dir.v.z);
     386}
     387
     388
     389/**
     390 * stops the generic animation
     391 */
     392void GenericNPC::stop()
     393{
     394  if( this->currentAnim != NULL)
     395  {
     396    this->currentAnim->stop();
     397    delete this->currentAnim;
     398    this->currentAnim = NULL;
     399
     400    this->setAnimation(STAND, MD2_ANIM_LOOP);
     401  }
     402}
     403
     404
     405/**
     406 * lookat a world entity
     407 * @param worldEntity: the worldentity to look at
     408 */
     409float GenericNPC::lookAt(WorldEntity* worldEntity)
     410{}
     411
     412
     413/**
     414 * turns to a given direction
     415 */
     416bool GenericNPC::turnTo(float qu, float qx, float qy, float qz)
     417{
     418  Quaternion destDir = Quaternion(Vector(qx, qy, qz).getNormalized(), qu);
     419
     420  printf("Turning: %f, %f, %f, %f \n",qu,qx,qy,qz);
     421  // check if this is the current goal
     422  if( this->destDir != destDir)
     423  {
     424//     if( this->currentAnim != NULL)
     425//       this->currentAnim->stop();
     426//
     427    PRINTF(0)("SET ANIMATION\n");
     428    this->destDir = destDir;
     429//
     430
     431
     432    if( this->currentAnim != NULL)
     433      delete this->currentAnim;
     434
     435    this->setAbsDir(destDir);
     436/*
     437    this->currentAnim = new Animation3D(this);
     438    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), 0.0f, ANIM_LINEAR, ANIM_LINEAR);
     439    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->getAbsDir(), time, ANIM_LINEAR, ANIM_LINEAR);
     440    this->currentAnim->addKeyFrame(this->getAbsCoor(), this->destDir, time, ANIM_LINEAR, ANIM_LINEAR);
     441
     442
     443    this->currentAnim->setInfinity(ANIM_INF_CONSTANT);
     444    this->currentAnim->play();*/
     445
     446    this->setAnimation(STAND, MD2_ANIM_LOOP);
     447  }
     448
     449  // calculate the distance
     450  Vector distance = this->getAbsCoor() - this->destCoor;
     451  return distance.len();
     452}
     453
     454
     455
     456/**
     457 * talk to a world entity and play a sound/music/voice
     458 * @param worldEntity: entity
     459 * @param dialogNr: sound nr to be played (from the xml load tags)
     460 */
     461float GenericNPC::talkTo(WorldEntity* worldEntity, int dialogNr)
     462{}
     463
     464
     465/**
     466 * world entity to shoot at if there is any weapon on the npc
     467 * @param entity: entity to shoot entity
     468 */
     469void GenericNPC::shootAt(WorldEntity* entity)
     470{}
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
    190481/**
    191482 * tick this world entity
     
    196487  if( likely(this->getModel(0) != NULL))
    197488    ((InteractiveModel*)this->getModel(0))->tick(time);
     489
    198490}
    199491
  • trunk/src/world_entities/npcs/generic_npc.h

    r8802 r8894  
    2828{
    2929 public:
     30  GenericNPC();
    3031  GenericNPC(const TiXmlElement* root);
    3132  virtual ~GenericNPC ();
     
    3839  inline void setVolume(float vol) { this->soundVolume = vol; }
    3940
    40   void playAnimation(int animationIndex, int animPlaybackMode);
    4141
    42   void playSound(std::string filename);
    43   void playSound(int i);
     42  /* npc controlling functions */
    4443
    45   float lookAt(WorldEntity* worldEntity);
    46 
     44  /* walking functions */
    4745  float walkTo(const Vector& coordinate, const Quaternion& dir);
     46  float walkTo(float x, float y, float z);
    4847  float walkTo(float x, float y, float z, float qu, float qx, float qy, float qz);
    4948  float walkTo(float x, float y, float qu, float qx, float qy, float qz);
    5049
     50  /* running functions */
    5151  float runTo(const Vector& coordinate, const Quaternion& dir);
    5252  float runTo(float x, float y, float z, float qu, float qx, float qy, float qz);
    5353  float runTo(float x, float y, float qu, float qx, float qy, float qz);
    5454
     55  /* couching functinos */
    5556  float crouchTo(const Vector& coordinate, const Quaternion& dir);
    5657  float crouchTo(float x, float y, float z, float qu, float qx, float qy, float qz);
    5758  float crouchTo(float x, float y, float qu, float qx, float qy, float qz);
    5859
     60  /* stopping the movement */
     61  void stop();
     62
     63  /* some oriantation functions */
     64  float lookAt(WorldEntity* worldEntity);
     65  bool turnTo(float qu, float qx, float qy, float qz);
     66
     67  /* talking funcitons*/
    5968  float talkTo(WorldEntity* worldEntity, int dialogNr);
     69
     70  /* shooting functions */
     71  void shootAt(WorldEntity* entity);
     72
     73
     74  /* some generic control funtions */
     75  void playAnimation(int animationIndex, int animPlaybackMode);
     76  void playSound(std::string filename);
     77  void playSound(int i);
     78
     79  void setTime(float newTime){ this->time = newTime; };
     80 
     81  virtual void tick (float time);
    6082
    6183
    6284  void destroy();
    63 
    64   virtual void tick (float time);
    6585
    6686
     
    7494
    7595   Animation3D*                            currentAnim;
     96   float                                   time;          //!< Duration of the action
    7697};
    7798
  • trunk/src/world_entities/npcs/npc.cc

    r8724 r8894  
    5050void NPC::loadParams(const TiXmlElement* root)
    5151{
    52   WorldEntity::loadParams(root);
     52  if(root != NULL)
     53   WorldEntity::loadParams(root);
    5354}
    5455
  • trunk/src/world_entities/script_trigger.cc

    r8783 r8894  
    2424CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER,
    2525                            addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    26                                 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    27                                 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    28                                 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     26                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     27                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     28                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    2929                       );
    3030
     
    4141
    4242  returnCount = 1;
    43   actionFinished = false;
     43  scriptFinished = false;
    4444  doDebugDraw = false;
    4545  invert = false;
    4646  scriptCalled = false;
    4747  scriptIsOk = false;
    48   triggerLasts = false;
     48  triggerLasts = true;
    4949  addToScript = false;
    5050 
     
    5454  loadParams(root);
    5555 
    56   if(addToScript)
     56  if(addToScript && scriptIsOk)
    5757  {
    5858    script->addObject( "ScriptTrigger", this->getName());
     
    102102        .describe("The name of the parent as it is in the *.oxw file")
    103103        .defaultValues("");
    104     LoadParam(root, "callonce", this, ScriptTrigger, setCallOnce)
    105         .describe("True if the script shoul only be called once")
    106         .defaultValues("");
    107104    LoadParam(root, "invert", this, ScriptTrigger, setInvert)
    108105        .describe("")
    109         .defaultValues("");
     106        .defaultValues("false");
    110107    LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
    111108        .describe("")
    112         .defaultValues("");
     109        .defaultValues("true");
    113110    LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
    114         .describe("True if the script should only be called once")
    115         .defaultValues("");
     111        .describe("")
     112        .defaultValues("false");
    116113    LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
    117114        .describe("True if this scripttrigger should be aviable in the script")
    118         .defaultValues("");
     115        .defaultValues("false");
    119116}
    120117
     
    159156void ScriptTrigger::tick(float timestep)
    160157{
    161   if(actionFinished) return;
     158  if(scriptFinished) return;
    162159
    163160  if(triggerLasts && scriptCalled)
     
    169166  if( !invert && this->distance(target) < radius)
    170167 {
    171   if(!callOnce)
    172    {
    173168    executeAction(timestep);
    174169    scriptCalled = true;
    175    }
    176   else if(callOnce && !scriptCalled)
    177   {
    178    executeAction(timestep);
    179    scriptCalled = true;
    180   }
    181170 
    182171 }
    183172 else if( invert && this->distance(target) > radius)
    184173 {
    185    if(!callOnce)
    186    {
    187      executeAction(timestep);
    188    }
    189    else if(callOnce && !scriptCalled)
    190    {
    191      executeAction(timestep);
     174     executeAction(timestep);
    192175     scriptCalled = true;
    193    }
    194    
    195176 }
    196177 //else
     
    202183void ScriptTrigger::executeAction(float timestep)
    203184{
     185 
    204186     if(scriptIsOk)
    205187     {
     
    213195       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
    214196     
    215      actionFinished = script->getReturnedBool();
     197     scriptFinished = script->getReturnedBool();
    216198     }
    217199     
  • trunk/src/world_entities/script_trigger.h

    r8783 r8894  
    3535    void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
    3636    void setTriggerParent(const std::string& name);
    37     void setCallOnce(const bool call) { this->callOnce = call; }
    3837    void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; }
    3938    void setInvert(const bool inv) { this->invert = invert; }
     
    5150
    5251    WorldEntity* target;
    53     bool         callOnce;
    5452    bool         triggerLasts;
    5553    bool         invert;
     
    6361    bool         scriptCalled;
    6462    bool         scriptIsOk;
    65     bool         actionFinished;
     63    bool         scriptFinished;
    6664    int          returnCount;        //TODO: set return count correctly
    6765
  • trunk/src/world_entities/world_entity.cc

    r8778 r8894  
    193193        PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str());
    194194
    195       if( modelNumber == 0)
     195      if( modelNumber == 0 && !this->isA(CL_WEAPON))
    196196        this->buildObbTree(obbTreeDepth);
    197197    }
     
    418418  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
    419419  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
    420   c->collide(entityA, entityB, bvA, bvB);
     420  c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
    421421
    422422  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
     
    433433 *  @param position it collides on the plane
    434434 */
    435 bool WorldEntity::registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)
     435bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
    436436{
    437437  // is there any handler listening?
     
    442442  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
    443443  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
    444   c->collide(entity, groundEntity, normal, position);
     444  c->collide(type, entity, groundEntity, normal, position, bInWall);
    445445
    446446  for( int i = 0; i < CREngine::CR_NUMBER; ++i)
  • trunk/src/world_entities/world_entity.h

    r8777 r8894  
    8888
    8989  bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
    90   bool registerCollision(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position);
     90  bool registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall = false);
    9191  /** @return true if there is at least on collision reaction subscribed */
    9292  inline bool isReactive() const { return this->bReactive; }
     
    115115  /** @returns a Reference to the Iterator */
    116116  ObjectManager::EntityList::iterator& getEntityIterator() { return this->objectListIterator; }
     117
     118  void hide() { if( this->objectListNumber != OM_DEAD) this->lastObjectListNumber = this->objectListNumber; this->toList(OM_DEAD); }
     119  void unhide() { this->toList(this->lastObjectListNumber); }
     120
    117121
    118122  /* --- Character Attribute Block --- */
     
    176180  OM_LIST                 objectListNumber;                //!< The ObjectList from ObjectManager this Entity is in.
    177181  ObjectManager::EntityList::iterator objectListIterator;  //!< The iterator position of this Entity in the given list of the ObjectManager.
     182  OM_LIST                 lastObjectListNumber;            //!< the last ObjectList from the ObjectManager this Entity was is in
    178183
    179184
Note: See TracChangeset for help on using the changeset viewer.