00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __SIM_PhysicalParms_h__
00017 #define __SIM_PhysicalParms_h__
00018
00019 #include "SIM_API.h"
00020 #include "SIM_Data.h"
00021 #include "SIM_DataUtils.h"
00022 #include "SIM_OptionsUser.h"
00023
00024 class SIM_Object;
00025 class GEO_PointTree;
00026 class SIM_PointTree;
00027 class SIM_Geometry;
00028 class ut_KDPQueue;
00029 class SIM_RawField;
00030 class SIM_VectorField;
00031
00032 #include <GEO/GEO_AttributeHandle.h>
00033 #include <GU/GU_Detail.h>
00034 #include <GU/GU_DetailHandle.h>
00035
00036
00037
00038
00039 typedef enum {
00040 SIM_PROPERTY_FRICTION = 0,
00041 SIM_PROPERTY_DYNAMICFRICTION,
00042 SIM_PROPERTY_BOUNCE,
00043 SIM_PROPERTY_TEMPERATURE,
00044 SIM_PROPERTY_COUNT
00045 } SIM_Property;
00046
00047
00048
00049
00050
00051 class SIM_API SIM_PropertyResolver
00052 {
00053 public:
00054 SIM_PropertyResolver() {}
00055 virtual ~SIM_PropertyResolver() {}
00056
00057
00058 virtual SIM_PropertyResolver *copy() const = 0;
00059
00060 virtual fpreal getF(const UT_Vector3 &pos) = 0;
00061 virtual UT_Vector3 getV3(const UT_Vector3 &pos) = 0;
00062
00063
00064 virtual bool threadsafe() const { return true; }
00065 };
00066
00067 class SIM_API SIM_PropertyResolverConstant : public SIM_PropertyResolver
00068 {
00069 public:
00070 SIM_PropertyResolverConstant(fpreal v) { myValue = v; }
00071 SIM_PropertyResolverConstant(UT_Vector3 v) { myValue = v; }
00072
00073 virtual SIM_PropertyResolver *copy() const
00074 {
00075 return new SIM_PropertyResolverConstant(*this);
00076 }
00077
00078 virtual fpreal getF(const UT_Vector3 &pos) { return myValue.x(); }
00079 virtual UT_Vector3 getV3(const UT_Vector3 &pos) { return myValue; }
00080 protected:
00081 UT_Vector3 myValue;
00082 };
00083
00084 class SIM_API SIM_PropertyResolverNearestPoint : public SIM_PropertyResolver
00085 {
00086 public:
00087 SIM_PropertyResolverNearestPoint(const SIM_PointTree *pttree,
00088 const SIM_Geometry *geo,
00089 const char *attribname,
00090 const UT_DMatrix4 &worldtogdp);
00091 virtual ~SIM_PropertyResolverNearestPoint();
00092
00093 virtual SIM_PropertyResolver *copy() const;
00094
00095 virtual fpreal getF(const UT_Vector3 &pos);
00096 virtual UT_Vector3 getV3(const UT_Vector3 &pos);
00097 const GEO_Point *getPt(const UT_Vector3 &pos);
00098 protected:
00099
00100 GU_ConstDetailHandle myGdpHandle;
00101 GEO_AttributeHandle myAttrib;
00102 UT_DMatrix4 myWorldToGdp;
00103 GEO_PointTree *myPointTree;
00104 ut_KDPQueue *myQueue;
00105 };
00106
00107 class SIM_API SIM_PropertyResolverField : public SIM_PropertyResolver
00108 {
00109 public:
00110 SIM_PropertyResolverField(const SIM_RawField *field);
00111 SIM_PropertyResolverField(const SIM_VectorField *field);
00112
00113 virtual SIM_PropertyResolver *copy() const
00114 {
00115 return new SIM_PropertyResolverField(*this);
00116 }
00117
00118
00119 virtual fpreal getF(const UT_Vector3 &pos);
00120 virtual UT_Vector3 getV3(const UT_Vector3 &pos);
00121 protected:
00122 const SIM_RawField *myField[3];
00123 };
00124
00125 class SIM_API SIM_PropertyResolverMotion : public SIM_PropertyResolver
00126 {
00127 public:
00128 SIM_PropertyResolverMotion(const UT_Vector3 &linvel,
00129 const UT_Vector3 &pivot,
00130 const UT_Vector3 &angvel);
00131
00132 virtual SIM_PropertyResolver *copy() const
00133 {
00134 return new SIM_PropertyResolverMotion(*this);
00135 }
00136
00137 virtual fpreal getF(const UT_Vector3 &pos) { return getV3(pos).x(); }
00138 virtual UT_Vector3 getV3(const UT_Vector3 &pos);
00139
00140 protected:
00141 UT_Vector3 myPivot, myLinVel, myAngVel;
00142 };
00143
00144 class SIM_API SIM_PropertyResolverVelAtPosition : public SIM_PropertyResolver
00145 {
00146 public:
00147 SIM_PropertyResolverVelAtPosition(const SIM_Object *obj,
00148 bool usesdfhistory,
00149 bool usegeohistory,
00150 fpreal integrateovertime)
00151 {
00152 myObject = obj;
00153 myUseSDF = usesdfhistory;
00154 myUseGeo = usegeohistory;
00155 myIntegrate = integrateovertime;
00156 }
00157
00158 virtual SIM_PropertyResolver *copy() const
00159 {
00160 return new SIM_PropertyResolverVelAtPosition(*this);
00161 }
00162
00163 virtual fpreal getF(const UT_Vector3 &pos) { return getV3(pos).x(); }
00164 virtual UT_Vector3 getV3(const UT_Vector3 &pos);
00165
00166 virtual bool threadsafe() const { return false; }
00167 protected:
00168 const SIM_Object *myObject;
00169 bool myUseSDF, myUseGeo;
00170 fpreal myIntegrate;
00171 };
00172
00173
00174 class SIM_API SIM_PhysicalParms : public SIM_Data,
00175 public SIM_OptionsUser
00176 {
00177 public:
00178
00179 GETSET_DATA_FUNCS_F(SIM_NAME_FRICTION, Friction)
00180
00181 GETSET_DATA_FUNCS_F(SIM_NAME_DYNAMICFRICTION, DynamicFriction)
00182
00183 GETSET_DATA_FUNCS_F(SIM_NAME_BOUNCE, Bounce)
00184
00185 GETSET_DATA_FUNCS_F(SIM_NAME_TEMPERATURE, Temperature)
00186
00187 fpreal getProperty(const SIM_Property &property) const;
00188
00189 protected:
00190 explicit SIM_PhysicalParms(const SIM_DataFactory *factory);
00191 virtual ~SIM_PhysicalParms();
00192
00193 private:
00194 static const SIM_DopDescription *getPhysicalParmsDopDescription();
00195
00196 DECLARE_STANDARD_GETCASTTOTYPE();
00197 DECLARE_DATAFACTORY(SIM_PhysicalParms,
00198 SIM_Data,
00199 "Physical Parameters",
00200 getPhysicalParmsDopDescription());
00201 };
00202
00203 #endif