| 1 | /* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield |
|---|
| 2 | * |
|---|
| 3 | * This software is open source and may be redistributed and/or modified under |
|---|
| 4 | * the terms of the GNU General Public License (GPL) version 2.0. |
|---|
| 5 | * The full license is in LICENSE.txt file included with this distribution,. |
|---|
| 6 | * |
|---|
| 7 | * This software is distributed in the hope that it will be useful, |
|---|
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 | * include LICENSE.txt for more details. |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | #ifndef SLIDESHOWCONSTRUCTOR |
|---|
| 14 | #define SLIDESHOWCONSTRUCTOR |
|---|
| 15 | |
|---|
| 16 | #include <osg/Vec3> |
|---|
| 17 | #include <osg/Vec4> |
|---|
| 18 | #include <osg/ImageUtils> |
|---|
| 19 | #include <osg/Group> |
|---|
| 20 | #include <osg/ClearNode> |
|---|
| 21 | #include <osg/Switch> |
|---|
| 22 | #include <osg/AnimationPath> |
|---|
| 23 | #include <osg/TransferFunction> |
|---|
| 24 | #include <osg/ImageStream> |
|---|
| 25 | #include <osg/ImageSequence> |
|---|
| 26 | #include <osgText/Text> |
|---|
| 27 | #include <osgGA/GUIEventAdapter> |
|---|
| 28 | |
|---|
| 29 | #include <osgDB/FileUtils> |
|---|
| 30 | |
|---|
| 31 | #include <osgPresentation/AnimationMaterial> |
|---|
| 32 | #include <osgPresentation/SlideEventHandler> |
|---|
| 33 | |
|---|
| 34 | namespace osgPresentation |
|---|
| 35 | { |
|---|
| 36 | |
|---|
| 37 | class OSGPRESENTATION_EXPORT HUDSettings : public osg::Referenced |
|---|
| 38 | { |
|---|
| 39 | public: |
|---|
| 40 | HUDSettings(double slideDistance, float eyeOffset, unsigned int leftMask, unsigned int rightMask); |
|---|
| 41 | |
|---|
| 42 | virtual bool getModelViewMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const; |
|---|
| 43 | |
|---|
| 44 | virtual bool getInverseModelViewMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const; |
|---|
| 45 | |
|---|
| 46 | double _slideDistance; |
|---|
| 47 | double _eyeOffset; |
|---|
| 48 | unsigned int _leftMask; |
|---|
| 49 | unsigned int _rightMask; |
|---|
| 50 | |
|---|
| 51 | protected: |
|---|
| 52 | |
|---|
| 53 | virtual ~HUDSettings(); |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | class OSGPRESENTATION_EXPORT HUDTransform : public osg::Transform |
|---|
| 58 | { |
|---|
| 59 | public: |
|---|
| 60 | |
|---|
| 61 | HUDTransform(HUDSettings* hudSettings); |
|---|
| 62 | |
|---|
| 63 | virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const; |
|---|
| 64 | |
|---|
| 65 | virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const; |
|---|
| 66 | |
|---|
| 67 | protected: |
|---|
| 68 | |
|---|
| 69 | virtual ~HUDTransform(); |
|---|
| 70 | |
|---|
| 71 | osg::ref_ptr<HUDSettings> _hudSettings; |
|---|
| 72 | |
|---|
| 73 | }; |
|---|
| 74 | |
|---|
| 75 | class OSGPRESENTATION_EXPORT SlideShowConstructor |
|---|
| 76 | { |
|---|
| 77 | public: |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | enum CoordinateFrame { SLIDE, MODEL }; |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | LayerAttributes* getOrCreateLayerAttributes(osg::Node* node); |
|---|
| 85 | |
|---|
| 86 | void setDuration(osg::Node* node,double duration) |
|---|
| 87 | { |
|---|
| 88 | getOrCreateLayerAttributes(node)->setDuration(duration); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | void addKey(osg::Node* node,const KeyPosition& kp) |
|---|
| 92 | { |
|---|
| 93 | getOrCreateLayerAttributes(node)->addKey(kp); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | void addRunString(osg::Node* node, const std::string& runString) |
|---|
| 97 | { |
|---|
| 98 | getOrCreateLayerAttributes(node)->addRunString(runString); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | void setJump(osg::Node* node, const JumpData& jumpData) |
|---|
| 102 | { |
|---|
| 103 | getOrCreateLayerAttributes(node)->setJump(jumpData); |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | void addPresentationKey(const KeyPosition& kp) |
|---|
| 107 | { |
|---|
| 108 | if (!_presentationSwitch) createPresentation(); |
|---|
| 109 | if (_presentationSwitch.valid()) addKey( _presentationSwitch.get(), kp); |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | void addPresentationRunString(const std::string& runString) |
|---|
| 113 | { |
|---|
| 114 | if (!_presentationSwitch) createPresentation(); |
|---|
| 115 | if (_presentationSwitch.valid()) addRunString( _presentationSwitch.get(),runString); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | void addSlideKey(const KeyPosition& kp) |
|---|
| 119 | { |
|---|
| 120 | if (!_slide) addSlide(); |
|---|
| 121 | if (_slide.valid()) addKey(_slide.get(),kp); |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | void addSlideRunString(const std::string& runString) |
|---|
| 125 | { |
|---|
| 126 | if (!_slide) addSlide(); |
|---|
| 127 | if (_slide.valid()) addRunString(_slide.get(),runString); |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | void setSlideJump(const JumpData& jumpData) |
|---|
| 131 | { |
|---|
| 132 | if (!_slide) addSlide(); |
|---|
| 133 | if (_slide.valid()) setJump(_slide.get(),jumpData); |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | void addLayerKey(const KeyPosition& kp) |
|---|
| 137 | { |
|---|
| 138 | if (!_currentLayer) addLayer(); |
|---|
| 139 | if (_currentLayer.valid()) addKey(_currentLayer.get(),kp); |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | void addLayerRunString(const std::string& runString) |
|---|
| 143 | { |
|---|
| 144 | if (!_currentLayer) addLayer(); |
|---|
| 145 | if (_currentLayer.valid()) addRunString(_currentLayer.get(),runString); |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | void setLayerJump(const JumpData& jumpData) |
|---|
| 150 | { |
|---|
| 151 | if (!_currentLayer) addLayer(); |
|---|
| 152 | if (_currentLayer.valid()) setJump(_currentLayer.get(),jumpData); |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | struct PositionData |
|---|
| 158 | { |
|---|
| 159 | PositionData(): |
|---|
| 160 | frame(SlideShowConstructor::SLIDE), |
|---|
| 161 | position(0.0f,1.0f,0.0f), |
|---|
| 162 | //position(0.5f,0.5f,0.0f), |
|---|
| 163 | scale(1.0f,1.0f,1.0f), |
|---|
| 164 | rotate(0.0f,0.0f,0.0f,1.0f), |
|---|
| 165 | rotation(0.0f,0.0f,1.0f,0.0f), |
|---|
| 166 | absolute_path(false), |
|---|
| 167 | inverse_path(false), |
|---|
| 168 | path_time_offset(0.0), |
|---|
| 169 | path_time_multiplier(1.0f), |
|---|
| 170 | path_loop_mode(osg::AnimationPath::NO_LOOPING), |
|---|
| 171 | animation_material_time_offset(0.0), |
|---|
| 172 | animation_material_time_multiplier(1.0), |
|---|
| 173 | animation_material_loop_mode(AnimationMaterial::NO_LOOPING), |
|---|
| 174 | autoRotate(false), |
|---|
| 175 | autoScale(false), |
|---|
| 176 | hud(false) {} |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | bool requiresPosition() const |
|---|
| 180 | { |
|---|
| 181 | return (position[0]!=0.0f || position[1]!=1.0f || position[2]!=1.0f); |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | bool requiresScale() const |
|---|
| 185 | { |
|---|
| 186 | return (scale[0]!=1.0f || scale[1]!=1.0f || scale[2]!=1.0f); |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | bool requiresRotate() const |
|---|
| 190 | { |
|---|
| 191 | return rotate[0]!=0.0f; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | bool requiresAnimation() const |
|---|
| 195 | { |
|---|
| 196 | return (rotation[0]!=0.0f || !path.empty()); |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | bool requiresMaterialAnimation() const |
|---|
| 200 | { |
|---|
| 201 | return !animation_material_filename.empty() || !fade.empty(); |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | CoordinateFrame frame; |
|---|
| 205 | osg::Vec3 position; |
|---|
| 206 | osg::Vec3 scale; |
|---|
| 207 | osg::Vec4 rotate; |
|---|
| 208 | osg::Vec4 rotation; |
|---|
| 209 | std::string animation_name; |
|---|
| 210 | bool absolute_path; |
|---|
| 211 | bool inverse_path; |
|---|
| 212 | double path_time_offset; |
|---|
| 213 | double path_time_multiplier; |
|---|
| 214 | osg::AnimationPath::LoopMode path_loop_mode; |
|---|
| 215 | std::string path; |
|---|
| 216 | double animation_material_time_offset; |
|---|
| 217 | double animation_material_time_multiplier; |
|---|
| 218 | AnimationMaterial::LoopMode animation_material_loop_mode; |
|---|
| 219 | std::string animation_material_filename; |
|---|
| 220 | std::string fade; |
|---|
| 221 | bool autoRotate; |
|---|
| 222 | bool autoScale; |
|---|
| 223 | bool hud; |
|---|
| 224 | }; |
|---|
| 225 | |
|---|
| 226 | struct ModelData |
|---|
| 227 | { |
|---|
| 228 | ModelData() {} |
|---|
| 229 | |
|---|
| 230 | std::string effect; |
|---|
| 231 | std::string options; |
|---|
| 232 | }; |
|---|
| 233 | |
|---|
| 234 | struct ImageData |
|---|
| 235 | { |
|---|
| 236 | ImageData(): |
|---|
| 237 | width(1.0f), |
|---|
| 238 | height(1.0f), |
|---|
| 239 | region(0.0f,0.0f,1.0f,1.0f), |
|---|
| 240 | region_in_pixel_coords(false), |
|---|
| 241 | texcoord_rotate(0.0f), |
|---|
| 242 | loopingMode(osg::ImageStream::NO_LOOPING), |
|---|
| 243 | page(-1), |
|---|
| 244 | backgroundColor(1.0f,1.0f,1.0f,1.0f), |
|---|
| 245 | fps(30.0), |
|---|
| 246 | duration(-1.0), |
|---|
| 247 | imageSequence(false), |
|---|
| 248 | imageSequencePagingMode(osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES), |
|---|
| 249 | imageSequenceInteractionMode(PLAY_AUTOMATICALLY_LIKE_MOVIE) |
|---|
| 250 | {} |
|---|
| 251 | |
|---|
| 252 | std::string options; |
|---|
| 253 | float width; |
|---|
| 254 | float height; |
|---|
| 255 | osg::Vec4 region; |
|---|
| 256 | bool region_in_pixel_coords; |
|---|
| 257 | float texcoord_rotate; |
|---|
| 258 | osg::ImageStream::LoopingMode loopingMode; |
|---|
| 259 | int page; |
|---|
| 260 | osg::Vec4 backgroundColor; |
|---|
| 261 | double fps; |
|---|
| 262 | double duration; |
|---|
| 263 | |
|---|
| 264 | bool imageSequence; |
|---|
| 265 | osg::ImageSequence::Mode imageSequencePagingMode; |
|---|
| 266 | |
|---|
| 267 | enum ImageSequenceInteractionMode |
|---|
| 268 | { |
|---|
| 269 | PLAY_AUTOMATICALLY_LIKE_MOVIE, |
|---|
| 270 | USE_MOUSE_X_POSITION, |
|---|
| 271 | USE_MOUSE_Y_POSITION |
|---|
| 272 | }; |
|---|
| 273 | ImageSequenceInteractionMode imageSequenceInteractionMode; |
|---|
| 274 | |
|---|
| 275 | }; |
|---|
| 276 | |
|---|
| 277 | struct VolumeData |
|---|
| 278 | { |
|---|
| 279 | enum ShadingModel |
|---|
| 280 | { |
|---|
| 281 | Standard, |
|---|
| 282 | Light, |
|---|
| 283 | Isosurface, |
|---|
| 284 | MaximumIntensityProjection |
|---|
| 285 | }; |
|---|
| 286 | |
|---|
| 287 | VolumeData(): |
|---|
| 288 | shadingModel(Standard), |
|---|
| 289 | useTabbedDragger(false), |
|---|
| 290 | useTrackballDragger(false), |
|---|
| 291 | region_in_pixel_coords(false), |
|---|
| 292 | alphaValue(1.0), |
|---|
| 293 | cutoffValue(0.1), |
|---|
| 294 | sampleDensityValue(0.005), |
|---|
| 295 | sampleDensityWhenMovingValue(0.0), |
|---|
| 296 | colorSpaceOperation(osg::NO_COLOUR_SPACE_OPERATION), |
|---|
| 297 | colorModulate(1.0f,1.0f,1.0f,1.0f) |
|---|
| 298 | { |
|---|
| 299 | region[0] = region[1] = region[2] = 0.0f; |
|---|
| 300 | region[3] = region[4] = region[5] = 1.0f; |
|---|
| 301 | } |
|---|
| 302 | |
|---|
| 303 | std::string options; |
|---|
| 304 | ShadingModel shadingModel; |
|---|
| 305 | osg::ref_ptr<osg::TransferFunction1D> transferFunction; |
|---|
| 306 | bool useTabbedDragger; |
|---|
| 307 | bool useTrackballDragger; |
|---|
| 308 | float region[6]; |
|---|
| 309 | bool region_in_pixel_coords; |
|---|
| 310 | float alphaValue; |
|---|
| 311 | float cutoffValue; |
|---|
| 312 | float sampleDensityValue; |
|---|
| 313 | float sampleDensityWhenMovingValue; |
|---|
| 314 | |
|---|
| 315 | osg::ColorSpaceOperation colorSpaceOperation; |
|---|
| 316 | osg::Vec4 colorModulate; |
|---|
| 317 | }; |
|---|
| 318 | |
|---|
| 319 | |
|---|
| 320 | struct FontData |
|---|
| 321 | { |
|---|
| 322 | FontData(): |
|---|
| 323 | font("fonts/arial.ttf"), |
|---|
| 324 | layout(osgText::Text::LEFT_TO_RIGHT), |
|---|
| 325 | alignment(osgText::Text::LEFT_BASE_LINE), |
|---|
| 326 | axisAlignment(osgText::Text::XZ_PLANE), |
|---|
| 327 | characterSizeMode(osgText::Text::OBJECT_COORDS), |
|---|
| 328 | characterSize(0.04f), |
|---|
| 329 | maximumHeight(1.0f), |
|---|
| 330 | maximumWidth(1.0f), |
|---|
| 331 | color(1.0f,1.0f,1.0f,1.0f) {} |
|---|
| 332 | |
|---|
| 333 | std::string font; |
|---|
| 334 | osgText::Text::Layout layout; |
|---|
| 335 | osgText::Text::AlignmentType alignment; |
|---|
| 336 | osgText::Text::AxisAlignment axisAlignment; |
|---|
| 337 | osgText::Text::CharacterSizeMode characterSizeMode; |
|---|
| 338 | float characterSize; |
|---|
| 339 | float maximumHeight; |
|---|
| 340 | float maximumWidth; |
|---|
| 341 | osg::Vec4 color; |
|---|
| 342 | }; |
|---|
| 343 | |
|---|
| 344 | SlideShowConstructor(osgDB::Options* options); |
|---|
| 345 | |
|---|
| 346 | void createPresentation(); |
|---|
| 347 | |
|---|
| 348 | void setBackgroundColor(const osg::Vec4& color, bool updateClearNode); |
|---|
| 349 | const osg::Vec4& getBackgroundColor() const { return _backgroundColor; } |
|---|
| 350 | |
|---|
| 351 | void setTextColor(const osg::Vec4& color); |
|---|
| 352 | const osg::Vec4& getTextColor() const { return _textFontDataDefault.color; } |
|---|
| 353 | |
|---|
| 354 | void setPresentationName(const std::string& name); |
|---|
| 355 | |
|---|
| 356 | void setPresentationAspectRatio(float aspectRatio); |
|---|
| 357 | |
|---|
| 358 | void setPresentationAspectRatio(const std::string& str); |
|---|
| 359 | |
|---|
| 360 | void setPresentationDuration(double duration); |
|---|
| 361 | |
|---|
| 362 | |
|---|
| 363 | void addSlide(); |
|---|
| 364 | |
|---|
| 365 | void selectSlide(int slideNum); |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | void setSlideTitle(const std::string& name, PositionData& positionData, FontData& fontData) |
|---|
| 369 | { |
|---|
| 370 | _titlePositionData = positionData; |
|---|
| 371 | _titleFontData = fontData; |
|---|
| 372 | _slideTitle = name; |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | void setSlideBackgrondHUD(bool hud) { _slideBackgroundAsHUD = hud; } |
|---|
| 376 | void setSlideBackground(const std::string& name) { _slideBackgroundImageFileName = name; } |
|---|
| 377 | |
|---|
| 378 | void setSlideDuration(double duration); |
|---|
| 379 | |
|---|
| 380 | |
|---|
| 381 | void addLayer(bool inheritPreviousLayers=true, bool defineAsBaseLayer=false); |
|---|
| 382 | |
|---|
| 383 | void selectLayer(int layerNum); |
|---|
| 384 | |
|---|
| 385 | void setLayerDuration(double duration); |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | // title settings |
|---|
| 389 | FontData& getTitleFontData() { return _titleFontData; } |
|---|
| 390 | FontData& getTitleFontDataDefault() { return _titleFontDataDefault; } |
|---|
| 391 | |
|---|
| 392 | PositionData& getTitlePositionData() { return _titlePositionData; } |
|---|
| 393 | PositionData& getTitlePositionDataDefault() { return _titlePositionDataDefault; } |
|---|
| 394 | |
|---|
| 395 | // text settings |
|---|
| 396 | FontData& getTextFontData() { return _textFontData; } |
|---|
| 397 | FontData& getTextFontDataDefault() { return _textFontDataDefault; } |
|---|
| 398 | |
|---|
| 399 | PositionData& getTextPositionData() { return _textPositionData; } |
|---|
| 400 | PositionData& getTextPositionDataDefault() { return _textPositionDataDefault; } |
|---|
| 401 | |
|---|
| 402 | void translateTextCursor(const osg::Vec3& delta) { _textPositionData.position += delta; } |
|---|
| 403 | |
|---|
| 404 | // image settings |
|---|
| 405 | PositionData& getImagePositionData() { return _imagePositionData; } |
|---|
| 406 | PositionData& getImagePositionDataDefault() { return _imagePositionDataDefault; } |
|---|
| 407 | |
|---|
| 408 | // model settings |
|---|
| 409 | PositionData& getModelPositionData() { return _modelPositionData; } |
|---|
| 410 | PositionData& getModelPositionDataDefault() { return _modelPositionDataDefault; } |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | enum PresentationContext { |
|---|
| 414 | CURRENT_PRESENTATION, |
|---|
| 415 | CURRENT_SLIDE, |
|---|
| 416 | CURRENT_LAYER |
|---|
| 417 | }; |
|---|
| 418 | |
|---|
| 419 | void addEventHandler(PresentationContext presentationContext, osg::ref_ptr<osgGA::GUIEventHandler> handler); |
|---|
| 420 | |
|---|
| 421 | void keyToDoOperation(PresentationContext presentationContext, int key, Operation operation, const JumpData& jumpData=JumpData()); |
|---|
| 422 | void keyToDoOperation(PresentationContext presentationContext, int key, const std::string& command, Operation operation, const JumpData& jumpData=JumpData()); |
|---|
| 423 | void keyEventOperation(PresentationContext presentationContext, int key, const KeyPosition& keyPos, const JumpData& jumpData=JumpData()); |
|---|
| 424 | |
|---|
| 425 | void layerClickToDoOperation(Operation operation, const JumpData& jumpData=JumpData()); |
|---|
| 426 | void layerClickToDoOperation(const std::string& command, Operation operation, const JumpData& jumpData=JumpData()); |
|---|
| 427 | void layerClickEventOperation(const KeyPosition& keyPos, const JumpData& jumpData=JumpData()); |
|---|
| 428 | |
|---|
| 429 | void addToCurrentLayer(osg::Node* subgraph); |
|---|
| 430 | |
|---|
| 431 | void addBullet(const std::string& bullet, PositionData& positionData, FontData& fontData); |
|---|
| 432 | |
|---|
| 433 | void addParagraph(const std::string& paragraph, PositionData& positionData, FontData& fontData); |
|---|
| 434 | |
|---|
| 435 | osg::Image* readImage(const std::string& filename, const ImageData& imageData); |
|---|
| 436 | |
|---|
| 437 | void addImage(const std::string& filename,const PositionData& positionData, const ImageData& imageData); |
|---|
| 438 | |
|---|
| 439 | void addStereoImagePair(const std::string& filenameLeft, const ImageData& imageDataLeft, const std::string& filenameRight,const ImageData& imageDataRight, const PositionData& positionData); |
|---|
| 440 | |
|---|
| 441 | void addGraph(const std::string& filename,const PositionData& positionData, const ImageData& imageData); |
|---|
| 442 | void addVNC(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const std::string& password); |
|---|
| 443 | void addBrowser(const std::string& filename,const PositionData& positionData, const ImageData& imageData); |
|---|
| 444 | void addPDF(const std::string& filename,const PositionData& positionData, const ImageData& imageData); |
|---|
| 445 | osg::Image* addInteractiveImage(const std::string& filename,const PositionData& positionData, const ImageData& imageData); |
|---|
| 446 | |
|---|
| 447 | void addModel(osg::Node* subgraph, const PositionData& positionData, const ModelData& modelData); |
|---|
| 448 | |
|---|
| 449 | void addModel(const std::string& filename, const PositionData& positionData, const ModelData& modelData); |
|---|
| 450 | |
|---|
| 451 | void addVolume(const std::string& filename, const PositionData& positionData, const VolumeData& volumeData); |
|---|
| 452 | |
|---|
| 453 | osg::Group* takePresentation() { return _root.release(); } |
|---|
| 454 | |
|---|
| 455 | osg::Group* getPresentation() { return _root.get(); } |
|---|
| 456 | |
|---|
| 457 | osg::Switch* getPresentationSwitch() { return _presentationSwitch.get(); } |
|---|
| 458 | |
|---|
| 459 | osg::Switch* getCurrentSlide() { return _slide.get(); } |
|---|
| 460 | |
|---|
| 461 | osg::Group* getCurrentLayer() { return _currentLayer.get(); } |
|---|
| 462 | |
|---|
| 463 | void setLoopPresentation(bool loop) { _loopPresentation = loop; } |
|---|
| 464 | bool getLoopPresentation() const { return _loopPresentation; } |
|---|
| 465 | |
|---|
| 466 | void setAutoSteppingActive(bool flag = true) { _autoSteppingActive = flag; } |
|---|
| 467 | bool getAutoSteppingActive() const { return _autoSteppingActive; } |
|---|
| 468 | |
|---|
| 469 | void setHUDSettings(HUDSettings* hudSettings) { _hudSettings = hudSettings; } |
|---|
| 470 | HUDSettings* getHUDSettings() { return _hudSettings.get(); } |
|---|
| 471 | const HUDSettings* getHUDSettings() const { return _hudSettings.get(); } |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | protected: |
|---|
| 475 | |
|---|
| 476 | void findImageStreamsAndAddCallbacks(osg::Node* node); |
|---|
| 477 | |
|---|
| 478 | osg::Geometry* createTexturedQuadGeometry(const osg::Vec3& pos, const osg::Vec4& rotation, float width,float height, osg::Image* image, bool& usedTextureRectangle); |
|---|
| 479 | |
|---|
| 480 | osg::Vec3 computePositionInModelCoords(const PositionData& positionData) const; |
|---|
| 481 | void updatePositionFromInModelCoords(const osg::Vec3& vertex, PositionData& positionData) const; |
|---|
| 482 | |
|---|
| 483 | osg::Vec3 convertSlideToModel(const osg::Vec3& position) const; |
|---|
| 484 | osg::Vec3 convertModelToSlide(const osg::Vec3& position) const; |
|---|
| 485 | |
|---|
| 486 | osg::AnimationPathCallback* getAnimationPathCallback(const PositionData& positionData); |
|---|
| 487 | |
|---|
| 488 | osg::Node* attachMaterialAnimation(osg::Node* model, const PositionData& positionData); |
|---|
| 489 | bool attachTexMat(osg::StateSet* stateset, const ImageData& imageData, float s, float t, bool textureRectangle); |
|---|
| 490 | |
|---|
| 491 | osg::StateSet* createTransformStateSet() |
|---|
| 492 | { |
|---|
| 493 | osg::StateSet* stateset = new osg::StateSet; |
|---|
| 494 | #if !defined(OSG_GLES2_AVAILABLE) |
|---|
| 495 | stateset->setMode(GL_NORMALIZE,osg::StateAttribute::ON); |
|---|
| 496 | #endif |
|---|
| 497 | return stateset; |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | osg::Node* decorateSubgraphForPosition(osg::Node* node, PositionData& positionData); |
|---|
| 501 | |
|---|
| 502 | osg::ref_ptr<osgDB::Options> _options; |
|---|
| 503 | |
|---|
| 504 | osg::Vec3 _slideOrigin; |
|---|
| 505 | osg::Vec3 _eyeOrigin; |
|---|
| 506 | double _slideWidth; |
|---|
| 507 | double _slideHeight; |
|---|
| 508 | double _slideDistance; |
|---|
| 509 | unsigned int _leftEyeMask; |
|---|
| 510 | unsigned int _rightEyeMask; |
|---|
| 511 | |
|---|
| 512 | osg::ref_ptr<HUDSettings> _hudSettings; |
|---|
| 513 | |
|---|
| 514 | // title settings |
|---|
| 515 | FontData _titleFontData; |
|---|
| 516 | FontData _titleFontDataDefault; |
|---|
| 517 | |
|---|
| 518 | PositionData _titlePositionData; |
|---|
| 519 | PositionData _titlePositionDataDefault; |
|---|
| 520 | |
|---|
| 521 | // text settings |
|---|
| 522 | FontData _textFontData; |
|---|
| 523 | FontData _textFontDataDefault; |
|---|
| 524 | |
|---|
| 525 | PositionData _textPositionData; |
|---|
| 526 | PositionData _textPositionDataDefault; |
|---|
| 527 | |
|---|
| 528 | // image settings |
|---|
| 529 | PositionData _imagePositionData; |
|---|
| 530 | PositionData _imagePositionDataDefault; |
|---|
| 531 | |
|---|
| 532 | // model settings |
|---|
| 533 | PositionData _modelPositionData; |
|---|
| 534 | PositionData _modelPositionDataDefault; |
|---|
| 535 | |
|---|
| 536 | |
|---|
| 537 | bool _loopPresentation; |
|---|
| 538 | bool _autoSteppingActive; |
|---|
| 539 | osg::Vec4 _backgroundColor; |
|---|
| 540 | std::string _presentationName; |
|---|
| 541 | double _presentationDuration; |
|---|
| 542 | |
|---|
| 543 | osg::ref_ptr<osgPresentation::PropertyManager> _propertyManager; |
|---|
| 544 | osg::ref_ptr<osgPresentation::PropertyEventCallback> _propertyEventCallback; |
|---|
| 545 | |
|---|
| 546 | osg::ref_ptr<osg::Group> _root; |
|---|
| 547 | osg::ref_ptr<osg::Switch> _presentationSwitch; |
|---|
| 548 | |
|---|
| 549 | osg::ref_ptr<osg::ClearNode> _slideClearNode; |
|---|
| 550 | osg::ref_ptr<osg::Switch> _slide; |
|---|
| 551 | std::string _slideTitle; |
|---|
| 552 | std::string _slideBackgroundImageFileName; |
|---|
| 553 | bool _slideBackgroundAsHUD; |
|---|
| 554 | |
|---|
| 555 | osg::ref_ptr<osg::Group> _previousLayer; |
|---|
| 556 | osg::ref_ptr<osg::Group> _currentLayer; |
|---|
| 557 | |
|---|
| 558 | osg::ref_ptr<FilePathData> _filePathData; |
|---|
| 559 | |
|---|
| 560 | osg::ref_ptr<osg::Group> _layerToApplyEventCallbackTo; |
|---|
| 561 | |
|---|
| 562 | typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList; |
|---|
| 563 | EventHandlerList _currentEventCallbacksToApply; |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | std::string findFileAndRecordPath(const std::string& filename); |
|---|
| 567 | |
|---|
| 568 | void recordOptionsFilePath(const osgDB::Options* options); |
|---|
| 569 | |
|---|
| 570 | }; |
|---|
| 571 | |
|---|
| 572 | } |
|---|
| 573 | |
|---|
| 574 | #endif |
|---|