Panda3D
|
00001 // Filename: physxSoftBody.h 00002 // Created by: enn0x (13Sep10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PHYSXSOFTBODY_H 00016 #define PHYSXSOFTBODY_H 00017 00018 #include "pandabase.h" 00019 #include "lvector3.h" 00020 #include "lpoint3.h" 00021 00022 #include "physxObject.h" 00023 #include "physxObjectCollection.h" 00024 #include "physxEnums.h" 00025 #include "physx_includes.h" 00026 00027 class PhysxScene; 00028 class PhysxGroupsMask; 00029 class PhysxSoftBodyNode; 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Class : PhysxSoftBody 00033 // Description : 00034 //////////////////////////////////////////////////////////////////// 00035 class EXPCL_PANDAPHYSX PhysxSoftBody : public PhysxObject, public PhysxEnums { 00036 00037 PUBLISHED: 00038 INLINE PhysxSoftBody(); 00039 INLINE ~PhysxSoftBody(); 00040 00041 PhysxScene *get_scene() const; 00042 PhysxSoftBodyNode *get_soft_body_node() const; 00043 PhysxSoftBodyNode *create_soft_body_node(const char *name); 00044 00045 void set_name(const char *name); 00046 void set_flag(PhysxSoftBodyFlag flag, bool value); 00047 void set_groups_mask(const PhysxGroupsMask &mask); 00048 void set_group(unsigned int group); 00049 void set_solver_iterations(unsigned int iterations); 00050 void set_particle_radius(float radius); 00051 #if NX_SDK_VERSION_NUMBER > 281 00052 void set_self_collision_thickness(float thickness); 00053 void set_hard_stretch_limitation_factor(float factor); 00054 #endif 00055 void set_volume_stiffness(float stiffness); 00056 void set_stretching_stiffness(float stiffness); 00057 void set_damping_coefficient(float coef); 00058 void set_friction(float friction); 00059 void set_tear_factor(float factor); 00060 void set_attachment_tear_factor(float factor); 00061 00062 const char *get_name() const; 00063 bool get_flag(PhysxSoftBodyFlag flag) const; 00064 PhysxGroupsMask get_groups_mask() const; 00065 unsigned int get_group() const; 00066 unsigned int get_num_particles(); 00067 unsigned int get_solver_iterations() const; 00068 float get_particle_radius() const; 00069 float get_density() const; 00070 float get_relative_grid_spacing() const; 00071 #if NX_SDK_VERSION_NUMBER > 281 00072 float get_self_collision_thickness() const; 00073 float get_hard_stretch_limitation_factor() const; 00074 #endif 00075 float get_volume_stiffness() const; 00076 float get_stretching_stiffness() const; 00077 float get_damping_coefficient() const; 00078 float get_friction() const; 00079 float get_tear_factor() const; 00080 float get_attachment_tear_factor() const; 00081 00082 /* 00083 // Attachment 00084 void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos); 00085 void free_vertex(unsigned int vertexId); 00086 void attach_to_shape(PhysxShape *shape); 00087 void attach_to_colliding_shapes(); 00088 void detach_from_shape(PhysxShape *shape); 00089 void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos); 00090 PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const; 00091 PhysxShape *get_vertex_attachment_shape(unsigned int vertexId) const; 00092 LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const; 00093 */ 00094 00095 // Sleeping 00096 bool is_sleeping() const; 00097 void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL); 00098 void put_to_sleep(); 00099 void set_sleep_linear_velocity(float threshold); 00100 float get_sleep_linear_velocity() const; 00101 00102 /* 00103 // Forces 00104 void set_external_acceleration(LVector3f const &acceleration); 00105 LVector3f get_external_acceleration() const; 00106 00107 void set_wind_acceleration(LVector3f const &acceleration); 00108 LVector3f get_wind_acceleration() const; 00109 00110 void add_force_at_vertex(LVector3f const &force, int vertexId, 00111 PhysxForceMode mode=FM_force); 00112 void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, 00113 PhysxForceMode mode=FM_force); 00114 void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, 00115 PhysxForceMode mode=FM_force); 00116 */ 00117 00118 00119 /* 00120 virtual void getWorldBounds (NxBounds3 &bounds) const =0 00121 virtual void attachToShape (const NxShape *shape, NxU32 attachmentFlags)=0 00122 virtual void attachToCollidingShapes (NxU32 attachmentFlags)=0 00123 virtual void detachFromShape (const NxShape *shape)=0 00124 virtual void attachVertexToShape (NxU32 vertexId, const NxShape *shape, const NxVec3 &localPos, NxU32 attachmentFlags)=0 00125 virtual void attachVertexToGlobalPosition (const NxU32 vertexId, const NxVec3 &pos)=0 00126 virtual void freeVertex (const NxU32 vertexId)=0 00127 virtual bool tearVertex (const NxU32 vertexId, const NxVec3 &normal)=0 00128 virtual bool raycast (const NxRay &worldRay, NxVec3 &hit, NxU32 &vertexId)=0 00129 virtual void setMeshData (NxMeshData &meshData)=0 00130 virtual NxMeshData getMeshData ()=0 00131 virtual void setSplitPairData (NxSoftBodySplitPairData &splitPairData)=0 00132 virtual NxSoftBodySplitPairData getSplitPairData ()=0 00133 virtual void setValidBounds (const NxBounds3 &validBounds)=0 00134 virtual void getValidBounds (NxBounds3 &validBounds) const =0 00135 virtual void setPosition (const NxVec3 &position, NxU32 vertexId)=0 00136 virtual void setPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 00137 virtual NxVec3 getPosition (NxU32 vertexId) const =0 00138 virtual void getPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 00139 virtual void setVelocity (const NxVec3 &velocity, NxU32 vertexId)=0 00140 virtual void setVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 00141 virtual NxVec3 getVelocity (NxU32 vertexId) const =0 00142 virtual void getVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 00143 virtual void setConstrainPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 00144 virtual void setConstrainNormals (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 00145 virtual void setConstrainCoefficients (const NxSoftBodyConstrainCoefficients *coefficients, NxU32 byteStride=sizeof(NxSoftBodyConstrainCoefficients))=0 00146 virtual NxU32 queryShapePointers ()=0 00147 virtual NxU32 getStateByteSize ()=0 00148 virtual void getShapePointers (NxShape **shapePointers, NxU32 *flags)=0 00149 virtual void setShapePointers (NxShape **shapePointers, unsigned int numShapes)=0 00150 virtual void saveStateToStream (NxStream &stream, bool permute=false)=0 00151 virtual void loadStateFromStream (NxStream &stream)=0 00152 virtual void setCollisionResponseCoefficient (NxReal coefficient)=0 00153 virtual NxReal getCollisionResponseCoefficient () const =0 00154 virtual void setAttachmentResponseCoefficient (NxReal coefficient)=0 00155 virtual NxReal getAttachmentResponseCoefficient () const =0 00156 virtual void setFromFluidResponseCoefficient (NxReal coefficient)=0 00157 virtual NxReal getFromFluidResponseCoefficient () const =0 00158 virtual void setToFluidResponseCoefficient (NxReal coefficient)=0 00159 virtual NxReal getToFluidResponseCoefficient () const =0 00160 virtual void setExternalAcceleration (NxVec3 acceleration)=0 00161 virtual NxVec3 getExternalAcceleration () const =0 00162 virtual void setMinAdhereVelocity (NxReal velocity)=0 00163 virtual NxReal getMinAdhereVelocity () const =0 00164 virtual void addForceAtVertex (const NxVec3 &force, NxU32 vertexId, NxForceMode mode=NX_FORCE)=0 00165 virtual void addForceAtPos (const NxVec3 &position, NxReal magnitude, NxReal radius, NxForceMode mode=NX_FORCE)=0 00166 virtual void addDirectedForceAtPos (const NxVec3 &position, const NxVec3 &force, NxReal radius, NxForceMode mode=NX_FORCE)=0 00167 virtual bool overlapAABBTetrahedra (const NxBounds3 &bounds, NxU32 &nb, const NxU32 *&indices) const =0 00168 virtual NxCompartment * getCompartment () const =0 00169 virtual NxForceFieldMaterial getForceFieldMaterial () const =0 00170 virtual void setForceFieldMaterial (NxForceFieldMaterial)=0 00171 */ 00172 00173 INLINE void ls() const; 00174 INLINE void ls(ostream &out, int indent_level=0) const; 00175 00176 public: 00177 void update(); 00178 00179 //////////////////////////////////////////////////////////////////// 00180 PUBLISHED: 00181 void release(); 00182 00183 public: 00184 INLINE NxSoftBody *ptr() const { return _ptr; }; 00185 00186 void link(NxSoftBody *ptr); 00187 void unlink(); 00188 00189 private: 00190 NxSoftBody *_ptr; 00191 PT(PhysxSoftBodyNode) _node; 00192 string _name; 00193 00194 //////////////////////////////////////////////////////////////////// 00195 public: 00196 static TypeHandle get_class_type() { 00197 return _type_handle; 00198 } 00199 static void init_type() { 00200 PhysxObject::init_type(); 00201 register_type(_type_handle, "PhysxSoftBody", 00202 PhysxObject::get_class_type()); 00203 } 00204 virtual TypeHandle get_type() const { 00205 return get_class_type(); 00206 } 00207 virtual TypeHandle force_init_type() { 00208 init_type(); 00209 return get_class_type(); 00210 } 00211 00212 private: 00213 static TypeHandle _type_handle; 00214 }; 00215 00216 #include "physxSoftBody.I" 00217 00218 #endif // PHYSXSOFTBODY_H