Changeset 11042 for code/branches/presentationHS15
- Timestamp:
- Jan 4, 2016, 6:31:29 PM (9 years ago)
- Location:
- code/branches/presentationHS15/src/modules/hover
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS15/src/modules/hover/Hover.cc
r11041 r11042 75 75 //Outer Walls 76 76 for(int i = 0; i<numCells; i++){ 77 new HoverWall(origin_->getContext(),0, i+1, cellSize, cellHeight, 1);78 new HoverWall(origin_->getContext(),numCells, i+1, cellSize, cellHeight, 1);79 new HoverWall(origin_->getContext(),i+1, 0, cellSize, cellHeight, 2);80 new HoverWall(origin_->getContext(),i+1, numCells, cellSize, cellHeight, 2);77 (new HoverWall(origin_->getContext()))->init(0, i+1, cellSize, cellHeight, 1); 78 (new HoverWall(origin_->getContext()))->init(numCells, i+1, cellSize, cellHeight, 1); 79 (new HoverWall(origin_->getContext()))->init(i+1, 0, cellSize, cellHeight, 2); 80 (new HoverWall(origin_->getContext()))->init(i+1, numCells, cellSize, cellHeight, 2); 81 81 } 82 82 … … 85 85 for(int x=0; x<numCells; x++){ 86 86 switch(levelcode[ y * numCells + x ]){ 87 case 1: new HoverWall(origin_->getContext(),x+1, numCells-y, cellSize, cellHeight, 1);87 case 1: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1); 88 88 break; 89 case 3: new HoverWall(origin_->getContext(),x+1, numCells-y, cellSize, cellHeight, 1);90 case 2: new HoverWall(origin_->getContext(),x+1, numCells-y, cellSize, cellHeight, 0);89 case 3: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1); 90 case 2: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0); 91 91 default: break; 92 92 } … … 96 96 //Generate 5 flags randomly 97 97 for ( int i = 0; i < 5; i++ ) 98 flagVector_.push_back(new HoverFlag(origin_->getContext(), rand()%numCells, rand()%numCells, cellSize)); 98 { 99 HoverFlag* flag = new HoverFlag(origin_->getContext()); 100 flag->init(rand()%numCells, rand()%numCells, cellSize); 101 flagVector_.push_back(flag); 102 } 99 103 100 104 flags_ = flagVector_.size(); -
code/branches/presentationHS15/src/modules/hover/HoverFlag.cc
r11041 r11042 48 48 { 49 49 RegisterObject(HoverFlag); 50 model_ = NULL; 51 cs_ = NULL; 50 51 this->model_ = NULL; 52 this->cs_ = NULL; 53 this->collided_ = false; 54 55 this->enableCollisionCallback(); 56 this->setCollisionResponse(true); 57 this->setCollisionType(Static); 52 58 } 53 59 54 60 /** 55 61 @brief 56 Constructor that expects two coordinate-values in the range 0-962 Initializes the flag. 57 63 @param xCoordinate 58 64 X-Coordinate of the flage, 0-9, origin is bottom left … … 60 66 Y-Coordinate of the flage, 0-9, origin is bottom left 61 67 */ 62 HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize) : StaticEntity(context)68 void HoverFlag::init(int xCoordinate, int yCoordinate, int cellSize) 63 69 { 64 RegisterObject(HoverFlag); 65 enableCollisionCallback(); 66 model_ = NULL; 67 cs_ = NULL; 68 69 model_ = new Model(context); 70 model_ = new Model(this->getContext()); 70 71 model_->setMeshSource("ss_flag_eu.mesh"); 71 72 model_->setScale3D(Vector3(5, 5, 5)); … … 74 75 this->attach(model_); 75 76 76 this->enableCollisionCallback(); 77 this->setCollisionResponse(true); 78 this->setCollisionType(Static); 79 80 cs_ = new BoxCollisionShape(context); 77 cs_ = new BoxCollisionShape(this->getContext()); 81 78 cs_->setHalfExtents(Vector3(5, 5, 5)); 82 79 cs_->setPosition(Vector3(xCoordinate*cellSize*1.0f + cellSize/2,0.0f,yCoordinate*cellSize*1.0f + cellSize/2)); 83 80 84 81 this->attachCollisionShape(cs_); 85 this->collided_ = false;86 87 82 } 88 83 -
code/branches/presentationHS15/src/modules/hover/HoverFlag.h
r11041 r11042 47 47 public: 48 48 HoverFlag(Context* context); 49 HoverFlag(Context* context, int xCoordinate, int yCoordinate, int cellSize);50 49 virtual ~HoverFlag(); 50 51 void init(int xCoordinate, int yCoordinate, int cellSize); 51 52 52 53 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint); -
code/branches/presentationHS15/src/modules/hover/HoverWall.cc
r11041 r11042 45 45 { 46 46 RegisterObject(HoverWall); 47 model_ = NULL; 48 cs_ = NULL; 47 48 this->model_ = NULL; 49 this->cs_ = NULL; 50 51 this->enableCollisionCallback(); 52 this->setCollisionResponse(true); 53 this->setCollisionType(Static); 49 54 } 50 51 55 52 56 /** 53 57 @brief 54 Constructor of a HoverWall 58 Destructor. 59 */ 60 HoverWall::~HoverWall() 61 { 62 63 } 64 65 /** 66 @brief 67 Initializes a HoverWall 55 68 @param x 56 69 x-Coordinate of the Square that the Wall is attached to, 0-9, Origin is Bottom left … … 60 73 Wall on the right side (1) or on top (2) of this square, 0-1 61 74 */ 62 HoverWall::HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation) : StaticEntity(context)75 void HoverWall::init(int x, int y, int cellSize, int cellHeight, int orientation) 63 76 { 64 RegisterObject(HoverWall);65 66 77 int xSize_, zSize_, xPos_, zPos_; 67 78 … … 80 91 81 92 82 model_ = new Model( context);93 model_ = new Model(this->getContext()); 83 94 model_->setMeshSource("CuboidBody.mesh"); 84 95 model_->setScale3D(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f)); … … 87 98 this->attach(model_); 88 99 89 this->enableCollisionCallback(); 90 this->setCollisionResponse(true); 91 this->setCollisionType(Static); 92 93 cs_ = new BoxCollisionShape(context); 100 cs_ = new BoxCollisionShape(this->getContext()); 94 101 cs_->setHalfExtents(Vector3(xSize_*1.0f, cellHeight*1.0f, zSize_*1.0f)); 95 102 cs_->setPosition(Vector3(xPos_*1.0f, 0.0f, zPos_*1.0f)); … … 97 104 this->attachCollisionShape(cs_); 98 105 } 99 100 /**101 @brief102 Destructor.103 */104 HoverWall::~HoverWall()105 {106 107 }108 106 } -
code/branches/presentationHS15/src/modules/hover/HoverWall.h
r11041 r11042 46 46 { 47 47 public: 48 HoverWall(Context* context); 49 HoverWall(Context* context, int x, int y, int cellSize, int cellHeight, int orientation); 48 HoverWall(Context* context); 50 49 virtual ~HoverWall(); 50 51 void init(int x, int y, int cellSize, int cellHeight, int orientation); 51 52 52 53 private:
Note: See TracChangeset
for help on using the changeset viewer.