| 65 | |
| 66 | |
| 67 | void TutorialApplication::setup() |
| 68 | { |
| 69 | // do not forget to call the base first |
| 70 | ApplicationContext::setup(); |
| 71 | addInputListener(this); |
| 72 | |
| 73 | // get a pointer to the already created root |
| 74 | Root* root = getRoot(); |
| 75 | SceneManager* scnMgr = root->createSceneManager(); |
| 76 | |
| 77 | // register our scene with the RTSS |
| 78 | RTShader::ShaderGenerator* shadergen = RTShader::ShaderGenerator::getSingletonPtr(); |
| 79 | shadergen->addSceneManager(scnMgr); |
| 80 | |
| 81 | // -- tutorial section start -- |
| 82 | //! [cameracreate] |
| 83 | SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode(); |
| 84 | Camera* cam = scnMgr->createCamera("myCam"); |
| 85 | //! [cameracreate] |
| 86 | |
| 87 | //! [cameraposition] |
| 88 | camNode->setPosition(200, 300, 400); |
| 89 | camNode->lookAt(Vector3(0, 0, 0), Node::TransformSpace::TS_WORLD); |
| 90 | //! [cameraposition] |
| 91 | |
| 92 | //! [cameralaststep] |
| 93 | cam->setNearClipDistance(5); |
| 94 | camNode->attachObject(cam); |
| 95 | //! [cameralaststep] |
| 96 | |
| 97 | //! [addviewport] |
| 98 | Viewport* vp = getRenderWindow()->addViewport(cam); |
| 99 | //! [addviewport] |
| 100 | |
| 101 | //! [viewportback] |
| 102 | vp->setBackgroundColour(ColourValue(0, 0, 0)); |
| 103 | //! [viewportback] |
| 104 | |
| 105 | //! [cameraratio] |
| 106 | cam->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight())); |
| 107 | //! [cameraratio] |
| 108 | |
| 109 | //! [lightingsset] |
| 110 | scnMgr->setAmbientLight(ColourValue(0, 0, 0)); |
| 111 | scnMgr->setShadowTechnique(ShadowTechnique::SHADOWTYPE_STENCIL_ADDITIVE); |
| 112 | //! [lightingsset] |
| 113 | |
| 114 | //! [ninja] |
| 115 | Entity* ninjaEntity = scnMgr->createEntity("ninja.mesh"); |
| 116 | ninjaEntity->setCastShadows(true); |
| 117 | |
| 118 | scnMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ninjaEntity); |
| 119 | //! [ninja] |
| 120 | |
| 121 | //! [plane] |
| 122 | Plane plane(Vector3::UNIT_Y, 0); |
| 123 | //! [plane] |
| 124 |
nothing calls this directly
no test coverage detected