MCPcopy Create free account
hub / github.com/OGRECave/ogre / setup

Method setup

Samples/Tutorials/BasicTutorial2.cpp:67–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67void 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

Callers

nothing calls this directly

Calls 15

setupFunction · 0.85
addInputListenerFunction · 0.85
getRootFunction · 0.85
Vector3Class · 0.85
getRenderWindowFunction · 0.85
addSceneManagerMethod · 0.80
getRootSceneNodeMethod · 0.80
setNearClipDistanceMethod · 0.80
attachObjectMethod · 0.80
addViewportMethod · 0.80
setAspectRatioMethod · 0.80
createEntityMethod · 0.80

Tested by

no test coverage detected