PuzzleSDK
Sprite3DLightMapTest类 参考

#include <Sprite3DTest.h>

+ 类 Sprite3DLightMapTest 继承关系图:
+ Sprite3DLightMapTest 的协作图:

Public 成员函数

 CREATE_FUNC (Sprite3DLightMapTest)
 
 Sprite3DLightMapTest ()
 
virtual ~Sprite3DLightMapTest ()
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
void onTouchesMoved (const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
 
- Public 成员函数 继承自 Sprite3DTestDemo
virtual ~Sprite3DTestDemo ()
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

Private 属性

cocos2d::Camera * _camera
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 Sprite3DTest.h139 行定义.

构造及析构函数说明

◆ Sprite3DLightMapTest()

Sprite3DLightMapTest::Sprite3DLightMapTest ( )

在文件 Sprite3DTest.cpp615 行定义.

616{
617 //the assets are from the OpenVR demo
618 //get the visible size.
619 Size visibleSize = Director::getInstance()->getVisibleSize();
620 _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200);
621 _camera->setCameraFlag(CameraFlag::USER1);
622 _camera->setPosition3D(Vec3(0.0f, 25.0f, 15.0f));
623 _camera->setRotation3D(Vec3(-35.0f, 0.0f, 0.0f));
624 auto LightMapScene = Sprite3D::create("Sprite3DTest/LightMapScene.c3b");
625 LightMapScene->setScale(0.1f);
626 addChild(LightMapScene);
627 addChild(_camera);
628 setCameraMask(2);
629
630 //add a point light
631 auto light = PointLight::create(Vec3(35, 75, -20.5), Color3B(255, 255, 255), 150);
632 addChild(light);
633 //set the ambient light
634 auto ambient = AmbientLight::create(Color3B(55, 55, 55));
635 addChild(ambient);
636
637 //create a listener
638 auto listener = EventListenerTouchAllAtOnce::create();
639 listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DLightMapTest::onTouchesMoved, this);
640 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
641}
cocos2d::Camera * _camera
Definition: Sprite3DTest.h:149
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)

引用了 _camera , 以及 onTouchesMoved().

+ 函数调用图:

◆ ~Sprite3DLightMapTest()

Sprite3DLightMapTest::~Sprite3DLightMapTest ( )
virtual

在文件 Sprite3DTest.cpp642 行定义.

643{
644
645}

成员函数说明

◆ CREATE_FUNC()

Sprite3DLightMapTest::CREATE_FUNC ( Sprite3DLightMapTest  )

◆ onTouchesMoved()

void Sprite3DLightMapTest::onTouchesMoved ( const std::vector< cocos2d::Touch * > &  touches,
cocos2d::Event *  event 
)

在文件 Sprite3DTest.cpp656 行定义.

657{
658 if (touches.size() == 1)
659 {
660 float delta = Director::getInstance()->getDeltaTime();
661 auto touch = touches[0];
662 auto location = touch->getLocation();
663 auto PreviousLocation = touch->getPreviousLocation();
664 Point newPos = PreviousLocation - location;
665
666 Vec3 cameraDir;
667 Vec3 cameraRightDir;
668 _camera->getNodeToWorldTransform().getForwardVector(&cameraDir);
669 cameraDir.normalize();
670 cameraDir.y = 0;
671 _camera->getNodeToWorldTransform().getRightVector(&cameraRightDir);
672 cameraRightDir.normalize();
673 cameraRightDir.y = 0;
674 Vec3 cameraPos = _camera->getPosition3D();
675 cameraPos += cameraDir * newPos.y*delta;
676 cameraPos += cameraRightDir * newPos.x*delta;
677 _camera->setPosition3D(cameraPos);
678 }
679}

引用了 _camera.

被这些函数引用 Sprite3DLightMapTest().

+ 这是这个函数的调用关系图:

◆ subtitle()

std::string Sprite3DLightMapTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 Sprite3DTest.cpp651 行定义.

652{
653 return "drag the screen to move around";
654}

◆ title()

std::string Sprite3DLightMapTest::title ( ) const
overridevirtual

重载 Sprite3DTestDemo .

在文件 Sprite3DTest.cpp646 行定义.

647{
648 return "light map test";
649}

类成员变量说明

◆ _camera

cocos2d::Camera* Sprite3DLightMapTest::_camera
private

在文件 Sprite3DTest.h149 行定义.

被这些函数引用 onTouchesMoved() , 以及 Sprite3DLightMapTest().


该类的文档由以下文件生成: