cameraSpline.h
Engine/source/T3D/cameraSpline.h
Classes:
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24 25#ifndef _CAMERASPLINE_H_ 26#define _CAMERASPLINE_H_ 27 28#include "math/mMath.h" 29#include "core/util/tVector.h" 30 31//---------------------------------------------------------------------------- 32class CameraSpline 33{ 34public: 35 struct Knot 36 { 37 public: 38 Point3F mPosition; 39 QuatF mRotation; 40 F32 mSpeed; /// in meters per second 41 enum Type { 42 NORMAL, 43 POSITION_ONLY, 44 KINK, 45 NUM_TYPE_BITS = 2 46 }mType; 47 48 enum Path { 49 LINEAR, 50 SPLINE, 51 NUM_PATH_BITS = 1 52 }mPath; 53 54 F32 mDistance; 55 Knot *prev; 56 Knot *next; 57 58 Knot(); 59 Knot(const Knot &k); 60 Knot(const Point3F &p, const QuatF &r, F32 s, Knot::Type type = NORMAL, Knot::Path path = SPLINE); 61 }; 62 63 64 CameraSpline(); 65 ~CameraSpline(); 66 67 bool isEmpty() { return (mFront == NULL); } 68 S32 size() { return mSize; } 69 Knot* remove(Knot *w); 70 void removeAll(); 71 72 Knot* front() { return mFront; } 73 Knot* back() { return (mFront == NULL) ? NULL : mFront->prev; } 74 75 void push_back(Knot *w); 76 void push_front(Knot *w) { push_back(w); mFront = w; mIsMapDirty = true; } 77 78 Knot* getKnot(S32 i); 79 Knot* next(Knot *k) { return (k && k->next == mFront) ? k : k->next; } 80 Knot* prev(Knot *k) { return (k && k == mFront) ? k : k->prev; } 81 82 F32 advanceTime(F32 t, S32 delta_ms); 83 F32 advanceDist(F32 t, F32 meters); 84 void value(F32 t, Knot *result, bool skip_rotation=false); 85 86 F32 getDistance(F32 t); 87 F32 getTime(F32 d); 88 89 void renderTimeMap(); 90 91 92private: 93 Knot *mFront; 94 S32 mSize; 95 bool mIsMapDirty; 96 97 struct TimeMap { 98 F32 mTime; 99 F32 mDistance; 100 }; 101 102 Vector<TimeMap> mTimeMap; 103 void buildTimeMap(); 104}; 105 106 107 108 109#endif 110