23 #include <osgViewer/CompositeViewer>
25 #include <osgEarth/VirtualProgram>
27 #include <boost/unordered_map.hpp>
28 #include <boost/signals.hpp>
41 class DtGLTextureBufferObject;
42 class DtInstanceProcessor;
43 class DtOsgIntersectorResult;
44 class DtChannelManager;
46 class DtPerViewUniformCallback;
57 typedef std::vector<osg::ref_ptr<osg::Geometry> >
GeometryVec;
60 typedef std::map<osg::ref_ptr< osgEarth::VirtualProgram >, osg::ref_ptr<osgEarth::VirtualProgram> >
VpMap;
61 typedef std::vector<osg::ref_ptr<osgEarth::VirtualProgram> >
VpRefList;
68 static const unsigned int NumVec4PerInstance = 8;
212 typedef std::vector<InstancedLod*>
LodVec;
272 bool intersect(
const osg::Vec3d& start,
const osg::Vec3d& end, std::vector<DtOsgIntersectorResult>& results);
279 void setSequenceSpeed(
DtInstanceState& instance,
unsigned int sequenceIndex,
float speed);
282 void setSequencePlayTime(
DtInstanceState& instance,
unsigned int sequenceIndex,
float loopTime);
295 void setDofAnimation(osg::Vec3f& hpr, osg::Vec3f hprVel,
DtInstanceState& state,
unsigned int partIndex);
298 void setDofTranslation(osg::Vec3f& trans,
DtInstanceState& state,
unsigned int partIndex);
303 void setSwitchState(
DtInstanceState& instance,
unsigned int partIndex,
unsigned int childIndex,
bool state);
308 void setUVOffset(
DtUniqueID id,
unsigned int drawableIx, osg::Vec2f uvOffset);
313 void setUserDefined(
DtUniqueID id,
float userDefined);
331 virtual void reset();
334 virtual osg::Node* instanceRoot();
337 bool isRegistered(
const std::string& modelType);
340 void registerModel(
const std::string& modelType,
GeometryVec& drawables,
LodVec& lods,
343 unsigned int nodeMask, osg::ref_ptr<osg::StateSet> rootNodeSS,
bool daylightControlledLights =
false);
346 osg::Geode *setupModelGeode(
const std::string& modelType,
unsigned int nodeMask);
349 void allocateImage( osg::View* view );
358 bool newInstance(
const std::string& modelType,
DtUniqueID id,
DtElementID elementId, osg::Node* rootNode);
442 inline osg::View*
lastView() {
return myLastView; }
445 inline unsigned int drawableIndex(
unsigned int instanceIx);
448 void reloadShaders();
453 virtual bool isDaylight();
535 double l, r, b,
t, n, f;
544 osgUtil::LineSegmentIntersector::Intersection
result;
556 void registerGeometry(
unsigned int templateIx, osg::Geometry* geometry,
VpMap& vpMap);
559 float computeDistanceToEye(
const Eyepoint& eye,
const osg::Vec3d& pos)
const;
562 void allocateRenderList();
565 unsigned int updateBuffers( osg::View* view,
DtGLTextureBufferObject* tbo,
const ArrayRange& drawableRange,
unsigned int bufferOffset, osg::Vec4* bufferStorage );
570 unsigned int updateRenderList(
const Eyepoint& eye,
const Frustum& frustum,
const osg::Matrixd& viewMat,
unsigned int nodeMask);
575 void allocateInstanceData();
580 unsigned int fillRenderList(
unsigned visibleSetStride,
unsigned int instanceOffset,
unsigned int numInstances );
583 void cullRange(
const Eyepoint& eye,
unsigned int instanceOffset,
unsigned int instanceCount,
584 std::vector<osg::Vec4d>& planes,
bool useScale,
unsigned int nodeMask );
593 void createHitList(
const osg::Vec3d& end,
const osg::Vec3d& start, std::vector<InstancingHit>& hitList);
596 void loadInstanceShaders(osg::ref_ptr<osgEarth::VirtualProgram> vp);
701 virtual bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo)
const
729 typedef boost::unordered_map<osg::View*, osg::ref_ptr<DtViewSpecificGroup> >
ViewToGroup;
733 typedef boost::unordered_map<osg::Geometry*, osg::ref_ptr<DtPerViewUniformCallback> >
GeometryToCallback;