Panda3D
Loading...
Searching...
No Matches
physxController.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 physxController.h
10 * @author enn0x
11 * @date 2009-09-24
12 */
13
14#ifndef PHYSXCONTROLLER_H
15#define PHYSXCONTROLLER_H
16
17#include "pandabase.h"
18#include "pointerTo.h"
19#include "luse.h"
20
21#include "physxObject.h"
22#include "physxEnums.h"
23#include "physx_includes.h"
24
25class PhysxActor;
26
27/**
28 * Abstract base class for character controllers.
29 */
30class EXPCL_PANDAPHYSX PhysxController : public PhysxObject, public PhysxEnums {
31
32PUBLISHED:
33 void release();
34
35 PhysxActor *get_actor() const;
36
37 void set_pos(const LPoint3f &pos);
38 void set_sharpness(float sharpness);
39 void set_collision(bool enable);
40 void set_min_distance(float min_dist);
41 void set_step_offset(float offset);
42
43 LPoint3f get_pos() const;
44 float get_sharpness() const;
45
46 void set_global_speed(const LVector3f &speed);
47 void set_local_speed(const LVector3f &speed);
48 void set_omega(float omega);
49 void set_h(float heading);
50 float get_h() const;
51
53 void start_jump(float v0);
54 void stop_jump();
55
56 INLINE void ls() const;
57 INLINE void ls(std::ostream &out, int indent_level=0) const;
58
59public:
60 void update_controller(float dt);
61
62 static PhysxController *factory(NxControllerType shapeType);
63
64 virtual NxController *ptr() const = 0;
65
66 virtual void link(NxController *controllerPtr) = 0;
67 virtual void unlink() = 0;
68
69protected:
70 INLINE PhysxController();
71
72private:
73 NxReal get_jump_height(float dt, NxVec3 &gravity);
74
75 float _sharpness;
76 float _min_dist;
77
78 bool _jumping;
79 float _jump_time;
80 float _jump_v0;
81
82 float _omega;
83 float _heading;
84 NxVec3 _speed;
85
86 NxVec3 _up_vector;
87 NxQuat _up_quat;
88 NxQuat _up_quat_inv;
89 NxHeightFieldAxis _up_axis;
90
91public:
92 static TypeHandle get_class_type() {
93 return _type_handle;
94 }
95 static void init_type() {
96 PhysxObject::init_type();
97 register_type(_type_handle, "PhysxController",
98 PhysxObject::get_class_type());
99 }
100 virtual TypeHandle get_type() const {
101 return get_class_type();
102 }
103 virtual TypeHandle force_init_type() {
104 init_type();
105 return get_class_type();
106 }
107
108private:
109 static TypeHandle _type_handle;
110};
111
112#include "physxController.I"
113
114#endif // PHYSXCONTROLLER_H
Actors are the main simulation objects.
Definition physxActor.h:44
void set_sharpness(float sharpness)
Sharpness is used to smooth motion with a feedback filter, having a value between 0 (so smooth it doe...
float get_h() const
Returns the heading of the controller in global space.
PhysxActor * get_actor() const
Retrieves the actor which this controller is associated with.
float get_sharpness() const
Returns the sharpness used to ease the motion curve when the auto-step feature is used.
void set_min_distance(float min_dist)
Sets the the minimum travelled distance to consider when moving the controller.
void stop_jump()
Leaves the jump mode.
void set_global_speed(const LVector3f &speed)
Sets the linear speed of the controller in global space.
void set_h(float heading)
Sets the heading of the controller is global space.
void set_step_offset(float offset)
Sets the step height/offset for the controller.
void start_jump(float v0)
Enters the jump mode.
void report_scene_changed()
The character controller uses caching in order to speed up collision testing, this caching can not de...
void set_omega(float omega)
Sets the angular velocity (degrees per second) of the controller.
LPoint3f get_pos() const
Retruns the position of the controller is global space.
void set_local_speed(const LVector3f &speed)
Sets the linear speed of the controller in local coordinates.
void set_collision(bool enable)
Enable/Disable collisions for this controller and actor.
void set_pos(const LPoint3f &pos)
Sets the position of the controller is global space.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition physxEnums.h:355
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(),...