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