Fixed bug that caused animated rotations to be incorrect
--HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40181
This commit is contained in:
@@ -77,16 +77,19 @@ void KRNode::loadXML(tinyxml2::XMLElement *e) {
|
||||
e->QueryFloatAttribute("translate_y", &y);
|
||||
e->QueryFloatAttribute("translate_z", &z);
|
||||
m_localTranslation = KRVector3(x,y,z);
|
||||
m_originalLocalTranslation = m_localTranslation;
|
||||
|
||||
e->QueryFloatAttribute("scale_x", &x);
|
||||
e->QueryFloatAttribute("scale_y", &y);
|
||||
e->QueryFloatAttribute("scale_z", &z);
|
||||
m_localScale = KRVector3(x,y,z);
|
||||
m_originalLocalScale = m_localScale;
|
||||
|
||||
e->QueryFloatAttribute("rotate_x", &x);
|
||||
e->QueryFloatAttribute("rotate_y", &y);
|
||||
e->QueryFloatAttribute("rotate_z", &z);
|
||||
m_localRotation = KRVector3(x,y,z) / 180.0 * M_PI; // Convert degrees to radians
|
||||
m_originalLocalRotation = m_localRotation;
|
||||
|
||||
m_modelMatrixValid = false;
|
||||
|
||||
@@ -100,17 +103,20 @@ void KRNode::loadXML(tinyxml2::XMLElement *e) {
|
||||
|
||||
}
|
||||
|
||||
void KRNode::setLocalTranslation(const KRVector3 &v) {
|
||||
void KRNode::setLocalTranslation(const KRVector3 &v, bool set_original) {
|
||||
m_localTranslation = v;
|
||||
if(set_original) m_originalLocalTranslation = v;
|
||||
invalidateModelMatrix();
|
||||
}
|
||||
void KRNode::setLocalScale(const KRVector3 &v) {
|
||||
void KRNode::setLocalScale(const KRVector3 &v, bool set_original) {
|
||||
m_localScale = v;
|
||||
if(set_original) m_originalLocalScale = v;
|
||||
invalidateModelMatrix();
|
||||
}
|
||||
|
||||
void KRNode::setLocalRotation(const KRVector3 &v) {
|
||||
void KRNode::setLocalRotation(const KRVector3 &v, bool set_original) {
|
||||
m_localRotation = v;
|
||||
if(set_original) m_originalLocalRotation = v;
|
||||
invalidateModelMatrix();
|
||||
}
|
||||
|
||||
@@ -255,7 +261,7 @@ bool KRNode::hasPhysics()
|
||||
|
||||
void KRNode::SetAttribute(node_attribute_type attrib, float v)
|
||||
{
|
||||
const float DEGREES_TO_RAD = M_2_PI / 360.0f;
|
||||
const float DEGREES_TO_RAD = M_PI / 180.0f;
|
||||
|
||||
//printf("%s - ", m_name.c_str());
|
||||
switch(attrib) {
|
||||
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
|
||||
KRNode *findChild(const std::string &name);
|
||||
|
||||
void setLocalTranslation(const KRVector3 &v);
|
||||
void setLocalScale(const KRVector3 &v);
|
||||
void setLocalRotation(const KRVector3 &v);
|
||||
void setLocalTranslation(const KRVector3 &v, bool set_original = false);
|
||||
void setLocalScale(const KRVector3 &v, bool set_original = false);
|
||||
void setLocalRotation(const KRVector3 &v, bool set_original = false);
|
||||
|
||||
const KRVector3 &getLocalTranslation();
|
||||
const KRVector3 &getLocalScale();
|
||||
@@ -100,6 +100,10 @@ protected:
|
||||
KRVector3 m_localScale;
|
||||
KRVector3 m_localRotation;
|
||||
|
||||
KRVector3 m_originalLocalTranslation;
|
||||
KRVector3 m_originalLocalScale;
|
||||
KRVector3 m_originalLocalRotation;
|
||||
|
||||
private:
|
||||
void invalidateModelMatrix();
|
||||
KRMat4 m_modelMatrix;
|
||||
|
||||
Reference in New Issue
Block a user