Changeset 2096 in orxonox.OLD for orxonox/branches/chris
- Timestamp:
- Jul 9, 2004, 11:14:42 AM (20 years ago)
- Location:
- orxonox/branches/chris/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/chris/src/camera.cc
r2080 r2096 21 21 using namespace std; 22 22 23 /** 24 \brief creates a Camera 25 26 This standard constructor sets all parameters to zero 27 */ 23 28 Camera::Camera () 24 29 { … … 30 35 } 31 36 37 /** 38 \brief default destructor 39 */ 32 40 Camera::~Camera () 33 41 { 34 42 } 35 43 44 /** 45 \brief time based actualisation of camera parameters 46 \param deltaT: The amount of time that has passed in milliseconds 47 48 This is called by the World in every time_slice, use it to do fancy time dependant effects (such 49 as smooth camera movement or swaying). 50 */ 36 51 void Camera::time_slice (Uint32 deltaT) 37 52 { … … 39 54 } 40 55 56 /** 57 \brief this calculates the location where the track wants the camera to be 58 59 This refreshes the placement the camera should have according to the bound entity's position on the track. 60 */ 41 61 void Camera::update_desired_place () 42 62 { … … 56 76 } 57 77 78 /** 79 \brief initialize rendering perspective according to this camera 80 81 This is called immediately before the a rendering cycle starts, it sets all global rendering options as 82 well as the GL_PROJECTION matrix according to the camera. 83 */ 58 84 void Camera::apply () 59 85 { … … 73 99 } 74 100 101 /** 102 \brief set the camera position 103 \param plc: The Placement to set the camera to 104 105 This will set the actual and desired placement of the camera to plc 106 */ 75 107 void Camera::jump (Placement* plc = NULL) 76 108 { … … 86 118 } 87 119 120 /** 121 \brief bind the camera to an entity 122 \param entity: The enitity to bind the camera to 123 124 This sets the focus of the camera to the given entity. This means that it will use the given WorldEntity's 125 Location and get_lookat() to determine the viewpoint the camera will render from. 126 Note that you cannot bind a camera to a free entity. 127 */ 88 128 void Camera::bind (WorldEntity* entity) 89 129 { -
orxonox/branches/chris/src/camera.h
r2068 r2096 1 /*! 2 \file camera.h 3 \brief Viewpoint controlling class definitions 4 */ 1 5 2 6 #ifndef CAMERA_H 3 7 #define CAMERA_H 4 8 9 //! Camera 10 /** 11 This class controls the viewpoint from which the World is rendered. To use the Camera it has 12 to be bound to a WorldEntity which serves as the reference focus point. The Camera itself calls 13 the WorldEntity::get_lookat() and World::calc_camera_pos() functions to calculate the position it 14 currently should be in. 15 */ 5 16 class Camera { 6 17 private: 7 WorldEntity* bound; 8 Placement actual_place; 9 Placement desired_place; 18 WorldEntity* bound; //!< the WorldEntity the Camera is bound to 19 Placement actual_place; //!< the Camera's current position 20 Placement desired_place; //!< where the Camera should be according to calculations 10 21 11 22 void update_desired_place (); -
orxonox/branches/chris/src/command_node.cc
r2068 r2096 23 23 24 24 using namespace std; 25 25 26 26 27 CommandNode::CommandNode (int ID) … … 173 174 List<WorldEntity>* plist = bound; 174 175 176 if( bLocalInput) send_over_network (cmd); 177 175 178 while( (plist = plist->get_next()) != NULL) 176 179 { … … 178 181 } 179 182 } 183 184 void CommandNode::set_netID (int ID) 185 { 186 } 187 188 void CommandNode::send_over_network (Command* cmd) 189 { 190 } -
orxonox/branches/chris/src/command_node.h
r2066 r2096 15 15 #define DEFAULT_KEYBIND_FILE "default.ini" 16 16 17 //! Key aliasing structure 18 /** 19 This structure contains the key aliasing information, e.g. the command strings that 20 have been bound to the keys. 21 */ 17 22 typedef struct 18 23 { … … 21 26 } KeyBindings; 22 27 28 //! Command Node 29 /** 30 This class gathers all incoming SDL_Events and processes them. Keyboard, mouse and joystick input is 31 captured and translated into command messages which are passed down to the bound WorldEntities (via WorldEntity::command()). 32 Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created 33 with bLocalInput set to false, it will query the network class for incoming commands that match his netID and pass 34 them on to his WorldEntities. 35 */ 23 36 class CommandNode { 24 37 private: 25 bool bLocalInput; 26 int netID; 38 bool bLocalInput; //!< Identifies the CommandNode that processes local input 39 int netID; //!< Unique identifier that is used to determine between remote CommandNodes 27 40 KeyBindings* aliases; 28 List<WorldEntity>* bound; 41 List<WorldEntity>* bound; //!< List of WorldEntites that recieve commands from this CommandNode 29 42 int coord[2]; 30 43 … … 33 46 void process_local (); 34 47 void process_network (); 35 void send_over_networ ();48 void send_over_network (Command* cmd); 36 49 37 50 public: … … 44 57 void unbind (WorldEntity* entity); 45 58 void process (); 59 60 void set_netID (int ID); 46 61 }; 47 62 -
orxonox/branches/chris/src/orxonox.cc
r2080 r2096 276 276 } 277 277 278 Camera* Orxonox::get_localinput () 279 { 280 return localinput; 281 } 282 278 283 Camera* Orxonox::get_world () 279 284 { -
orxonox/branches/chris/src/orxonox.h
r2068 r2096 50 50 int init (int argc, char** argv); 51 51 52 CommandNode* get_localinput(); 52 53 Camera* get_camera(); 53 54 World* get_world(); -
orxonox/branches/chris/src/player.cc
r2058 r2096 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: Christian Meyer 16 16 */ 17 17 … … 20 20 #include <GL/glut.h> 21 21 22 #include "shoot_laser.h"23 #include "shoot_rocket.h"24 #include "data_tank.h"25 26 22 #include "player.h" 27 23 … … 29 25 30 26 31 Player::Player() 32 : WorldEntity() { 33 //cout << "Player::Player" << endl; 34 xCor = yCor = zCor = 0; 35 shootLaser = new ShootLaser; 36 shootRocket = new ShootRocket; 27 Player::Player(bool isFree) : WorldEntity(isFree) 28 { 37 29 } 38 30 39 31 Player::~Player () 40 32 { 41 //delete shootLaser;42 33 } 43 34 44 45 void Player::setPosition( float x, float y, float z) 35 void Player::post_spawn () 46 36 { 47 xCor = x; yCor = y; zCor = z; 37 travel_speed = 1.0; 38 velocity = Vector(); 39 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 40 bFire = false; 41 acceleration = 10.0; 42 set_collision (new CollisionCluster (1.0, Vector(0,0,0)); 48 43 } 49 44 50 51 void Player::getPosition(float* x, float* y, float* z) 45 void Player::tick (float time) 52 46 { 53 *x = xCor; *y = yCor; *z = zCor; 47 // movement 48 move (float time); 54 49 } 55 50 56 57 void Player::setCollisionRadius(float radius) 51 void Player::hit (WorldEntity* weapon, Vector loc) 58 52 { 59 collisionRadius = radius;60 53 } 61 54 62 63 void Player::goX(float x) 55 void Player::destroy () 64 56 { 65 xCor += x;66 57 } 67 58 68 69 void Player::goY(float y) 59 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) 70 60 { 71 yCor += y;72 61 } 73 62 74 void Player:: goZ(float z)63 void Player::command (Command* cmd) 75 64 { 76 zCor += z; 65 if( strcmp( cmd->cmd, "up")) bUp = !cmd->bUp; 66 else if( strcmp( cmd->cmd, "down")) bDown = !cmd->bUp; 67 else if( strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp; 68 else if( strcmp( cmd->cmd, "right")) bRight = !cmd->bUp; 69 else if( strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp; 77 70 } 78 71 79 80 81 void Player::shoot(int n) 72 void Player::draw () 82 73 { 83 84 // if (shootLaser->inhibitor++ <= 100)85 shootLaser->addShoot(xCor, yCor, zCor);86 // else if (shootLaser->inhibitor++ <= 200)87 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);88 // else if (shootLaser->inhibitor++ <= 300)89 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);90 // else91 shootLaser->inhibitor =0;92 93 // if (shootRocket->inhibitor++ >=80)94 {95 shootRocket->addBackParable(xCor, yCor, zCor);96 shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT);97 shootRocket->addSideAcc(xCor, yCor, zCor, LEFT);98 shootRocket->addRotater(xCor, yCor, zCor);99 // if (shootRocket->inhibitor >=90)100 // shootRocket->inhibitor =0;101 }102 //cout << "Player::shoot" << endl;103 104 /*105 shootLaser->addShoot(xCor, yCor, zCor);106 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);107 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);108 //shootRocket->addShoot(xCor, yCor, zCor);109 //cout << "Player::shoot" << endl;110 */111 74 } 112 75 76 void Player::get_lookat (Location* locbuf) 77 { 78 *locbuf = *get_location(); 79 locbuf->dist += 5.0; 80 } 113 81 114 //void Player::addIO(InputOutput *io) {} 82 void Player::left_world () 83 { 84 } 115 85 116 117 void Player::paint() 86 void Player::move (float time) 118 87 { 119 //cout << "Player::drawPlayer" << endl; 120 glPushMatrix(); 121 glTranslatef(xCor, yCor, 3.0); 122 glScalef(1.0, 3.0, 1.0); 123 glutWireCube(1.0); 124 glPopMatrix(); 125 /* draw all the shoots additionaly */ 126 shootLaser->drawShoot(); 127 shootRocket->drawShoot(); 128 //cout << "Player::drawPlayer, end" << endl; 88 float xAccel, yAccel, zAccel; 89 xAccel = yAccel = zAccel = 0; 90 if( bUp) xAccel += acceleration; 91 if( bDown) xAccel -= acceleration; 92 if( bLeft) yAccel += acceleration; 93 if( bRight) yAccel -= acceleration; 94 if( bAscend) zAccel += acceleration; 95 if( bDescend) zAccel -= acceleration; 96 97 Vector accel( xAccel, yAccel, zAccel); 98 99 Location* l = get_location(); 100 101 // r(t) = r(0) + v(0)*t + 1/2*a*t^2 102 // r = position 103 // v = velocity 104 // a = acceleration 105 106 l->pos = l->pos + velocity*time + (accel*(0.5*t*t))); 107 l->dist += travel_speed * time; 108 109 velocity += accel * time; 129 110 } 130 111 … … 146 127 147 128 148 149 150 151 152 153 154 155 -
orxonox/branches/chris/src/player.h
r2058 r2096 5 5 #include "world_entity.h" 6 6 7 class ShootLaser;8 class ShootRocket;9 10 11 7 class Player : public WorldEntity 12 8 { 9 friend class World; 13 10 14 11 public: 15 Player ( );12 Player (bool isFree); 16 13 ~Player (); 17 14 18 /* position of the spacecraft */ 19 float xCor; 20 float yCor; 21 float zCor; 15 virtual void post_spawn (); 16 virtual void tick (float time); 17 virtual void hit (WorldEntity* weapon, Vector loc); 18 virtual void destroy (); 19 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 20 virtual void command (Command* cmd); 22 21 23 float collisionRadius; 22 virtual void draw (); 23 virtual void get_lookat (Location* locbuf); 24 24 25 26 /* this player wanna shoot? so include a ref to ShootLaser */ 27 ShootLaser* shootLaser; 28 ShootRocket* shootRocket; 29 30 void setPosition(float x, float y, float z); 31 void getPosition(float* x, float* y, float* z); 32 void setCollisionRadius(float radius); 33 void paint(); 34 void goX(float x); 35 void goY(float y); 36 void goZ(float x); 37 void shoot(int n); 38 // void addIO(InputOutput *io); 39 void drawPlayer(void); 25 virtual void left_world (); 40 26 41 27 private: 42 43 28 bool bUp, bDown, bLeft, bRight, bAscend, bDescend; 29 bool bFire; 30 Vector velocity; 31 float travel_speed; 32 float acceleration; 33 34 void move (float time); 35 44 36 }; 45 37 -
orxonox/branches/chris/src/vector.h
r2080 r2096 12 12 #define PI 3.14159265359f 13 13 14 //! 3D vector 15 /** 16 Class for 3-dimensional vector calculation 17 18 Supports all common vector operations (dot, cross, lenght and so on) 19 */ 14 CommandNode:: 20 15 class Vector { 21 16 -
orxonox/branches/chris/src/world.cc
r2080 r2096 223 223 224 224 // create a player 225 Worldentity* myPlayer = spawn<Player>(); 225 226 226 227 // bind input 228 Orxonox *orx = Orxonox::getInstance(); 229 orx->get_localinput()->bind (myPlayer); 230 227 231 // bind camera 228 } 232 orx->get_camera()->bind (myPlayer); 233 } -
orxonox/branches/chris/src/world.h
r2080 r2096 10 10 11 11 template<class T> T* spawn<T>(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity 12 template<class T> T* spawn<T>(Placement* plc, WorldEntity* owner = NULL) 12 13 13 14 void time_slice (Uint32 deltaT); -
orxonox/branches/chris/src/world_entity.cc
r2080 r2096 45 45 WorldEntity::~WorldEntity () {} 46 46 47 Location* WorldEntity::get Location ()47 Location* WorldEntity::get_location () 48 48 { 49 49 return &loc; 50 50 } 51 51 52 Placement* WorldEntity::get Placement ()52 Placement* WorldEntity::get_placement () 53 53 { 54 54 return &place; … … 152 152 owner = spawnowner; 153 153 } 154 -
orxonox/branches/chris/src/world_entity.h
r2080 r2096 20 20 Placement* get_placement (); 21 21 void set_collision (CollisionCluster* newhull); 22 22 23 23 //void addAbility(Ability* ability); 24 24 //void removeAbility(Ability* ability);
Note: See TracChangeset
for help on using the changeset viewer.