2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
|
2009-04-28 19:57:51 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This software is open source and may be redistributed and/or modified under
|
2009-04-28 19:57:51 +08:00
|
|
|
* the terms of the GNU General Public License (GPL) version 2.0.
|
|
|
|
* The full license is in LICENSE.txt file included with this distribution,.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2009-04-28 19:57:51 +08:00
|
|
|
* This software is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-04-28 19:57:51 +08:00
|
|
|
* include LICENSE.txt for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SLIDESHOWCONSTRUCTOR
|
|
|
|
#define SLIDESHOWCONSTRUCTOR
|
|
|
|
|
|
|
|
#include <osg/Vec3>
|
|
|
|
#include <osg/Vec4>
|
2012-11-13 21:16:10 +08:00
|
|
|
#include <osg/ImageUtils>
|
2009-04-28 19:57:51 +08:00
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/ClearNode>
|
|
|
|
#include <osg/Switch>
|
|
|
|
#include <osg/AnimationPath>
|
2009-08-05 22:37:56 +08:00
|
|
|
#include <osg/TransferFunction>
|
2009-04-28 19:57:51 +08:00
|
|
|
#include <osg/ImageStream>
|
2012-06-12 03:54:07 +08:00
|
|
|
#include <osg/ImageSequence>
|
2013-12-19 18:02:16 +08:00
|
|
|
#include <osg/ScriptEngine>
|
2009-04-28 19:57:51 +08:00
|
|
|
#include <osgText/Text>
|
|
|
|
#include <osgGA/GUIEventAdapter>
|
|
|
|
|
|
|
|
#include <osgDB/FileUtils>
|
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
#include <osgVolume/VolumeTile>
|
2014-07-03 21:01:05 +08:00
|
|
|
#include <osgVolume/VolumeSettings>
|
2012-11-30 22:21:45 +08:00
|
|
|
|
2015-03-05 02:36:44 +08:00
|
|
|
#include <osgPresentation/AnimationMaterial>
|
|
|
|
#include <osgPresentation/SlideEventHandler>
|
|
|
|
#include <osgPresentation/PropertyManager>
|
|
|
|
#include <osgPresentation/Timeout>
|
2009-04-28 22:03:02 +08:00
|
|
|
|
|
|
|
namespace osgPresentation
|
|
|
|
{
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2011-03-16 18:51:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
class OSGPRESENTATION_EXPORT HUDTransform : public osg::Transform
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
HUDTransform(HUDSettings* hudSettings);
|
|
|
|
|
|
|
|
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const;
|
|
|
|
|
|
|
|
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~HUDTransform();
|
|
|
|
|
|
|
|
osg::ref_ptr<HUDSettings> _hudSettings;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-06-25 00:03:49 +08:00
|
|
|
class OSGPRESENTATION_EXPORT SlideShowConstructor
|
2009-04-28 19:57:51 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
enum CoordinateFrame { SLIDE, MODEL };
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
LayerAttributes* getOrCreateLayerAttributes(osg::Node* node);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setDuration(osg::Node* node,double duration)
|
|
|
|
{
|
|
|
|
getOrCreateLayerAttributes(node)->setDuration(duration);
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void addKey(osg::Node* node,const KeyPosition& kp)
|
|
|
|
{
|
|
|
|
getOrCreateLayerAttributes(node)->addKey(kp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addRunString(osg::Node* node, const std::string& runString)
|
|
|
|
{
|
|
|
|
getOrCreateLayerAttributes(node)->addRunString(runString);
|
|
|
|
}
|
|
|
|
|
2012-11-10 05:32:54 +08:00
|
|
|
void setJump(osg::Node* node, const JumpData& jumpData)
|
2009-04-28 19:57:51 +08:00
|
|
|
{
|
2012-11-10 05:32:54 +08:00
|
|
|
getOrCreateLayerAttributes(node)->setJump(jumpData);
|
2009-04-28 19:57:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void addPresentationKey(const KeyPosition& kp)
|
|
|
|
{
|
2012-03-22 01:36:20 +08:00
|
|
|
if (!_presentationSwitch) createPresentation();
|
2009-04-28 19:57:51 +08:00
|
|
|
if (_presentationSwitch.valid()) addKey( _presentationSwitch.get(), kp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addPresentationRunString(const std::string& runString)
|
|
|
|
{
|
2012-03-22 01:36:20 +08:00
|
|
|
if (!_presentationSwitch) createPresentation();
|
2009-04-28 19:57:51 +08:00
|
|
|
if (_presentationSwitch.valid()) addRunString( _presentationSwitch.get(),runString);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addSlideKey(const KeyPosition& kp)
|
|
|
|
{
|
|
|
|
if (!_slide) addSlide();
|
|
|
|
if (_slide.valid()) addKey(_slide.get(),kp);
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void addSlideRunString(const std::string& runString)
|
|
|
|
{
|
|
|
|
if (!_slide) addSlide();
|
|
|
|
if (_slide.valid()) addRunString(_slide.get(),runString);
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2012-11-10 05:32:54 +08:00
|
|
|
void setSlideJump(const JumpData& jumpData)
|
2009-04-28 19:57:51 +08:00
|
|
|
{
|
|
|
|
if (!_slide) addSlide();
|
2012-11-10 05:32:54 +08:00
|
|
|
if (_slide.valid()) setJump(_slide.get(),jumpData);
|
2009-04-28 19:57:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void addLayerKey(const KeyPosition& kp)
|
|
|
|
{
|
|
|
|
if (!_currentLayer) addLayer();
|
|
|
|
if (_currentLayer.valid()) addKey(_currentLayer.get(),kp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addLayerRunString(const std::string& runString)
|
|
|
|
{
|
|
|
|
if (!_currentLayer) addLayer();
|
|
|
|
if (_currentLayer.valid()) addRunString(_currentLayer.get(),runString);
|
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2012-11-10 05:32:54 +08:00
|
|
|
void setLayerJump(const JumpData& jumpData)
|
2009-04-28 19:57:51 +08:00
|
|
|
{
|
|
|
|
if (!_currentLayer) addLayer();
|
2012-11-10 05:32:54 +08:00
|
|
|
if (_currentLayer.valid()) setJump(_currentLayer.get(),jumpData);
|
2009-04-28 19:57:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct PositionData
|
|
|
|
{
|
2009-05-14 21:40:02 +08:00
|
|
|
PositionData():
|
2009-04-28 19:57:51 +08:00
|
|
|
frame(SlideShowConstructor::SLIDE),
|
|
|
|
position(0.0f,1.0f,0.0f),
|
|
|
|
//position(0.5f,0.5f,0.0f),
|
|
|
|
scale(1.0f,1.0f,1.0f),
|
|
|
|
rotate(0.0f,0.0f,0.0f,1.0f),
|
|
|
|
rotation(0.0f,0.0f,1.0f,0.0f),
|
|
|
|
absolute_path(false),
|
2009-05-14 21:40:02 +08:00
|
|
|
inverse_path(false),
|
2009-04-28 19:57:51 +08:00
|
|
|
path_time_offset(0.0),
|
|
|
|
path_time_multiplier(1.0f),
|
|
|
|
path_loop_mode(osg::AnimationPath::NO_LOOPING),
|
|
|
|
animation_material_time_offset(0.0),
|
|
|
|
animation_material_time_multiplier(1.0),
|
2011-03-15 05:36:32 +08:00
|
|
|
animation_material_loop_mode(AnimationMaterial::NO_LOOPING),
|
|
|
|
autoRotate(false),
|
2011-03-16 03:54:57 +08:00
|
|
|
autoScale(false),
|
|
|
|
hud(false) {}
|
2011-03-15 05:36:32 +08:00
|
|
|
|
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
bool requiresPosition() const
|
|
|
|
{
|
|
|
|
return (position[0]!=0.0f || position[1]!=1.0f || position[2]!=1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool requiresScale() const
|
|
|
|
{
|
|
|
|
return (scale[0]!=1.0f || scale[1]!=1.0f || scale[2]!=1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool requiresRotate() const
|
|
|
|
{
|
|
|
|
return rotate[0]!=0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool requiresAnimation() const
|
|
|
|
{
|
|
|
|
return (rotation[0]!=0.0f || !path.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool requiresMaterialAnimation() const
|
|
|
|
{
|
|
|
|
return !animation_material_filename.empty() || !fade.empty();
|
|
|
|
}
|
|
|
|
|
2009-05-14 21:40:02 +08:00
|
|
|
CoordinateFrame frame;
|
|
|
|
osg::Vec3 position;
|
|
|
|
osg::Vec3 scale;
|
|
|
|
osg::Vec4 rotate;
|
|
|
|
osg::Vec4 rotation;
|
2009-04-28 19:57:51 +08:00
|
|
|
std::string animation_name;
|
2009-05-14 21:40:02 +08:00
|
|
|
bool absolute_path;
|
|
|
|
bool inverse_path;
|
2009-04-28 19:57:51 +08:00
|
|
|
double path_time_offset;
|
|
|
|
double path_time_multiplier;
|
|
|
|
osg::AnimationPath::LoopMode path_loop_mode;
|
2009-05-14 21:40:02 +08:00
|
|
|
std::string path;
|
2009-04-28 19:57:51 +08:00
|
|
|
double animation_material_time_offset;
|
|
|
|
double animation_material_time_multiplier;
|
2009-06-25 00:03:49 +08:00
|
|
|
AnimationMaterial::LoopMode animation_material_loop_mode;
|
2009-05-14 21:40:02 +08:00
|
|
|
std::string animation_material_filename;
|
|
|
|
std::string fade;
|
2011-03-15 05:36:32 +08:00
|
|
|
bool autoRotate;
|
|
|
|
bool autoScale;
|
2011-03-16 03:54:57 +08:00
|
|
|
bool hud;
|
2009-04-28 19:57:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ModelData
|
|
|
|
{
|
2011-10-26 22:25:56 +08:00
|
|
|
ModelData() {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2012-12-20 20:14:53 +08:00
|
|
|
std::string region;
|
2009-04-28 19:57:51 +08:00
|
|
|
std::string effect;
|
2011-10-26 22:25:56 +08:00
|
|
|
std::string options;
|
2009-04-28 19:57:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ImageData
|
|
|
|
{
|
|
|
|
ImageData():
|
|
|
|
width(1.0f),
|
|
|
|
height(1.0f),
|
|
|
|
region(0.0f,0.0f,1.0f,1.0f),
|
|
|
|
region_in_pixel_coords(false),
|
|
|
|
texcoord_rotate(0.0f),
|
|
|
|
loopingMode(osg::ImageStream::NO_LOOPING),
|
|
|
|
page(-1),
|
2012-06-08 12:18:28 +08:00
|
|
|
backgroundColor(1.0f,1.0f,1.0f,1.0f),
|
|
|
|
fps(30.0),
|
2012-06-12 03:54:07 +08:00
|
|
|
duration(-1.0),
|
2012-10-29 23:58:02 +08:00
|
|
|
imageSequence(false),
|
|
|
|
imageSequencePagingMode(osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES),
|
2012-11-13 22:22:37 +08:00
|
|
|
imageSequenceInteractionMode(PLAY_AUTOMATICALLY_LIKE_MOVIE),
|
2013-01-10 22:37:52 +08:00
|
|
|
blendingHint(USE_IMAGE_ALPHA),
|
|
|
|
delayTime(0.0),
|
|
|
|
startTime(0.0),
|
2013-01-11 19:30:44 +08:00
|
|
|
stopTime(-1.0),
|
|
|
|
volume("")
|
2012-06-12 03:54:07 +08:00
|
|
|
{}
|
2011-10-26 22:25:56 +08:00
|
|
|
|
|
|
|
std::string options;
|
2009-04-28 19:57:51 +08:00
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
osg::Vec4 region;
|
|
|
|
bool region_in_pixel_coords;
|
|
|
|
float texcoord_rotate;
|
|
|
|
osg::ImageStream::LoopingMode loopingMode;
|
|
|
|
int page;
|
|
|
|
osg::Vec4 backgroundColor;
|
2012-06-08 12:18:28 +08:00
|
|
|
double fps;
|
|
|
|
double duration;
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2012-10-29 23:58:02 +08:00
|
|
|
bool imageSequence;
|
2012-06-12 03:54:07 +08:00
|
|
|
osg::ImageSequence::Mode imageSequencePagingMode;
|
2012-10-29 23:58:02 +08:00
|
|
|
|
|
|
|
enum ImageSequenceInteractionMode
|
|
|
|
{
|
|
|
|
PLAY_AUTOMATICALLY_LIKE_MOVIE,
|
2012-11-08 23:45:23 +08:00
|
|
|
USE_MOUSE_X_POSITION,
|
|
|
|
USE_MOUSE_Y_POSITION
|
2012-10-29 23:58:02 +08:00
|
|
|
};
|
|
|
|
ImageSequenceInteractionMode imageSequenceInteractionMode;
|
2012-11-13 22:22:37 +08:00
|
|
|
|
|
|
|
enum BlendingHint
|
|
|
|
{
|
|
|
|
USE_IMAGE_ALPHA,
|
|
|
|
OFF,
|
|
|
|
ON
|
|
|
|
};
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2013-01-10 22:37:52 +08:00
|
|
|
BlendingHint blendingHint;
|
|
|
|
|
|
|
|
double delayTime;
|
|
|
|
double startTime;
|
|
|
|
double stopTime;
|
2013-01-11 19:30:44 +08:00
|
|
|
std::string volume;
|
2012-11-13 22:22:37 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
};
|
|
|
|
|
2009-08-05 22:37:56 +08:00
|
|
|
struct VolumeData
|
|
|
|
{
|
2014-07-03 21:01:05 +08:00
|
|
|
typedef osgVolume::VolumeSettings::ShadingModel ShadingModel;
|
|
|
|
typedef osgVolume::VolumeSettings::Technique Technique;
|
2013-12-17 20:18:06 +08:00
|
|
|
|
2009-08-05 22:37:56 +08:00
|
|
|
VolumeData():
|
2014-07-03 21:01:05 +08:00
|
|
|
shadingModel(osgVolume::VolumeSettings::Standard),
|
2009-08-05 22:37:56 +08:00
|
|
|
useTabbedDragger(false),
|
2009-08-28 00:42:47 +08:00
|
|
|
useTrackballDragger(false),
|
|
|
|
region_in_pixel_coords(false),
|
2014-07-05 00:45:05 +08:00
|
|
|
alphaValue(),
|
|
|
|
cutoffValue(),
|
|
|
|
exteriorTransparencyFactorValue(),
|
|
|
|
sampleDensityValue(),
|
|
|
|
sampleRatioValue(),
|
2012-11-13 21:32:01 +08:00
|
|
|
colorSpaceOperation(osg::NO_COLOR_SPACE_OPERATION),
|
2013-12-17 20:18:06 +08:00
|
|
|
colorModulate(1.0f,1.0f,1.0f,1.0f),
|
2014-07-03 21:01:05 +08:00
|
|
|
technique(osgVolume::VolumeSettings::RayTraced)
|
2009-08-28 00:42:47 +08:00
|
|
|
{
|
2014-03-17 23:54:52 +08:00
|
|
|
hullPositionData.position = osg::Vec3(0.0,0.0,0.0);
|
|
|
|
hullPositionData.frame = osgPresentation::SlideShowConstructor::MODEL;
|
2009-08-28 00:42:47 +08:00
|
|
|
}
|
2009-08-05 22:37:56 +08:00
|
|
|
|
2014-07-03 21:01:05 +08:00
|
|
|
osg::ref_ptr<osgVolume::VolumeSettings> volumeSettings;
|
|
|
|
|
2011-10-26 22:25:56 +08:00
|
|
|
std::string options;
|
2009-08-05 22:37:56 +08:00
|
|
|
ShadingModel shadingModel;
|
|
|
|
osg::ref_ptr<osg::TransferFunction1D> transferFunction;
|
|
|
|
bool useTabbedDragger;
|
|
|
|
bool useTrackballDragger;
|
2012-11-30 22:21:45 +08:00
|
|
|
std::string region;
|
2009-08-28 00:42:47 +08:00
|
|
|
bool region_in_pixel_coords;
|
2012-11-30 22:21:45 +08:00
|
|
|
std::string alphaValue;
|
|
|
|
std::string cutoffValue;
|
2014-03-19 02:14:15 +08:00
|
|
|
std::string exteriorTransparencyFactorValue;
|
2012-11-30 22:21:45 +08:00
|
|
|
std::string sampleDensityValue;
|
|
|
|
std::string sampleDensityWhenMovingValue;
|
2012-11-13 21:16:10 +08:00
|
|
|
|
2014-01-22 02:48:53 +08:00
|
|
|
std::string sampleRatioValue;
|
|
|
|
std::string sampleRatioWhenMovingValue;
|
|
|
|
|
2012-11-13 21:16:10 +08:00
|
|
|
osg::ColorSpaceOperation colorSpaceOperation;
|
|
|
|
osg::Vec4 colorModulate;
|
2013-12-17 20:18:06 +08:00
|
|
|
Technique technique;
|
2014-01-17 01:17:37 +08:00
|
|
|
std::string hull;
|
2014-02-05 19:07:03 +08:00
|
|
|
PositionData hullPositionData;
|
2009-08-05 22:37:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
struct FontData
|
|
|
|
{
|
2009-05-14 21:40:02 +08:00
|
|
|
FontData():
|
|
|
|
font("fonts/arial.ttf"),
|
|
|
|
layout(osgText::Text::LEFT_TO_RIGHT),
|
|
|
|
alignment(osgText::Text::LEFT_BASE_LINE),
|
|
|
|
axisAlignment(osgText::Text::XZ_PLANE),
|
2011-03-15 05:36:32 +08:00
|
|
|
characterSizeMode(osgText::Text::OBJECT_COORDS),
|
2009-05-14 21:40:02 +08:00
|
|
|
characterSize(0.04f),
|
|
|
|
maximumHeight(1.0f),
|
|
|
|
maximumWidth(1.0f),
|
|
|
|
color(1.0f,1.0f,1.0f,1.0f) {}
|
|
|
|
|
2011-03-15 05:36:32 +08:00
|
|
|
std::string font;
|
|
|
|
osgText::Text::Layout layout;
|
|
|
|
osgText::Text::AlignmentType alignment;
|
|
|
|
osgText::Text::AxisAlignment axisAlignment;
|
|
|
|
osgText::Text::CharacterSizeMode characterSizeMode;
|
|
|
|
float characterSize;
|
|
|
|
float maximumHeight;
|
|
|
|
float maximumWidth;
|
|
|
|
osg::Vec4 color;
|
2009-04-28 19:57:51 +08:00
|
|
|
};
|
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
enum ScriptCallbackType
|
|
|
|
{
|
|
|
|
UPDATE_SCRIPT,
|
|
|
|
EVENT_SCRIPT
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::pair<ScriptCallbackType, std::string> ScriptPair;
|
|
|
|
|
|
|
|
struct ScriptData
|
|
|
|
{
|
|
|
|
ScriptData() {}
|
|
|
|
|
|
|
|
typedef std::vector<ScriptPair> Scripts;
|
|
|
|
Scripts scripts;
|
|
|
|
|
|
|
|
bool hasScripts() const { return !scripts.empty(); }
|
|
|
|
};
|
|
|
|
|
2010-04-29 02:53:34 +08:00
|
|
|
SlideShowConstructor(osgDB::Options* options);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
|
|
|
void createPresentation();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setBackgroundColor(const osg::Vec4& color, bool updateClearNode);
|
|
|
|
const osg::Vec4& getBackgroundColor() const { return _backgroundColor; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setTextColor(const osg::Vec4& color);
|
|
|
|
const osg::Vec4& getTextColor() const { return _textFontDataDefault.color; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setPresentationName(const std::string& name);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setPresentationAspectRatio(float aspectRatio);
|
|
|
|
|
|
|
|
void setPresentationAspectRatio(const std::string& str);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setPresentationDuration(double duration);
|
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addScriptEngine(const std::string& scriptEngineName);
|
|
|
|
|
|
|
|
void addScriptFile(const std::string& name, const std::string& filename);
|
|
|
|
|
|
|
|
void addScript(const std::string& name, const std::string& language, const std::string& script);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
|
|
|
void addSlide();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void selectSlide(int slideNum);
|
|
|
|
|
|
|
|
|
|
|
|
void setSlideTitle(const std::string& name, PositionData& positionData, FontData& fontData)
|
|
|
|
{
|
|
|
|
_titlePositionData = positionData;
|
|
|
|
_titleFontData = fontData;
|
|
|
|
_slideTitle = name;
|
|
|
|
}
|
|
|
|
|
2011-03-16 18:51:42 +08:00
|
|
|
void setSlideBackgrondHUD(bool hud) { _slideBackgroundAsHUD = hud; }
|
2009-04-28 19:57:51 +08:00
|
|
|
void setSlideBackground(const std::string& name) { _slideBackgroundImageFileName = name; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setSlideDuration(double duration);
|
|
|
|
|
2013-01-17 17:51:15 +08:00
|
|
|
Timeout* addTimeout();
|
2009-04-28 19:57:51 +08:00
|
|
|
|
|
|
|
void addLayer(bool inheritPreviousLayers=true, bool defineAsBaseLayer=false);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void selectLayer(int layerNum);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
void setLayerDuration(double duration);
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
// title settings
|
|
|
|
FontData& getTitleFontData() { return _titleFontData; }
|
|
|
|
FontData& getTitleFontDataDefault() { return _titleFontDataDefault; }
|
|
|
|
|
|
|
|
PositionData& getTitlePositionData() { return _titlePositionData; }
|
|
|
|
PositionData& getTitlePositionDataDefault() { return _titlePositionDataDefault; }
|
|
|
|
|
|
|
|
// text settings
|
|
|
|
FontData& getTextFontData() { return _textFontData; }
|
|
|
|
FontData& getTextFontDataDefault() { return _textFontDataDefault; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
PositionData& getTextPositionData() { return _textPositionData; }
|
|
|
|
PositionData& getTextPositionDataDefault() { return _textPositionDataDefault; }
|
|
|
|
|
|
|
|
void translateTextCursor(const osg::Vec3& delta) { _textPositionData.position += delta; }
|
|
|
|
|
|
|
|
// image settings
|
|
|
|
PositionData& getImagePositionData() { return _imagePositionData; }
|
|
|
|
PositionData& getImagePositionDataDefault() { return _imagePositionDataDefault; }
|
|
|
|
|
|
|
|
// model settings
|
|
|
|
PositionData& getModelPositionData() { return _modelPositionData; }
|
|
|
|
PositionData& getModelPositionDataDefault() { return _modelPositionDataDefault; }
|
|
|
|
|
|
|
|
|
2012-11-10 05:32:54 +08:00
|
|
|
enum PresentationContext {
|
|
|
|
CURRENT_PRESENTATION,
|
|
|
|
CURRENT_SLIDE,
|
|
|
|
CURRENT_LAYER
|
|
|
|
};
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2012-11-10 05:32:54 +08:00
|
|
|
void addEventHandler(PresentationContext presentationContext, osg::ref_ptr<osgGA::GUIEventHandler> handler);
|
|
|
|
|
|
|
|
void keyToDoOperation(PresentationContext presentationContext, int key, Operation operation, const JumpData& jumpData=JumpData());
|
|
|
|
void keyToDoOperation(PresentationContext presentationContext, int key, const std::string& command, Operation operation, const JumpData& jumpData=JumpData());
|
|
|
|
void keyEventOperation(PresentationContext presentationContext, int key, const KeyPosition& keyPos, const JumpData& jumpData=JumpData());
|
|
|
|
|
|
|
|
void layerClickToDoOperation(Operation operation, const JumpData& jumpData=JumpData());
|
|
|
|
void layerClickToDoOperation(const std::string& command, Operation operation, const JumpData& jumpData=JumpData());
|
|
|
|
void layerClickEventOperation(const KeyPosition& keyPos, const JumpData& jumpData=JumpData());
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2012-11-27 23:09:44 +08:00
|
|
|
void addPropertyAnimation(PresentationContext presentationContext, PropertyAnimation* propertyAnimation);
|
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addScriptCallback(PresentationContext presentationContext, ScriptCallbackType scriptCallbackType, const std::string& functionName);
|
|
|
|
|
|
|
|
void addScriptToNode(ScriptCallbackType scriptCallbackType, const std::string& name, osg::Node* node);
|
|
|
|
|
|
|
|
void addScriptsToNode(const ScriptData& scriptData, osg::Node* node);
|
|
|
|
|
2012-01-24 22:27:17 +08:00
|
|
|
void addToCurrentLayer(osg::Node* subgraph);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addBullet(const std::string& bullet, PositionData& positionData, FontData& fontData, const ScriptData& scriptData);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addParagraph(const std::string& paragraph, PositionData& positionData, FontData& fontData, const ScriptData& scriptData);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2015-10-22 21:42:19 +08:00
|
|
|
osg::ref_ptr<osg::Image> readImage(const std::string& filename, const ImageData& imageData);
|
2012-06-08 18:26:23 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addImage(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const ScriptData& scriptData);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addStereoImagePair(const std::string& filenameLeft, const ImageData& imageDataLeft, const std::string& filenameRight,const ImageData& imageDataRight, const PositionData& positionData, const ScriptData& scriptData);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addGraph(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const ScriptData& scriptData);
|
|
|
|
void addVNC(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const std::string& password, const ScriptData& scriptData);
|
|
|
|
void addBrowser(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const ScriptData& scriptData);
|
|
|
|
void addPDF(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const ScriptData& scriptData);
|
2015-10-22 21:42:19 +08:00
|
|
|
osg::ref_ptr<osg::Image> addInteractiveImage(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const ScriptData& scriptData);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addModel(osg::Node* subgraph, const PositionData& positionData, const ModelData& modelData, const ScriptData& scriptData);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addModel(const std::string& filename, const PositionData& positionData, const ModelData& modelData, const ScriptData& scriptData);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
void setUpVolumeScalarProperty(osgVolume::VolumeTile* tile, osgVolume::ScalarProperty* property, const std::string& source);
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
void addVolume(const std::string& filename, const PositionData& positionData, const VolumeData& volumeData, const ScriptData& scriptData);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
|
|
|
osg::Group* takePresentation() { return _root.release(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::Group* getPresentation() { return _root.get(); }
|
|
|
|
|
|
|
|
osg::Switch* getPresentationSwitch() { return _presentationSwitch.get(); }
|
|
|
|
|
|
|
|
osg::Switch* getCurrentSlide() { return _slide.get(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2013-12-20 17:57:35 +08:00
|
|
|
void pushCurrentLayer(osg::Group* newLayerGroup);
|
2013-01-17 00:13:30 +08:00
|
|
|
void popCurrentLayer();
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::Group* getCurrentLayer() { return _currentLayer.get(); }
|
|
|
|
|
|
|
|
void setLoopPresentation(bool loop) { _loopPresentation = loop; }
|
|
|
|
bool getLoopPresentation() const { return _loopPresentation; }
|
|
|
|
|
|
|
|
void setAutoSteppingActive(bool flag = true) { _autoSteppingActive = flag; }
|
|
|
|
bool getAutoSteppingActive() const { return _autoSteppingActive; }
|
|
|
|
|
2011-03-16 18:51:42 +08:00
|
|
|
void setHUDSettings(HUDSettings* hudSettings) { _hudSettings = hudSettings; }
|
|
|
|
HUDSettings* getHUDSettings() { return _hudSettings.get(); }
|
|
|
|
const HUDSettings* getHUDSettings() const { return _hudSettings.get(); }
|
|
|
|
|
2014-03-13 18:28:18 +08:00
|
|
|
osg::ScriptEngine* getOrCreateScriptEngine(const std::string& language);
|
2009-08-05 22:37:56 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
void findImageStreamsAndAddCallbacks(osg::Node* node);
|
|
|
|
|
|
|
|
osg::Geometry* createTexturedQuadGeometry(const osg::Vec3& pos, const osg::Vec4& rotation, float width,float height, osg::Image* image, bool& usedTextureRectangle);
|
2013-01-11 19:30:44 +08:00
|
|
|
void setUpMovieVolume(osg::Node* subgraph, osg::ImageStream* imageStream, const ImageData& imageData);
|
2009-04-28 19:57:51 +08:00
|
|
|
|
|
|
|
osg::Vec3 computePositionInModelCoords(const PositionData& positionData) const;
|
|
|
|
void updatePositionFromInModelCoords(const osg::Vec3& vertex, PositionData& positionData) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::Vec3 convertSlideToModel(const osg::Vec3& position) const;
|
|
|
|
osg::Vec3 convertModelToSlide(const osg::Vec3& position) const;
|
|
|
|
|
|
|
|
osg::AnimationPathCallback* getAnimationPathCallback(const PositionData& positionData);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::Node* attachMaterialAnimation(osg::Node* model, const PositionData& positionData);
|
|
|
|
bool attachTexMat(osg::StateSet* stateset, const ImageData& imageData, float s, float t, bool textureRectangle);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::StateSet* createTransformStateSet()
|
|
|
|
{
|
|
|
|
osg::StateSet* stateset = new osg::StateSet;
|
2009-10-29 04:31:57 +08:00
|
|
|
#if !defined(OSG_GLES2_AVAILABLE)
|
|
|
|
stateset->setMode(GL_NORMALIZE,osg::StateAttribute::ON);
|
|
|
|
#endif
|
2009-04-28 19:57:51 +08:00
|
|
|
return stateset;
|
|
|
|
}
|
|
|
|
|
2011-03-16 03:54:57 +08:00
|
|
|
osg::Node* decorateSubgraphForPosition(osg::Node* node, PositionData& positionData);
|
2014-03-17 23:54:52 +08:00
|
|
|
osg::Node* decorateSubgraphForPositionAndAnimation(osg::Node* node, const PositionData& positionData);
|
2011-03-16 03:54:57 +08:00
|
|
|
|
2010-04-29 02:53:34 +08:00
|
|
|
osg::ref_ptr<osgDB::Options> _options;
|
2009-05-14 21:40:02 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::Vec3 _slideOrigin;
|
|
|
|
osg::Vec3 _eyeOrigin;
|
2011-03-16 03:54:57 +08:00
|
|
|
double _slideWidth;
|
|
|
|
double _slideHeight;
|
|
|
|
double _slideDistance;
|
2011-03-16 18:51:42 +08:00
|
|
|
unsigned int _leftEyeMask;
|
|
|
|
unsigned int _rightEyeMask;
|
|
|
|
|
|
|
|
osg::ref_ptr<HUDSettings> _hudSettings;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
// title settings
|
|
|
|
FontData _titleFontData;
|
|
|
|
FontData _titleFontDataDefault;
|
|
|
|
|
|
|
|
PositionData _titlePositionData;
|
|
|
|
PositionData _titlePositionDataDefault;
|
|
|
|
|
|
|
|
// text settings
|
|
|
|
FontData _textFontData;
|
|
|
|
FontData _textFontDataDefault;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
PositionData _textPositionData;
|
|
|
|
PositionData _textPositionDataDefault;
|
|
|
|
|
|
|
|
// image settings
|
|
|
|
PositionData _imagePositionData;
|
|
|
|
PositionData _imagePositionDataDefault;
|
|
|
|
|
|
|
|
// model settings
|
|
|
|
PositionData _modelPositionData;
|
|
|
|
PositionData _modelPositionDataDefault;
|
|
|
|
|
|
|
|
|
|
|
|
bool _loopPresentation;
|
|
|
|
bool _autoSteppingActive;
|
|
|
|
osg::Vec4 _backgroundColor;
|
|
|
|
std::string _presentationName;
|
|
|
|
double _presentationDuration;
|
|
|
|
|
2012-11-01 00:07:23 +08:00
|
|
|
osg::ref_ptr<osgPresentation::PropertyManager> _propertyManager;
|
|
|
|
osg::ref_ptr<osgPresentation::PropertyEventCallback> _propertyEventCallback;
|
2013-08-19 02:10:39 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::ref_ptr<osg::Group> _root;
|
|
|
|
osg::ref_ptr<osg::Switch> _presentationSwitch;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2013-12-19 18:02:16 +08:00
|
|
|
typedef std::map< std::string, osg::ref_ptr<osg::ScriptEngine> > ScriptEngineMap;
|
|
|
|
ScriptEngineMap _scriptEngines;
|
|
|
|
|
|
|
|
typedef std::map< std::string, osg::ref_ptr<osg::Script> > ScriptMap;
|
|
|
|
ScriptMap _scripts;
|
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::ref_ptr<osg::ClearNode> _slideClearNode;
|
|
|
|
osg::ref_ptr<osg::Switch> _slide;
|
|
|
|
std::string _slideTitle;
|
|
|
|
std::string _slideBackgroundImageFileName;
|
2011-03-16 18:51:42 +08:00
|
|
|
bool _slideBackgroundAsHUD;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::ref_ptr<osg::Group> _previousLayer;
|
|
|
|
osg::ref_ptr<osg::Group> _currentLayer;
|
2013-01-17 00:13:30 +08:00
|
|
|
typedef std::vector< osg::ref_ptr<osg::Group> > LayerStack;
|
|
|
|
LayerStack _layerStack;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
osg::ref_ptr<FilePathData> _filePathData;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2012-01-24 22:27:17 +08:00
|
|
|
osg::ref_ptr<osg::Group> _layerToApplyEventCallbackTo;
|
2012-11-10 05:32:54 +08:00
|
|
|
|
|
|
|
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList;
|
|
|
|
EventHandlerList _currentEventCallbacksToApply;
|
2012-01-24 22:27:17 +08:00
|
|
|
|
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
std::string findFileAndRecordPath(const std::string& filename);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-05-14 21:40:02 +08:00
|
|
|
void recordOptionsFilePath(const osgDB::Options* options);
|
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
};
|
|
|
|
|
2009-04-28 22:03:02 +08:00
|
|
|
}
|
|
|
|
|
2009-04-28 19:57:51 +08:00
|
|
|
#endif
|