Added new osgcallback demo, and updated small API changes to improve the
flexiblity of callbacks. Added beginings of convex planer occlusions culling.
This commit is contained in:
parent
a5a267d305
commit
ae5e4f848f
@ -66,6 +66,7 @@ PLUGIN_DIRS += tiff
|
||||
DEMOS_DIRS = \
|
||||
hangglide\
|
||||
osgbillboard\
|
||||
osgcallback\
|
||||
osgclip\
|
||||
osgcluster\
|
||||
osgconv\
|
||||
|
95
VisualStudio/Demos/osgcallback/osgcallback.dsp
Executable file
95
VisualStudio/Demos/osgcallback/osgcallback.dsp
Executable file
@ -0,0 +1,95 @@
|
||||
# Microsoft Developer Studio Project File - Name="Demo osgcallback" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=Demo osgcallback - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "osgcallback.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "osgcallback.mak" CFG="Demo osgcallback - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Demo osgcallback - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Demo osgcallback - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Demo osgcallback - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 /nologo /subsystem:console /pdb:none /machine:I386 /out:"../../../bin/osgcallback.exe" /libpath:"../../../lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Demo osgcallback - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /FR /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 glut32.lib glu32.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../../bin/osgcallbackd.exe" /pdbtype:sept /libpath:"../../../lib"
|
||||
# SUBTRACT LINK32 /incremental:no
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Demo osgcallback - Win32 Release"
|
||||
# Name "Demo osgcallback - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\Demos\osgcallback\osgcallback.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Project
|
@ -180,6 +180,32 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Demo osgcallback"=".\Demos\osgcallback\osgcallback.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osg
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgDB
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgGA
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgGLUT
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgUtil
|
||||
End Project Dependency
|
||||
}}}
|
||||
###############################################################################
|
||||
|
||||
Project: "Demo osgcopy"=".\Demos\osgcopy\osgcopy.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
@ -133,6 +133,14 @@ SOURCE=..\..\src\osg\ColorMatrix.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\ConvexPlanerOccluder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\ConvexPlanerPolygon.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\CopyOp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -293,6 +301,10 @@ SOURCE=..\..\src\osg\ShadeModel.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\ShadowOccluderVolume.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\State.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -393,6 +405,14 @@ SOURCE=..\..\Include\Osg\ClipPlane
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\ConvexPlanerOccluder
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\ConvexPlanerPolygon
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\ColorMask
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -597,6 +617,10 @@ SOURCE=..\..\Include\Osg\ShadeModel
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\ShadowOccluderVolume
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\State
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -83,10 +83,8 @@ class SG_EXPORT Billboard : public Geode
|
||||
struct ComputeBillboardCallback : public osg::Referenced
|
||||
{
|
||||
/** Get the transformation matrix which moves from local coords to world coords.*/
|
||||
virtual const bool computeMatrix(const Matrix& modelview, const Billboard* billboard, const Vec3& eye_local, const Vec3& pos_local) const;
|
||||
virtual const bool computeMatrix(Matrix& modelview, const Billboard* billboard, const Vec3& eye_local, const Vec3& pos_local) const = 0;
|
||||
};
|
||||
|
||||
friend struct osg::Billboard::ComputeBillboardCallback;
|
||||
|
||||
/** Set the ComputeBillboardCallback which allows users to attach custom computation of the local transformation as
|
||||
* seen by cull traversers and alike.*/
|
||||
@ -107,14 +105,14 @@ class SG_EXPORT Billboard : public Geode
|
||||
return computeMatrix(modelview,eye_local,pos_local);
|
||||
}
|
||||
|
||||
virtual const bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Billboard();
|
||||
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
virtual const bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const;
|
||||
|
||||
enum AxisAligned
|
||||
{
|
||||
AXIAL_ROT_X_AXIS=AXIAL_ROT+1,
|
||||
|
61
include/osg/ConvexPlanerOccluder
Normal file
61
include/osg/ConvexPlanerOccluder
Normal file
@ -0,0 +1,61 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_CONVEXPLANEROCCLUDER
|
||||
#define OSG_CONVEXPLANEROCCLUDER 1
|
||||
|
||||
#include <osg/ConvexPlanerPolygon>
|
||||
#include <osg/Referenced>
|
||||
|
||||
namespace osg {
|
||||
|
||||
class OccluderVolume;
|
||||
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.
|
||||
* When adding planes, their normals should point inwards (into the volume) */
|
||||
class SG_EXPORT ConvexPlanerOccluder : public Referenced
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
inline ConvexPlanerOccluder() {}
|
||||
|
||||
|
||||
|
||||
void setOccluder(const ConvexPlanerPolygon& cpp) { _occluder = cpp; }
|
||||
|
||||
ConvexPlanerPolygon& getOccluder() { return _occluder; }
|
||||
|
||||
const ConvexPlanerPolygon& getOccluder() const { return _occluder; }
|
||||
|
||||
|
||||
|
||||
typedef std::vector<ConvexPlanerPolygon> HoleList;
|
||||
|
||||
void addHole(const ConvexPlanerPolygon& cpp) { _holeList.push_back(cpp); }
|
||||
|
||||
HoleList& getHoleList() { return _holeList; }
|
||||
|
||||
const HoleList& getHoleList() const { return _holeList; }
|
||||
|
||||
void computeAttributes();
|
||||
|
||||
void computeBound(BoundingBox& bb) const;
|
||||
|
||||
void computeBound(BoundingSphere& bs) const;
|
||||
|
||||
protected:
|
||||
|
||||
float _area;
|
||||
Vec3 _center;
|
||||
Vec3 _normal;
|
||||
|
||||
ConvexPlanerPolygon _occluder;
|
||||
HoleList _holeList;
|
||||
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif
|
57
include/osg/ConvexPlanerPolygon
Normal file
57
include/osg/ConvexPlanerPolygon
Normal file
@ -0,0 +1,57 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_CONVEXPLANERPOLYGON
|
||||
#define OSG_CONVEXPLANERPOLYGON 1
|
||||
|
||||
#include <osg/Plane>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace osg {
|
||||
|
||||
class BoundingBox;
|
||||
class BoundingSphere;
|
||||
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.
|
||||
* When adding planes, their normals should point inwards (into the volume) */
|
||||
class SG_EXPORT ConvexPlanerPolygon
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
inline ConvexPlanerPolygon() {}
|
||||
|
||||
float area() { return _area; }
|
||||
|
||||
const Vec3& center() { return _center; }
|
||||
|
||||
const Vec3& normal() { return _normal; }
|
||||
|
||||
typedef std::vector<osg::Vec3> VertexList;
|
||||
|
||||
void add(const Vec3& v) { _vertexList.push_back(v); }
|
||||
|
||||
VertexList& getVertexList() { return _vertexList; }
|
||||
|
||||
const VertexList& getVertexList() const { return _vertexList; }
|
||||
|
||||
void computeAttributes();
|
||||
|
||||
void computeBound(BoundingBox& bb) const;
|
||||
|
||||
void computeBound(BoundingSphere& bs) const;
|
||||
|
||||
protected:
|
||||
|
||||
float _area;
|
||||
Vec3 _center;
|
||||
Vec3 _normal;
|
||||
VertexList _vertexList;
|
||||
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif
|
@ -171,8 +171,6 @@ class SG_EXPORT Drawable : public Object
|
||||
/** do customized draw code.*/
|
||||
virtual void drawImmediateMode(State& state,osg::Drawable* drawable) const = 0;
|
||||
};
|
||||
|
||||
friend struct osg::Drawable::DrawCallback;
|
||||
|
||||
/** Set the DrawCallback which allows users to attach customize the drawing of existing Drawable object.*/
|
||||
void setDrawCallback(DrawCallback* dc) { _drawCallback=dc; dirtyDisplayList(); }
|
||||
@ -186,10 +184,8 @@ class SG_EXPORT Drawable : public Object
|
||||
struct CullCallback : public osg::Referenced
|
||||
{
|
||||
/** do customized cull code.*/
|
||||
virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable) = 0;
|
||||
virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable) const = 0;
|
||||
};
|
||||
|
||||
friend struct osg::Drawable::CullCallback;
|
||||
|
||||
/** Set the CullCallback which allows users to attach customize the drawing of existing Drawable object.*/
|
||||
void setCullCallback(CullCallback* cc) { _cullCallback=cc; }
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Drawable>
|
||||
#include <osg/ConvexPlanerOccluder>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@ -107,6 +108,17 @@ class SG_EXPORT Geode : public Node
|
||||
|
||||
/** compile OpenGL Display List for each geoset.*/
|
||||
void compileDrawables(State& state);
|
||||
|
||||
|
||||
|
||||
/** Attach a ConvexPlanerOccluder to a Geode.*/
|
||||
void setOccluder(ConvexPlanerOccluder* occluder) { _occluder = occluder; }
|
||||
|
||||
/** Get the ConvexPlanerOccluder* attached to a Geode. */
|
||||
ConvexPlanerOccluder* getOccluder() { return _occluder.get(); }
|
||||
|
||||
/** Get the const ConvexPlanerOccluder* attached to a Geode.*/
|
||||
const ConvexPlanerOccluder* getOccluder() const { return _occluder.get(); }
|
||||
|
||||
protected:
|
||||
|
||||
@ -114,7 +126,8 @@ class SG_EXPORT Geode : public Node
|
||||
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
DrawableList _drawables;
|
||||
DrawableList _drawables;
|
||||
ref_ptr<ConvexPlanerOccluder> _occluder;
|
||||
|
||||
};
|
||||
|
||||
|
@ -60,10 +60,8 @@ class SG_EXPORT LOD : public Group
|
||||
struct EvaluateLODCallback : public osg::Referenced
|
||||
{
|
||||
/** Compute the child to select.*/
|
||||
virtual const int evaluateLODChild(const osg::LOD* lod, const Vec3& eye_local, const float bias) const;
|
||||
virtual const int evaluateLODChild(const osg::LOD* lod, const Vec3& eye_local, const float bias) const = 0;
|
||||
};
|
||||
|
||||
friend struct osg::LOD::EvaluateLODCallback;
|
||||
|
||||
/** Set the EvaluateLODCallback which allows users to attach customize computation of the the selection of LOD children.*/
|
||||
void setEvaluateLODCallback(EvaluateLODCallback* cbc) { _evaluateLODCallback=cbc; }
|
||||
@ -74,8 +72,6 @@ class SG_EXPORT LOD : public Group
|
||||
/** Get the const ComputeBillboardCallback.*/
|
||||
const EvaluateLODCallback* getEvaluateLODCallback() const { return _evaluateLODCallback.get(); }
|
||||
|
||||
|
||||
|
||||
/** return the child to traverse.
|
||||
Selected by the distance between the eye point in local
|
||||
coordinates and the LOD center, multiplied by the bias.*/
|
||||
@ -88,10 +84,11 @@ class SG_EXPORT LOD : public Group
|
||||
}
|
||||
|
||||
|
||||
virtual const int evaluateLODChild(const Vec3& eye_local,const float bias) const;
|
||||
|
||||
protected :
|
||||
virtual ~LOD() {}
|
||||
|
||||
virtual const int evaluateLODChild(const Vec3& eye_local,const float bias) const;
|
||||
|
||||
typedef std::vector<float> RangeList;
|
||||
RangeList _rangeList;
|
||||
|
@ -36,13 +36,13 @@ class SG_EXPORT PositionAttitudeTransform : public Transform
|
||||
|
||||
const Quat& getAttitude() const { return _attitude; }
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
||||
|
||||
virtual const bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
||||
|
||||
protected :
|
||||
|
||||
|
||||
Vec3 _position;
|
||||
Quat _attitude;
|
||||
|
||||
|
56
include/osg/ShadowOccluderVolume
Normal file
56
include/osg/ShadowOccluderVolume
Normal file
@ -0,0 +1,56 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_SHADOWOCCLUDERVOLUME
|
||||
#define OSG_SHADOWOCCLUDERVOLUME 1
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/ClippingVolume>
|
||||
#include <osg/ConvexPlanerOccluder>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** ShadowOccluderVolume is a helper class for implementating shadow occlusion culling. */
|
||||
class SG_EXPORT ShadowOccluderVolume : public Referenced
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
ShadowOccluderVolume(const ShadowOccluderVolume& soc,Matrix& MVP);
|
||||
|
||||
ShadowOccluderVolume(const ConvexPlanerOccluder& occluder,Matrix& MVP);
|
||||
|
||||
typedef std::vector<ClippingVolume> ClippingHoleList;
|
||||
|
||||
/** Convert shadow occluder into local coords by multiplying the
|
||||
* clip space occluder by the ModelViewProjectionMatrix.*/
|
||||
void set(const ShadowOccluderVolume& soc,Matrix& MVP);
|
||||
|
||||
/** Initialize a ShadowOccluderVolume to a ConvexPlanerOccluder
|
||||
* transformed into clipspace.*/
|
||||
void set(const ConvexPlanerOccluder& occluder,Matrix& MVP);
|
||||
|
||||
/** return true if the specified bounding sphere is contaned entirely
|
||||
* within this shadow occluder volume.*/
|
||||
bool contains(const BoundingSphere& bs);
|
||||
|
||||
/** return true if the specified bounding box is contained entirely
|
||||
* within this shadow occluder volume.*/
|
||||
bool contains(const BoundingBox& bs);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// the original shadow occluder computed in clip space
|
||||
ref_ptr<ShadowOccluderVolume> _clipSpaceOccluder;
|
||||
|
||||
ClippingVolume _occluderVolume;
|
||||
ClippingHoleList _clippingHoleList;
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif
|
@ -69,8 +69,6 @@ class SG_EXPORT Transform : public Group
|
||||
/** Get the transformation matrix which moves from world coords to local coords.*/
|
||||
virtual const bool computeWorldToLocalMatrix(Matrix& matrix,const Transform* transform, NodeVisitor* nv) const = 0;
|
||||
};
|
||||
|
||||
friend struct osg::Transform::ComputeTransformCallback;
|
||||
|
||||
/** Set the ComputerTransfromCallback which allows users to attach custom computation of the local transformation as
|
||||
* seen by cull traversers and alike.*/
|
||||
@ -118,16 +116,6 @@ class SG_EXPORT Transform : public Group
|
||||
/** postMult transform.*/
|
||||
void postMult(const Matrix& mat) { _matrix->postMult(mat); _inverseDirty=true; computeInverse(); dirtyBound(); }
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Transform();
|
||||
|
||||
/** Override's Group's computeBound.
|
||||
* There is no need to override in subclasses from osg::Transform since this computeBound() uses
|
||||
* the underlying matrix (calling computeMatrix if required.) */
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
virtual const bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const
|
||||
{
|
||||
if (_referenceFrame==RELATIVE_TO_PARENTS)
|
||||
@ -153,6 +141,16 @@ class SG_EXPORT Transform : public Group
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Transform();
|
||||
|
||||
/** Override's Group's computeBound.
|
||||
* There is no need to override in subclasses from osg::Transform since this computeBound() uses
|
||||
* the underlying matrix (calling computeMatrix if required.) */
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
|
||||
inline void computeInverse() const
|
||||
{
|
||||
|
16
src/Demos/osgcallback/Makefile
Normal file
16
src/Demos/osgcallback/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgcallback.cpp\
|
||||
|
||||
LIBS += $(OSG_LIBS) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
Makefile.inst=Makefile
|
||||
|
||||
EXEC = osgcallback
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
|
12
src/Demos/osgcallback/Makefile.inst
Normal file
12
src/Demos/osgcallback/Makefile.inst
Normal file
@ -0,0 +1,12 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgcallback.cpp\
|
||||
|
||||
LIBS += $(OSG_LIBS) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
EXEC = osgcallback
|
||||
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
251
src/Demos/osgcallback/osgcallback.cpp
Normal file
251
src/Demos/osgcallback/osgcallback.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
#include <osg/GL>
|
||||
#include <osgGLUT/glut>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <osg/Transform>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Group>
|
||||
#include <osg/LOD>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgUtil/TrackballManipulator>
|
||||
#include <osgUtil/FlightManipulator>
|
||||
#include <osgUtil/DriveManipulator>
|
||||
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
void write_usage(std::ostream& out,const std::string& name)
|
||||
{
|
||||
out << std::endl;
|
||||
out <<"usage:"<< std::endl;
|
||||
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
|
||||
out << std::endl;
|
||||
out <<"options:"<< std::endl;
|
||||
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
|
||||
out <<" i.e. -l osgdb_pfb"<< std::endl;
|
||||
out <<" Useful for loading reader/writers which can load"<< std::endl;
|
||||
out <<" other file formats in addition to its extension."<< std::endl;
|
||||
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
|
||||
out <<" i.e. -e pfb"<< std::endl;
|
||||
out <<" Useful short hand for specifying full library name as"<< std::endl;
|
||||
out <<" done with -l above, as it automatically expands to"<< std::endl;
|
||||
out <<" the full library name appropriate for each platform."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
|
||||
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
|
||||
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
|
||||
out <<" further details on setting up accurate stereo "<< std::endl;
|
||||
out <<" for your system. "<< std::endl;
|
||||
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
|
||||
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
|
||||
out <<" also allows the depth complexity statistics mode"<< std::endl;
|
||||
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
class AppCallback : public osg::NodeCallback
|
||||
{
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
std::cout<<"app callback - pre traverse"<<node<<std::endl;
|
||||
traverse(node,nv);
|
||||
std::cout<<"app callback - post traverse"<<node<<std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class CullCallback : public osg::NodeCallback
|
||||
{
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
std::cout<<"cull callback - pre traverse"<<node<<std::endl;
|
||||
traverse(node,nv);
|
||||
std::cout<<"cull callback - post traverse"<<node<<std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class DrawableCallback : public osg::Drawable::DrawCallback
|
||||
{
|
||||
virtual void drawImmediateMode(osg::State& state,osg::Drawable* drawable) const
|
||||
{
|
||||
std::cout<<"draw call back - pre drawImmediateMode"<<drawable<<std::endl;
|
||||
drawable->drawImmediateMode(state);
|
||||
std::cout<<"draw call back - post drawImmediateMode"<<drawable<<std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
struct LODCallback : public osg::LOD::EvaluateLODCallback
|
||||
{
|
||||
/** Compute the child to select.*/
|
||||
virtual const int evaluateLODChild(const osg::LOD* lod, const osg::Vec3& eye_local, const float bias) const
|
||||
{
|
||||
std::cout<<"evaluateLODChild callback - pre lod->evaluateLODChild"<<std::endl;
|
||||
int result = lod->evaluateLODChild(eye_local,bias);
|
||||
std::cout<<"evaluateLODChild callback - post lod->evaluateLODChild"<<std::endl;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
struct TransformCallback : public osg::Transform::ComputeTransformCallback
|
||||
{
|
||||
/** Get the transformation matrix which moves from local coords to world coords.*/
|
||||
virtual const bool computeLocalToWorldMatrix(osg::Matrix& matrix,const osg::Transform* transform, osg::NodeVisitor* nv) const
|
||||
{
|
||||
std::cout<<"computeLocalToWorldMatrix - pre transform->computeLocalToWorldMatrix"<<std::endl;
|
||||
bool result = transform->computeLocalToWorldMatrix(matrix,nv);
|
||||
std::cout<<"computeLocalToWorldMatrix - post transform->computeLocalToWorldMatrix"<<std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Get the transformation matrix which moves from world coords to local coords.*/
|
||||
virtual const bool computeWorldToLocalMatrix(osg::Matrix& matrix,const osg::Transform* transform, osg::NodeVisitor* nv) const
|
||||
{
|
||||
std::cout<<"computeWorldToLocalMatrix - pre transform->computeWorldToLocalMatrix"<<std::endl;
|
||||
bool result = transform->computeWorldToLocalMatrix(matrix,nv);
|
||||
std::cout<<"computeWorldToLocalMatrix - post transform->computeWorldToLocalMatrix"<<std::endl;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct BillboardCallback : public osg::Billboard::ComputeBillboardCallback
|
||||
{
|
||||
/** Get the transformation matrix which moves from local coords to world coords.*/
|
||||
virtual const bool computeMatrix(osg::Matrix& modelview, const osg::Billboard* billboard, const osg::Vec3& eye_local, const osg::Vec3& pos_local) const
|
||||
{
|
||||
std::cout<<"ComputeBillboardCallback - pre billboard->computeMatrix"<<std::endl;
|
||||
bool result = billboard->computeMatrix(modelview,eye_local,pos_local);
|
||||
std::cout<<"ComputeBillboardCallback - post billboard->computeMatrix"<<std::endl;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
struct DrawableCullCallback : public osg::Drawable::CullCallback
|
||||
{
|
||||
/** do customized cull code.*/
|
||||
virtual bool cull(osg::NodeVisitor*, osg::Drawable* drawable) const
|
||||
{
|
||||
std::cout<<"Drawable cull callback "<<drawable<<std::endl;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class InsertCallbacksVisitor : public osg::NodeVisitor
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
InsertCallbacksVisitor():NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void apply(osg::Node& node)
|
||||
{
|
||||
node.setAppCallback(new AppCallback());
|
||||
node.setCullCallback(new CullCallback());
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
virtual void apply(osg::Geode& geode)
|
||||
{
|
||||
geode.setAppCallback(new AppCallback());
|
||||
|
||||
//note, it makes no sense to attach a cull callback to the node
|
||||
//at there are no nodes to traverse below the geode, only
|
||||
//drawables, and as such the Cull node callbacks is ignored.
|
||||
//If you wish to control the culling of drawables
|
||||
//then use a drawable cullback...
|
||||
|
||||
for(int i=0;i<geode.getNumDrawables();++i)
|
||||
{
|
||||
geode.getDrawable(i)->setCullCallback(new DrawableCullCallback());
|
||||
geode.getDrawable(i)->setDrawCallback(new DrawableCallback());
|
||||
}
|
||||
}
|
||||
|
||||
virtual void apply(osg::Billboard& node)
|
||||
{
|
||||
node.setComputeBillboardCallback(new BillboardCallback());
|
||||
apply((osg::Geode&)node);
|
||||
}
|
||||
|
||||
virtual void apply(osg::Transform& node)
|
||||
{
|
||||
node.setComputeTransformCallback(new TransformCallback());
|
||||
apply((osg::Node&)node);
|
||||
}
|
||||
|
||||
virtual void apply(osg::LOD& node)
|
||||
{
|
||||
node.setEvaluateLODCallback(new LODCallback());
|
||||
apply((osg::Node&)node);
|
||||
}
|
||||
};
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
write_usage(std::cout,argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create the commandline args.
|
||||
std::vector<std::string> commandLine;
|
||||
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
|
||||
|
||||
|
||||
// initialize the viewer.
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.setWindowTitle(argv[0]);
|
||||
|
||||
// configure the viewer from the commandline arguments, and eat any
|
||||
// parameters that have been matched.
|
||||
viewer.readCommandLine(commandLine);
|
||||
|
||||
// configure the plugin registry from the commandline arguments, and
|
||||
// eat any parameters that have been matched.
|
||||
osgDB::readCommandLine(commandLine);
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
osg::Node* rootnode = osgDB::readNodeFiles(commandLine);
|
||||
if (!rootnode)
|
||||
{
|
||||
// write_usage(osg::notify(osg::NOTICE),argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// run optimization over the scene graph
|
||||
osgUtil::Optimizer optimzer;
|
||||
optimzer.optimize(rootnode);
|
||||
|
||||
// insert all the callbacks
|
||||
InsertCallbacksVisitor icv;
|
||||
rootnode->accept(icv);
|
||||
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.addViewport( rootnode );
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer.registerCameraManipulator(new osgUtil::TrackballManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::FlightManipulator);
|
||||
viewer.registerCameraManipulator(new osgUtil::DriveManipulator);
|
||||
|
||||
// open the viewer window.
|
||||
viewer.open();
|
||||
|
||||
// fire up the event loop.
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
}
|
3
src/osg/ConvexPlanerOccluder.cpp
Normal file
3
src/osg/ConvexPlanerOccluder.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include <osg/ConvexPlanerOccluder>
|
||||
|
||||
using namespace osg;
|
4
src/osg/ConvexPlanerPolygon.cpp
Normal file
4
src/osg/ConvexPlanerPolygon.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include <osg/ConvexPlanerPolygon>
|
||||
|
||||
using namespace osg;
|
||||
|
@ -103,7 +103,12 @@ void Drawable::compile(State& state)
|
||||
|
||||
globj = glGenLists( 1 );
|
||||
glNewList( globj, GL_COMPILE );
|
||||
drawImmediateMode(state);
|
||||
|
||||
if (_drawCallback.valid())
|
||||
_drawCallback->drawImmediateMode(state,this);
|
||||
else
|
||||
drawImmediateMode(state);
|
||||
|
||||
glEndList();
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ Geode::Geode(const Geode& geode,const CopyOp& copyop):
|
||||
Drawable* drawable = copyop(itr->get());
|
||||
if (drawable) addDrawable(drawable);
|
||||
}
|
||||
|
||||
_occluder = dynamic_cast<ConvexPlanerOccluder*>(copyop(geode.getOccluder()));
|
||||
}
|
||||
|
||||
Geode::~Geode()
|
||||
@ -101,6 +103,8 @@ const bool Geode::computeBound() const
|
||||
{
|
||||
BoundingBox bb;
|
||||
|
||||
// if (_occluder.valid()) _occluder->computeBound(bb);
|
||||
|
||||
DrawableList::const_iterator itr;
|
||||
for(itr=_drawables.begin();
|
||||
itr!=_drawables.end();
|
||||
@ -126,6 +130,8 @@ const bool Geode::computeBound() const
|
||||
}
|
||||
}
|
||||
|
||||
// if (_occluder.valid()) _occluder->computeBound(_bsphere);
|
||||
|
||||
_bsphere_computed=true;
|
||||
return true;
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ CXXFILES =\
|
||||
ClipPlane.cpp\
|
||||
ColorMask.cpp\
|
||||
ColorMatrix.cpp\
|
||||
ConvexPlanerPolygon.cpp\
|
||||
ConvexPlanerOccluder.cpp\
|
||||
CopyOp.cpp\
|
||||
CullFace.cpp\
|
||||
Depth.cpp\
|
||||
@ -52,6 +54,7 @@ CXXFILES =\
|
||||
Projection.cpp\
|
||||
Quat.cpp\
|
||||
ShadeModel.cpp\
|
||||
ShadowOccluderVolume.cpp\
|
||||
State.cpp\
|
||||
StateSet.cpp\
|
||||
Stencil.cpp\
|
||||
|
3
src/osg/ShadowOccluderVolume.cpp
Normal file
3
src/osg/ShadowOccluderVolume.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include <osg/ShadowOccluderVolume>
|
||||
|
||||
using namespace osg;
|
Loading…
Reference in New Issue
Block a user