| 248 | } |
| 249 | |
| 250 | bool Scene3DTestScene::init() |
| 251 | { |
| 252 | bool ret = false; |
| 253 | do |
| 254 | { |
| 255 | AX_BREAK_IF(false == TestCase::init()); |
| 256 | |
| 257 | // prepare for camera creation, we need several custom cameras |
| 258 | _gameCameras.resize(CAMERA_COUNT); |
| 259 | auto visibleSize = Director::getInstance()->getVisibleSize(); |
| 260 | Camera* ca = nullptr; // temp variable |
| 261 | |
| 262 | //////////////////////////////////////////////////////////////////////// |
| 263 | // create world 3D scene, this scene has two camera |
| 264 | _worldScene = Node::create(); |
| 265 | // create a camera to look the skybox |
| 266 | ca = _gameCameras[CAMERA_WORLD_3D_SKYBOX] = |
| 267 | Camera::createPerspective(60, visibleSize.width / visibleSize.height, 10, 1000); |
| 268 | ca->setDepth(CAMERA_WORLD_3D_SKYBOX); |
| 269 | ca->setName(s_CameraNames[CAMERA_WORLD_3D_SKYBOX]); |
| 270 | ca->setCameraFlag(s_CF[LAYER_BACKGROUND]); |
| 271 | ca->setPosition3D(Vec3(0.f, 0.f, 50.f)); |
| 272 | _worldScene->addChild(ca); |
| 273 | // create a camera to look the 3D models in world 3D scene |
| 274 | ca = _gameCameras[CAMERA_WORLD_3D_SCENE] = |
| 275 | Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200); |
| 276 | ca->setDepth(CAMERA_WORLD_3D_SCENE); |
| 277 | ca->setName(s_CameraNames[CAMERA_WORLD_3D_SCENE]); |
| 278 | _worldScene->addChild(ca); |
| 279 | // create 3D objects and add to world scene |
| 280 | createWorld3D(); |
| 281 | _worldScene->addChild(_skyBox); |
| 282 | _worldScene->addChild(_terrain); |
| 283 | _worldScene->addChild(_player); |
| 284 | _worldScene->addChild(_monsters[0]); |
| 285 | _worldScene->addChild(_monsters[1]); |
| 286 | // move camera above player |
| 287 | ca->setPosition3D(_player->getPosition3D() + Vec3(0, 45, 60)); |
| 288 | ca->setRotation3D(Vec3(-45, 0, 0)); |
| 289 | _worldScene->setPosition3D(s_scenePositons[SCENE_WORLD]); |
| 290 | this->addChild(_worldScene); |
| 291 | |
| 292 | //////////////////////////////////////////////////////////////////////// |
| 293 | // test scene is UI scene, use default camera |
| 294 | // use the default camera to look 2D base UI layer |
| 295 | ca = _gameCameras[CAMERA_UI_2D] = this->getDefaultCamera(); |
| 296 | ca->setDepth(CAMERA_UI_2D); |
| 297 | ca->setName(s_CameraNames[CAMERA_UI_2D]); |
| 298 | // create UI element and add to ui scene |
| 299 | createUI(); |
| 300 | this->addChild(_ui); |
| 301 | |
| 302 | //////////////////////////////////////////////////////////////////////// |
| 303 | // create dialog scene, this scene has two dialog and three cameras |
| 304 | _dlgScene = Node::create(); |
| 305 | // use default camera to render the base 2D elements |
| 306 | ca = _gameCameras[CAMERA_DIALOG_2D_BASE] = Camera::create(); |
| 307 | ca->setDepth(CAMERA_DIALOG_2D_BASE); |
nothing calls this directly
no test coverage detected