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