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;
|
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-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
|
|
|
class EffectSprite3D;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
class Effect3D : public cocos2d::Ref
|
2014-05-19 05:49:16 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(const cocos2d::Mat4 &transform) = 0;
|
2014-05-27 14:50:46 +08:00
|
|
|
virtual void setTarget(EffectSprite3D *sprite) = 0;
|
2014-05-19 05:49:16 +08:00
|
|
|
protected:
|
|
|
|
Effect3D() : _glProgramState(nullptr) {}
|
|
|
|
virtual ~Effect3D()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(_glProgramState);
|
|
|
|
}
|
|
|
|
protected:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::GLProgramState* _glProgramState;
|
2014-05-19 05:49:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class Effect3DOutline: public Effect3D
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Effect3DOutline* create();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void setOutlineColor(const cocos2d::Vec3& color);
|
2014-05-19 05:49:16 +08:00
|
|
|
|
|
|
|
void setOutlineWidth(float width);
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(const cocos2d::Mat4 &transform) override;
|
2014-05-27 14:50:46 +08:00
|
|
|
virtual void setTarget(EffectSprite3D *sprite) override;
|
2014-05-19 05:49:16 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
Effect3DOutline();
|
|
|
|
virtual ~Effect3DOutline();
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Vec3 _outlineColor;
|
2014-05-19 05:49:16 +08:00
|
|
|
float _outlineWidth;
|
2014-07-01 14:48:46 +08:00
|
|
|
//weak reference
|
2014-05-27 14:50:46 +08:00
|
|
|
EffectSprite3D* _sprite;
|
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-05-30 10:56:03 +08:00
|
|
|
#endif
|
2014-05-19 05:49:16 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static const std::string _vertShaderFile;
|
|
|
|
static const std::string _fragShaderFile;
|
|
|
|
static const std::string _keyInGLProgramCache;
|
2014-08-08 18:01:36 +08:00
|
|
|
|
|
|
|
static const std::string _vertSkinnedShaderFile;
|
|
|
|
static const std::string _fragSkinnedShaderFile;
|
|
|
|
static const std::string _keySkinnedInGLProgramCache;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
static cocos2d::GLProgram* getOrCreateProgram(bool isSkinned = false);
|
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;
|
|
|
|
};
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
class EffectSprite3D : public cocos2d::Sprite3D
|
2014-05-19 05:49:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static EffectSprite3D* createFromObjFileAndTexture(const std::string& objFilePath, const std::string& textureFilePath);
|
2014-08-12 09:56:25 +08:00
|
|
|
static EffectSprite3D* create(const std::string& path);
|
|
|
|
|
2014-05-19 05:49:16 +08:00
|
|
|
void setEffect3D(Effect3D* effect);
|
|
|
|
void addEffect(Effect3DOutline* effect, ssize_t order);
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
|
2014-05-19 05:49:16 +08:00
|
|
|
protected:
|
|
|
|
EffectSprite3D();
|
|
|
|
virtual ~EffectSprite3D();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
std::vector<std::tuple<ssize_t,Effect3D*, cocos2d::CustomCommand>> _effects;
|
2014-05-19 05:49:16 +08:00
|
|
|
Effect3D* _defaultEffect;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::CustomCommand _command;
|
2014-05-19 05:49:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class Sprite3DEffectTest : public Sprite3DTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Sprite3DEffectTest);
|
|
|
|
Sprite3DEffectTest();
|
|
|
|
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);
|
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-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();
|
|
|
|
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);
|
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;
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2014-05-19 05:49:16 +08:00
|
|
|
#endif
|