Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/main_reto/src/orxonox_scene.cc @ 146

Last change on this file since 146 was 146, checked in by rgrieder, 16 years ago
File size: 3.0 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software: you can redistribute it and/or modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 *   Author:
22 *      Reto Grieder
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "orxonox_scene.h"
29
30
31OrxonoxScene::OrxonoxScene(SceneManager *mSceneMgr) : mSceneMgr(mSceneMgr)
32{
33}
34
35
36OrxonoxScene::~OrxonoxScene()
37{
38}
39
40
41bool OrxonoxScene::initialise()
42{
43        // Load resources
44        loadResources();
45
46        distance = 0;
47        radius = 100;
48
49        createScene();
50
51        return true;
52}
53
54
55// method where you can perform resource group loading
56// Must at least do
57// ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
58void OrxonoxScene::loadResources(void)
59{
60        // Initialise, parse scripts etc
61        ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
62}
63
64
65// Currently just a test scene with an ogre head an a surrounding light
66void OrxonoxScene::createScene(void)
67{
68        mSceneMgr->setAmbientLight(ColourValue(0.3,0.3,0.3));
69
70        //create first entity
71        Entity *head = mSceneMgr->createEntity("head", "ogrehead.mesh");
72
73        //create a scene node to attach the head to
74        SceneNode *node = mSceneMgr->getRootSceneNode()
75        ->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
76        //attach the ogre head
77        node->attachObject(head);
78
79        // set up skybox
80        mSceneMgr->setSkyBox(true, "Examples/SceneSkyBox2");
81
82        // set up one mLight source
83        mLight = mSceneMgr->createLight("Light1");
84        mLight->setType(Light::LT_POINT);
85        mLight->setPosition(Vector3(0, 0, 0));
86        mLight->setDiffuseColour(1.0, 1.0, 1.0);
87        mLight->setSpecularColour(1.0, 1.0, 1.0);
88
89        //create billboard
90        bbs = mSceneMgr->createBillboardSet("bb", 1);
91        bbs->createBillboard(Vector3::ZERO, ColourValue(1.0, 1.0, 1.0));
92        bbs->setMaterialName("Examples/Flare");
93
94        lightNode = mSceneMgr->getRootSceneNode()
95        ->createChildSceneNode("LightNode", Vector3(0, 100, 0));
96
97        lightNode->attachObject(bbs);
98        lightNode->attachObject(mLight);
99}
100
101
102// compute something between frames if neccessary
103void OrxonoxScene::tick(unsigned long time, float deltaTime)
104{
105        float t = time/1000.0;
106
107        lightNode->setPosition(radius*sin(5*t), radius*cos(5*t), sin(1*t)*distance);
108       
109        mLight->setDiffuseColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));
110        mLight->setSpecularColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));
111
112        bbs->getBillboard(0)->setColour(ColourValue(sin(1*t),
113        sin(1*t + 2.09), sin(1*t + 2.09*2)));
114}
Note: See TracBrowser for help on using the repository browser.