From 33eeada4518adaf90743c0c6240c706684d3a3d7 Mon Sep 17 00:00:00 2001 From: kearwood Date: Sun, 2 Dec 2012 09:31:01 +0000 Subject: [PATCH] Animation system in progress --HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40173 --- KREngine/KREngine.xcodeproj/project.pbxproj | 24 ++++++++ KREngine/KREngine/Classes/KRAnimation.cpp | 29 +++++++++- KREngine/KREngine/Classes/KRAnimation.h | 27 ++++++++- .../KREngine/Classes/KRAnimationAttribute.cpp | 56 +++++++++++++++++++ .../KREngine/Classes/KRAnimationAttribute.h | 54 ++++++++++++++++++ .../KREngine/Classes/KRAnimationCurve.cpp | 27 ++++++++- KREngine/KREngine/Classes/KRAnimationCurve.h | 27 ++++++++- .../KREngine/Classes/KRAnimationCurveKey.cpp | 32 +++++++++++ .../KREngine/Classes/KRAnimationCurveKey.h | 37 ++++++++++++ .../KREngine/Classes/KRAnimationLayer.cpp | 55 +++++++++++++++--- KREngine/KREngine/Classes/KRAnimationLayer.h | 31 +++++++++- .../KREngine/Classes/KRAnimationManager.cpp | 27 ++++++++- .../KREngine/Classes/KRAnimationManager.h | 27 ++++++++- KREngine/KREngine/Classes/KRResource+fbx.cpp | 22 +++++--- 14 files changed, 444 insertions(+), 31 deletions(-) create mode 100644 KREngine/KREngine/Classes/KRAnimationAttribute.cpp create mode 100644 KREngine/KREngine/Classes/KRAnimationAttribute.h create mode 100644 KREngine/KREngine/Classes/KRAnimationCurveKey.cpp create mode 100644 KREngine/KREngine/Classes/KRAnimationCurveKey.h diff --git a/KREngine/KREngine.xcodeproj/project.pbxproj b/KREngine/KREngine.xcodeproj/project.pbxproj index 51147e5..e0d36ab 100644 --- a/KREngine/KREngine.xcodeproj/project.pbxproj +++ b/KREngine/KREngine.xcodeproj/project.pbxproj @@ -33,6 +33,14 @@ E428C312166971FF00A16EDF /* KRAnimationLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = E428C30F166971FE00A16EDF /* KRAnimationLayer.h */; settings = {ATTRIBUTES = (Public, ); }; }; E428C313166971FF00A16EDF /* KRAnimationLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E428C310166971FE00A16EDF /* KRAnimationLayer.cpp */; }; E428C314166971FF00A16EDF /* KRAnimationLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E428C310166971FE00A16EDF /* KRAnimationLayer.cpp */; }; + E428C3161669A24B00A16EDF /* KRAnimationAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = E428C3151669A24B00A16EDF /* KRAnimationAttribute.h */; }; + E428C3171669A24B00A16EDF /* KRAnimationAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = E428C3151669A24B00A16EDF /* KRAnimationAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E428C3191669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E428C3181669A25D00A16EDF /* KRAnimationAttribute.cpp */; }; + E428C31A1669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E428C3181669A25D00A16EDF /* KRAnimationAttribute.cpp */; }; + E428C31C1669A77D00A16EDF /* KRAnimationCurveKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E428C31B1669A77D00A16EDF /* KRAnimationCurveKey.h */; }; + E428C31D1669A77D00A16EDF /* KRAnimationCurveKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E428C31B1669A77D00A16EDF /* KRAnimationCurveKey.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E428C31F1669A78D00A16EDF /* KRAnimationCurveKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E428C31E1669A78C00A16EDF /* KRAnimationCurveKey.cpp */; }; + E428C3201669A78D00A16EDF /* KRAnimationCurveKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E428C31E1669A78C00A16EDF /* KRAnimationCurveKey.cpp */; }; E42CB1EC158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; }; E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; settings = {ATTRIBUTES = (Public, ); }; }; E42CB1F0158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; }; @@ -238,6 +246,10 @@ E428C3061669628A00A16EDF /* KRAnimationCurve.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRAnimationCurve.cpp; path = Classes/KRAnimationCurve.cpp; sourceTree = ""; }; E428C30F166971FE00A16EDF /* KRAnimationLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRAnimationLayer.h; path = Classes/KRAnimationLayer.h; sourceTree = ""; }; E428C310166971FE00A16EDF /* KRAnimationLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRAnimationLayer.cpp; path = Classes/KRAnimationLayer.cpp; sourceTree = ""; }; + E428C3151669A24B00A16EDF /* KRAnimationAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRAnimationAttribute.h; path = Classes/KRAnimationAttribute.h; sourceTree = ""; }; + E428C3181669A25D00A16EDF /* KRAnimationAttribute.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRAnimationAttribute.cpp; path = Classes/KRAnimationAttribute.cpp; sourceTree = ""; }; + E428C31B1669A77D00A16EDF /* KRAnimationCurveKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRAnimationCurveKey.h; path = Classes/KRAnimationCurveKey.h; sourceTree = ""; }; + E428C31E1669A78C00A16EDF /* KRAnimationCurveKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRAnimationCurveKey.cpp; path = Classes/KRAnimationCurveKey.cpp; sourceTree = ""; }; E42CB1EB158446940066E0D8 /* KRQuaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRQuaternion.h; path = Classes/KRQuaternion.h; sourceTree = ""; }; E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRQuaternion.cpp; path = Classes/KRQuaternion.cpp; sourceTree = ""; }; E430D08015F8882F0010558D /* occlusion_test.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.fsh; path = Shaders/occlusion_test.fsh; sourceTree = ""; }; @@ -412,6 +424,10 @@ E428C2FA1669613200A16EDF /* KRAnimation.cpp */, E428C3031669627900A16EDF /* KRAnimationCurve.h */, E428C3061669628A00A16EDF /* KRAnimationCurve.cpp */, + E428C3151669A24B00A16EDF /* KRAnimationAttribute.h */, + E428C3181669A25D00A16EDF /* KRAnimationAttribute.cpp */, + E428C31B1669A77D00A16EDF /* KRAnimationCurveKey.h */, + E428C31E1669A78C00A16EDF /* KRAnimationCurveKey.cpp */, ); name = Animation; sourceTree = ""; @@ -806,6 +822,8 @@ E428C2F81669612500A16EDF /* KRAnimation.h in Headers */, E428C3041669627900A16EDF /* KRAnimationCurve.h in Headers */, E428C311166971FF00A16EDF /* KRAnimationLayer.h in Headers */, + E428C3161669A24B00A16EDF /* KRAnimationAttribute.h in Headers */, + E428C31C1669A77D00A16EDF /* KRAnimationCurveKey.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -849,7 +867,9 @@ E40BA45715EFF79500D7C3DD /* KRAABB.h in Headers */, E428C312166971FF00A16EDF /* KRAnimationLayer.h in Headers */, E4AFC6B615F7C46800DDB4C8 /* KRAABB.cpp in Headers */, + E428C3171669A24B00A16EDF /* KRAnimationAttribute.h in Headers */, E4AFC6BE15F7C9E600DDB4C8 /* KROctreeNode.h in Headers */, + E428C31D1669A77D00A16EDF /* KRAnimationCurveKey.h in Headers */, E4AFC6BD15F7C9DA00DDB4C8 /* KROctree.h in Headers */, E46A6B701559EF0A000DBD37 /* KRResource+blend.h in Headers */, E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */, @@ -994,6 +1014,8 @@ E428C2FB1669613200A16EDF /* KRAnimation.cpp in Sources */, E428C3071669628A00A16EDF /* KRAnimationCurve.cpp in Sources */, E428C313166971FF00A16EDF /* KRAnimationLayer.cpp in Sources */, + E428C3191669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */, + E428C31F1669A78D00A16EDF /* KRAnimationCurveKey.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1048,6 +1070,8 @@ E428C2FC1669613200A16EDF /* KRAnimation.cpp in Sources */, E428C3081669628A00A16EDF /* KRAnimationCurve.cpp in Sources */, E428C314166971FF00A16EDF /* KRAnimationLayer.cpp in Sources */, + E428C31A1669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */, + E428C3201669A78D00A16EDF /* KRAnimationCurveKey.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/KREngine/KREngine/Classes/KRAnimation.cpp b/KREngine/KREngine/Classes/KRAnimation.cpp index 8456256..f034740 100644 --- a/KREngine/KREngine/Classes/KRAnimation.cpp +++ b/KREngine/KREngine/Classes/KRAnimation.cpp @@ -2,8 +2,31 @@ // KRAnimation.cpp // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #include "KRAnimation.h" @@ -33,7 +56,6 @@ bool KRAnimation::save(const std::string& path) { tinyxml2::XMLDocument doc; tinyxml2::XMLElement *animation_node = doc.NewElement( "animation" ); doc.InsertEndChild(animation_node); -// m_pRootNode->saveXML(animation_node); for(std::map::iterator itr = m_layers.begin(); itr != m_layers.end(); ++itr){ (*itr).second->saveXML(animation_node); @@ -56,6 +78,7 @@ KRAnimation *KRAnimation::Load(KRContext &context, const std::string &name, KRDa for(tinyxml2::XMLElement *child_element=animation_node->FirstChildElement(); child_element != NULL; child_element = child_element->NextSiblingElement()) { if(strcmp(child_element->Name(), "layer") == 0) { KRAnimationLayer *new_layer = new KRAnimationLayer(context); + new_layer->loadXML(child_element); new_animation->m_layers[new_layer->getName()] = new_layer; } } diff --git a/KREngine/KREngine/Classes/KRAnimation.h b/KREngine/KREngine/Classes/KRAnimation.h index 8405aae..0b5b200 100644 --- a/KREngine/KREngine/Classes/KRAnimation.h +++ b/KREngine/KREngine/Classes/KRAnimation.h @@ -2,8 +2,31 @@ // KRAnimation.h // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #ifndef KRANIMATION_H diff --git a/KREngine/KREngine/Classes/KRAnimationAttribute.cpp b/KREngine/KREngine/Classes/KRAnimationAttribute.cpp new file mode 100644 index 0000000..7135a8c --- /dev/null +++ b/KREngine/KREngine/Classes/KRAnimationAttribute.cpp @@ -0,0 +1,56 @@ +// +// KRAnimationAttribute.cpp +// KREngine +// +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#include "KRAnimationAttribute.h" + + +KRAnimationAttribute::KRAnimationAttribute(KRContext &context) : KRContextObject(context) +{ + +} + +KRAnimationAttribute::~KRAnimationAttribute() +{ + +} + +tinyxml2::XMLElement *KRAnimationAttribute::saveXML( tinyxml2::XMLNode *parent) +{ + tinyxml2::XMLDocument *doc = parent->GetDocument(); + tinyxml2::XMLElement *e = doc->NewElement("attribute"); + tinyxml2::XMLNode *n = parent->InsertEndChild(e); + + return e; +} + +void KRAnimationAttribute::loadXML(tinyxml2::XMLElement *e) +{ +} diff --git a/KREngine/KREngine/Classes/KRAnimationAttribute.h b/KREngine/KREngine/Classes/KRAnimationAttribute.h new file mode 100644 index 0000000..b29c5d2 --- /dev/null +++ b/KREngine/KREngine/Classes/KRAnimationAttribute.h @@ -0,0 +1,54 @@ +// +// KRAnimationAttribute.h +// KREngine +// +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#ifndef KRANIMATIONATTRIBUTE_H +#define KRANIMATIONATTRIBUTE_H + +#import "KRContextObject.h" +#import "KREngine-common.h" +#import "tinyxml2.h" + +class KRAnimationAttribute : public KRContextObject { +public: + KRAnimationAttribute(KRContext &context); + ~KRAnimationAttribute(); + + tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent); + void loadXML(tinyxml2::XMLElement *e); + + std::string getTargetName() const; + void setTargetName(const std::string &target_name); + +private: + std::string m_target_name; +}; + +#endif diff --git a/KREngine/KREngine/Classes/KRAnimationCurve.cpp b/KREngine/KREngine/Classes/KRAnimationCurve.cpp index 04efb8f..0e31df7 100644 --- a/KREngine/KREngine/Classes/KRAnimationCurve.cpp +++ b/KREngine/KREngine/Classes/KRAnimationCurve.cpp @@ -2,8 +2,31 @@ // KRAnimationCurve.cpp // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #include "KRAnimationCurve.h" diff --git a/KREngine/KREngine/Classes/KRAnimationCurve.h b/KREngine/KREngine/Classes/KRAnimationCurve.h index 1278c5b..632deb1 100644 --- a/KREngine/KREngine/Classes/KRAnimationCurve.h +++ b/KREngine/KREngine/Classes/KRAnimationCurve.h @@ -2,8 +2,31 @@ // KRAnimationCurve.h // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #ifndef KRANIMATIONCURVE_H diff --git a/KREngine/KREngine/Classes/KRAnimationCurveKey.cpp b/KREngine/KREngine/Classes/KRAnimationCurveKey.cpp new file mode 100644 index 0000000..46dc44a --- /dev/null +++ b/KREngine/KREngine/Classes/KRAnimationCurveKey.cpp @@ -0,0 +1,32 @@ +// +// KRAnimationCurveKey.cpp +// KREngine +// +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#include "KRAnimationCurveKey.h" diff --git a/KREngine/KREngine/Classes/KRAnimationCurveKey.h b/KREngine/KREngine/Classes/KRAnimationCurveKey.h new file mode 100644 index 0000000..770ccd5 --- /dev/null +++ b/KREngine/KREngine/Classes/KRAnimationCurveKey.h @@ -0,0 +1,37 @@ +// +// KRAnimationCurveKey.h +// KREngine +// +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#ifndef KRANIMATIONCURVEKEY_H +#define KRANIMATIONCURVEKEY_H + + + +#endif diff --git a/KREngine/KREngine/Classes/KRAnimationLayer.cpp b/KREngine/KREngine/Classes/KRAnimationLayer.cpp index dd25e2b..69efe2c 100644 --- a/KREngine/KREngine/Classes/KRAnimationLayer.cpp +++ b/KREngine/KREngine/Classes/KRAnimationLayer.cpp @@ -2,8 +2,31 @@ // KRAnimationLayer.cpp // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #include "KRAnimationLayer.h" @@ -13,12 +36,14 @@ KRAnimationLayer::KRAnimationLayer(KRContext &context) : KRContextObject(context m_name = ""; m_blend_mode = KRENGINE_ANIMATION_BLEND_MODE_ADDITIVE; m_rotation_accumulation_mode = KRENGINE_ANIMATION_ROTATION_ACCUMULATION_BY_LAYER; - m_scale_accumulation_mode = KRENGINE_ANIMATION_SCALE_ACCUMULATION_ADDITIVE; + m_scale_accumulation_mode = KRENGINE_ANIMATION_SCALE_ACCUMULATION_MULTIPLY; } KRAnimationLayer::~KRAnimationLayer() { - + for(std::vector::iterator itr = m_attributes.begin(); itr != m_attributes.end(); ++itr){ + delete (*itr); + } } std::string KRAnimationLayer::getName() const @@ -69,15 +94,17 @@ tinyxml2::XMLElement *KRAnimationLayer::saveXML( tinyxml2::XMLNode *parent) break; } + for(std::vector::iterator itr = m_attributes.begin(); itr != m_attributes.end(); ++itr){ + (*itr)->saveXML(n); + } + return e; } void KRAnimationLayer::loadXML(tinyxml2::XMLElement *e) { m_name = e->Attribute("name"); - if(e->QueryFloatAttribute("weight", &m_weight) == tinyxml2::XML_SUCCESS) { - m_weight /= 100.0f; - } else { + if(e->QueryFloatAttribute("weight", &m_weight) != tinyxml2::XML_SUCCESS) { m_weight = 1.0f; // default } @@ -107,7 +134,15 @@ void KRAnimationLayer::loadXML(tinyxml2::XMLElement *e) } else if(strcmp(szScaleAccumulationMode, "multiply") == 0) { m_scale_accumulation_mode = KRENGINE_ANIMATION_SCALE_ACCUMULATION_MULTIPLY; } else { - m_scale_accumulation_mode = KRENGINE_ANIMATION_SCALE_ACCUMULATION_ADDITIVE; // default + m_scale_accumulation_mode = KRENGINE_ANIMATION_SCALE_ACCUMULATION_MULTIPLY; // default + } + + for(tinyxml2::XMLElement *child_element=e->FirstChildElement(); child_element != NULL; child_element = child_element->NextSiblingElement()) { + if(strcmp(child_element->Name(), "attribute") == 0) { + KRAnimationAttribute *new_attribute = new KRAnimationAttribute(getContext()); + new_attribute->loadXML(child_element); + m_attributes.push_back(new_attribute); + } } } @@ -152,3 +187,7 @@ void KRAnimationLayer::setScaleAccumulationMode(const KRAnimationLayer::scale_ac m_scale_accumulation_mode = scale_accumulation_mode; } +void KRAnimationLayer::addAttribute(KRAnimationAttribute *attribute) +{ + m_attributes.push_back(attribute); +} diff --git a/KREngine/KREngine/Classes/KRAnimationLayer.h b/KREngine/KREngine/Classes/KRAnimationLayer.h index f168ed6..2516069 100644 --- a/KREngine/KREngine/Classes/KRAnimationLayer.h +++ b/KREngine/KREngine/Classes/KRAnimationLayer.h @@ -2,8 +2,31 @@ // KRAnimationLayer.h // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #ifndef KRANIMATIONLAYER_H @@ -12,6 +35,7 @@ #import "KRContextObject.h" #import "KREngine-common.h" #import "tinyxml2.h" +#import "KRAnimationAttribute.h" class KRAnimationLayer : public KRContextObject { public: @@ -52,6 +76,7 @@ public: scale_accumulation_mode_t getScaleAccumulationMode() const; void setScaleAccumulationMode(const scale_accumulation_mode_t &scale_accumulation_mode); + void addAttribute(KRAnimationAttribute *attribute); private: std::string m_name; @@ -59,6 +84,8 @@ private: blend_mode_t m_blend_mode; rotation_accumulation_mode_t m_rotation_accumulation_mode; scale_accumulation_mode_t m_scale_accumulation_mode; + + std::vector m_attributes; }; #endif diff --git a/KREngine/KREngine/Classes/KRAnimationManager.cpp b/KREngine/KREngine/Classes/KRAnimationManager.cpp index 7c4b05d..df01a74 100644 --- a/KREngine/KREngine/Classes/KRAnimationManager.cpp +++ b/KREngine/KREngine/Classes/KRAnimationManager.cpp @@ -2,8 +2,31 @@ // KRAnimationManager.cpp // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #include "KRAnimationManager.h" diff --git a/KREngine/KREngine/Classes/KRAnimationManager.h b/KREngine/KREngine/Classes/KRAnimationManager.h index bc7ed53..ba1449d 100644 --- a/KREngine/KREngine/Classes/KRAnimationManager.h +++ b/KREngine/KREngine/Classes/KRAnimationManager.h @@ -2,8 +2,31 @@ // KRAnimationManager.h // KREngine // -// Created by Kearwood Gilbert on 2012-11-30. -// Copyright (c) 2012 Kearwood Software. All rights reserved. +// Copyright 2012 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. // #ifndef KRANIMATIONMANAGER_H diff --git a/KREngine/KREngine/Classes/KRResource+fbx.cpp b/KREngine/KREngine/Classes/KRResource+fbx.cpp index b92b1f5..12a4234 100644 --- a/KREngine/KREngine/Classes/KRResource+fbx.cpp +++ b/KREngine/KREngine/Classes/KRResource+fbx.cpp @@ -78,6 +78,14 @@ std::vector KRResource::LoadFbx(KRContext &context, const std::str pNode->ResetPivotSetAndConvertAnimation(); } + // ----====---- Import Animation Layers ----====---- + + int animation_count = pFbxScene->GetSrcObjectCount(FBX_TYPE(FbxAnimStack)); + for(int i = 0; i < animation_count; i++) { + // FbxAnimStack* pAnimStack = FbxCast(pFbxScene->GetSrcObject(FBX_TYPE(FbxAnimStack), i)); + resources.push_back(LoadAnimation(context, pFbxScene->GetSrcObject(i))); + } + // ----====---- Import Scene Graph Nodes ----====---- if(pNode) { @@ -87,13 +95,7 @@ std::vector KRResource::LoadFbx(KRContext &context, const std::str } } - // ----====---- Import Animations ----====---- - - int animation_count = pFbxScene->GetSrcObjectCount(FBX_TYPE(FbxAnimStack)); - for(int i = 0; i < animation_count; i++) { -// FbxAnimStack* pAnimStack = FbxCast(pFbxScene->GetSrcObject(FBX_TYPE(FbxAnimStack), i)); - resources.push_back(LoadAnimation(context, pFbxScene->GetSrcObject(i))); - } + DestroySdkObjects(lSdkManager); @@ -286,7 +288,7 @@ KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLaye { KRAnimationLayer *new_layer = new KRAnimationLayer(context); new_layer->setName(pAnimLayer->GetName()); - new_layer->setWeight(pAnimLayer->Weight.Get()); + new_layer->setWeight(pAnimLayer->Weight.Get() / 100.0f); switch(pAnimLayer->BlendMode.Get()) { case FbxAnimLayer::eBlendAdditive: new_layer->setBlendMode(KRAnimationLayer::KRENGINE_ANIMATION_BLEND_MODE_ADDITIVE); @@ -314,6 +316,7 @@ KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLaye new_layer->setScaleAccumulationMode(KRAnimationLayer::KRENGINE_ANIMATION_SCALE_ACCUMULATION_MULTIPLY); break; } + return new_layer; } // @@ -446,6 +449,9 @@ void LoadNode(KRNode *parent_node, std::vector &resources, FbxGeom KFbxVector4 lTmpVector; pNode->UpdatePropertiesFromPivotsAndLimits(); // Transform = T * Roff * Rp * Rpre * R * Rpost * inverse(Rp) * Soff * Sp * S * inverse(Sp) + + + fbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSourcePivot); fbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSourcePivot); fbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSourcePivot);