Last change
on this file since 2080 was
2080,
checked in by chris, 20 years ago
|
orxonox/branches/chris: Implemented basic track and spawning functionality. Added a function to convert a Rotation into a glmatrix. Implemented operator* in Rotation. Refined World, made World friend class of world_entity. Implemented camera functionality (can now be bound to the worldentity it should focus on).
|
File size:
1.4 KB
|
Rev | Line | |
---|
[2068] | 1 | |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | orxonox - the future of 3D-vertical-scrollers |
---|
| 5 | |
---|
| 6 | Copyright (C) 2004 orx |
---|
| 7 | |
---|
| 8 | This program is free software; you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | any later version. |
---|
| 12 | |
---|
| 13 | ### File Specific: |
---|
[2080] | 14 | main-programmer: Christian Meyer |
---|
[2068] | 15 | co-programmer: ... |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #include "track.h" |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | using namespace std; |
---|
| 22 | |
---|
[2080] | 23 | Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish) |
---|
[2068] | 24 | { |
---|
[2080] | 25 | ID = number; |
---|
| 26 | offset = start; |
---|
| 27 | end = finish; |
---|
| 28 | nextID = next; |
---|
[2068] | 29 | } |
---|
| 30 | |
---|
| 31 | Track::~Track () |
---|
| 32 | { |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | void Track::map_camera (Location* lookat, Placement* camplc) |
---|
| 36 | { |
---|
[2080] | 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); |
---|
[2068] | 42 | } |
---|
| 43 | |
---|
[2080] | 44 | bool Track::map_coords (Location* loc, Placement* plc) |
---|
[2068] | 45 | { |
---|
[2080] | 46 | Line trace(*offset, *end - *offset); |
---|
| 47 | float l = trace.len (); |
---|
[2068] | 48 | |
---|
[2080] | 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; |
---|
[2068] | 62 | } |
---|
| 63 | |
---|
[2080] | 64 | void Track::post_enter (WorldEntity* entity) |
---|
| 65 | { |
---|
| 66 | } |
---|
[2068] | 67 | |
---|
[2080] | 68 | void Track::post_leave (WorldEntity* entity) |
---|
| 69 | { |
---|
| 70 | } |
---|
[2068] | 71 | |
---|
[2080] | 72 | void Track::tick (float deltaT) |
---|
| 73 | { |
---|
| 74 | } |
---|
[2068] | 75 | |
---|
| 76 | |
---|
[2080] | 77 | |
---|
| 78 | |
---|
| 79 | |
---|
Note: See
TracBrowser
for help on using the repository browser.