|
Blender
V2.59
|
00001 /* 00002 * $Id: IK_QJacobianSolver.h 35154 2011-02-25 11:43:19Z jesterking $ 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Original Author: Laurence 00025 * Contributor(s): Brecht 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #ifndef NAN_INCLUDED_IK_QJacobianSolver_h 00036 00037 #define NAN_INCLUDED_IK_QJacobianSolver_h 00038 00044 #include <vector> 00045 #include <list> 00046 00047 #include "MT_Vector3.h" 00048 #include "MT_Transform.h" 00049 #include "IK_QJacobian.h" 00050 #include "IK_QSegment.h" 00051 #include "IK_QTask.h" 00052 00053 class IK_QJacobianSolver 00054 { 00055 public: 00056 IK_QJacobianSolver(); 00057 ~IK_QJacobianSolver() {}; 00058 00059 // setup pole vector constraint 00060 void SetPoleVectorConstraint(IK_QSegment *tip, MT_Vector3& goal, 00061 MT_Vector3& polegoal, float poleangle, bool getangle); 00062 float GetPoleAngle() { return m_poleangle; }; 00063 00064 // call setup once before solving, if it fails don't solve 00065 bool Setup(IK_QSegment *root, std::list<IK_QTask*>& tasks); 00066 00067 // returns true if converged, false if max number of iterations was used 00068 bool Solve( 00069 IK_QSegment *root, 00070 std::list<IK_QTask*> tasks, 00071 const MT_Scalar tolerance, 00072 const int max_iterations 00073 ); 00074 00075 private: 00076 void AddSegmentList(IK_QSegment *seg); 00077 bool UpdateAngles(MT_Scalar& norm); 00078 void ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTask*>& tasks); 00079 00080 MT_Scalar ComputeScale(); 00081 void Scale(float scale, std::list<IK_QTask*>& tasks); 00082 00083 private: 00084 00085 IK_QJacobian m_jacobian; 00086 IK_QJacobian m_jacobian_sub; 00087 00088 bool m_secondary_enabled; 00089 00090 std::vector<IK_QSegment*> m_segments; 00091 00092 MT_Transform m_rootmatrix; 00093 00094 bool m_poleconstraint; 00095 bool m_getpoleangle; 00096 MT_Vector3 m_goal; 00097 MT_Vector3 m_polegoal; 00098 float m_poleangle; 00099 IK_QSegment *m_poletip; 00100 }; 00101 00102 #endif 00103