2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2022-07-10 09:47:41 +08:00
|
|
|
https://axis-project.github.io/
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
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:
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
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>
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
|
|
|
|
2021-12-31 12:12:40 +08:00
|
|
|
class Physics3DConstraint;
|
2022-07-11 17:50:21 +08:00
|
|
|
|
|
|
|
NS_AX_END
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
DEFINE_TEST_SUITE(Physics3DTests);
|
|
|
|
|
2022-07-15 19:44:31 +08:00
|
|
|
#if CC_USE_3D_PHYSICS == 0
|
2019-11-23 20:27:39 +08:00
|
|
|
class Physics3DDemoDisabled : public TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Physics3DDemoDisabled);
|
|
|
|
|
|
|
|
virtual void onEnter() override;
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
|
|
|
|
class Physics3DTestDemo : public TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Physics3DTestDemo);
|
|
|
|
Physics3DTestDemo();
|
|
|
|
virtual ~Physics3DTestDemo();
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
// overrides
|
|
|
|
virtual bool init() override;
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void update(float delta) override;
|
2021-12-28 21:00:45 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesBegan(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
|
|
|
virtual void onTouchesMoved(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
|
|
|
virtual void onTouchesEnded(const std::vector<axis::Touch*>& touches, axis::Event* event);
|
2021-12-31 11:00:35 +08:00
|
|
|
|
2021-12-31 12:12:40 +08:00
|
|
|
protected:
|
2022-07-11 17:50:21 +08:00
|
|
|
void shootBox(const axis::Vec3& des);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
protected:
|
2021-12-31 12:12:40 +08:00
|
|
|
std::string _title;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Camera* _camera = nullptr;
|
2021-12-31 12:12:40 +08:00
|
|
|
float _angle = 0.f;
|
|
|
|
bool _needShootBox = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
2021-12-31 12:12:40 +08:00
|
|
|
Physics3DConstraintDemo() : _constraint(nullptr), _pickingDistance(0.f){};
|
2019-11-23 20:27:39 +08:00
|
|
|
virtual ~Physics3DConstraintDemo(){};
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
virtual bool init() override;
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesBegan(const std::vector<axis::Touch*>& touches, axis::Event* event) override;
|
|
|
|
virtual void onTouchesMoved(const std::vector<axis::Touch*>& touches, axis::Event* event) override;
|
|
|
|
virtual void onTouchesEnded(const std::vector<axis::Touch*>& touches, axis::Event* event) override;
|
2021-12-31 12:12:40 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Physics3DConstraint* _constraint; // for picking
|
2021-12-31 12:12:40 +08:00
|
|
|
float _pickingDistance; // picking distance
|
2019-11-23 20:27:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|