Changeset 2080 in orxonox.OLD for orxonox/branches/chris/src
- Timestamp:
- Jul 6, 2004, 10:29:05 PM (20 years ago)
- Location:
- orxonox/branches/chris/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/camera.cc
r2068 r2080 12 12 13 13 ### File Specific: 14 main-programmer: ...14 main-programmer: Christian Meyer 15 15 co-programmer: ... 16 16 */ … … 70 70 71 71 glMatrixMode (GL_MODELVIEW); 72 glLoadIdentity (); 72 73 } 73 74 … … 87 88 void Camera::bind (WorldEntity* entity) 88 89 { 89 if( entity != NULL) bound = entity; 90 if( entity != NULL) 91 { 92 if( entity->bFree) printf("Cannot bind camera to free entity"); 93 else bound = entity; 94 } 90 95 } -
orxonox/branches/chris/src/orxonox.cc
r2068 r2080 87 87 88 88 if( path != NULL) strcpy (configfilename, path); 89 else strcpy (configfilename, "./"); 89 90 strcat (configfilename, "/.orxonox.conf"); 90 91 } … … 191 192 int Orxonox::init_world () 192 193 { 193 printf("Not yet implemented\n"); 194 world = new World(); 195 196 // TO DO: replace this with a menu/intro 197 world->load_debug_level(); 198 194 199 return 0; 195 200 } -
orxonox/branches/chris/src/track.cc
r2068 r2080 12 12 13 13 ### File Specific: 14 main-programmer: ...14 main-programmer: Christian Meyer 15 15 co-programmer: ... 16 16 */ … … 21 21 using namespace std; 22 22 23 24 25 Track::Track () 23 Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish) 26 24 { 25 ID = number; 26 offset = start; 27 end = finish; 28 nextID = next; 27 29 } 28 30 … … 33 35 void Track::map_camera (Location* lookat, Placement* camplc) 34 36 { 37 Line trace(*offset, *end - *offset); 38 float l = trace.len (); 39 40 camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0); 41 camplc->w = Rotation( (trace.r + (trace.a * ((lookat->dist) / l))) - camplc->r); 35 42 } 36 43 37 voidTrack::map_coords (Location* loc, Placement* plc)44 bool Track::map_coords (Location* loc, Placement* plc) 38 45 { 46 Line trace(*offset, *end - *offset); 47 float l = trace.len (); 39 48 49 if( loc->dist > l) 50 { 51 loc->dist -= l; 52 loc->part = nextID; 53 return true; 54 } 55 56 Rotation dir(trace.a); 57 58 plc->r = trace.r + (trace.a * ((loc->dist) / l)) + rotate_vector( loc->pos, dir); 59 plc->w = dir * loc->rot; 60 61 return false; 62 } 63 64 void Track::post_enter (WorldEntity* entity) 65 { 66 } 67 68 void Track::post_leave (WorldEntity* entity) 69 { 70 } 71 72 void Track::tick (float deltaT) 73 { 40 74 } 41 75 -
orxonox/branches/chris/src/track.h
r2068 r2080 9 9 Vector* offset; 10 10 Vector* end; 11 Uint32 nextID; 11 12 12 13 public: 13 Track ( );14 Track (Uint32 number, Uint32 next, Vector* start, Vector* finish); 14 15 ~Track (); 15 16 17 virtual void post_enter (WorldEntity* entity); // handle coordinate transition in here !!! (when dist < 0 or dist > lasttracklenght) 18 virtual void post_leave (WorldEntity* entity); 19 virtual void tick (float deltaT); 16 20 virtual void map_camera (Location* lookat, Placement* camplc); 17 virtual void map_coords (Location* loc, Placement* plc);21 virtual bool map_coords (Location* loc, Placement* plc); // this should return true if the entity left track boundaries 18 22 }; 19 23 -
orxonox/branches/chris/src/vector.cc
r2068 r2080 291 291 } 292 292 293 /** 294 \brief multiplies two rotational matrices 295 \param r: another Rotation 296 \return the matrix product of the Rotations 297 298 Use this to rotate one rotation by another 299 */ 300 Rotation Rotation::operator* (Rotation& r) 301 { 302 Rotation p(); 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]; 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]; 315 316 return p; 317 } 318 293 319 294 320 /** -
orxonox/branches/chris/src/vector.h
r2068 r2080 58 58 ~Rotation () {} 59 59 60 Rotation operator* (const Rotation& r); 61 60 62 glmatrix (float* buffer); 61 63 }; -
orxonox/branches/chris/src/world.cc
r2068 r2080 18 18 #include <stdlib.h> 19 19 #include <cmath> 20 21 #include "npc.h"22 #include "player.h"23 #include "environment.h"24 #include "shoot_laser.h"25 #include "shoot_rocket.h"26 #include "stdincl.h"27 #include "data_tank.h"28 20 29 21 #include "world.h" … … 46 38 World::~World () 47 39 { 40 unload (); 48 41 delete entities; 49 42 } 50 43 51 template<class T> T* World::spawn<T>(Location* loc, WorldEntity* owner) 52 { 44 template<class T> T* World::spawn<T>(Location* loc = NULL, WorldEntity* owner = NULL) 45 { 46 Location zeroloc; 53 47 T* entity = new T(); 54 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 (); 55 78 return entity; 56 79 } … … 107 130 void World::update () 108 131 { 132 List<WorldEntity> *l; 133 WorldEntity* entity; 134 Location* loc; 135 Placement* plc; 136 Uint32 t; 137 138 l = entities->get_next(); 139 while( l != NULL) 140 { 141 entity = l->get_object(); 142 143 if( entity != bFree) 144 { 145 loc = entity->get_location(); 146 plc = entity->get_placement(); 147 t = loc->part; 148 149 if( t >= tracklen) 150 { 151 printf("An entity is out of the game area\n"); 152 entity->left_world (); 153 } 154 else 155 { 156 while( track[t].map_coords( loc, plc)) 157 { 158 track[t]->post_leave (entity); 159 if( loc->part >= tracklen) 160 { 161 printf("An entity has left the game area\n"); 162 entity->left_world (); 163 break; 164 } 165 track[loc->part]->post_enter (entity); 166 } 167 } 168 } 169 else 170 { 171 // TO DO: implement check whether this particular free entity is out of the game area 172 // TO DO: call function to notify the entity that it left the game area 173 } 174 175 l = l->get_next(); 176 } 177 109 178 } 110 179 … … 124 193 l = l->get_next(); 125 194 } 126 } 195 196 for( int i = 0; i < tracklen) track[i].tick (seconds); 197 } 198 199 void World::unload() 200 { 201 if( pathnodes) delete []pathnodes; 202 if( track) delete []pathnodes; 203 } 204 205 void World::load_debug_level() 206 { 207 // create some path nodes 208 pathnodes = new Vector[6]; 209 pathnodes[0] = Vector(0, 0, 0); 210 pathnodes[1] = Vector(-100, 40, 0); 211 pathnodes[2] = Vector(-100, 140, 0); 212 pathnodes[3] = Vector(0, 180, 0); 213 pathnodes[4] = Vector(100, 140, 0); 214 pathnodes[5] = Vector(100, 40, 0); 215 216 // create the tracks 217 tracklen = 6; 218 track = new Track[6]; 219 for( int i = 0; i < tracklen; i++) 220 { 221 track[i] = Track( i, (i+1)%tracklen, &pathnodes[i], &pathnodes[(i+1)%tracklen]); 222 } 223 224 // create a player 225 226 // bind input 227 // bind camera 228 } -
orxonox/branches/chris/src/world.h
r2068 r2080 17 17 void calc_camera_pos (Location* loc, Placement* plc); 18 18 19 void unload (); 20 21 void load_debug_level (); 22 19 23 private: 20 24 -
orxonox/branches/chris/src/world_entity.cc
r2068 r2080 37 37 This is some sort of standard interface to all WorldEntities... 38 38 */ 39 WorldEntity::WorldEntity ( )39 WorldEntity::WorldEntity (bool isFree = false) : bFree(isFree) 40 40 { 41 health = 100;42 speed = 0;41 collisioncluster = NULL; 42 owner = NULL; 43 43 } 44 45 44 46 45 WorldEntity::~WorldEntity () {} 47 46 48 /** 49 \brief sets the position of this entity 50 \param position: Vector, pointing (from 0,0,0) to the new position 51 */ 52 void WorldEntity::setPosition(Vector* position) {} 47 Location* WorldEntity::getLocation () 48 { 49 return &loc; 50 } 53 51 54 /** 55 \brief gets the postion of this entity 56 \return a Vector, pointing (from 0,0,0) to the new position 57 */ 58 Vector* getPosition() {} 52 Placement* WorldEntity::getPlacement () 53 { 54 return &place; 55 } 59 56 60 /** 61 \brief sets orientation of this entity 62 \param orientation: vector specifying in which direction the entity looks 63 */ 64 void WorldEntity::setOrientation(Vector* orientation) {} 65 66 /** 67 \brief gets orientation of this entity 68 \return vector specifying in which direction the entity looks 69 */ 70 Vector* WorldEntity::getOrientation() {} 57 void WorldEntity::set_collision (CollisionCluster* newhull) 58 { 59 if( newhull == NULL) return; 60 if( collisioncluster != NULL) delete collisioncluster; 61 collisioncluster = newhull; 62 } 71 63 72 64 /** … … 149 141 void WorldEntity::destroy() {} 150 142 151 /** 152 \brief this function is automatically called before the entity enters the world 153 */ 154 void WorldEntity::entityPreEnter() {} 143 void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner) 144 { 145 loc = *spawnloc; 146 owner = spawnowner; 147 } 155 148 156 /** 157 \brief this function is automatically called after the entity enters the world 158 159 */ 160 void WorldEntity::entityPostEnter() {} 161 162 /** 163 \brief this function is automatically called before the entity quits the world 164 165 */ 166 void WorldEntity::entityPreQuit() {} 167 168 /** 169 \brief this function is automatically called after the entity quits the world 170 */ 171 void WorldEntity::entityPostQuit() {} 149 void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner) 150 { 151 plc = *spawnplc; 152 owner = spawnowner; 153 } -
orxonox/branches/chris/src/world_entity.h
r2068 r2080 9 9 class Ability; 10 10 11 class WorldEntity { 11 class WorldEntity 12 { 13 friend class World; 12 14 13 15 public: 14 WorldEntity ( );16 WorldEntity (bool isFree); 15 17 ~WorldEntity (); 16 18 19 Location* get_location (); 20 Placement* get_placement (); 21 void set_collision (CollisionCluster* newhull); 22 23 //void addAbility(Ability* ability); 24 //void removeAbility(Ability* ability); 17 25 18 void setPosition(Vector* position); 19 Vector* getPosition(); 20 void setOrientation(Vector* orientation); 21 Vector* getOrientation(); 22 void setSpawnPoint(Vector* place); 23 void setSpeed(float speed); 24 float getSpeed(); 25 void setHealth(float health); 26 float getHealth(); 27 28 void addAbility(Ability* ability); 29 void removeAbility(Ability* ability); 30 26 virtual void post_spawn (); 31 27 virtual void tick (float time); 32 virtual void draw ();33 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags);34 28 virtual void hit (WorldEntity* weapon, Vector loc); 35 29 virtual void destroy (); 36 virtual void command (Command* cmd); 30 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 31 virtual void command (Command* cmd); 32 33 virtual void draw (); 37 34 virtual void get_lookat (Location* locbuf); 38 35 39 virtual void entityPreEnter(); 40 virtual void entityPostEnter(); 41 virtual void entityPreQuit(); 42 virtual void entityPostQuit(); 36 virtual void left_world (); 43 37 38 private: 44 39 bool bCollide; 45 40 bool bDraw; 46 47 private:41 bool bFree; // Whether entity movement is bound to the track 42 48 43 WorldEntity* owner; 49 44 CollisionCluster* collisioncluster; 50 45 Placement place; 51 46 Location loc; 52 /* List of abilities */53 float health;54 float speed;55 /* entity can be in the air or at ground: */56 int airGround;57 47 58 59 48 void init( Location* spawnloc, WorldEntity* spawnowner); 49 void init( Placement* spawnplc, WorldEntity* spawnowner); 60 50 }; 61 51
Note: See TracChangeset
for help on using the changeset viewer.