00001 /* 00002 * This file is part of Micole Architecture 00003 * 00004 * Copyright (C) 2007 Micole partners 00005 * 00006 * Micole Architecture is free software: you can redistribute it 00007 * and/or modify it under the terms of the GNU Lesser General 00008 * Public License as published by the Free Software Foundation, 00009 * either version 3 of the License, or (at your option) any 00010 * later version. 00011 * 00012 * Micole Architecture is distributed in the hope that it will be 00013 * useful, * but WITHOUT ANY WARRANTY; without even the implied 00014 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00015 * PURPOSE. See the GNU Lesser General Public License for more 00016 * details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with Micole Architecture. If not, see 00020 * <http://www.gnu.org/licenses/>. 00021 */ 00022 00023 #ifndef FF3DPOINTFORCEMODEL_H 00024 #define FF3DPOINTFORCEMODEL_H 00025 #include "micolelib.h" 00026 00027 #include "FF3DForceModel.h" 00028 #include "Playback.h" 00029 using namespace Reachin; 00030 00034 struct MICOLELIB_API FF3DPointForceModel : FF3DForceModel 00035 { 00036 mgFloat _stiffness; 00037 Playback* _pb; 00038 00039 Vec3f _stick_point; 00040 00041 00042 FF3DPointForceModel(Playback* pb, const Vec3f &, const mgFloat &stiffness = STIFFNESS); 00043 FF3DPointForceModel(Playback* pb, const FF3DPointForceModel &fm); 00044 00045 00046 virtual FF3DForceModel * clone() { return new FF3DPointForceModel(*this); } 00047 00048 virtual Vec3f evaluate( const Vec3f &pos, const mgFloat &w ) 00049 { 00050 Vec3f diff = _stick_point - pos; 00051 _pb->stickToPointAndGetForce(pos, _stick_point, _oldForce); 00052 return _oldForce; 00053 //fprintf(log, "%f, %f, %f, %f, %f, %f, %f, %f\n", pos.x, pos.y, pos.z, _stick_point.x, _stick_point.y, _stick_point.z); 00054 /* diff = _stiffness * diff; 00055 fprintf(log, "%f, %f, %f\n", diff.x, diff.y, diff.z); 00056 return diff;*/ 00057 00058 //diff.x = 0; only for linear 00059 //_oldForce= (_oldForce*0.95)+ (_stiffness * diff)*0.05; 00060 //return _oldForce; 00061 // return _stiffness * diff; 00062 } 00063 }; 00064 00065 #endif