2015-02-19 16:18:54 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CocosStudio3DTest.h"
|
|
|
|
#include "cocostudio/CocoStudio.h"
|
|
|
|
|
2015-04-09 12:23:47 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
|
2015-02-19 16:18:54 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IDC_NEXT = 100,
|
|
|
|
IDC_BACK,
|
|
|
|
IDC_RESTART
|
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
CocosStudio3DTests::CocosStudio3DTests()
|
2015-02-19 16:18:54 +08:00
|
|
|
{
|
2015-04-03 14:31:03 +08:00
|
|
|
ADD_TEST_CASE(CSNode3DTest);
|
|
|
|
ADD_TEST_CASE(CSSprite3DTest);
|
|
|
|
ADD_TEST_CASE(CSUserCameraTest);
|
|
|
|
ADD_TEST_CASE(CSParticle3DTest);
|
2015-02-19 16:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// CocosStudio3DTestDemo
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
CocosStudio3DTestDemo::CocosStudio3DTestDemo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CocosStudio3DTestDemo::~CocosStudio3DTestDemo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CocosStudio3DTestDemo::title() const
|
|
|
|
{
|
|
|
|
return "No title";
|
|
|
|
}
|
|
|
|
|
2015-03-31 11:22:34 +08:00
|
|
|
void CocosStudio3DTestDemo::onExit()
|
|
|
|
{
|
2015-03-31 19:55:56 +08:00
|
|
|
cocostudio::destroyCocosStudio();
|
2015-04-03 14:31:03 +08:00
|
|
|
TestCase::onExit();
|
2015-02-19 16:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// CSNode3DTestTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
CSNode3DTest::CSNode3DTest()
|
|
|
|
{
|
2015-02-25 15:49:04 +08:00
|
|
|
auto node = CSLoader::createNode("ccs-res/CocosStudio3DTest/Node3D.csb");
|
2015-02-19 16:18:54 +08:00
|
|
|
|
2015-06-24 14:58:14 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
|
|
|
auto label = Label::create();
|
|
|
|
label->setString(std::string("Function demo, no content to show"));
|
|
|
|
label->setPosition(size.width / 2, size.height / 2);
|
|
|
|
label->setTextColor(Color4B::ORANGE);
|
|
|
|
node->addChild(label);
|
|
|
|
|
2015-02-19 16:18:54 +08:00
|
|
|
addChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSNode3DTest::title() const
|
|
|
|
{
|
2015-02-23 00:34:30 +08:00
|
|
|
return "Node3DReader Test";
|
2015-02-19 16:18:54 +08:00
|
|
|
}
|
|
|
|
|
2015-02-23 00:34:30 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// CSSprite3DTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
CSSprite3DTest::CSSprite3DTest()
|
|
|
|
{
|
2015-02-25 15:49:04 +08:00
|
|
|
auto node = CSLoader::createNode("ccs-res/CocosStudio3DTest/Sprite3D.csb");
|
2015-02-23 00:34:30 +08:00
|
|
|
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
|
|
|
auto sprite3D = node->getChildByTag(8);
|
|
|
|
|
|
|
|
sprite3D->setPosition(size.width / 2, size.height / 2 - 50);
|
|
|
|
sprite3D->setColor(Color3B::WHITE);
|
|
|
|
sprite3D->setOpacity(255);
|
|
|
|
|
|
|
|
addChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSSprite3DTest::title() const
|
|
|
|
{
|
|
|
|
return "Sprite3DReader Test";
|
|
|
|
}
|
|
|
|
|
2015-02-25 14:19:08 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// CSUserCameraTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
CSUserCameraTest::CSUserCameraTest()
|
|
|
|
{
|
2015-02-25 15:49:04 +08:00
|
|
|
auto node = CSLoader::createNode("ccs-res/CocosStudio3DTest/UserCamera.csb");
|
2015-02-25 14:19:08 +08:00
|
|
|
|
2015-02-25 15:49:04 +08:00
|
|
|
auto sprite3D = Sprite3D::create("ccs-res/CocosStudio3DTest/dragon/dragon.c3b");
|
2015-02-25 14:19:08 +08:00
|
|
|
sprite3D->setPosition3D(Vec3(100, 95, 80));
|
|
|
|
sprite3D->setCameraMask((unsigned int)CameraFlag::USER1);
|
|
|
|
|
|
|
|
addChild(node);
|
|
|
|
addChild(sprite3D);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSUserCameraTest::title() const
|
|
|
|
{
|
|
|
|
return "UserCameraReader Test";
|
|
|
|
}
|
|
|
|
|
2015-02-26 09:19:14 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// CSParticle3DTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
CSParticle3DTest::CSParticle3DTest()
|
|
|
|
{
|
|
|
|
auto node = CSLoader::createNode("ccs-res/CocosStudio3DTest/Particle3D.csb");
|
|
|
|
|
|
|
|
addChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSParticle3DTest::title() const
|
|
|
|
{
|
|
|
|
return "Particle3DReader Test";
|
|
|
|
}
|