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"
21#include "physxObjectCollection.h"
22#include "physxEnums.h"
23#include "physx_includes.h"
24
25 class PhysxScene;
26 class PhysxGroupsMask;
27 class PhysxClothNode;
28
29/**
30 *
31 */
32 class 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;
51 PhysxGroupsMask get_groups_mask() 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);
61 void attach_to_colliding_shapes();
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
92 public:
93 void update();
94
95PUBLISHED:
96 void release();
97
98 public:
99 INLINE NxCloth *ptr() const { return _ptr; };
100
101 void link(NxCloth *ptr);
102 void unlink();
103
104 private:
105 NxCloth *_ptr;
106 PT(PhysxClothNode) _node;
107 std::string _name;
108
109 public:
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
126 private:
127 static TypeHandle _type_handle;
128};
129
130#include "physxCloth.I"
131
132#endif // PHYSXCLOTH_H
PhysxClothNode
Renderable geometry which represents a cloth mesh.
Definition physxClothNode.h:33
PhysxCloth::set_wind_acceleration
void set_wind_acceleration(LVector3f const &acceleration)
Sets an acceleration acting normal to the cloth surface at each vertex.
Definition physxCloth.cxx:499
PhysxCloth::put_to_sleep
void put_to_sleep()
Forces the cloth to sleep.
Definition physxCloth.cxx:321
PhysxCloth::get_thickness
float get_thickness() const
Gets the cloth thickness.
Definition physxCloth.cxx:185
PhysxCloth::get_relative_grid_spacing
float get_relative_grid_spacing() const
Gets the relative grid spacing for the broad phase.
Definition physxCloth.cxx:208
PhysxCloth::get_external_acceleration
LVector3f get_external_acceleration() const
Retrieves the external acceleration which affects all non attached particles of the cloth.
Definition physxCloth.cxx:512
PhysxCloth::attach_vertex_to_global_pos
void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos)
Attaches a cloth vertex to a position in world space.
Definition physxCloth.cxx:357
PhysxCloth::get_wind_acceleration
LVector3f get_wind_acceleration() const
Retrieves the acceleration acting normal to the cloth surface at each vertex.
Definition physxCloth.cxx:523
PhysxCloth::detach_from_shape
void detach_from_shape(PhysxShape *shape)
Detaches the cloth from a shape it has been attached to before.
Definition physxCloth.cxx:404
PhysxCloth::add_force_at_vertex
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...
Definition physxCloth.cxx:534
PhysxCloth::set_group
void set_group(unsigned int group)
Sets which collision group this cloth is part of.
Definition physxCloth.cxx:154
PhysxCloth::attach_vertex_to_shape
void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos)
Attaches a cloth vertex to a local position within a shape.
Definition physxCloth.cxx:426
PhysxCloth::add_force_at_pos
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.
Definition physxCloth.cxx:547
PhysxCloth::add_directed_force_at_pos
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.
Definition physxCloth.cxx:561
PhysxCloth::set_external_acceleration
void set_external_acceleration(LVector3f const &acceleration)
Sets an external acceleration which affects all non attached particles of the cloth.
Definition physxCloth.cxx:487
PhysxCloth::set_sleep_linear_velocity
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an cloth may go to sleep.
Definition physxCloth.cxx:335
PhysxCloth::get_name
const char * get_name() const
Retrieves the name string.
Definition physxCloth.cxx:143
PhysxCloth::set_groups_mask
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
Definition physxCloth.cxx:259
PhysxCloth::set_flag
void set_flag(PhysxClothFlag flag, bool value)
Sets the value of a single flag.
Definition physxCloth.cxx:228
PhysxCloth::get_sleep_linear_velocity
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.
Definition physxCloth.cxx:347
PhysxCloth::get_vertex_attachment_status
PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const
Return the attachment status of the given vertex.
Definition physxCloth.cxx:442
PhysxCloth::get_num_particles
unsigned int get_num_particles()
Gets the number of cloth particles.
Definition physxCloth.cxx:218
PhysxCloth::wake_up
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the cloth if it is sleeping.
Definition physxCloth.cxx:307
PhysxCloth::attach_to_shape
void attach_to_shape(PhysxShape *shape)
Attaches the cloth to a shape.
Definition physxCloth.cxx:373
PhysxCloth::get_vertex_attachment_pos
LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const
Returns the attachment position of the given vertex.
Definition physxCloth.cxx:473
PhysxCloth::get_density
float get_density() const
Gets the cloth density.
Definition physxCloth.cxx:195
PhysxCloth::attach_to_colliding_shapes
void attach_to_colliding_shapes()
Attaches the cloth to all shapes, currently colliding.
Definition physxCloth.cxx:389
PhysxCloth::get_groups_mask
PhysxGroupsMask get_groups_mask() const
Gets the 128-bit groups mask used for collision filtering.
Definition physxCloth.cxx:271
PhysxCloth::set_thickness
void set_thickness(float thickness)
Sets the cloth thickness (must be positive).
Definition physxCloth.cxx:175
PhysxCloth::get_flag
bool get_flag(PhysxClothFlag flag) const
Retrieves the value of a single flag.
Definition physxCloth.cxx:248
PhysxCloth::get_vertex_attachment_shape
PhysxShape * get_vertex_attachment_shape(unsigned int vertexId) const
Returns the pointer to an attached shape pointer of the given vertex.
Definition physxCloth.cxx:456
PhysxCloth::get_group
unsigned int get_group() const
Retrieves the collision group this cloth is part of.
Definition physxCloth.cxx:165
PhysxCloth::set_name
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
Definition physxCloth.cxx:131
PhysxCloth::is_sleeping
bool is_sleeping() const
Returns true if this cloth is sleeping.
Definition physxCloth.cxx:293
PhysxCloth::get_scene
PhysxScene * get_scene() const
Returns the scene which this cloth belongs to.
Definition physxCloth.cxx:96
PhysxCloth::free_vertex
void free_vertex(unsigned int vertexId)
Frees a previously attached cloth point.
Definition physxCloth.cxx:416
PhysxEnums
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition physxEnums.h:355
PhysxGroupsMask
128-bit bitmask class.
Definition physxGroupsMask.h:24
PhysxScene
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition physxScene.h:69
PhysxShape
Abstract base class for shapes.
Definition physxShape.h:39
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxCloth.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxEnums.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxObjectCollection.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxObject.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physx_includes.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22