Last change
on this file since 2112 was
2112,
checked in by chris, 20 years ago
|
orxonox/branches/chris: Implemented quaternion class… but something is still f up… the camera keeps pointing into the wrong direction… matrix rotation calculation seems not to be my strenght…
|
File size:
1.5 KB
|
Rev | Line | |
---|
[1853] | 1 | |
---|
| 2 | #ifndef WORLD_H |
---|
| 3 | #define WORLD_H |
---|
| 4 | |
---|
[2101] | 5 | #include "stdincl.h" |
---|
| 6 | |
---|
[2100] | 7 | class Track; |
---|
[2101] | 8 | class WorldEntity; |
---|
[2100] | 9 | |
---|
[1853] | 10 | class World { |
---|
| 11 | |
---|
| 12 | public: |
---|
| 13 | World (); |
---|
| 14 | ~World (); |
---|
| 15 | |
---|
[2101] | 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); |
---|
[1917] | 20 | |
---|
[2068] | 21 | void time_slice (Uint32 deltaT); |
---|
| 22 | void collide (); |
---|
| 23 | void draw (); |
---|
| 24 | void update (); // maps Locations to Placements |
---|
| 25 | void calc_camera_pos (Location* loc, Placement* plc); |
---|
| 26 | |
---|
[2080] | 27 | void unload (); |
---|
| 28 | |
---|
| 29 | void load_debug_level (); |
---|
| 30 | |
---|
[1883] | 31 | private: |
---|
[2068] | 32 | |
---|
| 33 | List<WorldEntity>* entities; |
---|
| 34 | |
---|
| 35 | // base level data |
---|
| 36 | Track* track; |
---|
| 37 | Uint32 tracklen; |
---|
| 38 | Vector* pathnodes; |
---|
[1855] | 39 | |
---|
[1853] | 40 | }; |
---|
| 41 | |
---|
[2101] | 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(); |
---|
[2112] | 52 | zeroloc.rot = Quaternion(); |
---|
[2101] | 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 | |
---|
[1853] | 79 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.