Panda3D
Loading...
Searching...
No Matches
physxCloth.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file physxCloth.h
10 * @author enn0x
11 * @date 2010-03-30
12 */
13
14#ifndef PHYSXCLOTH_H
15#define PHYSXCLOTH_H
16
17#include "pandabase.h"
18#include "luse.h"
19
20#include "physxObject.h"
22#include "physxEnums.h"
23#include "physx_includes.h"
24
25class PhysxScene;
26class PhysxGroupsMask;
27class PhysxClothNode;
28
29/**
30 *
31 */
32class EXPCL_PANDAPHYSX PhysxCloth : public PhysxObject, public PhysxEnums {
33
34PUBLISHED:
35 INLINE PhysxCloth();
36 INLINE ~PhysxCloth();
37
38 PhysxScene *get_scene() const;
39 PhysxClothNode *get_cloth_node() const;
40 PhysxClothNode *create_cloth_node(const char *name);
41
42 void set_name(const char *name);
43 void set_group(unsigned int group);
44 void set_groups_mask(const PhysxGroupsMask &mask);
45 void set_flag(PhysxClothFlag flag, bool value);
46 void set_thickness(float thickness);
47
48 const char *get_name() const;
49 unsigned int get_num_particles();
50 unsigned int get_group() const;
52 bool get_flag(PhysxClothFlag flag) const;
53 float get_thickness() const;
54 float get_density() const;
55 float get_relative_grid_spacing() const;
56
57 // Attachment
58 void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos);
59 void free_vertex(unsigned int vertexId);
60 void attach_to_shape(PhysxShape *shape);
62 void detach_from_shape(PhysxShape *shape);
63 void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos);
64 PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const;
65 PhysxShape *get_vertex_attachment_shape(unsigned int vertexId) const;
66 LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const;
67
68 // Sleeping
69 bool is_sleeping() const;
70 void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL);
71 void put_to_sleep();
72 void set_sleep_linear_velocity(float threshold);
73 float get_sleep_linear_velocity() const;
74
75 // Forces
76 void set_external_acceleration(LVector3f const &acceleration);
77 LVector3f get_external_acceleration() const;
78
79 void set_wind_acceleration(LVector3f const &acceleration);
80 LVector3f get_wind_acceleration() const;
81
82 void add_force_at_vertex(LVector3f const &force, int vertexId,
83 PhysxForceMode mode=FM_force);
84 void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius,
85 PhysxForceMode mode=FM_force);
86 void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius,
87 PhysxForceMode mode=FM_force);
88
89 INLINE void ls() const;
90 INLINE void ls(std::ostream &out, int indent_level=0) const;
91
92public:
93 void update();
94
95PUBLISHED:
96 void release();
97
98public:
99 INLINE NxCloth *ptr() const { return _ptr; };
100
101 void link(NxCloth *ptr);
102 void unlink();
103
104private:
105 NxCloth *_ptr;
106 PT(PhysxClothNode) _node;
107 std::string _name;
108
109public:
110 static TypeHandle get_class_type() {
111 return _type_handle;
112 }
113 static void init_type() {
114 PhysxObject::init_type();
115 register_type(_type_handle, "PhysxCloth",
116 PhysxObject::get_class_type());
117 }
118 virtual TypeHandle get_type() const {
119 return get_class_type();
120 }
121 virtual TypeHandle force_init_type() {
122 init_type();
123 return get_class_type();
124 }
125
126private:
127 static TypeHandle _type_handle;
128};
129
130#include "physxCloth.I"
131
132#endif // PHYSXCLOTH_H
Renderable geometry which represents a cloth mesh.
void set_wind_acceleration(LVector3f const &acceleration)
Sets an acceleration acting normal to the cloth surface at each vertex.
void put_to_sleep()
Forces the cloth to sleep.
float get_thickness() const
Gets the cloth thickness.
float get_relative_grid_spacing() const
Gets the relative grid spacing for the broad phase.
LVector3f get_external_acceleration() const
Retrieves the external acceleration which affects all non attached particles of the cloth.
void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos)
Attaches a cloth vertex to a position in world space.
LVector3f get_wind_acceleration() const
Retrieves the acceleration acting normal to the cloth surface at each vertex.
void detach_from_shape(PhysxShape *shape)
Detaches the cloth from a shape it has been attached to before.
void add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode=FM_force)
Applies a force (or impulse) defined in the global coordinate frame, to a particular vertex of the cl...
void set_group(unsigned int group)
Sets which collision group this cloth is part of.
void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos)
Attaches a cloth vertex to a local position within a shape.
void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceMode mode=FM_force)
Applies a radial force (or impulse) at a particular position.
void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, PhysxForceMode mode=FM_force)
Applies a directed force (or impulse) at a particular position.
void set_external_acceleration(LVector3f const &acceleration)
Sets an external acceleration which affects all non attached particles of the cloth.
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an cloth may go to sleep.
const char * get_name() const
Retrieves the name string.
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
void set_flag(PhysxClothFlag flag, bool value)
Sets the value of a single flag.
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.
PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const
Return the attachment status of the given vertex.
unsigned int get_num_particles()
Gets the number of cloth particles.
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the cloth if it is sleeping.
void attach_to_shape(PhysxShape *shape)
Attaches the cloth to a shape.
LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const
Returns the attachment position of the given vertex.
float get_density() const
Gets the cloth density.
void attach_to_colliding_shapes()
Attaches the cloth to all shapes, currently colliding.
PhysxGroupsMask get_groups_mask() const
Gets the 128-bit groups mask used for collision filtering.
void set_thickness(float thickness)
Sets the cloth thickness (must be positive).
bool get_flag(PhysxClothFlag flag) const
Retrieves the value of a single flag.
PhysxShape * get_vertex_attachment_shape(unsigned int vertexId) const
Returns the pointer to an attached shape pointer of the given vertex.
unsigned int get_group() const
Retrieves the collision group this cloth is part of.
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
bool is_sleeping() const
Returns true if this cloth is sleeping.
PhysxScene * get_scene() const
Returns the scene which this cloth belongs to.
void free_vertex(unsigned int vertexId)
Frees a previously attached cloth point.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition physxEnums.h:355
128-bit bitmask class.
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition physxScene.h:69
Abstract base class for shapes.
Definition physxShape.h:39
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...