-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "CollisionManager.h" | ||
|
||
CollisionManager::CollisionManager(std::vector<std::ObjectInfo> *Obs) | ||
{ | ||
Objects=Obs; | ||
} | ||
CheckCollisionAnswer CollisionManager::checkCollisionAABB(std::ObjectInfo object) | ||
{ | ||
CheckCollisionAnswer answer; | ||
answer.amount=0; | ||
answer.objectName=object.getObjectName(); | ||
answer.collided=false; | ||
Ogre::AxisAlignedBox spbox = static_cast<Ogre::SceneNode*>(object.getNode())->_getWorldAABB(); | ||
for (std::vector<std::ObjectInfo>::iterator iter = Objects->begin(); iter != Objects->end(); iter++) | ||
{ | ||
|
||
if(object.getObjectName() != iter->getObjectName() ) | ||
{ | ||
Ogre::AxisAlignedBox cbbox=static_cast<Ogre::SceneNode*>(iter->getNode())->_getWorldAABB(); | ||
|
||
if(spbox.intersects(cbbox))//collided | ||
{ | ||
answer.amount++; | ||
answer.collided=true; | ||
answer.collidedList.push_back(*iter); | ||
} | ||
} | ||
} | ||
return answer; | ||
} | ||
|
||
CheckCollisionAnswer CollisionManager::checkCameraCollision() | ||
{ | ||
CheckCollisionAnswer answer; | ||
answer.amount=0; | ||
answer.objectName="camera"; | ||
answer.collided=false; | ||
|
||
//Ogre::AxisAlignedBox spbox = new Ogre::AxisAlignedBox( | ||
//for (std::vector<std::ObjectInfo>::iterator iter = Objects->begin(); iter != Objects->end(); iter++) | ||
// { | ||
|
||
// if(object.getObjectName() != iter->getObjectName() ) | ||
// { | ||
// Ogre::AxisAlignedBox cbbox=static_cast<Ogre::SceneNode*>(iter->getNode())->_getWorldAABB(); | ||
|
||
// if(spbox.intersects(cbbox))//collided | ||
// { | ||
// answer.amount++; | ||
// answer.collided=true; | ||
// answer.collidedList.push_back(*iter); | ||
// } | ||
// } | ||
// } | ||
return answer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef COLLISIONMANAGER_H | ||
#define COLLISIONMANAGER_H | ||
|
||
#include <Ogre.h> | ||
#include "ObjectInfo.h" | ||
#include <vector> | ||
|
||
struct CheckCollisionAnswer | ||
{ | ||
bool collided; | ||
std::string objectName; | ||
int amount; //how many object have collided with this one | ||
std::vector<std::ObjectInfo> collidedList; | ||
}; | ||
|
||
class CollisionManager | ||
{ | ||
public: | ||
CollisionManager(std::vector<std::ObjectInfo> *Obs); | ||
|
||
std::vector<std::ObjectInfo> *Objects; | ||
|
||
CheckCollisionAnswer checkCollisionAABB(std::ObjectInfo object); | ||
|
||
CheckCollisionAnswer checkCameraCollision(); | ||
|
||
private: | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters