00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #ifndef VRS_SG_CAMERAPATHRECORDER_H
00066 #define VRS_SG_CAMERAPATHRECORDER_H
00067
00068 #include <vrs/vector.h>
00069 #include <vrs/time.h>
00070 #include <vrs/sg/behaviornode.h>
00071 #include <vrs/image/avimaker.h>
00072
00073 namespace VRS {
00074
00075 class LookAt;
00076 class KeyEvent;
00077 class TimeEvent;
00078 class Canvas;
00079 template<typename T> class Array;
00080 class PathNavigation;
00081
00087 class VRS_CORE_API CameraPathRecorder : public BehaviorNode {
00088
00089 public:
00090 CameraPathRecorder(SO<VRS::LookAt> lookAt);
00091
00092 void setMaxFramesPerSecond(unsigned int frames);
00096 unsigned int getMaxFramesPerSecond() const;
00097
00098 enum State { OFF, RECORDING, PLAYING };
00099 VRS_SERIALIZABLE_CLASS_ENUM(State);
00100
00101 State getState() const;
00103
00104 void startRecording();
00109 void startPlaying();
00112 void stop();
00115 void savePath(const std::string& fileName);
00116 void loadPath(const std::string& fileName);
00119 void enableKeys(unsigned char recordKey, unsigned char playKey, unsigned char stopKey,
00120 unsigned char loadKey, unsigned char saveKey, const std::string& file);
00122 void disableKeys();
00123
00124
00125 void recordVideo(
00126 SO<Canvas> canvas,
00127 unsigned int frameRate = 25,
00128 unsigned int width = 800,
00129 unsigned int height = 600,
00130 const std::string& exportDirectory = "",
00131 const std::string& exportImageFileName = "image",
00132 const std::string& exportImageFormat = ".bmp",
00133 PathNavigation *pathNavigation = 0,
00134 VRS::VideoCompressor* compressor = NULL
00135 );
00147 void enableVideoExport(
00148 unsigned char recordKey,
00149 SO<Canvas> canvas,
00150 unsigned int frameRate = 25,
00151 unsigned int width = 800,
00152 unsigned int height = 600,
00153 const std::string& exportDirectory = "",
00154 const std::string& exportImageFileName = "image",
00155 const std::string& exportImageFormat = ".bmp"
00156 );
00157 void disableVideoExport();
00162 SO<Iterator<Vector> > getKeyPositions() const;
00163 SO<Iterator<Vector> > getKeyDirections() const;
00164 SO<Iterator<double> > getKeyTimes() const;
00168
00169
00170 void setKeyFrames(SO<Iterator<Vector> > keyPositions, SO<Iterator<Vector> > keyDirections, SO<Iterator<double> > keyTimes);
00171
00175 void setPBufferEnabled(bool yesNo = false);
00176 bool getPBufferEnabled() const;
00177
00182 bool getInterpolatedView(double elapsedTime, SO<LookAt> target) const;
00183
00184 VRS_TYPEINFO(CameraPathRecorder, BehaviorNode);
00185 VRS_SERIALIZABLE(CameraPathRecorder);
00186
00187 private:
00188
00189 CameraPathRecorder();
00190
00191 virtual BehaviorNode::InvalidationHint handle(Event* event);
00192
00193 BehaviorNode::InvalidationHint onTimer(SO<TimeEvent> te);
00194 BehaviorNode::InvalidationHint onKey(SO<KeyEvent> ke);
00195
00196 State state_;
00197 unsigned int maxFramesPerSecond_;
00198 SO<Array<Vector> > positions_;
00199 SO<Array<Vector> > directions_;
00200 SO<Array<double> > times_;
00201 SO<LookAt> lookAt_;
00202 double elapsedTime_;
00203 unsigned int renderedFrames_;
00204
00205 bool enableKeys_;
00206 unsigned char recordKey_;
00207 unsigned char playKey_;
00208 unsigned char stopKey_;
00209 unsigned char loadKey_;
00210 unsigned char saveKey_;
00211 std::string fileName_;
00212
00213 static std::string KeyString;
00214 static std::string PathHeaderString;
00215
00216
00217 bool videoExportKeyEnabled_;
00218 unsigned int videoFrameRate_;
00219 unsigned int videoWidth_;
00220 unsigned int videoHeight_;
00221 unsigned char videoExportKey_;
00222 SO<Canvas> canvas_;
00223 std::string exportDirectory_;
00224 std::string exportImageFileName_;
00225 std::string exportImageFormat_;
00226
00227 bool m_enablePBuffer;
00228 };
00229
00230
00231 }
00232
00233 #endif // VRS_SG_CAMERAPATHRECORDER_H
00234
00235