|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_ConstraintActuator.h 35063 2011-02-22 10:33:14Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef __KX_CONSTRAINTACTUATOR 00035 #define __KX_CONSTRAINTACTUATOR 00036 00037 #include "SCA_IActuator.h" 00038 #include "MT_Scalar.h" 00039 #include "MT_Vector3.h" 00040 #include "KX_ClientObjectInfo.h" 00041 00042 class KX_RayCast; 00043 class KX_GameObject; 00044 00045 class KX_ConstraintActuator : public SCA_IActuator 00046 { 00047 Py_Header; 00048 protected: 00049 // Damp time (int), 00050 int m_posDampTime; 00051 int m_rotDampTime; 00052 // min (float) 00053 float m_minimumBound; 00054 // max (float) 00055 float m_maximumBound; 00056 // sinus of minimum angle 00057 float m_minimumSine; 00058 // sinus of maximum angle 00059 float m_maximumSine; 00060 // reference direction 00061 float m_refDirection[3]; 00062 MT_Vector3 m_refDirVector; // same as m_refDirection 00063 // locrotxyz choice (pick one): only one choice allowed at a time! 00064 int m_locrot; 00065 // active time of actuator 00066 int m_activeTime; 00067 int m_currentTime; 00068 // option 00069 int m_option; 00070 // property to check 00071 STR_String m_property; 00072 // hit object 00073 KX_GameObject* m_hitObject; 00074 00079 void Clamp(MT_Scalar &var, float min, float max); 00080 00081 00082 public: 00083 // m_locrot 00084 enum KX_CONSTRAINTTYPE { 00085 KX_ACT_CONSTRAINT_NODEF = 0, 00086 KX_ACT_CONSTRAINT_LOCX, 00087 KX_ACT_CONSTRAINT_LOCY, 00088 KX_ACT_CONSTRAINT_LOCZ, 00089 KX_ACT_CONSTRAINT_ROTX, 00090 KX_ACT_CONSTRAINT_ROTY, 00091 KX_ACT_CONSTRAINT_ROTZ, 00092 KX_ACT_CONSTRAINT_DIRPX, 00093 KX_ACT_CONSTRAINT_DIRPY, 00094 KX_ACT_CONSTRAINT_DIRPZ, 00095 KX_ACT_CONSTRAINT_DIRNX, 00096 KX_ACT_CONSTRAINT_DIRNY, 00097 KX_ACT_CONSTRAINT_DIRNZ, 00098 KX_ACT_CONSTRAINT_ORIX, 00099 KX_ACT_CONSTRAINT_ORIY, 00100 KX_ACT_CONSTRAINT_ORIZ, 00101 KX_ACT_CONSTRAINT_FHPX, 00102 KX_ACT_CONSTRAINT_FHPY, 00103 KX_ACT_CONSTRAINT_FHPZ, 00104 KX_ACT_CONSTRAINT_FHNX, 00105 KX_ACT_CONSTRAINT_FHNY, 00106 KX_ACT_CONSTRAINT_FHNZ, 00107 KX_ACT_CONSTRAINT_MAX 00108 }; 00109 // match ACT_CONST_... values from BIF_interface.h 00110 enum KX_CONSTRAINTOPT { 00111 KX_ACT_CONSTRAINT_NORMAL = 64, 00112 KX_ACT_CONSTRAINT_MATERIAL = 128, 00113 KX_ACT_CONSTRAINT_PERMANENT = 256, 00114 KX_ACT_CONSTRAINT_DISTANCE = 512, 00115 KX_ACT_CONSTRAINT_LOCAL = 1024, 00116 KX_ACT_CONSTRAINT_DOROTFH = 2048 00117 }; 00118 bool IsValidMode(KX_CONSTRAINTTYPE m); 00119 bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); 00120 bool NeedRayCast(KX_ClientObjectInfo*); 00121 00122 KX_ConstraintActuator(SCA_IObject* gameobj, 00123 int posDamptime, 00124 int rotDampTime, 00125 float min, 00126 float max, 00127 float refDir[3], 00128 int locrot, 00129 int time, 00130 int option, 00131 char *property); 00132 virtual ~KX_ConstraintActuator(); 00133 virtual CValue* GetReplica() { 00134 KX_ConstraintActuator* replica = new KX_ConstraintActuator(*this); 00135 replica->ProcessReplica(); 00136 return replica; 00137 }; 00138 00139 virtual bool Update(double curtime, bool frame); 00140 00141 /* --------------------------------------------------------------------- */ 00142 /* Python interface ---------------------------------------------------- */ 00143 /* --------------------------------------------------------------------- */ 00144 00145 static int pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00146 static int pyattr_check_min(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00147 00148 }; 00149 00150 #endif //__KX_CONSTRAINTACTUATOR 00151