Panda3D
Loading...
Searching...
No Matches
physxActorDesc.cxx
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 physxActorDesc.cxx
10 * @author enn0x
11 * @date 2009-09-05
12 */
13
14#include "physxActorDesc.h"
15#include "physxBodyDesc.h"
16#include "physxManager.h"
17
18/**
19 * Adds a shape to the list of collision shapes composing this actor.
20 */
23
24 _desc.shapes.push_back(desc.ptr());
25}
26
27/**
28 * Sets the optional debug name for the actor.
29 */
31set_name(const char *name) {
32
33 _name = name ? name : "";
34 _desc.name = _name.c_str();
35}
36
37/**
38 * Set the density used during mass/intertia computation. This value is used
39 * if the actor's shapes do not have a mass asigned.
40 */
42set_density(float density) {
43
44 _desc.density = density;
45}
46
47/**
48 * Set the position of the actor in global space.
49 */
51set_global_pos(const LPoint3f &pos) {
52
53 _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
54}
55
56/**
57 * Set the position and orientation of the actor in global space. Scaling and
58 * shear arenot supported, even if the matrix contains a scale or shear.
59 */
61set_global_mat(const LMatrix4f &mat) {
62
63 _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
64}
65
66/**
67 * Sets the orientation of the actor in global space by providing angles for
68 * heading, pitch and roll.
69 */
71set_global_hpr(float h, float p, float r) {
72
73 LQuaternionf q;
74 LMatrix3f rot;
75 NxMat34 m;
76
77 q.set_hpr(LVector3f(h, p, r));
78 q.extract_to_matrix(rot);
79
80 _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot);
81}
82
83/**
84 * Sets the body descriptor for this actor. The actor will be dynmaic if a
85 * body descriptor is set, and static if no body descriptor is set.
86 */
89
90 _desc.body = &(desc._desc);
91}
92
93/**
94 * Gets the body descriptor for this actor.
95 */
97get_body() const {
98 assert(false /* Not implemented */);
99
100 // PhysxBodyDesc value; value._desc = *(_desc.body); return value;
101 return PhysxBodyDesc();
102}
103
104/**
105 * Returns the optional debug name for this actor.
106 */
108get_name() const {
109
110 return _desc.name;
111}
112
113/**
114 * Returns the actor's density.
115 */
117get_density() const {
118
119 return _desc.density;
120}
121
122/**
123 * Returns the actor's position in global space.
124 */
126get_global_pos() const {
127
128 return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
129}
130
131/**
132 * Returns the actor's transform in global space.
133 */
135get_global_mat() const {
136
137 return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
138}
LMatrix4f get_global_mat() const
Returns the actor's transform in global space.
void set_density(float density)
Set the density used during mass/intertia computation.
void set_body(PhysxBodyDesc &desc)
Sets the body descriptor for this actor.
void set_global_mat(const LMatrix4f &mat)
Set the position and orientation of the actor in global space.
void set_name(const char *name)
Sets the optional debug name for the actor.
LPoint3f get_global_pos() const
Returns the actor's position in global space.
const char * get_name() const
Returns the optional debug name for this actor.
void set_global_pos(const LPoint3f &pos)
Set the position of the actor in global space.
float get_density() const
Returns the actor's density.
PhysxBodyDesc get_body() const
Gets the body descriptor for this actor.
void add_shape(PhysxShapeDesc &desc)
Adds a shape to the list of collision shapes composing this actor.
void set_global_hpr(float h, float p, float r)
Sets the orientation of the actor in global space by providing angles for heading,...
Descriptor for the optional rigid body dynamic state of PhysxActor.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Abstract base class for shape descriptors.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.