Changeset 2101 in orxonox.OLD for orxonox/branches/chris
- Timestamp:
- Jul 10, 2004, 2:00:04 PM (20 years ago)
- Location:
- orxonox/branches/chris/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/orxonox.cc
r2096 r2101 24 24 */ 25 25 26 #ifdef __WIN32__ 27 #include <windows.h> 28 #endif 29 30 #include <iostream> 31 #include <cstdio> 32 #include <GL/glut.h> 33 #include <SDL/SDL.h> 34 35 #include "environment.h" 26 #include "orxonox.h" 36 27 #include "world.h" 37 #include " input_output.h"28 #include "camera.h" 38 29 #include "data_tank.h" 39 #include "stdincl.h" 40 #include "player.h" 41 #include "npc.h" 42 #include "shoot_laser.h" 43 44 #include "orxonox.h" 30 #include "command_node.h" 45 31 46 32 using namespace std; 47 48 33 49 34 Orxonox::Orxonox () … … 59 44 if( world != NULL) delete world; 60 45 if( localinput != NULL) delete world; 61 if( localcamera != NULL) delete camera;46 if( localcamera != NULL) delete localcamera; 62 47 if( resources != NULL) delete resources; 63 48 } … … 79 64 void Orxonox::get_config_file (int argc, char** argv) 80 65 { 81 char* path;66 /* char* path; 82 67 #ifdef __WIN32__ 83 68 path = getenv(""); … … 88 73 if( path != NULL) strcpy (configfilename, path); 89 74 else strcpy (configfilename, "./"); 90 strcat (configfilename, "/.orxonox.conf"); 75 strcat (configfilename, "/.orxonox.conf");*/ 76 77 strcpy (configfilename, "./orxonox.conf"); 91 78 } 92 79 … … 207 194 void Orxonox::mainLoop() 208 195 { 196 lastframe = SDL_GetTicks(); 197 209 198 // This is where everything is run 210 199 while( !bQuitOrxonox) … … 237 226 { 238 227 // localinput 239 localinput .process();228 localinput->process(); 240 229 // remoteinput 241 230 } … … 261 250 { 262 251 // clear buffer 263 glClear( GL_COLOR_BUFFER_BIT ,GL_DEPTH_BUFFER_BIT);252 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 264 253 // set camera 265 254 localcamera->apply (); … … 276 265 } 277 266 278 C amera* Orxonox::get_localinput ()267 CommandNode* Orxonox::get_localinput () 279 268 { 280 269 return localinput; 281 270 } 282 271 283 Camera* Orxonox::get_world ()272 World* Orxonox::get_world () 284 273 { 285 274 return world; … … 295 284 return -1; 296 285 } 297 298 lastframe = SDL_GetTicks();299 286 300 287 (*orx).mainLoop(); -
orxonox/branches/chris/src/player.cc
r2096 r2101 16 16 */ 17 17 18 #include <iostream>19 #include <stdlib.h>20 #include <GL/glut.h>21 22 18 #include "player.h" 19 #include "stdincl.h" 20 #include "collision.h" 23 21 24 22 using namespace std; … … 40 38 bFire = false; 41 39 acceleration = 10.0; 42 set_collision (new CollisionCluster (1.0, Vector(0,0,0)) ;40 set_collision (new CollisionCluster (1.0, Vector(0,0,0))); 43 41 } 44 42 … … 46 44 { 47 45 // movement 48 move ( floattime);46 move (time); 49 47 } 50 48 … … 104 102 // a = acceleration 105 103 106 l->pos = l->pos + velocity*time + (accel*(0.5*t *t)));104 l->pos = l->pos + velocity*time + (accel*(0.5*time*time)); 107 105 l->dist += travel_speed * time; 108 106 109 velocity += accel * time;107 velocity = velocity + (accel * time); 110 108 } 111 109 -
orxonox/branches/chris/src/player.h
r2096 r2101 10 10 11 11 public: 12 Player (bool isFree );12 Player (bool isFree = false); 13 13 ~Player (); 14 14 -
orxonox/branches/chris/src/track.cc
r2080 r2101 18 18 #include "track.h" 19 19 20 using namespace std; 20 21 21 using namespace std; 22 Track::Track () 23 { 24 ID = 0; 25 offset = NULL; 26 end = NULL; 27 nextID = 0; 28 } 22 29 23 30 Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish) -
orxonox/branches/chris/src/track.h
r2080 r2101 2 2 #ifndef TRACK_H 3 3 #define TRACK_H 4 5 #include "stdincl.h" 4 6 5 7 class Track … … 12 14 13 15 public: 16 Track (); 14 17 Track (Uint32 number, Uint32 next, Vector* start, Vector* finish); 15 18 ~Track (); -
orxonox/branches/chris/src/vector.cc
r2080 r2101 298 298 Use this to rotate one rotation by another 299 299 */ 300 Rotation Rotation::operator* ( Rotation& r)301 { 302 Rotation p ();300 Rotation Rotation::operator* (const Rotation& r) 301 { 302 Rotation p; 303 303 304 p [0] = m[0]*r.m[0] + m[1]*r.m[3] + m[2]*r.m[6];305 p [1] = m[0]*r.m[1] + m[1]*r.m[4] + m[2]*r.m[7];306 p [2] = m[0]*r.m[2] + m[1]*r.m[5] + m[2]*r.m[8];304 p.m[0] = m[0]*r.m[0] + m[1]*r.m[3] + m[2]*r.m[6]; 305 p.m[1] = m[0]*r.m[1] + m[1]*r.m[4] + m[2]*r.m[7]; 306 p.m[2] = m[0]*r.m[2] + m[1]*r.m[5] + m[2]*r.m[8]; 307 307 308 p [3] = m[3]*r.m[0] + m[4]*r.m[3] + m[5]*r.m[6];309 p [4] = m[3]*r.m[1] + m[4]*r.m[4] + m[5]*r.m[7];310 p [5] = m[3]*r.m[2] + m[4]*r.m[5] + m[5]*r.m[8];311 312 p [6] = m[6]*r.m[0] + m[7]*r.m[3] + m[8]*r.m[6];313 p [7] = m[6]*r.m[1] + m[7]*r.m[4] + m[8]*r.m[7];314 p [8] = m[6]*r.m[2] + m[7]*r.m[5] + m[8]*r.m[8];308 p.m[3] = m[3]*r.m[0] + m[4]*r.m[3] + m[5]*r.m[6]; 309 p.m[4] = m[3]*r.m[1] + m[4]*r.m[4] + m[5]*r.m[7]; 310 p.m[5] = m[3]*r.m[2] + m[4]*r.m[5] + m[5]*r.m[8]; 311 312 p.m[6] = m[6]*r.m[0] + m[7]*r.m[3] + m[8]*r.m[6]; 313 p.m[7] = m[6]*r.m[1] + m[7]*r.m[4] + m[8]*r.m[7]; 314 p.m[8] = m[6]*r.m[2] + m[7]*r.m[5] + m[8]*r.m[8]; 315 315 316 316 return p; -
orxonox/branches/chris/src/world.cc
r2096 r2101 15 15 */ 16 16 17 #include <iostream>18 #include <stdlib.h>19 #include <cmath>20 21 17 #include "world.h" 22 18 #include "world_entity.h" 19 #include "collision.h" 20 #include "track.h" 21 #include "player.h" 22 #include "command_node.h" 23 #include "camera.h" 23 24 24 25 using namespace std; … … 32 33 World::World () 33 34 { 34 entities = new List<WorldEntit ites>();35 entities = new List<WorldEntity>(); 35 36 } 36 37 … … 42 43 } 43 44 44 template<class T> T* World::spawn<T>(Location* loc = NULL, WorldEntity* owner = NULL) 45 { 46 Location zeroloc; 47 T* entity = new T(); 48 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 49 if( loc == NULL) 50 { 51 zeroloc.dist = 0; 52 zeroloc.part = 0; 53 zeroloc.pos = Vector(); 54 zeroloc.rot = Rotation(); 55 loc = &zeroloc; 56 } 57 entity->init (loc, owner); 58 if (entity->bFree) 59 { 60 track[loc->part].map_coords( loc, entity->get_placement()) 61 } 62 entity->post_spawn (); 63 return entity; 64 } 65 66 template<class T> T* World::spawn<T>(Placement* plc, WorldEntity* owner = NULL) 67 { 68 T* entity = new T(); 69 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 70 entity->init (plc, owner); 71 if (!entity->bFree) 72 { 73 printf("Can't spawn unfree entity with placement\n"); 74 entities->remove( (WorldEntity*)entity, LIST_FIND_FW); 75 return NULL; 76 } 77 entity->post_spawn (); 78 return entity; 79 } 80 81 World::collide () 45 void World::collide () 82 46 { 83 47 List<WorldEntity> *a, *b; … … 97 61 if( bobj->bCollide && bobj->collisioncluster != NULL) 98 62 { 99 Uint32ahitflg, bhitflg;100 if check_collision ( aobj->place, aobj->collisioncluster, &ahitflg, bobj->place, bobj->collisioncluster, &bhitflg);63 unsigned long ahitflg, bhitflg; 64 if( check_collision ( &aobj->place, aobj->collisioncluster, &ahitflg, &bobj->place, bobj->collisioncluster, &bhitflg)); 101 65 { 102 66 aobj->collide (bobj, ahitflg, bhitflg); … … 141 105 entity = l->get_object(); 142 106 143 if( entity != bFree)107 if( !entity->isFree()) 144 108 { 145 109 loc = entity->get_location(); … … 156 120 while( track[t].map_coords( loc, plc)) 157 121 { 158 track[t] ->post_leave (entity);122 track[t].post_leave (entity); 159 123 if( loc->part >= tracklen) 160 124 { … … 163 127 break; 164 128 } 165 track[loc->part] ->post_enter (entity);129 track[loc->part].post_enter (entity); 166 130 } 167 131 } … … 194 158 } 195 159 196 for( int i = 0; i < tracklen ) track[i].tick (seconds);160 for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 197 161 } 198 162 … … 223 187 224 188 // create a player 225 World entity* myPlayer =spawn<Player>();189 WorldEntity* myPlayer = (WorldEntity*) spawn<Player>(); 226 190 227 191 // bind input -
orxonox/branches/chris/src/world.h
r2100 r2101 3 3 #define WORLD_H 4 4 5 #include "stdincl.h" 6 5 7 class Track; 8 class WorldEntity; 6 9 7 10 class World { … … 11 14 ~World (); 12 15 13 template< classT>14 T* spawn <T>(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity15 template< classT>16 T* spawn <T>(Placement* plc, WorldEntity* owner);16 template<typename T> 17 T* spawn(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity 18 template<typename T> 19 T* spawn(Placement* plc, WorldEntity* owner); 17 20 18 21 void time_slice (Uint32 deltaT); … … 37 40 }; 38 41 42 template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL) 43 { 44 Location zeroloc; 45 T* entity = new T(); 46 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 47 if( loc == NULL) 48 { 49 zeroloc.dist = 0; 50 zeroloc.part = 0; 51 zeroloc.pos = Vector(); 52 zeroloc.rot = Rotation(); 53 loc = &zeroloc; 54 } 55 entity->init (loc, owner); 56 if (entity->bFree) 57 { 58 track[loc->part].map_coords( loc, entity->get_placement()); 59 } 60 entity->post_spawn (); 61 return entity; 62 } 63 64 template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL) 65 { 66 T* entity = new T(); 67 entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); 68 entity->init (plc, owner); 69 if (!entity->bFree) 70 { 71 printf("Can't spawn unfree entity with placement\n"); 72 entities->remove( (WorldEntity*)entity, LIST_FIND_FW); 73 return NULL; 74 } 75 entity->post_spawn (); 76 return entity; 77 } 78 39 79 #endif -
orxonox/branches/chris/src/world_entity.cc
r2100 r2101 19 19 20 20 #include "world_entity.h" 21 22 #include " vector.h"21 #include "stdincl.h" 22 #include "collision.h" 23 23 24 24 using namespace std; … … 37 37 This is some sort of standard interface to all WorldEntities... 38 38 */ 39 WorldEntity::WorldEntity (bool isFree = false) : bFree(isFree)39 WorldEntity::WorldEntity (bool isFree) : bFree(isFree) 40 40 { 41 41 collisioncluster = NULL; … … 65 65 if( collisioncluster != NULL) delete collisioncluster; 66 66 collisioncluster = newhull; 67 }68 69 /**70 \brief sets the speed of the entity, if any71 \param speed: the speed in points (openGL points) per seconds72 */73 void WorldEntity::setSpeed(float speed)74 {75 this->speed = speed;76 }77 78 /**79 \brief gets the speed of the entity, if any80 \return the speed in points (openGL points) per seconds81 */82 float WorldEntity::getSpeed()83 {84 return speed;85 }86 87 /**88 \brief sets the health of the entity89 \param health: number for the life count, normaly {0..100}90 */91 void WorldEntity::setHealth(float health)92 {93 this->health = health;94 }95 96 /**97 \brief gets the health of the entity98 \return number for the life count, normaly {0..100}99 */100 float WorldEntity::getHealth()101 {102 return health;103 67 } 104 68 … … 154 118 void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner) 155 119 { 156 pl c= *spawnplc;120 place = *spawnplc; 157 121 owner = spawnowner; 158 122 } -
orxonox/branches/chris/src/world_entity.h
r2100 r2101 2 2 #ifndef WORLD_ENTITY_H 3 3 #define WORLD_ENTITY_H 4 5 #include "stdincl.h" 4 6 5 7 class CollisionCluster; … … 10 12 11 13 public: 12 WorldEntity (bool isFree );14 WorldEntity (bool isFree = false); 13 15 ~WorldEntity (); 14 16 … … 16 18 Placement* get_placement (); 17 19 void set_collision (CollisionCluster* newhull); 18 20 19 21 bool isFree (); 20 22 … … 35 37 36 38 private: 39 const bool bFree; 37 40 bool bCollide; 38 41 bool bDraw; 39 bool bFree; // Whether entity movement is bound to the track40 42 41 43 WorldEntity* owner;
Note: See TracChangeset
for help on using the changeset viewer.