Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2101 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Jul 10, 2004, 2:00:04 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/chris: Finished the "GETITTOCOMPILE" project… compiling should work now, but linking is a different story

Location:
orxonox/branches/chris/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/chris/src/orxonox.cc

    r2096 r2101  
    2424*/
    2525
    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"
    3627#include "world.h"
    37 #include "input_output.h"
     28#include "camera.h"
    3829#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"
    4531
    4632using namespace std;
    47 
    4833
    4934Orxonox::Orxonox ()
     
    5944        if( world != NULL) delete world;
    6045        if( localinput != NULL) delete world;
    61         if( localcamera != NULL) delete camera;
     46        if( localcamera != NULL) delete localcamera;
    6247        if( resources != NULL) delete resources;
    6348}
     
    7964void Orxonox::get_config_file (int argc, char** argv)
    8065{
    81         char* path;
     66/*      char* path;
    8267        #ifdef __WIN32__
    8368        path = getenv("");
     
    8873        if( path != NULL) strcpy (configfilename, path);
    8974        else strcpy (configfilename, "./");
    90         strcat (configfilename, "/.orxonox.conf");
     75        strcat (configfilename, "/.orxonox.conf");*/
     76       
     77        strcpy (configfilename, "./orxonox.conf");
    9178}
    9279
     
    207194void Orxonox::mainLoop()
    208195{
     196        lastframe = SDL_GetTicks();
     197
    209198  // This is where everything is run
    210199  while( !bQuitOrxonox)
     
    237226{
    238227        // localinput
    239                 localinput.process();
     228                localinput->process();
    240229        // remoteinput
    241230}
     
    261250{
    262251                // clear buffer
    263         glClear( GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT);
     252        glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    264253                // set camera
    265254        localcamera->apply ();
     
    276265}
    277266
    278 Camera* Orxonox::get_localinput ()
     267CommandNode* Orxonox::get_localinput ()
    279268{
    280269        return localinput;
    281270}
    282271
    283 Camera* Orxonox::get_world ()
     272World* Orxonox::get_world ()
    284273{
    285274        return world;
     
    295284    return -1;
    296285  }
    297 
    298         lastframe = SDL_GetTicks();
    299286       
    300287  (*orx).mainLoop();
  • orxonox/branches/chris/src/player.cc

    r2096 r2101  
    1616*/
    1717
    18 #include <iostream>
    19 #include <stdlib.h>
    20 #include <GL/glut.h>
    21 
    2218#include "player.h"
     19#include "stdincl.h"
     20#include "collision.h"
    2321
    2422using namespace std;
     
    4038        bFire = false;
    4139        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)));
    4341}
    4442
     
    4644{
    4745        // movement
    48         move (float time);
     46        move (time);
    4947}
    5048
     
    104102        // a = acceleration
    105103       
    106         l->pos = l->pos + velocity*time + (accel*(0.5*t*t)));
     104        l->pos = l->pos + velocity*time + (accel*(0.5*time*time));
    107105        l->dist += travel_speed * time;
    108106       
    109         velocity += accel * time;
     107        velocity = velocity + (accel * time);
    110108}
    111109
  • orxonox/branches/chris/src/player.h

    r2096 r2101  
    1010
    1111 public:
    12   Player (bool isFree);
     12  Player (bool isFree = false);
    1313  ~Player ();
    1414
  • orxonox/branches/chris/src/track.cc

    r2080 r2101  
    1818#include "track.h"
    1919
     20using namespace std;
    2021
    21 using namespace std;
     22Track::Track ()
     23{
     24        ID = 0;
     25        offset = NULL;
     26        end = NULL;
     27        nextID = 0;
     28}
    2229
    2330Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish)
  • orxonox/branches/chris/src/track.h

    r2080 r2101  
    22#ifndef TRACK_H
    33#define TRACK_H
     4
     5#include "stdincl.h"
    46
    57class Track
     
    1214       
    1315 public:
     16        Track ();
    1417  Track (Uint32 number, Uint32 next, Vector* start, Vector* finish);
    1518  ~Track ();
  • orxonox/branches/chris/src/vector.cc

    r2080 r2101  
    298298   Use this to rotate one rotation by another
    299299*/
    300 Rotation Rotation::operator* (Rotation& r)
    301 {
    302         Rotation p();
     300Rotation Rotation::operator* (const Rotation& r)
     301{
     302        Rotation p;
    303303       
    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];
    307307       
    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];
    315315       
    316316        return p;
  • orxonox/branches/chris/src/world.cc

    r2096 r2101  
    1515*/
    1616
    17 #include <iostream>
    18 #include <stdlib.h>
    19 #include <cmath>
    20 
    2117#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"
    2324
    2425using namespace std;
     
    3233World::World ()
    3334{
    34         entities = new List<WorldEntitites>();
     35        entities = new List<WorldEntity>();
    3536}
    3637
     
    4243}
    4344
    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 ()
     45void World::collide ()
    8246{
    8347        List<WorldEntity> *a, *b;
     
    9761                                if( bobj->bCollide && bobj->collisioncluster != NULL)
    9862                                {
    99                                         Uint32 ahitflg, 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));
    10165                                        {
    10266                                                aobj->collide (bobj, ahitflg, bhitflg);
     
    141105                entity = l->get_object();
    142106               
    143                 if( entity != bFree)
     107                if( !entity->isFree())
    144108                {
    145109                        loc = entity->get_location();
     
    156120                                while( track[t].map_coords( loc, plc))
    157121                                {
    158                                         track[t]->post_leave (entity);
     122                                        track[t].post_leave (entity);
    159123                                        if( loc->part >= tracklen)
    160124                                        {
     
    163127                                                break;
    164128                                        }
    165                                         track[loc->part]->post_enter (entity);
     129                                        track[loc->part].post_enter (entity);
    166130                                }
    167131                        }
     
    194158        }
    195159       
    196         for( int i = 0; i < tracklen) track[i].tick (seconds);
     160        for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    197161}
    198162
     
    223187       
    224188        // create a player
    225         Worldentity* myPlayer = spawn<Player>();
     189        WorldEntity* myPlayer = (WorldEntity*) spawn<Player>();
    226190       
    227191        // bind input
  • orxonox/branches/chris/src/world.h

    r2100 r2101  
    33#define WORLD_H
    44
     5#include "stdincl.h"
     6
    57class Track;
     8class WorldEntity;
    69
    710class World {
     
    1114  ~World ();
    1215
    13         template<class T>
    14           T* spawn<T>(Location* loc, WorldEntity* owner);       // template to be able to spawn any derivation of WorldEntity
    15         template<class T>
    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);
    1720
    1821        void time_slice (Uint32 deltaT);
     
    3740};
    3841
     42template<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
     64template<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
    3979#endif
  • orxonox/branches/chris/src/world_entity.cc

    r2100 r2101  
    1919
    2020#include "world_entity.h"
    21 
    22 #include "vector.h"
     21#include "stdincl.h"
     22#include "collision.h"
    2323
    2424using namespace std;
     
    3737This is some sort of standard interface to all WorldEntities...
    3838*/
    39 WorldEntity::WorldEntity (bool isFree = false) : bFree(isFree)
     39WorldEntity::WorldEntity (bool isFree) : bFree(isFree)
    4040{
    4141        collisioncluster = NULL;
     
    6565        if( collisioncluster != NULL) delete collisioncluster;
    6666        collisioncluster = newhull;
    67 }
    68 
    69 /**
    70    \brief sets the speed of the entity, if any
    71    \param speed: the speed in points (openGL points) per seconds
    72 */
    73 void WorldEntity::setSpeed(float speed)
    74 {
    75   this->speed = speed;
    76 }
    77 
    78 /**
    79    \brief gets the speed of the entity, if any
    80    \return the speed in points (openGL points) per seconds
    81 */
    82 float WorldEntity::getSpeed()
    83 {
    84   return speed;
    85 }
    86 
    87 /**
    88    \brief sets the health of the entity
    89    \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 entity
    98    \return number for the life count, normaly {0..100}
    99 */
    100 float WorldEntity::getHealth()
    101 {
    102   return health;
    10367}
    10468
     
    154118void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner)
    155119{
    156         plc = *spawnplc;
     120        place = *spawnplc;
    157121        owner = spawnowner;
    158122}
  • orxonox/branches/chris/src/world_entity.h

    r2100 r2101  
    22#ifndef WORLD_ENTITY_H
    33#define WORLD_ENTITY_H
     4
     5#include "stdincl.h"
    46
    57class CollisionCluster;
     
    1012
    1113 public:
    12   WorldEntity (bool isFree);
     14  WorldEntity (bool isFree = false);
    1315  ~WorldEntity ();
    1416
     
    1618        Placement* get_placement ();
    1719        void set_collision (CollisionCluster* newhull);
    18        
     20
    1921        bool isFree ();
    2022       
     
    3537
    3638 private:
     39  const bool bFree;     
    3740  bool bCollide;
    3841  bool bDraw;
    39   bool bFree;           // Whether entity movement is bound to the track
    4042 
    4143        WorldEntity* owner;
Note: See TracChangeset for help on using the changeset viewer.