00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __SPLINES_H
00023 #define __SPLINES_H
00024
00025 extern "C" {
00026 #ifdef Q3RADIANT
00027 #include "../qgl.h"
00028 #else
00029 #include "../renderer/qgl.h"
00030 #endif
00031 }
00032 #include "util_list.h"
00033 #include "util_str.h"
00034 #include "math_vector.h"
00035
00036 typedef int fileHandle_t;
00037
00038 extern void glBox(idVec3_t &color, idVec3_t &point, float size);
00039 extern void glLabeledPoint(idVec3_t &color, idVec3_t &point, float size, const char *label);
00040
00041 static vec4_t blue(0, 0, 1, 1);
00042 static vec4_t red(1, 0, 0, 1);
00043
00044 class idPointListInterface {
00045 public:
00046 idPointListInterface() {
00047 selectedPoints.Clear();
00048 };
00049 ~idPointListInterface() {};
00050
00051 virtual int numPoints() {
00052 return 0;
00053 }
00054
00055 virtual void addPoint(const float x, const float y, const float z) {}
00056 virtual void addPoint(const idVec3_t &v) {}
00057 virtual void removePoint(int index) {}
00058 virtual idVec3_t *getPoint(int index) { return NULL; }
00059
00060 int selectPointByRay(float ox, float oy, float oz, float dx, float dy, float dz, bool single) {
00061 idVec3_t origin(ox, oy, oz);
00062 idVec3_t dir(dx, dy, dz);
00063 return selectPointByRay(origin, dir, single);
00064 }
00065
00066 int selectPointByRay(const idVec3_t origin, const idVec3_t direction, bool single) {
00067 int i, besti, count;
00068 float d, bestd;
00069 idVec3_t temp, temp2;
00070
00071
00072 besti = -1;
00073 bestd = 8;
00074 count = numPoints();
00075
00076 for (i=0; i < count; i++) {
00077 temp = *getPoint(i);
00078 temp2 = temp;
00079 temp -= origin;
00080 d = DotProduct(temp, direction);
00081 __VectorMA (origin, d, direction, temp);
00082 temp2 -= temp;
00083 d = temp2.Length();
00084 if (d <= bestd) {
00085 bestd = d;
00086 besti = i;
00087 }
00088 }
00089
00090 if (besti >= 0) {
00091 selectPoint(besti, single);
00092 }
00093
00094 return besti;
00095 }
00096
00097 int isPointSelected(int index) {
00098 int count = selectedPoints.Num();
00099 for (int i = 0; i < count; i++) {
00100 if (selectedPoints[i] == index) {
00101 return i;
00102 }
00103 }
00104 return -1;
00105 }
00106
00107 int selectPoint(int index, bool single) {
00108 if (index >= 0 && index < numPoints()) {
00109 if (single) {
00110 deselectAll();
00111 } else {
00112 if (isPointSelected(index) >= 0) {
00113 selectedPoints.Remove(index);
00114 }
00115 }
00116 return selectedPoints.Append(index);
00117 }
00118 return -1;
00119 }
00120
00121 void selectAll() {
00122 selectedPoints.Clear();
00123 for (int i = 0; i < numPoints(); i++) {
00124 selectedPoints.Append(i);
00125 }
00126 }
00127
00128 void deselectAll() {
00129 selectedPoints.Clear();
00130 }
00131
00132 int numSelectedPoints();
00133
00134 idVec3_t *getSelectedPoint(int index) {
00135 assert(index >= 0 && index < numSelectedPoints());
00136 return getPoint(selectedPoints[index]);
00137 }
00138
00139 virtual void updateSelection(float x, float y, float z) {
00140 idVec3_t move(x, y, z);
00141 updateSelection(move);
00142 }
00143
00144 virtual void updateSelection(const idVec3_t &move) {
00145 int count = selectedPoints.Num();
00146 for (int i = 0; i < count; i++) {
00147 *getPoint(selectedPoints[i]) += move;
00148 }
00149 }
00150
00151 void drawSelection() {
00152 int count = selectedPoints.Num();
00153 for (int i = 0; i < count; i++) {
00154 glBox(red, *getPoint(selectedPoints[i]), 4);
00155 }
00156 }
00157
00158 protected:
00159 idList<int> selectedPoints;
00160
00161 };
00162
00163
00164 class idSplineList {
00165
00166 public:
00167
00168 idSplineList() {
00169 clear();
00170 }
00171
00172 idSplineList(const char *p) {
00173 clear();
00174 name = p;
00175 };
00176
00177 ~idSplineList() {
00178 clear();
00179 };
00180
00181 void clearControl() {
00182 for (int i = 0; i < controlPoints.Num(); i++) {
00183 delete controlPoints[i];
00184 }
00185 controlPoints.Clear();
00186 }
00187
00188 void clearSpline() {
00189 for (int i = 0; i < splinePoints.Num(); i++) {
00190 delete splinePoints[i];
00191 }
00192 splinePoints.Clear();
00193 }
00194
00195 void parse(const char *(*text));
00196 void write(fileHandle_t file, const char *name);
00197
00198 void clear() {
00199 clearControl();
00200 clearSpline();
00201 splineTime.Clear();
00202 selected = NULL;
00203 dirty = true;
00204 activeSegment = 0;
00205 granularity = 0.025;
00206 pathColor.set(1.0, 0.5, 0.0);
00207 controlColor.set(0.7, 0.0, 1.0);
00208 segmentColor.set(0.0, 0.0, 1.0);
00209 activeColor.set(1.0, 0.0, 0.0);
00210 }
00211
00212 void initPosition(long startTime, long totalTime);
00213 const idVec3_t *getPosition(long time);
00214
00215
00216 void draw(bool editMode);
00217 void addToRenderer();
00218
00219 void setSelectedPoint(idVec3_t *p);
00220 idVec3_t *getSelectedPoint() {
00221 return selected;
00222 }
00223
00224 void addPoint(const idVec3_t &v) {
00225 controlPoints.Append(new idVec3_t(v));
00226 dirty = true;
00227 }
00228
00229 void addPoint(float x, float y, float z) {
00230 controlPoints.Append(new idVec3_t(x, y, z));
00231 dirty = true;
00232 }
00233
00234 void updateSelection(const idVec3_t &move);
00235
00236 void startEdit() {
00237 editMode = true;
00238 }
00239
00240 void stopEdit() {
00241 editMode = false;
00242 }
00243
00244 void buildSpline();
00245
00246 void setGranularity(float f) {
00247 granularity = f;
00248 }
00249
00250 float getGranularity() {
00251 return granularity;
00252 }
00253
00254 int numPoints() {
00255 return controlPoints.Num();
00256 }
00257
00258 idVec3_t *getPoint(int index) {
00259 assert(index >= 0 && index < controlPoints.Num());
00260 return controlPoints[index];
00261 }
00262
00263 idVec3_t *getSegmentPoint(int index) {
00264 assert(index >= 0 && index < splinePoints.Num());
00265 return splinePoints[index];
00266 }
00267
00268
00269 void setSegmentTime(int index, int time) {
00270 assert(index >= 0 && index < splinePoints.Num());
00271 splineTime[index] = time;
00272 }
00273
00274 int getSegmentTime(int index) {
00275 assert(index >= 0 && index < splinePoints.Num());
00276 return splineTime[index];
00277 }
00278 void addSegmentTime(int index, int time) {
00279 assert(index >= 0 && index < splinePoints.Num());
00280 splineTime[index] += time;
00281 }
00282
00283 float totalDistance();
00284
00285 static idVec3_t zero;
00286
00287 int getActiveSegment() {
00288 return activeSegment;
00289 }
00290
00291 void setActiveSegment(int i) {
00292
00293 activeSegment = i;
00294 }
00295
00296 int numSegments() {
00297 return splinePoints.Num();
00298 }
00299
00300 void setColors(idVec3_t &path, idVec3_t &segment, idVec3_t &control, idVec3_t &active) {
00301 pathColor = path;
00302 segmentColor = segment;
00303 controlColor = control;
00304 activeColor = active;
00305 }
00306
00307 const char *getName() {
00308 return name.c_str();
00309 }
00310
00311 void setName(const char *p) {
00312 name = p;
00313 }
00314
00315 bool validTime() {
00316 if (dirty) {
00317 buildSpline();
00318 }
00319
00320
00321 return (bool)(splineTime.Num() > 0 && splineTime.Num() == splinePoints.Num());
00322 }
00323
00324 void setTime(long t) {
00325 time = t;
00326 }
00327
00328 void setBaseTime(long t) {
00329 baseTime = t;
00330 }
00331
00332 protected:
00333 idStr name;
00334 float calcSpline(int step, float tension);
00335 idList<idVec3_t*> controlPoints;
00336 idList<idVec3_t*> splinePoints;
00337 idList<float> splineTime;
00338 idVec3_t *selected;
00339 idVec3_t pathColor, segmentColor, controlColor, activeColor;
00340 float granularity;
00341 bool editMode;
00342 bool dirty;
00343 int activeSegment;
00344 long baseTime;
00345 long time;
00346 friend class idCamera;
00347 };
00348
00349
00350
00351 struct idVelocity {
00352 idVelocity(long start, long duration, float s) {
00353 startTime = start;
00354 time = duration;
00355 speed = s;
00356 }
00357 long startTime;
00358 long time;
00359 float speed;
00360 };
00361
00362
00363
00364 class idCameraPosition : public idPointListInterface {
00365 public:
00366
00367 virtual void clear() {
00368 editMode = false;
00369 for (int i = 0; i < velocities.Num(); i++) {
00370 delete velocities[i];
00371 velocities[i] = NULL;
00372 }
00373 velocities.Clear();
00374 }
00375
00376 idCameraPosition(const char *p) {
00377 name = p;
00378 }
00379
00380 idCameraPosition() {
00381 time = 0;
00382 name = "position";
00383 }
00384
00385 idCameraPosition(long t) {
00386 time = t;
00387 }
00388
00389 virtual ~idCameraPosition() {
00390 clear();
00391 }
00392
00393
00394
00395
00396
00397 enum positionType {
00398 FIXED = 0x00,
00399 INTERPOLATED,
00400 SPLINE,
00401 POSITION_COUNT
00402 };
00403
00404
00405 virtual void start(long t) {
00406 startTime = t;
00407 }
00408
00409 long getTime() {
00410 return time;
00411 }
00412
00413 virtual void setTime(long t) {
00414 time = t;
00415 }
00416
00417 float getVelocity(long t) {
00418 long check = t - startTime;
00419 for (int i = 0; i < velocities.Num(); i++) {
00420 if (check >= velocities[i]->startTime && check <= velocities[i]->startTime + velocities[i]->time) {
00421 return velocities[i]->speed;
00422 }
00423 }
00424 return baseVelocity;
00425 }
00426
00427 void addVelocity(long start, long duration, float speed) {
00428 velocities.Append(new idVelocity(start, duration, speed));
00429 }
00430
00431 virtual const idVec3_t *getPosition(long t) {
00432 assert(true);
00433 return NULL;
00434 }
00435
00436 virtual void draw(bool editMode) {};
00437
00438 virtual void parse(const char *(*text)) {};
00439 virtual void write(fileHandle_t file, const char *name);
00440 virtual bool parseToken(const char *key, const char *(*text));
00441
00442 const char *getName() {
00443 return name.c_str();
00444 }
00445
00446 void setName(const char *p) {
00447 name = p;
00448 }
00449
00450 virtual startEdit() {
00451 editMode = true;
00452 }
00453
00454 virtual stopEdit() {
00455 editMode = false;
00456 }
00457
00458 virtual void draw() {};
00459
00460 const char *typeStr() {
00461 return positionStr[static_cast<int>(type)];
00462 }
00463
00464 void calcVelocity(float distance) {
00465 float secs = (float)time / 1000;
00466 baseVelocity = distance / secs;
00467 }
00468
00469 protected:
00470 static const char* positionStr[POSITION_COUNT];
00471 long startTime;
00472 long time;
00473 idCameraPosition::positionType type;
00474 idStr name;
00475 bool editMode;
00476 idList<idVelocity*> velocities;
00477 float baseVelocity;
00478 };
00479
00480 class idFixedPosition : public idCameraPosition {
00481 public:
00482
00483 void init() {
00484 pos.Zero();
00485 type = idCameraPosition::FIXED;
00486 }
00487
00488 idFixedPosition() : idCameraPosition() {
00489 init();
00490 }
00491
00492 idFixedPosition(idVec3_t p) : idCameraPosition() {
00493 init();
00494 pos = p;
00495 }
00496
00497 virtual void addPoint(const idVec3_t &v) {
00498 pos = v;
00499 }
00500
00501 virtual void addPoint(const float x, const float y, const float z) {
00502 pos.set(x, y, z);
00503 }
00504
00505
00506 ~idFixedPosition() {
00507 }
00508
00509 virtual const idVec3_t *getPosition(long t) {
00510 return &pos;
00511 }
00512
00513 void parse(const char *(*text));
00514 void write(fileHandle_t file, const char *name);
00515
00516 virtual int numPoints() {
00517 return 1;
00518 }
00519
00520 virtual idVec3_t *getPoint(int index) {
00521 if (index != 0) {
00522 assert(true);
00523 };
00524 return &pos;
00525 }
00526
00527 virtual void draw(bool editMode) {
00528 glLabeledPoint(blue, pos, (editMode) ? 5 : 3, "Fixed point");
00529 }
00530
00531 protected:
00532 idVec3_t pos;
00533 };
00534
00535 class idInterpolatedPosition : public idCameraPosition {
00536 public:
00537
00538 void init() {
00539 type = idCameraPosition::INTERPOLATED;
00540 first = true;
00541 startPos.Zero();
00542 endPos.Zero();
00543 }
00544
00545 idInterpolatedPosition() : idCameraPosition() {
00546 init();
00547 }
00548
00549 idInterpolatedPosition(idVec3_t start, idVec3_t end, long time) : idCameraPosition(time) {
00550 init();
00551 startPos = start;
00552 endPos = end;
00553 }
00554
00555 ~idInterpolatedPosition() {
00556 }
00557
00558 virtual const idVec3_t *getPosition(long t);
00559
00560 void parse(const char *(*text));
00561 void write(fileHandle_t file, const char *name);
00562
00563 virtual int numPoints() {
00564 return 2;
00565 }
00566
00567 virtual idVec3_t *getPoint(int index) {
00568 assert(index >= 0 && index < 2);
00569 if (index == 0) {
00570 return &startPos;
00571 }
00572 return &endPos;
00573 }
00574
00575 virtual void addPoint(const float x, const float y, const float z) {
00576 if (first) {
00577 startPos.set(x, y, z);
00578 first = false;
00579 } else {
00580 endPos.set(x, y, z);
00581 first = true;
00582 }
00583 }
00584
00585 virtual void addPoint(const idVec3_t &v) {
00586 if (first) {
00587 startPos = v;
00588 first = false;
00589 } else {
00590 endPos = v;
00591 first = true;
00592 }
00593 }
00594
00595 virtual void draw(bool editMode) {
00596 glLabeledPoint(blue, startPos, (editMode) ? 5 : 3, "Start interpolated");
00597 glLabeledPoint(blue, endPos, (editMode) ? 5 : 3, "End interpolated");
00598 qglBegin(GL_LINES);
00599 qglVertex3fv(startPos);
00600 qglVertex3fv(endPos);
00601 qglEnd();
00602 }
00603
00604 virtual void start(long t) {
00605 idCameraPosition::start(t);
00606 lastTime = startTime;
00607 distSoFar = 0.0;
00608 idVec3_t temp = startPos;
00609 temp -= endPos;
00610 calcVelocity(temp.Length());
00611 }
00612
00613 protected:
00614 bool first;
00615 idVec3_t startPos;
00616 idVec3_t endPos;
00617 long lastTime;
00618 float distSoFar;
00619 };
00620
00621 class idSplinePosition : public idCameraPosition {
00622 public:
00623
00624 void init() {
00625 type = idCameraPosition::SPLINE;
00626 }
00627
00628 idSplinePosition() : idCameraPosition() {
00629 init();
00630 }
00631
00632 idSplinePosition(long time) : idCameraPosition(time) {
00633 init();
00634 }
00635
00636 ~idSplinePosition() {
00637 }
00638
00639 virtual void start(long t) {
00640 idCameraPosition::start(t);
00641 target.initPosition(t, time);
00642 calcVelocity(target.totalDistance());
00643 }
00644
00645 virtual const idVec3_t *getPosition(long t) {
00646 return target.getPosition(t);
00647 }
00648
00649
00650
00651 void addControlPoint(idVec3_t &v) {
00652 target.addPoint(v);
00653 }
00654
00655 void parse(const char *(*text));
00656 void write(fileHandle_t file, const char *name);
00657
00658 virtual int numPoints() {
00659 return target.numPoints();
00660 }
00661
00662 virtual idVec3_t *getPoint(int index) {
00663 return target.getPoint(index);
00664 }
00665
00666 virtual void addPoint(const idVec3_t &v) {
00667 target.addPoint(v);
00668 }
00669
00670 virtual void addPoint(const float x, const float y, const float z) {
00671 target.addPoint(x, y, z);
00672 }
00673
00674 virtual void draw(bool editMode) {
00675 target.draw(editMode);
00676 }
00677
00678 virtual void updateSelection(const idVec3_t &move) {
00679 idCameraPosition::updateSelection(move);
00680 target.buildSpline();
00681 }
00682
00683 protected:
00684 idSplineList target;
00685 };
00686
00687 class idCameraFOV {
00688 public:
00689
00690 idCameraFOV() {
00691 time = 0;
00692 fov = 90;
00693 }
00694
00695 idCameraFOV(int v) {
00696 time = 0;
00697 fov = v;
00698 }
00699
00700 idCameraFOV(int s, int e, long t) {
00701 startFOV = s;
00702 endFOV = e;
00703 time = t;
00704 }
00705
00706
00707 ~idCameraFOV(){}
00708
00709 void setFOV(float f) {
00710 fov = f;
00711 }
00712
00713 float getFOV(long t) {
00714 if (time) {
00715 assert(startTime);
00716 float percent = t / startTime;
00717 float temp = startFOV - endFOV;
00718 temp *= percent;
00719 fov = startFOV + temp;
00720 }
00721 return fov;
00722 }
00723
00724 int start(long t) {
00725 startTime = t;
00726 }
00727
00728 void parse(const char *(*text));
00729 void write(fileHandle_t file, const char *name);
00730
00731 protected:
00732 float fov;
00733 float startFOV;
00734 float endFOV;
00735 int startTime;
00736 int time;
00737 };
00738
00739
00740
00741
00742 class idCameraEvent {
00743 public:
00744 enum eventType {
00745 EVENT_NA = 0x00,
00746 EVENT_WAIT,
00747 EVENT_TARGETWAIT,
00748 EVENT_SPEED,
00749 EVENT_TARGET,
00750 EVENT_SNAPTARGET,
00751 EVENT_FOV,
00752 EVENT_SCRIPT,
00753 EVENT_TRIGGER,
00754 EVENT_STOP,
00755 EVENT_COUNT
00756 };
00757
00758 static const char* eventStr[EVENT_COUNT];
00759
00760 idCameraEvent() {
00761 paramStr = "";
00762 type = EVENT_NA;
00763 time = 0;
00764 }
00765
00766 idCameraEvent(eventType t, const char *param, long n) {
00767 type = t;
00768 paramStr = param;
00769 time = n;
00770 }
00771
00772 ~idCameraEvent() {};
00773
00774 eventType getType() {
00775 return type;
00776 }
00777
00778 const char *typeStr() {
00779 return eventStr[static_cast<int>(type)];
00780 }
00781
00782 const char *getParam() {
00783 return paramStr.c_str();
00784 }
00785
00786 long getTime() {
00787 return time;
00788 }
00789
00790 void setTime(long n) {
00791 time = n;
00792 }
00793
00794 void parse(const char *(*text));
00795 void write(fileHandle_t file, const char *name);
00796
00797 void setTriggered(bool b) {
00798 triggered = b;
00799 }
00800
00801 bool getTriggered() {
00802 return triggered;
00803 }
00804
00805 protected:
00806 eventType type;
00807 idStr paramStr;
00808 long time;
00809 bool triggered;
00810
00811 };
00812
00813 class idCameraDef {
00814 public:
00815
00816 void clear() {
00817 currentCameraPosition = 0;
00818 cameraRunning = false;
00819 lastDirection.Zero();
00820 baseTime = 30;
00821 activeTarget = 0;
00822 name = "camera01";
00823 fov.setFOV(90);
00824 int i;
00825 for (i = 0; i < targetPositions.Num(); i++) {
00826 delete targetPositions[i];
00827 }
00828 for (i = 0; i < events.Num(); i++) {
00829 delete events[i];
00830 }
00831 delete cameraPosition;
00832 cameraPosition = NULL;
00833 events.Clear();
00834 targetPositions.Clear();
00835 }
00836
00837 idCameraPosition *startNewCamera(idCameraPosition::positionType type) {
00838 clear();
00839 if (type == idCameraPosition::SPLINE) {
00840 cameraPosition = new idSplinePosition();
00841 } else if (type == idCameraPosition::INTERPOLATED) {
00842 cameraPosition = new idInterpolatedPosition();
00843 } else {
00844 cameraPosition = new idFixedPosition();
00845 }
00846 return cameraPosition;
00847 }
00848
00849 idCameraDef() {
00850 clear();
00851 }
00852
00853 ~idCameraDef() {
00854 clear();
00855 }
00856
00857 void addEvent(idCameraEvent::eventType t, const char *param, long time);
00858
00859 void addEvent(idCameraEvent *event);
00860
00861 static int sortEvents(const void *p1, const void *p2);
00862
00863 int numEvents() {
00864 return events.Num();
00865 }
00866
00867 idCameraEvent *getEvent(int index) {
00868 assert(index >= 0 && index < events.Num());
00869 return events[index];
00870 }
00871
00872 void parse(const char *(*text));
00873 bool load(const char *filename);
00874 void save(const char *filename);
00875
00876 void buildCamera();
00877
00878
00879
00880
00881
00882 static idCameraPosition *newFromType(idCameraPosition::positionType t) {
00883 switch (t) {
00884 case idCameraPosition::FIXED : return new idFixedPosition();
00885 case idCameraPosition::INTERPOLATED : return new idInterpolatedPosition();
00886 case idCameraPosition::SPLINE : return new idSplinePosition();
00887 };
00888 return NULL;
00889 }
00890
00891 void addTarget(const char *name, idCameraPosition::positionType type);
00892
00893 idCameraPosition *getActiveTarget() {
00894 if (targetPositions.Num() == 0) {
00895 addTarget(NULL, idCameraPosition::FIXED);
00896 }
00897 return targetPositions[activeTarget];
00898 }
00899
00900 idCameraPosition *getActiveTarget(int index) {
00901 if (targetPositions.Num() == 0) {
00902 addTarget(NULL, idCameraPosition::FIXED);
00903 return targetPositions[0];
00904 }
00905 return targetPositions[index];
00906 }
00907
00908 int numTargets() {
00909 return targetPositions.Num();
00910 }
00911
00912
00913 void setActiveTargetByName(const char *name) {
00914 for (int i = 0; i < targetPositions.Num(); i++) {
00915 if (stricmp(name, targetPositions[i]->getName()) == 0) {
00916 setActiveTarget(i);
00917 return;
00918 }
00919 }
00920 }
00921
00922 void setActiveTarget(int index) {
00923 assert(index >= 0 && index < targetPositions.Num());
00924 activeTarget = index;
00925 }
00926
00927 void setRunning(bool b) {
00928 cameraRunning = b;
00929 }
00930
00931 void setBaseTime(float f) {
00932 baseTime = f;
00933 }
00934
00935 float getBaseTime() {
00936 return baseTime;
00937 }
00938
00939 float getTotalTime() {
00940 return totalTime;
00941 }
00942
00943 void startCamera(long t);
00944 void stopCamera() {
00945 cameraRunning = true;
00946 }
00947 void getActiveSegmentInfo(int segment, idVec3_t &origin, idVec3_t &direction, float *fv);
00948
00949 bool getCameraInfo(long time, idVec3_t &origin, idVec3_t &direction, float *fv);
00950 bool getCameraInfo(long time, float *origin, float *direction, float *fv) {
00951 idVec3_t org, dir;
00952 org[0] = origin[0];
00953 org[1] = origin[1];
00954 org[2] = origin[2];
00955 dir[0] = direction[0];
00956 dir[1] = direction[1];
00957 dir[2] = direction[2];
00958 bool b = getCameraInfo(time, org, dir, fv);
00959 origin[0] = org[0];
00960 origin[1] = org[1];
00961 origin[2] = org[2];
00962 direction[0] = dir[0];
00963 direction[1] = dir[1];
00964 direction[2] = dir[2];
00965 return b;
00966 }
00967
00968 void draw(bool editMode) {
00969
00970
00971 if (cameraPosition) {
00972 cameraPosition->draw((bool)((editMode || cameraRunning) && cameraEdit));
00973 int count = targetPositions.Num();
00974 for (int i = 0; i < count; i++) {
00975 targetPositions[i]->draw((bool)((editMode || cameraRunning) && i == activeTarget && !cameraEdit));
00976 }
00977 }
00978 }
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 int numPoints() {
01004 if (cameraEdit) {
01005 return cameraPosition->numPoints();
01006 }
01007 return getActiveTarget()->numPoints();
01008 }
01009
01010 const idVec3_t *getPoint(int index) {
01011 if (cameraEdit) {
01012 return cameraPosition->getPoint(index);
01013 }
01014 return getActiveTarget()->getPoint(index);
01015 }
01016
01017 void stopEdit() {
01018 editMode = false;
01019 if (cameraEdit) {
01020 cameraPosition->stopEdit();
01021 } else {
01022 getActiveTarget()->stopEdit();
01023 }
01024 }
01025
01026 void startEdit(bool camera) {
01027 cameraEdit = camera;
01028 if (camera) {
01029 cameraPosition->startEdit();
01030 for (int i = 0; i < targetPositions.Num(); i++) {
01031 targetPositions[i]->stopEdit();
01032 }
01033 } else {
01034 getActiveTarget()->startEdit();
01035 cameraPosition->stopEdit();
01036 }
01037 editMode = true;
01038 }
01039
01040 bool waitEvent(int index);
01041
01042 const char *getName() {
01043 return name.c_str();
01044 }
01045
01046 void setName(const char *p) {
01047 name = p;
01048 }
01049
01050 idCameraPosition *getPositionObj() {
01051 if (cameraPosition == NULL) {
01052 cameraPosition = new idFixedPosition();
01053 }
01054 return cameraPosition;
01055 }
01056
01057 protected:
01058 idStr name;
01059 int currentCameraPosition;
01060 idVec3_t lastDirection;
01061 bool cameraRunning;
01062 idCameraPosition *cameraPosition;
01063 idList<idCameraPosition*> targetPositions;
01064 idList<idCameraEvent*> events;
01065 idCameraFOV fov;
01066 int activeTarget;
01067 float totalTime;
01068 float baseTime;
01069 long startTime;
01070
01071 bool cameraEdit;
01072 bool editMode;
01073 };
01074
01075 extern bool g_splineMode;
01076
01077 extern idCameraDef *g_splineList;
01078
01079
01080 #endif