diff options
author | Lukas Steiblys <imbusy@imbusy.org> | 2009-10-02 02:29:15 +0400 |
---|---|---|
committer | Lukas Steiblys <imbusy@imbusy.org> | 2009-10-02 02:29:15 +0400 |
commit | 0677398a649b6b8c293df3ce3c6668f0a3be3bc8 (patch) | |
tree | 9d510a5bd23559bf4fae670ed04d7e5d6c12578c /intern/itasc/FixedObject.cpp | |
parent | 59248e9f62006ba05e3098e4d213f3dcb23fe711 (diff) | |
parent | bc942eceacb638735dc4f4f68252c4c207147a70 (diff) |
merge from 23153 to 23595soc-2009-imbusy
Diffstat (limited to 'intern/itasc/FixedObject.cpp')
-rw-r--r-- | intern/itasc/FixedObject.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/intern/itasc/FixedObject.cpp b/intern/itasc/FixedObject.cpp new file mode 100644 index 00000000000..fad77d4825e --- /dev/null +++ b/intern/itasc/FixedObject.cpp @@ -0,0 +1,70 @@ +/* $Id$ + * FixedObject.cpp + * + * Created on: Feb 10, 2009 + * Author: benoitbolsee + */ + +#include "FixedObject.hpp" + +namespace iTaSC{ + + +FixedObject::FixedObject():UncontrolledObject(), + m_finalized(false), m_nframe(0) +{ +} + +FixedObject::~FixedObject() +{ + m_frameArray.clear(); +} + +int FixedObject::addFrame(const std::string& name, const Frame& frame) +{ + if (m_finalized) + return -1; + FrameList::iterator it; + unsigned int i; + for (i=0, it=m_frameArray.begin(); i<m_nframe; i++, it++) { + if (it->first == name) { + // this frame will replace the old frame + it->second = frame; + return i; + } + } + m_frameArray.push_back(FrameList::value_type(name,frame)); + return m_nframe++; +} + +int FixedObject::addEndEffector(const std::string& name) +{ + // verify that this frame name exist + FrameList::iterator it; + unsigned int i; + for (i=0, it=m_frameArray.begin(); i<m_nframe; i++, it++) { + if (it->first == name) { + return i; + } + } + return -1; +} + +void FixedObject::finalize() +{ + if (m_finalized) + return; + initialize(0, m_nframe); + m_finalized = true; +} + +const Frame& FixedObject::getPose(const unsigned int frameIndex) +{ + if (frameIndex < m_nframe) { + return m_frameArray[frameIndex].second; + } else { + return F_identity; + } +} + +} |