Panda3D
 All Classes Functions Variables Enumerations
physxMaterial.h
00001 // Filename: physxMaterial.h
00002 // Created by:  enn0x (21Sep09)
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 PHYSXMATERIAL_H
00016 #define PHYSXMATERIAL_H
00017 
00018 #include "pandabase.h"
00019 #include "luse.h"
00020 
00021 #include "physxObject.h"
00022 #include "physxEnums.h"
00023 #include "physx_includes.h"
00024 
00025 class PhysxScene;
00026 class PhysxMaterialDesc;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : PhysxMaterial
00030 // Description : A class for describing a shape's surface
00031 //               properties.
00032 //
00033 //               You can create a material which has different
00034 //               friction coefficients depending on the direction
00035 //               that a body in contact is trying to move in. This
00036 //               is called anisotropic friction.
00037 //
00038 //               Anisotropic friction is useful for modeling things
00039 //               like sledges, skis etc
00040 //
00041 //               When you create an anisotropic material you specify
00042 //               the default friction parameters and also friction
00043 //               parameters for the V axis. The friction parameters
00044 //               for the V axis are applied to motion along the
00045 //               direction of anisotropy (dirOfAnisotropy).
00046 //
00047 //               Default material: You can change the properties of
00048 //               the default material by querying for material
00049 //               index 0.
00050 ////////////////////////////////////////////////////////////////////
00051 class EXPCL_PANDAPHYSX PhysxMaterial : public PhysxObject, public PhysxEnums {
00052 
00053 PUBLISHED:
00054   INLINE PhysxMaterial();
00055   INLINE ~PhysxMaterial();
00056 
00057   PhysxScene *get_scene() const;
00058   unsigned short get_material_index() const;
00059 
00060   void load_from_desc(const PhysxMaterialDesc &materialDesc);
00061   void save_to_desc(PhysxMaterialDesc &materialDesc) const;
00062 
00063   void set_dynamic_friction(float coef);
00064   void set_static_friction(float coef);
00065   void set_restitution(float rest);
00066   void set_dynamic_friction_v(float coef);
00067   void set_static_friction_v(float coef);
00068   void set_dir_of_anisotropy(const LVector3f dir);
00069   void set_flag(PhysxMaterialFlag flag, bool value);
00070   void set_friction_combine_mode(PhysxCombineMode mode);
00071   void set_restitution_combine_mode(PhysxCombineMode mode);
00072 
00073   float get_dynamic_friction() const;
00074   float get_static_friction() const;
00075   float get_restitution() const;
00076   float get_dynamic_friction_v() const;
00077   float get_static_friction_v() const;
00078   LVector3f get_dir_of_anisotropy() const;
00079   bool get_flag(PhysxMaterialFlag flag) const;
00080   PhysxCombineMode get_friction_combine_mode() const;
00081   PhysxCombineMode get_restitution_combine_mode() const;
00082 
00083   INLINE void ls() const;
00084   INLINE void ls(ostream &out, int indent_level=0) const;
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 PUBLISHED:
00088   void release();
00089 
00090 public:
00091   INLINE NxMaterial *ptr() const { return _ptr; };
00092 
00093   void link(NxMaterial *ptr);
00094   void unlink();
00095 
00096 private:
00097   NxMaterial *_ptr;
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 public:
00101   static TypeHandle get_class_type() {
00102     return _type_handle;
00103   }
00104   static void init_type() {
00105     PhysxObject::init_type();
00106     register_type(_type_handle, "PhysxMaterial", 
00107                   PhysxObject::get_class_type());
00108   }
00109   virtual TypeHandle get_type() const {
00110     return get_class_type();
00111   }
00112   virtual TypeHandle force_init_type() {
00113     init_type();
00114     return get_class_type();
00115   }
00116 
00117 private:
00118   static TypeHandle _type_handle;
00119 };
00120 
00121 #include "physxMaterial.I"
00122 
00123 #endif // PHYSXMATERIAL_H
 All Classes Functions Variables Enumerations