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