-
-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathPhysics3DTest.h
164 lines (123 loc) · 4.53 KB
/
Physics3DTest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
https://axmol.dev/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef _PHYSICS3D_TEST_H_
#define _PHYSICS3D_TEST_H_
#include "../BaseTest.h"
#include <string>
namespace ax
{
class Physics3DConstraint;
}
DEFINE_TEST_SUITE(Physics3DTests);
#if !defined(AX_ENABLE_3D_PHYSICS)
class Physics3DDemoDisabled : public TestCase
{
public:
CREATE_FUNC(Physics3DDemoDisabled);
virtual void onEnter() override;
};
#else
class Physics3DTestDemo : public TestCase
{
public:
CREATE_FUNC(Physics3DTestDemo);
Physics3DTestDemo();
virtual ~Physics3DTestDemo();
// overrides
virtual bool init() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void update(float delta) override;
virtual void onTouchesBegan(const std::vector<ax::Touch*>& touches, ax::Event* event);
virtual void onTouchesMoved(const std::vector<ax::Touch*>& touches, ax::Event* event);
virtual void onTouchesEnded(const std::vector<ax::Touch*>& touches, ax::Event* event);
protected:
void shootBox(const ax::Vec3& des);
protected:
std::string _title;
ax::Camera* _camera = nullptr;
float _angle = 0.f;
bool _needShootBox = false;
};
class BasicPhysics3DDemo : public Physics3DTestDemo
{
public:
CREATE_FUNC(BasicPhysics3DDemo);
BasicPhysics3DDemo(){};
virtual ~BasicPhysics3DDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
};
class Physics3DConstraintDemo : public Physics3DTestDemo
{
public:
CREATE_FUNC(Physics3DConstraintDemo);
Physics3DConstraintDemo() : _constraint(nullptr), _pickingDistance(0.f){};
virtual ~Physics3DConstraintDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
virtual void onTouchesBegan(const std::vector<ax::Touch*>& touches, ax::Event* event) override;
virtual void onTouchesMoved(const std::vector<ax::Touch*>& touches, ax::Event* event) override;
virtual void onTouchesEnded(const std::vector<ax::Touch*>& touches, ax::Event* event) override;
protected:
ax::Physics3DConstraint* _constraint; // for picking
float _pickingDistance; // picking distance
};
class Physics3DKinematicDemo : public Physics3DTestDemo
{
public:
CREATE_FUNC(Physics3DKinematicDemo);
Physics3DKinematicDemo(){};
virtual ~Physics3DKinematicDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
};
class Physics3DCollisionCallbackDemo : public Physics3DTestDemo
{
public:
CREATE_FUNC(Physics3DCollisionCallbackDemo);
Physics3DCollisionCallbackDemo(){};
virtual ~Physics3DCollisionCallbackDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
};
class Physics3DTerrainDemo : public Physics3DTestDemo
{
public:
CREATE_FUNC(Physics3DTerrainDemo);
Physics3DTerrainDemo(){};
virtual ~Physics3DTerrainDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
private:
};
class Physics3DColliderDemo : public Physics3DTestDemo
{
public:
CREATE_FUNC(Physics3DColliderDemo);
Physics3DColliderDemo(){};
virtual ~Physics3DColliderDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
private:
};
#endif
#endif