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

Method setup

Samples/Tutorials/BasicTutorial1.cpp:59–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58
59void BasicTutorial1::setup()
60{
61 // do not forget to call the base first
62 ApplicationContext::setup();
63 addInputListener(this);
64
65 // get a pointer to the already created root
66 Root* root = getRoot();
67 SceneManager* scnMgr = root->createSceneManager();
68
69 // register our scene with the RTSS
70 RTShader::ShaderGenerator* shadergen = RTShader::ShaderGenerator::getSingletonPtr();
71 shadergen->addSceneManager(scnMgr);
72
73 // -- tutorial section start --
74 //! [turnlights]
75 scnMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
76 //! [turnlights]
77
78 //! [newlight]
79 Light* light = scnMgr->createLight("MainLight");
80 SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode();
81 lightNode->attachObject(light);
82 //! [newlight]
83
84 //! [lightpos]
85 lightNode->setPosition(20, 80, 50);
86 //! [lightpos]
87
88 //! [camera]
89 SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode();
90
91 // create the camera
92 Camera* cam = scnMgr->createCamera("myCam");
93 cam->setNearClipDistance(5); // specific to this sample
94 cam->setAutoAspectRatio(true);
95 camNode->attachObject(cam);
96 camNode->setPosition(0, 0, 140);
97
98 // and tell it to render into the main window
99 getRenderWindow()->addViewport(cam);
100 //! [camera]
101
102 //! [entity1]
103 Entity* ogreEntity = scnMgr->createEntity("ogrehead.mesh");
104 //! [entity1]
105
106 //! [entity1node]
107 SceneNode* ogreNode = scnMgr->getRootSceneNode()->createChildSceneNode();
108 //! [entity1node]
109
110 //! [entity1nodeattach]
111 ogreNode->attachObject(ogreEntity);
112 //! [entity1nodeattach]
113
114 //! [cameramove]
115 camNode->setPosition(0, 47, 222);
116 //! [cameramove]

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected