Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox/src/Universe.cpp @ 2145

Last change on this file since 2145 was 484, checked in by gabrieho, 17 years ago

lala

File size: 3.7 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 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29 @file  orxonox.cc
30 @brief Orxonox Main File
31 */
32
33#include <Ogre.h>
34#include <OIS/OIS.h>
35//#include <CEGUI/CEGUI.h>
36//#include <OgreCEGUIRenderer.h>
37
38#include <string>
39#include <iostream>
40#include <ctime>
41#include <cstdlib>
42#include "Universe.h"
43
44#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
45#include <CoreFoundation/CoreFoundation.h>
46#include "windows.h"
47
48
49// This function will locate the path to our application on OS X,
50// unlike windows you can not rely on the curent working directory
51// for locating your configuration files and resources.
52std::string macBundlePath()
53{
54  char path[1024];
55  CFBundleRef mainBundle = CFBundleGetMainBundle();
56  assert(mainBundle);
57
58  CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
59  assert(mainBundleURL);
60
61  CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
62  assert(cfStringRef);
63
64  CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
65
66  CFRelease(mainBundleURL);
67  CFRelease(cfStringRef);
68
69  return std::string(path);
70}
71#endif
72
73
74// Wir brauchen beliebig viele koordinaten fuer das Licht => Billboards haben gleiche Koordinaten Ogre::Vector3
75
76Universe::Universe(int number){
77        this->numberOfStars = number;
78}
79
80
81void Universe::createCoordinates()
82                        {
83                                int x, y, z;
84                                unsigned int bigsum;
85                                for(int u = 0; u < numberOfStars; u++){
86                                do{
87                                        x = (rand() % 100000) - 50000;
88                                        y = (rand() % 100000) - 50000;
89                                        z = (rand() % 100000) - 50000;
90                                        bigsum = x*x + y*y + z*z;
91
92                                 }while(bigsum < 6000*6000 or bigsum > 50000*50000);
93                                lightcoordinates[u][0] = x;
94                                lightcoordinates[u][1] = y;
95                                lightcoordinates[u][2] = z;
96                               
97                                                                        }
98}
99
100
101        void Universe::createBillboards(Ogre::SceneManager *mgrtemp, Ogre::Camera * camtemp, Ogre::Root *mRoottemp)
102        {       // wir haben viele coordinates, die wir gebrauchen koennen
103
104        char lightnames[30];
105        char lightnodenames[30];
106        char billboardnames[30];
107        char flarenames[30];
108
109
110        for(unsigned int x = 0; x < numberOfStars; x++){
111                sprintf(lightnames, "lights_%d", x);
112                sprintf(lightnodenames, "lightnodes_%d", x);
113                sprintf(billboardnames, "billboards_%d", x);
114                sprintf(flarenames, "Flare%d", x%2);
115       
116
117                /*Ogre::Light *light = mgrtemp->createLight(lightnames);
118                light->setType(Ogre::Light::LT_POINT);
119                light->setPosition(Ogre::Vector3(0, 0, 0));
120
121                light->setDiffuseColour(1.0, 0.0, 0.0);
122                light->setSpecularColour(1.0, 0.0, 0.0);
123                */
124                Ogre::BillboardSet *bbs = mgrtemp->createBillboardSet(billboardnames, 1);
125                bbs->createBillboard(Ogre::Vector3::ZERO, Ogre::ColourValue(1.0, 1.0, 1.0));
126                bbs->setMaterialName(flarenames);
127
128                Ogre::SceneNode *myNode;
129                myNode = mgrtemp->getRootSceneNode()->createChildSceneNode(lightnodenames, Ogre::Vector3(lightcoordinates[x][0],lightcoordinates[x][1],lightcoordinates[x][2]));
130                myNode->attachObject(bbs);
131                //myNode->attachObject(light);
132                //light->setPosition(0.0, 0.0, 0.0);
133                }
134
135        }
136
137
138
139
Note: See TracBrowser for help on using the repository browser.