Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
PhysXActor.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_PHYSX_ACTOR_H_
34#define DVD_PHYSX_ACTOR_H_
35
36// PhysX includes
37
39
40#include <physx/PxRigidActor.h>
41
42namespace Divide {
43
44namespace Util {
45 vec3<F32> toVec3(const physx::PxVec3& vec) noexcept;
46 physx::PxVec3 toVec3(const vec3<F32>& vec) noexcept;
47} //namespace Util
48
49class PhysXActor final : public PhysicsAsset {
50public:
51 explicit PhysXActor(RigidBodyComponent& parent) noexcept;
52 ~PhysXActor() override;
53
54 void setPosition(const vec3<F32>& position) override;
55 void setPosition(F32 x, F32 y, F32 z) override;
56 void setPositionX(F32 positionX) override;
57 void setPositionY(F32 positionY) override;
58 void setPositionZ(F32 positionZ) override;
59 void translate(const vec3<F32>& axisFactors) override;
61
62 void setScale(const vec3<F32>& scale) override;
63 void setScaleX(F32 amount) override;
64 void setScaleY(F32 amount) override;
65 void setScaleZ(F32 amount) override;
66 void scale(const vec3<F32>& axisFactors) override;
67 void scaleX(F32 amount) override;
68 void scaleY(F32 amount) override;
69 void scaleZ(F32 amount) override;
71
72 void setRotation(const vec3<F32>& axis, Angle::DEGREES<F32> degrees) override;
74 void setRotation(const Quaternion<F32>& quat) override;
75 void setRotationX(Angle::DEGREES<F32> angle) override;
76 void setRotationY(Angle::DEGREES<F32> angle) override;
77 void setRotationZ(Angle::DEGREES<F32> angle) override;
79
80 void rotate(const vec3<F32>& axis, Angle::DEGREES<F32> degrees) override;
82 void rotate(const Quaternion<F32>& quat) override;
83 void rotateSlerp(const Quaternion<F32>& quat, D64 deltaTime) override;
84 void rotateX(Angle::DEGREES<F32> angle) override;
85 void rotateY(Angle::DEGREES<F32> angle) override;
86 void rotateZ(Angle::DEGREES<F32> angle) override;
88
89 void getScale(vec3<F32>& scaleOut) const override;
90 void getPosition(vec3<F32>& posOut) const override;
91 void getOrientation(Quaternion<F32>& quatOut) const override;
92
93 void physicsCollisionGroup(PhysicsGroup group) override;
94
95protected:
96 friend class PhysX;
97 friend class PhysXSceneInterface;
98
99 physx::PxRigidActor* _actor = nullptr;
100 physx::PxGeometryType::Enum _type = physx::PxGeometryType::eINVALID;
103
105};
106}; //namespace Divide
107
108#endif //DVD_PHYSX_ACTOR_H_
virtual void rotate(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees)=0
virtual void setScale(const vec3< F32 > &amount)=0
Set the local X,Y and Z scale factors.
virtual void setPosition(const vec3< F32 > &position)=0
Set the local X,Y and Z position.
virtual void setRotation(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees)=0
void setPositionZ(F32 positionZ) override
Set the object's position on the Z axis.
Definition: PhysXActor.cpp:54
physx::PxGeometryType::Enum _type
Definition: PhysXActor.h:100
void setPositionX(F32 positionX) override
Set the object's position on the X axis.
Definition: PhysXActor.cpp:44
void setScaleX(F32 amount) override
Set the scaling factor on the X axis.
Definition: PhysXActor.cpp:122
void setScaleZ(F32 amount) override
Set the scaling factor on the Z axis.
Definition: PhysXActor.cpp:132
void setPosition(const vec3< F32 > &position) override
Set the local X,Y and Z position.
Definition: PhysXActor.cpp:32
void rotateSlerp(const Quaternion< F32 > &quat, D64 deltaTime) override
Perform a SLERP rotation towards the specified quaternion.
Definition: PhysXActor.cpp:116
void setRotationX(Angle::DEGREES< F32 > angle) override
Definition: PhysXActor.cpp:171
physx::PxRigidActor * _actor
Definition: PhysXActor.h:99
void setScaleY(F32 amount) override
Set the scaling factor on the Y axis.
Definition: PhysXActor.cpp:127
void setPositionY(F32 positionY) override
Set the object's position on the Y axis.
Definition: PhysXActor.cpp:49
void getScale(vec3< F32 > &scaleOut) const override
Return the scale factor.
Definition: PhysXActor.cpp:188
void getOrientation(Quaternion< F32 > &quatOut) const override
Return the orientation quaternion.
Definition: PhysXActor.cpp:198
void scale(const vec3< F32 > &axisFactors) override
Add the specified scale factors to the current local position.
Definition: PhysXActor.cpp:89
void setRotationY(Angle::DEGREES< F32 > angle) override
Definition: PhysXActor.cpp:177
void rotateZ(Angle::DEGREES< F32 > angle) override
Definition: PhysXActor.cpp:165
void scaleX(F32 amount) override
Increase the scaling factor on the X axis by the specified factor.
Definition: PhysXActor.cpp:137
void rotate(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees) override
Definition: PhysXActor.cpp:96
void getPosition(vec3< F32 > &posOut) const override
Return the position.
Definition: PhysXActor.cpp:193
mat4< F32 > _cachedLocalMatrix
Definition: PhysXActor.h:104
void setRotationZ(Angle::DEGREES< F32 > angle) override
Definition: PhysXActor.cpp:183
void scaleZ(F32 amount) override
Increase the scaling factor on the Z axis by the specified factor.
Definition: PhysXActor.cpp:147
void translate(const vec3< F32 > &axisFactors) override
Add the specified translation factors to the current local position.
Definition: PhysXActor.cpp:84
~PhysXActor() override
Definition: PhysXActor.cpp:24
void scaleY(F32 amount) override
Increase the scaling factor on the Y axis by the specified factor.
Definition: PhysXActor.cpp:142
void physicsCollisionGroup(PhysicsGroup group) override
Definition: PhysXActor.cpp:202
void setRotation(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees) override
Definition: PhysXActor.cpp:65
void rotateX(Angle::DEGREES< F32 > angle) override
Definition: PhysXActor.cpp:153
void setScale(const vec3< F32 > &scale) override
Set the local X,Y and Z scale factors.
Definition: PhysXActor.cpp:59
void rotateY(Angle::DEGREES< F32 > angle) override
Definition: PhysXActor.cpp:159
vec3< F32 > toVec3(const physx::PxVec3 &vec) noexcept
Definition: PhysXActor.cpp:10
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
Project & parent
Definition: DefaultScene.h:41
double D64