Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/old.chris/src/track.cc @ 3500

Last change on this file since 3500 was 2141, checked in by chris, 20 years ago

orxonox/branches/chris: added lots and lots of doxygen tags

File size: 3.6 KB
Line 
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:
14   main-programmer: Christian Meyer
15   co-programmer: ...
16*/
17
18#include "track.h"
19
20using namespace std;
21
22/**
23        \brief creates a null Track part
24*/
25Track::Track ()
26{
27        ID = 0;
28        offset = NULL;
29        end = NULL;
30        nextID = 0;
31}
32
33/**
34        \brief creates a functional base Track part
35        \param number: the ID if this Track part
36        \param next: the ID of the next Track part
37        \param start: pointer to an anchor point (Vector) representing the offset of this part
38        \param finish: pointer to an anchor point (Vector) representing the end of this part
39*/
40Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish)
41{
42        ID = number;
43        offset = start;
44        end = finish;
45        nextID = next;
46}
47
48/**
49        \brief removes the Track part from memory
50*/
51Track::~Track ()
52{
53}
54
55/**
56        \brief calculate a camera Placement from a "look at"-Location
57        \param lookat: the Location the camera should be centered on
58        \param camplc: pointer to a buffer where the new camera Placement should be put into
59       
60        Theoretically you can place the camera wherever you want, but for the sake of common sense I suggest that you at least
61        try to keep the thing that should be looked at inside camera boundaries.
62*/
63void Track::map_camera (Location* lookat, Placement* camplc)
64{
65        Line trace(*offset, *end - *offset);
66        float l = trace.len ();
67       
68//      camplc->r = *offset + Vector(0,0,0.5);
69//      camplc->w = Quaternion (trace.a, Vector(0,0,1));
70        float r = (lookat->dist)*PI / l;
71        camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
72        camplc->w = Quaternion(Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r)), Vector(0,sin(r),cos(r)));
73       
74}
75
76/**
77        \brief calculate a Placement from a given Location
78        \param loc: the Location the entity is in
79        \param plc: a pointer to a buffer where the corresponding Placement should be put into
80       
81        There are no limitations to how you transform a Location into a Placement, but for the sake of placement compatibility between
82        track parts you should make sure that the resulting Placement at dist == 0 is equal to the offset Vector and the Placement at
83        dist == len() is equal to the end Vector. Elseway there will be ugly artifacts when transfering between track parts.
84*/
85bool Track::map_coords (Location* loc, Placement* plc)
86{
87        Line trace(*offset, *end - *offset);
88        float l = trace.len ();
89       
90        if( loc->dist > l)
91        {
92                loc->dist -= l;
93                loc->part = nextID;
94                return true;
95        }
96       
97        Quaternion dir(trace.a, Vector(0,0,1));
98       
99        plc->r = trace.r + (trace.a * ((loc->dist) / l)) + /*dir.apply*/(loc->pos);
100        plc->w = dir * loc->rot;
101       
102        return false;
103}
104
105/**
106        \brief this is called when a WorldEntity enters a Track part
107        \param entity: pointer to the WorldEntity in question
108       
109        You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here.
110*/
111void Track::post_enter (WorldEntity* entity)
112{
113}
114
115/**
116        \brief this is called when a WorldEntity leaves a Track part
117        \param entity: pointer to the WorldEntity in question
118       
119        You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here.
120*/
121void Track::post_leave (WorldEntity* entity)
122{
123}
124
125/**
126        \brief this is called every frame
127        \param deltaT: amount of time passed since the last frame in seconds
128       
129        Do time based or polling scripts here.
130*/
131void Track::tick (float deltaT)
132{
133}
134
135
136
137
138
Note: See TracBrowser for help on using the repository browser.