Panda3D

physxCloth.h

00001 // Filename: physxCloth.h
00002 // Created by:  enn0x (30Mar10)
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 PHYSXCLOTH_H
00016 #define PHYSXCLOTH_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 PhysxClothNode;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : PhysxCloth
00033 // Description : 
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDAPHYSX PhysxCloth : public PhysxObject, public PhysxEnums {
00036 
00037 PUBLISHED:
00038   INLINE PhysxCloth();
00039   INLINE ~PhysxCloth();
00040 
00041   PhysxScene *get_scene() const;
00042   PhysxClothNode *get_cloth_node() const;
00043   PhysxClothNode *create_cloth_node(const char *name);
00044 
00045   void set_name(const char *name);
00046   void set_group(unsigned int group);
00047   void set_groups_mask(const PhysxGroupsMask &mask);
00048   void set_flag(PhysxClothFlag flag, bool value);
00049   void set_thickness(float thickness);
00050 
00051   const char *get_name() const;
00052   unsigned int get_num_particles();
00053   unsigned int get_group() const;
00054   PhysxGroupsMask get_groups_mask() const;
00055   bool get_flag(PhysxClothFlag flag) const;
00056   float get_thickness() const;
00057   float get_density() const;
00058   float get_relative_grid_spacing() const;
00059 
00060   // Attachment
00061   void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos);
00062   void free_vertex(unsigned int vertexId);
00063   void attach_to_shape(PhysxShape *shape);
00064   void attach_to_colliding_shapes();
00065   void detach_from_shape(PhysxShape *shape);
00066   void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos);
00067   PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const;
00068   PhysxShape *get_vertex_attachment_shape(unsigned int vertexId) const;
00069   LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const;
00070 
00071   // Sleeping
00072   bool is_sleeping() const;
00073   void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL);
00074   void put_to_sleep();
00075   void set_sleep_linear_velocity(float threshold);
00076   float get_sleep_linear_velocity() const;
00077 
00078   // Forces
00079   void set_external_acceleration(LVector3f const &acceleration);
00080   LVector3f get_external_acceleration() const;
00081 
00082   void set_wind_acceleration(LVector3f const &acceleration);
00083   LVector3f get_wind_acceleration() const;
00084 
00085   void add_force_at_vertex(LVector3f const &force, int vertexId,
00086                            PhysxForceMode mode=FM_force);
00087   void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius,
00088                         PhysxForceMode mode=FM_force);
00089   void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius,
00090                                  PhysxForceMode mode=FM_force);
00091 
00092   INLINE void ls() const;
00093   INLINE void ls(ostream &out, int indent_level=0) const;
00094 
00095 public:
00096   void update();
00097 
00098 ////////////////////////////////////////////////////////////////////
00099 PUBLISHED:
00100   void release();
00101 
00102 public:
00103   INLINE NxCloth *ptr() const { return _ptr; };
00104 
00105   void link(NxCloth *ptr);
00106   void unlink();
00107 
00108 private:
00109   NxCloth *_ptr;
00110   PT(PhysxClothNode) _node;
00111   string _name;
00112 
00113 ////////////////////////////////////////////////////////////////////
00114 public:
00115   static TypeHandle get_class_type() {
00116     return _type_handle;
00117   }
00118   static void init_type() {
00119     PhysxObject::init_type();
00120     register_type(_type_handle, "PhysxCloth", 
00121                   PhysxObject::get_class_type());
00122   }
00123   virtual TypeHandle get_type() const {
00124     return get_class_type();
00125   }
00126   virtual TypeHandle force_init_type() {
00127     init_type();
00128     return get_class_type();
00129   }
00130 
00131 private:
00132   static TypeHandle _type_handle;
00133 };
00134 
00135 #include "physxCloth.I"
00136 
00137 #endif // PHYSXCLOTH_H
 All Classes Functions Variables Enumerations