2014-05-19 05:49:16 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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 _SPRITE3D_TEST_H_
|
|
|
|
#define _SPRITE3D_TEST_H_
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
#include "BaseTest.h"
|
2014-05-19 05:49:16 +08:00
|
|
|
#include <string>
|
|
|
|
|
2014-06-26 18:35:12 +08:00
|
|
|
namespace cocos2d {
|
2015-03-26 13:05:42 +08:00
|
|
|
class Animate3D;
|
|
|
|
class Sprite3D;
|
|
|
|
class Delay;
|
|
|
|
class Ray;
|
|
|
|
class DrawNode3D;
|
|
|
|
class GLProgramState;
|
2015-09-01 10:39:31 +08:00
|
|
|
class MotionStreak3D;
|
2014-06-26 18:35:12 +08:00
|
|
|
}
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(Sprite3DTests);
|
|
|
|
|
|
|
|
class Sprite3DTestDemo : public TestCase
|
2014-05-19 05:49:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// overrides
|
|
|
|
virtual std::string title() const override;
|
2015-09-09 11:13:17 +08:00
|
|
|
|
|
|
|
virtual ~Sprite3DTestDemo();
|
2014-05-19 05:49:16 +08:00
|
|
|
};
|
|
|
|
|
2015-01-29 16:21:33 +08:00
|
|
|
class Sprite3DForceDepthTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DForceDepthTest);
|
|
|
|
Sprite3DForceDepthTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2015-01-14 08:41:24 +08:00
|
|
|
class Sprite3DEmptyTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DEmptyTest);
|
|
|
|
Sprite3DEmptyTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2014-05-19 05:49:16 +08:00
|
|
|
class Sprite3DBasicTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DBasicTest);
|
|
|
|
Sprite3DBasicTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2014-05-19 05:49:16 +08:00
|
|
|
};
|
|
|
|
|
2014-11-12 17:42:45 +08:00
|
|
|
class Sprite3DUVAnimationTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DUVAnimationTest);
|
|
|
|
Sprite3DUVAnimationTest();
|
2014-12-30 11:48:39 +08:00
|
|
|
virtual ~Sprite3DUVAnimationTest();
|
2014-11-12 17:42:45 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-11-13 14:16:38 +08:00
|
|
|
|
|
|
|
protected:
|
2014-11-12 17:42:45 +08:00
|
|
|
void cylinderUpdate(float dt);
|
2014-11-13 14:16:38 +08:00
|
|
|
|
|
|
|
float _cylinder_texture_offset;
|
|
|
|
float _shining_duraion;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::GLProgramState * _state;
|
2014-12-30 11:48:39 +08:00
|
|
|
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
2014-12-30 11:48:39 +08:00
|
|
|
#endif
|
2014-11-12 17:42:45 +08:00
|
|
|
};
|
2014-12-17 13:31:35 +08:00
|
|
|
|
|
|
|
class Sprite3DFakeShadowTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-12-19 09:05:53 +08:00
|
|
|
enum State
|
|
|
|
{
|
|
|
|
State_None = 0,
|
|
|
|
State_Idle = 0x01,
|
|
|
|
State_Move = 0x02,
|
|
|
|
State_Rotate = 0x04
|
|
|
|
};
|
2014-12-17 13:31:35 +08:00
|
|
|
CREATE_FUNC(Sprite3DFakeShadowTest);
|
|
|
|
Sprite3DFakeShadowTest();
|
2014-12-30 11:48:39 +08:00
|
|
|
virtual ~Sprite3DFakeShadowTest();
|
2014-12-17 13:31:35 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-12-18 16:09:29 +08:00
|
|
|
void Move(cocos2d::Ref* sender,int value);
|
2014-12-19 09:05:53 +08:00
|
|
|
void updateCamera(float fDelta);
|
|
|
|
void move3D(float elapsedTime);
|
|
|
|
void updateState(float elapsedTime);
|
|
|
|
bool isState(unsigned int state,unsigned int bit) const;
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2014-12-18 16:09:29 +08:00
|
|
|
private:
|
2014-12-19 09:05:53 +08:00
|
|
|
cocos2d::Camera * _camera;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Vec3 _targetPos;
|
2014-12-19 09:05:53 +08:00
|
|
|
unsigned int _curState;
|
2014-12-18 16:09:29 +08:00
|
|
|
cocos2d::Sprite3D * _plane;
|
|
|
|
cocos2d::Sprite3D * _orc;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::GLProgramState * _state;
|
2014-12-30 11:48:39 +08:00
|
|
|
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
2014-12-30 11:48:39 +08:00
|
|
|
#endif
|
2014-12-17 13:31:35 +08:00
|
|
|
};
|
|
|
|
|
2014-12-18 16:09:29 +08:00
|
|
|
class Sprite3DLightMapTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DLightMapTest);
|
|
|
|
Sprite3DLightMapTest();
|
2014-12-30 11:48:39 +08:00
|
|
|
virtual ~Sprite3DLightMapTest();
|
2014-12-18 16:09:29 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2015-04-03 14:31:03 +08:00
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2014-12-18 16:09:29 +08:00
|
|
|
private:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Camera * _camera;
|
2014-12-18 16:09:29 +08:00
|
|
|
};
|
2014-12-19 17:39:26 +08:00
|
|
|
|
2014-12-17 13:31:35 +08:00
|
|
|
class Sprite3DBasicToonShaderTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DBasicToonShaderTest);
|
|
|
|
Sprite3DBasicToonShaderTest();
|
2014-12-30 11:48:39 +08:00
|
|
|
virtual ~Sprite3DBasicToonShaderTest();
|
2014-12-17 13:31:35 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-12-30 11:48:39 +08:00
|
|
|
|
|
|
|
protected:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::GLProgramState * _state;
|
2014-12-30 11:48:39 +08:00
|
|
|
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
2014-12-30 11:48:39 +08:00
|
|
|
#endif
|
2014-12-18 16:09:29 +08:00
|
|
|
|
2014-12-17 13:31:35 +08:00
|
|
|
};
|
2014-05-19 05:49:16 +08:00
|
|
|
|
2014-07-29 10:49:06 +08:00
|
|
|
class Sprite3DHitTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DHitTest);
|
|
|
|
Sprite3DHitTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2014-05-19 05:49:16 +08:00
|
|
|
class Sprite3DEffectTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DEffectTest);
|
|
|
|
Sprite3DEffectTest();
|
2015-09-08 14:13:53 +08:00
|
|
|
virtual ~Sprite3DEffectTest();
|
2014-05-19 05:49:16 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-05-19 05:49:16 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2015-09-08 14:13:53 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<cocos2d::Sprite3D*> _sprites;
|
|
|
|
|
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
|
|
|
#endif
|
2014-05-19 05:49:16 +08:00
|
|
|
};
|
|
|
|
|
2014-12-05 15:01:30 +08:00
|
|
|
class AsyncLoadSprite3DTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(AsyncLoadSprite3DTest);
|
|
|
|
AsyncLoadSprite3DTest();
|
2014-12-19 10:22:42 +08:00
|
|
|
virtual ~AsyncLoadSprite3DTest();
|
2014-12-05 15:01:30 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void menuCallback_asyncLoadSprite(cocos2d::Ref* sender);
|
2014-12-05 15:01:30 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void asyncLoad_Callback(cocos2d::Sprite3D* sprite, void* param);
|
2014-12-05 15:01:30 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<std::string> _paths; //model paths to be loaded
|
|
|
|
};
|
|
|
|
|
2014-06-06 19:12:08 +08:00
|
|
|
class Sprite3DWithSkinTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DWithSkinTest);
|
|
|
|
Sprite3DWithSkinTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-06-06 19:12:08 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void switchAnimationQualityCallback(cocos2d::Ref* sender);
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2015-07-09 17:54:21 +08:00
|
|
|
|
|
|
|
std::string getAnimationQualityMessage() const;
|
2015-03-30 17:08:49 +08:00
|
|
|
private:
|
2015-04-09 08:37:30 +08:00
|
|
|
std::vector<cocos2d::Sprite3D*> _sprits;
|
2015-04-24 11:49:28 +08:00
|
|
|
int _animateQuality;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::MenuItemFont* _menuItem;
|
2014-06-06 19:12:08 +08:00
|
|
|
};
|
|
|
|
|
2014-08-08 18:01:36 +08:00
|
|
|
class Sprite3DWithSkinOutlineTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DWithSkinOutlineTest);
|
|
|
|
Sprite3DWithSkinOutlineTest();
|
2015-09-08 14:13:53 +08:00
|
|
|
virtual ~Sprite3DWithSkinOutlineTest();
|
2014-08-08 18:01:36 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-08-08 18:01:36 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2015-09-08 14:13:53 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<cocos2d::Sprite3D*> _sprites;
|
|
|
|
|
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
|
|
|
#endif
|
2014-08-08 18:01:36 +08:00
|
|
|
};
|
|
|
|
|
2014-06-26 18:35:12 +08:00
|
|
|
class Animate3DTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Animate3DTest);
|
|
|
|
Animate3DTest();
|
2014-06-27 16:36:01 +08:00
|
|
|
~Animate3DTest();
|
2014-06-26 18:35:12 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2014-06-27 16:36:01 +08:00
|
|
|
|
|
|
|
virtual void update(float dt) override;
|
|
|
|
|
2014-06-26 18:35:12 +08:00
|
|
|
protected:
|
|
|
|
void addSprite3D();
|
|
|
|
|
2014-06-27 16:36:01 +08:00
|
|
|
enum class State
|
2014-06-26 18:35:12 +08:00
|
|
|
{
|
2014-06-27 16:36:01 +08:00
|
|
|
SWIMMING,
|
|
|
|
SWIMMING_TO_HURT,
|
|
|
|
HURT,
|
|
|
|
HURT_TO_SWIMMING,
|
2014-06-26 18:35:12 +08:00
|
|
|
};
|
|
|
|
|
2014-06-27 16:36:01 +08:00
|
|
|
void reachEndCallBack();
|
|
|
|
|
|
|
|
void renewCallBack();
|
|
|
|
|
2014-06-26 18:35:12 +08:00
|
|
|
cocos2d::Sprite3D* _sprite;
|
2014-06-27 16:36:01 +08:00
|
|
|
|
2014-08-29 18:25:42 +08:00
|
|
|
cocos2d::Action* _swim;
|
2014-06-27 16:36:01 +08:00
|
|
|
cocos2d::Animate3D* _hurt;
|
2014-08-29 18:25:42 +08:00
|
|
|
|
2014-06-27 16:36:01 +08:00
|
|
|
float _elapseTransTime;
|
|
|
|
|
|
|
|
State _state;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::MoveTo* _moveAction;
|
2014-06-26 18:35:12 +08:00
|
|
|
};
|
|
|
|
|
2014-07-29 10:49:06 +08:00
|
|
|
class AttachmentTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(AttachmentTest);
|
|
|
|
AttachmentTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2014-07-29 10:49:06 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-07-29 10:49:06 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _hasWeapon;
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
};
|
|
|
|
|
2014-08-19 15:25:00 +08:00
|
|
|
class Sprite3DReskinTest : public Sprite3DTestDemo
|
2014-08-19 14:03:41 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-08-19 15:25:00 +08:00
|
|
|
CREATE_FUNC(Sprite3DReskinTest);
|
|
|
|
Sprite3DReskinTest();
|
2014-08-19 14:03:41 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-11-19 16:50:09 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void menuCallback_reSkin(cocos2d::Ref* sender);
|
2014-08-19 14:03:41 +08:00
|
|
|
protected:
|
2014-10-25 14:11:32 +08:00
|
|
|
void applyCurSkin();
|
|
|
|
|
|
|
|
enum class SkinType
|
|
|
|
{
|
|
|
|
UPPER_BODY = 0,
|
|
|
|
PANTS,
|
|
|
|
SHOES,
|
|
|
|
HAIR,
|
|
|
|
FACE,
|
|
|
|
HAND,
|
|
|
|
GLASSES,
|
2014-11-19 16:50:09 +08:00
|
|
|
MAX_TYPE,
|
2014-10-25 14:11:32 +08:00
|
|
|
};
|
2014-11-19 16:50:09 +08:00
|
|
|
|
|
|
|
std::vector<std::string> _skins[(int)SkinType::MAX_TYPE]; //all skins
|
|
|
|
int _curSkin[(int)SkinType::MAX_TYPE]; //current skin index
|
2014-08-19 14:03:41 +08:00
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
};
|
2015-01-13 18:00:20 +08:00
|
|
|
class Sprite3DWithOBBPerformanceTest : public Sprite3DTestDemo
|
2014-08-08 11:16:33 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-01-13 18:00:20 +08:00
|
|
|
CREATE_FUNC(Sprite3DWithOBBPerformanceTest);
|
|
|
|
Sprite3DWithOBBPerformanceTest();
|
2014-08-08 11:16:33 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void update(float dt) override;
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewOBBWithCoords(cocos2d::Vec2 p);
|
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
|
|
|
void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void addOBBCallback(cocos2d::Ref* sender);
|
|
|
|
void delOBBCallback(cocos2d::Ref* sender);
|
2014-08-08 11:16:33 +08:00
|
|
|
void addOBBWithCount(float value);
|
|
|
|
void delOBBWithCount(float value);
|
|
|
|
protected:
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
2015-04-09 08:37:30 +08:00
|
|
|
std::vector<cocos2d::OBB> _obb;
|
|
|
|
cocos2d::DrawNode3D* _drawOBB;
|
|
|
|
cocos2d::Label* _labelCubeCount;
|
|
|
|
cocos2d::MoveTo* _moveAction;
|
|
|
|
cocos2d::OBB _obbt;
|
2015-10-14 13:43:02 +08:00
|
|
|
cocos2d::OBB _obbtOri; //tortoise origin obb
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::DrawNode3D* _drawDebug;
|
2014-08-08 11:16:33 +08:00
|
|
|
bool _hasCollider;
|
|
|
|
std::set<int> _intersetList;
|
|
|
|
void initDrawBox();
|
|
|
|
void reachEndCallBack();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void unproject(const cocos2d::Mat4& viewProjection, const cocos2d::Size* viewport, cocos2d::Vec3* src, cocos2d::Vec3* dst);
|
|
|
|
void calculateRayByLocationInView(cocos2d::Ray* ray, const cocos2d::Vec2& location);
|
2014-08-08 11:16:33 +08:00
|
|
|
};
|
|
|
|
|
2014-08-13 17:38:16 +08:00
|
|
|
class Sprite3DMirrorTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DMirrorTest);
|
|
|
|
Sprite3DMirrorTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-08-13 17:38:16 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _hasWeapon;
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
cocos2d::Sprite3D* _mirrorSprite;
|
|
|
|
};
|
|
|
|
|
2014-12-29 14:36:25 +08:00
|
|
|
class QuaternionTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(QuaternionTest);
|
|
|
|
QuaternionTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2014-12-29 14:36:25 +08:00
|
|
|
virtual void update(float delta) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
float _arcSpeed;
|
|
|
|
float _radius;
|
|
|
|
float _accAngle;
|
|
|
|
};
|
|
|
|
|
2015-01-27 15:24:15 +08:00
|
|
|
// 3d + 2d use case
|
2015-01-23 18:24:15 +08:00
|
|
|
class UseCaseSprite3D : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(UseCaseSprite3D);
|
|
|
|
UseCaseSprite3D();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-01-26 14:58:16 +08:00
|
|
|
virtual void update(float delta) override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void menuCallback_Message(cocos2d::Ref* sender);
|
2015-01-27 15:24:15 +08:00
|
|
|
|
2015-01-23 18:24:15 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void switchCase();
|
|
|
|
|
|
|
|
enum class USECASE{
|
|
|
|
_3D_WITH_2D,
|
2015-01-26 18:44:30 +08:00
|
|
|
_UI_3D_UI,
|
2015-01-23 18:24:15 +08:00
|
|
|
MAX_CASE_NUM,
|
|
|
|
};
|
2015-01-26 15:03:01 +08:00
|
|
|
cocos2d::Label* _label;
|
|
|
|
int _caseIdx; // use case index
|
|
|
|
std::string _useCaseTitles[(int)USECASE::MAX_CASE_NUM];
|
2015-01-23 18:24:15 +08:00
|
|
|
};
|
|
|
|
|
2015-03-26 10:20:28 +08:00
|
|
|
// node animation test, cocos2d-x supports both skeletal animation and node animation
|
2015-04-09 12:23:47 +08:00
|
|
|
class NodeAnimationTest : public Sprite3DTestDemo
|
2014-05-19 05:49:16 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-26 10:20:28 +08:00
|
|
|
CREATE_FUNC(NodeAnimationTest);
|
|
|
|
NodeAnimationTest();
|
2015-03-26 09:12:05 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2 p);
|
2015-03-26 09:12:05 +08:00
|
|
|
protected:
|
2015-04-09 08:37:30 +08:00
|
|
|
std::vector<cocos2d::Sprite3D*> _sprites;
|
2015-03-26 09:12:05 +08:00
|
|
|
int _vectorIndex;
|
2014-05-19 05:49:16 +08:00
|
|
|
};
|
|
|
|
|
2015-01-29 09:28:14 +08:00
|
|
|
namespace cocos2d
|
|
|
|
{
|
2015-03-24 15:43:59 +08:00
|
|
|
class TextureCube;
|
|
|
|
class Skybox;
|
2015-01-29 09:28:14 +08:00
|
|
|
}
|
|
|
|
class Sprite3DCubeMapTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DCubeMapTest);
|
|
|
|
Sprite3DCubeMapTest();
|
|
|
|
~Sprite3DCubeMapTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteWithCoords(cocos2d::Vec2);
|
2015-01-29 09:28:14 +08:00
|
|
|
|
2015-04-14 13:56:05 +08:00
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2015-04-14 01:39:23 +08:00
|
|
|
|
2015-01-29 09:28:14 +08:00
|
|
|
protected:
|
2015-04-14 01:39:23 +08:00
|
|
|
cocos2d::TextureCube* _textureCube;
|
2015-04-14 13:56:05 +08:00
|
|
|
cocos2d::Skybox* _skyBox;
|
|
|
|
cocos2d::Sprite3D* _teapot;
|
2015-04-14 01:39:23 +08:00
|
|
|
cocos2d::Camera *_camera;
|
2015-03-24 15:43:59 +08:00
|
|
|
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
2015-03-24 15:43:59 +08:00
|
|
|
#endif
|
2015-01-29 09:28:14 +08:00
|
|
|
};
|
|
|
|
|
2015-05-13 16:16:45 +08:00
|
|
|
/// issue 9767 setGLProgram
|
|
|
|
class Issue9767 : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
enum class ShaderType
|
|
|
|
{
|
|
|
|
SHADER_TEX,
|
|
|
|
SHADER_COLOR,
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue9767);
|
|
|
|
Issue9767();
|
|
|
|
~Issue9767();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
void menuCallback_SwitchShader(cocos2d::Ref* sender);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ShaderType _shaderType;
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
};
|
|
|
|
|
2015-07-01 14:48:37 +08:00
|
|
|
/// Clipping Sprite3D
|
|
|
|
class Sprite3DClippingTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DClippingTest);
|
|
|
|
Sprite3DClippingTest();
|
|
|
|
~Sprite3DClippingTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2015-07-15 11:13:27 +08:00
|
|
|
class Animate3DCallbackTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Animate3DCallbackTest);
|
|
|
|
Animate3DCallbackTest();
|
|
|
|
~Animate3DCallbackTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2015-07-17 11:08:27 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
cocos2d::Sprite3D* _sprite3d;
|
2015-07-15 11:13:27 +08:00
|
|
|
};
|
|
|
|
|
2015-07-12 11:33:22 +08:00
|
|
|
class Sprite3DTestMeshLight : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DTestMeshLight);
|
|
|
|
Sprite3DTestMeshLight();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
};
|
|
|
|
|
2015-08-21 10:27:19 +08:00
|
|
|
class CameraBackgroundClearTest : public Sprite3DTestDemo
|
2015-08-20 16:19:57 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-08-21 10:27:19 +08:00
|
|
|
CREATE_FUNC(CameraBackgroundClearTest);
|
|
|
|
CameraBackgroundClearTest();
|
2015-08-20 16:19:57 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
void switch_CameraClearMode(cocos2d::Ref* sender);
|
|
|
|
protected:
|
|
|
|
cocos2d::Camera* _camera;
|
|
|
|
cocos2d::Label* _label;
|
|
|
|
};
|
|
|
|
|
2015-09-02 16:30:24 +08:00
|
|
|
class Sprite3DVertexColorTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DVertexColorTest);
|
|
|
|
Sprite3DVertexColorTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2015-09-07 14:45:09 +08:00
|
|
|
|
2015-09-08 10:53:36 +08:00
|
|
|
virtual ~Sprite3DVertexColorTest();
|
2015-09-02 16:30:24 +08:00
|
|
|
protected:
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
2015-09-08 10:53:36 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
cocos2d::EventListenerCustom* _backToForegroundListener;
|
|
|
|
#endif
|
2015-09-02 16:30:24 +08:00
|
|
|
};
|
|
|
|
|
2015-09-01 10:39:31 +08:00
|
|
|
class MotionStreak3DTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(MotionStreak3DTest);
|
|
|
|
MotionStreak3DTest();
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void update(float delta) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cocos2d::Sprite3D* _sprite;
|
|
|
|
cocos2d::MotionStreak3D* _streak;
|
|
|
|
};
|
2015-09-18 14:08:33 +08:00
|
|
|
|
2014-05-19 05:49:16 +08:00
|
|
|
#endif
|