Added IDs to track objects, coding style fixes

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-05-30 08:15:34 +05:30
parent 79d267ad9e
commit ad71674b2c
3 changed files with 18 additions and 5 deletions

View File

@ -91,6 +91,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
m_physical_object = NULL;
xml_node.get("id", &m_id );
xml_node.get("model", &m_name );
xml_node.get("xyz", &m_init_xyz );
xml_node.get("hpr", &m_init_hpr );

View File

@ -55,6 +55,8 @@ private:
std::string m_name;
std::string m_id;
protected:
@ -113,6 +115,8 @@ public:
const std::string getName() const { return m_name; }
const std::string getID() const { return m_id; }
const std::string getInteraction() const { return m_interaction; }
bool isEnabled() const { return m_enabled; }

View File

@ -92,10 +92,12 @@ void TrackObjectManager::disable(std::string name , std::string type){
for_in (curr,m_all_objects){
if (type != curr->getType())continue;
if (curr->getName() == (name)){
if (curr->getName() == (name))
{
curr->setEnable(false);
if (type == "mesh"){
if (type == "mesh")
{
curr->getPhysicalObject()->removeBody();
}
}
@ -104,13 +106,16 @@ void TrackObjectManager::disable(std::string name , std::string type){
void TrackObjectManager::enable(std::string name , std::string type){
TrackObject* curr;
for_in (curr,m_all_objects){
if (type != curr->getType())continue;
if (curr->getName() == (name)){
if (curr->getName() == (name))
{
curr->reset();
curr->setEnable(true);
if (type == "mesh"){
if (type == "mesh")
{
curr->getPhysicalObject()->addBody();
}
@ -120,12 +125,15 @@ void TrackObjectManager::enable(std::string name , std::string type){
bool TrackObjectManager::getStatus(std::string name){
TrackObject* curr;
for_in (curr,m_all_objects){
if (curr->getName() == (name)){
if (curr->getName() == (name))
{
return curr->isEnabled();
}
}
//object not found
return false;
}
/** Handles an explosion, i.e. it makes sure that all physical objects are
* affected accordingly.