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