diff --git a/AUTHORS b/AUTHORS index fc741763c..0c6449599 100644 --- a/AUTHORS +++ b/AUTHORS @@ -45,6 +45,9 @@ Ben Discoe - png plugin. - fixes to OBJ plugin. +Maroc Jez + - osgParticle + Byan Woods - Port to MacOS, various code changes to support this. - Metrowerks CodeWarrior makefiles. diff --git a/Make/makedirdefs b/Make/makedirdefs index 91e83f387..10281c222 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -11,6 +11,7 @@ SRC_DIRS = \ osgUtil\ osgDB\ osgGA\ + osgParticle\ osgGLUT\ osgPlugins\ osgText\ @@ -74,6 +75,7 @@ DEMOS_DIRS = \ osgcube\ osghud\ osgimpostor\ + osgparticle\ osgreflect\ osgscribe\ osgstereoimage\ diff --git a/VisualStudio/Demos/osgparticle/osgparticle.dsp b/VisualStudio/Demos/osgparticle/osgparticle.dsp new file mode 100644 index 000000000..900a2b6df --- /dev/null +++ b/VisualStudio/Demos/osgparticle/osgparticle.dsp @@ -0,0 +1,95 @@ +# Microsoft Developer Studio Project File - Name="Demo osgparticle" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=Demo osgparticle - 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 "osgparticle.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 "osgparticle.mak" CFG="Demo osgparticle - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Demo osgparticle - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "Demo osgparticle - 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 osgparticle - 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/osgparticle.exe" /libpath:"../../../lib" + +!ELSEIF "$(CFG)" == "Demo osgparticle - 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/osgparticled.exe" /pdbtype:sept /libpath:"../../../lib" +# SUBTRACT LINK32 /incremental:no + +!ENDIF + +# Begin Target + +# Name "Demo osgparticle - Win32 Release" +# Name "Demo osgparticle - Win32 Debug" +# Begin Source File + +SOURCE=..\..\..\src\Demos\osgparticle\osgparticle.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 diff --git a/VisualStudio/VisualStudio.dsw b/VisualStudio/VisualStudio.dsw index 171b581a9..38bd25249 100644 --- a/VisualStudio/VisualStudio.dsw +++ b/VisualStudio/VisualStudio.dsw @@ -182,6 +182,42 @@ Package=<4> +Project: "Core osgParticle"=.\osgParticle\osgParticle.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 + +}}} + + + +############################################################################### + + + Project: "Core osgUtil"=.\osgUtil\osgUtil.dsp - Package Owner=<4> @@ -1106,6 +1142,66 @@ Package=<4> +Project: "Demo sgv"=.\Demos\sgv\sgv.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 osgParticle + + 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: "osgPlugin 3ds"=.\osgPlugins\lib3ds\lib3ds.dsp - Package Owner=<4> diff --git a/VisualStudio/osgParticle/osgParticle.dsp b/VisualStudio/osgParticle/osgParticle.dsp new file mode 100644 index 000000000..5d6338867 --- /dev/null +++ b/VisualStudio/osgParticle/osgParticle.dsp @@ -0,0 +1,680 @@ +# Microsoft Developer Studio Project File - Name="Core osgParticle" - Package Owner=<4> + +# Microsoft Developer Studio Generated Build File, Format Version 6.00 + +# ** DO NOT EDIT ** + + + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + + + +CFG=Core osgParticle - 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 "osgParticle.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 "osgParticle.mak" CFG="Core osgParticle - Win32 Release" + +!MESSAGE + +!MESSAGE Possible choices for configuration are: + +!MESSAGE + +!MESSAGE "Core osgParticle - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") + +!MESSAGE "Core osgParticle - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") + +!MESSAGE + + + +# Begin Project + +# PROP AllowPerConfigDependencies 0 + +# PROP Scc_ProjName "" + +# PROP Scc_LocalPath "" + +CPP=cl.exe + +MTL=midl.exe + +RSC=rc.exe + + + +!IF "$(CFG)" == "Core osgParticle - Win32 Release" + + + +# PROP BASE Use_MFC 0 + +# PROP BASE Use_Debug_Libraries 0 + +# PROP BASE Output_Dir "../../lib" + +# PROP BASE Intermediate_Dir "Release" + +# PROP BASE Target_Dir "" + +# PROP Use_MFC 0 + +# PROP Use_Debug_Libraries 0 + +# PROP Output_Dir "../../lib" + +# PROP Intermediate_Dir "Release" + +# PROP Ignore_Export_Lib 0 + +# PROP Target_Dir "" + +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "FTGL_LIBRARY_STATIC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c + +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "osgParticle_LIBRARY" /D "FTGL_LIBRARY_STATIC" /D "WIN32" /D "_WINDOWS" /YX /FD /c + +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + +# 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 /dll /machine:I386 + +# ADD LINK32 glu32.lib opengl32.lib /nologo /dll /pdb:none /machine:I386 /out:"../../bin/osgParticle.dll" /libpath:"../../lib" + + + +!ELSEIF "$(CFG)" == "Core osgParticle - 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 "../../lib" + +# PROP Intermediate_Dir "Debug" + +# PROP Ignore_Export_Lib 0 + +# PROP Target_Dir "" + +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "FTGL_LIBRARY_STATIC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c + +# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../include" /D "osgParticle_LIBRARY" /D "FTGL_LIBRARY_STATIC" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c + +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + +# 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 /dll /debug /machine:I386 /pdbtype:sept + +# ADD LINK32 glu32.lib opengl32.lib /nologo /dll /debug /machine:I386 /out:"../../bin/osgParticled.dll" /pdbtype:sept /libpath:"../../lib" + +# SUBTRACT LINK32 /pdb:none + + + +!ENDIF + + + +# Begin Target + + + +# Name "Core osgParticle - Win32 Release" + +# Name "Core osgParticle - Win32 Debug" + +# Begin Group "Source Files" + + + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\Emitter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\FluidFrictionOperator.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_AccelOperator.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_CenteredPlacer.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_Emitter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_FluidFrictionOperator.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_ForceOperator.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_LinearInterpolator.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_ModularEmitter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_ModularProgram.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_MultiSegmentPlacer.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_Particle.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_ParticleProcessor.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_ParticleSystem.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_ParticleSystemUpdater.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_PointPlacer.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_Program.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_RadialShooter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_RandomRateCounter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_SectorPlacer.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_SegmentPlacer.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\IO_VariableRateCounter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\ModularEmitter.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\ModularProgram.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\MultiSegmentPlacer.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\Particle.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\ParticleProcessor.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\ParticleSystem.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\ParticleSystemUpdater.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\Program.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\src\osgParticle\Version.cpp + +# End Source File + +# End Group + +# Begin Group "Header Files" + + + +# PROP Default_Filter ";h;hpp;hxx;hm;inl" + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\AccelOperator + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\CenteredPlacer + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Counter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Emitter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Export + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\FluidFrictionOperator + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\ForceOperator + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Interpolator + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\LinearInterpolator + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\ModularEmitter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\ModularProgram + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\MultiSegmentPlacer + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Operator + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Particle + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\ParticleProcessor + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\ParticleSystem + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\ParticleSystemUpdater + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Placer + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\PointPlacer + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Program + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\RadialShooter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\RandomRateCounter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\SectorPlacer + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\SegmentPlacer + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Shooter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\VariableRateCounter + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\Version + +# End Source File + +# Begin Source File + + + +SOURCE=..\..\include\osgParticle\range + +# End Source File + +# End Group + +# Begin Group "Resource Files" + + + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + +# End Group + +# End Target + +# End Project + diff --git a/doc/doc++/osgParticle/AccelOperator.html b/doc/doc++/osgParticle/AccelOperator.html new file mode 100644 index 000000000..fd22394ca --- /dev/null +++ b/doc/doc++/osgParticle/AccelOperator.html @@ -0,0 +1,132 @@ + + + + + class osgParticle::AccelOperator + + + + +

class osgParticle::AccelOperator

An operator class that applies a constant acceleration to the particles
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(AccelOperator) +
+[more]inline AccelOperator() +
+[more]inline AccelOperator(const AccelOperator &copy, const osg::CopyOp &copyop) +
+[more]inline const osg::Vec3& getAcceleration() const +
Get the acceleration vector +
+[more]inline void setAcceleration(const osg::Vec3 &v) +
Set the acceleration vector +
+[more]inline void setToGravity(float scale) +
Quickly set the acceleration vector to the gravity on earth (0, 0, -981). +
+[more]inline void operate(Particle* P, double dt) +
Apply the acceleration to a particle. +
+[more]inline void beginOperate(Program* prg) +
Perform some initializations. +

+ +

+

Protected Methods

+[more]virtual ~AccelOperator() +
+[more]AccelOperator& operator=(const AccelOperator &) +

+ +
+

Inherited from Operator:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +
+ovirtual void endOperate() +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +

+ +
+ + +
+

Documentation

+
An operator class that applies a constant acceleration to the particles
+
+ + + +
o META_Object(AccelOperator) +

+ + +

ovirtual ~AccelOperator() +

+ + +

oAccelOperator& operator=(const AccelOperator &) +

+ + +

oinline AccelOperator() +

+ + +

oinline AccelOperator(const AccelOperator &copy, const osg::CopyOp &copyop) +

+ + +

oinline const osg::Vec3& getAcceleration() const +
Get the acceleration vector +

+ + +

oinline void setAcceleration(const osg::Vec3 &v) +
Set the acceleration vector +

+ + +

oinline void setToGravity(float scale) +
Quickly set the acceleration vector to the gravity on earth (0, 0, -981). +The acceleration will be multiplied by the scale parameter. +

+ + +

oinline void operate(Particle* P, double dt) +
Apply the acceleration to a particle. Do not call this method manually. +

+ + +

oinline void beginOperate(Program* prg) +
Perform some initializations. Do not call this method manually. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/CenteredPlacer.html b/doc/doc++/osgParticle/CenteredPlacer.html new file mode 100644 index 000000000..df21597b8 --- /dev/null +++ b/doc/doc++/osgParticle/CenteredPlacer.html @@ -0,0 +1,115 @@ + + + + + class osgParticle::CenteredPlacer + + + + +

class osgParticle::CenteredPlacer

An abstract placer base class for placers which need a center point
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]inline CenteredPlacer() +
+[more]inline CenteredPlacer(const CenteredPlacer &copy, const osg::CopyOp &copyop) +
+[more]inline const osg::Vec3& getCenter() const +
Get the center point +
+[more]inline void setCenter(const osg::Vec3 &v) +
Set the center point +
+[more]inline void setCenter(float x, float y, float z) +
Set the center point +

+ +

+

Protected Methods

+[more]virtual ~CenteredPlacer() +

+ +
+

Inherited from Placer:

+
+

+

Public Methods

+ovirtual void place(Particle* P) const +

+ +

+

Protected Methods

+oPlacer& operator=(const Placer &) +

+ +
+ + +
+

Documentation

+
An abstract placer base class for placers which need a center point
+
+ + + +
ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual ~CenteredPlacer() +

+ + +

oinline CenteredPlacer() +

+ + +

oinline CenteredPlacer(const CenteredPlacer &copy, const osg::CopyOp &copyop) +

+ + +

oinline const osg::Vec3& getCenter() const +
Get the center point +

+ + +

oinline void setCenter(const osg::Vec3 &v) +
Set the center point +

+ + +

oinline void setCenter(float x, float y, float z) +
Set the center point +

+
+
Direct child classes: +
SectorPlacer
+PointPlacer
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ClassGraph.class b/doc/doc++/osgParticle/ClassGraph.class new file mode 100644 index 000000000..4f41a1fb2 Binary files /dev/null and b/doc/doc++/osgParticle/ClassGraph.class differ diff --git a/doc/doc++/osgParticle/ClassGraphPanel.class b/doc/doc++/osgParticle/ClassGraphPanel.class new file mode 100644 index 000000000..4f3ea86bb Binary files /dev/null and b/doc/doc++/osgParticle/ClassGraphPanel.class differ diff --git a/doc/doc++/osgParticle/ClassLayout.class b/doc/doc++/osgParticle/ClassLayout.class new file mode 100644 index 000000000..69a6f494e Binary files /dev/null and b/doc/doc++/osgParticle/ClassLayout.class differ diff --git a/doc/doc++/osgParticle/Counter.html b/doc/doc++/osgParticle/Counter.html new file mode 100644 index 000000000..d5ecf1d82 --- /dev/null +++ b/doc/doc++/osgParticle/Counter.html @@ -0,0 +1,87 @@ + + + + + class osgParticle::Counter + + + + +

class osgParticle::Counter


+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]virtual int numParticlesToCreate(double dt) const = 0 +
+[more]inline Counter() +
+[more]inline Counter(const Counter &copy, const osg::CopyOp &copyop) +

+ +

+

Protected Methods

+[more] ~Counter() +
+[more]Counter& operator=(const Counter &) +

+ +
+ + +
+

Documentation

+
+ + + +
ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual int numParticlesToCreate(double dt) const = 0 +

+ + +

o ~Counter() +

+ + +

oCounter& operator=(const Counter &) +

+ + +

oinline Counter() +

+ + +

oinline Counter(const Counter &copy, const osg::CopyOp &copyop) +

+
+
Direct child classes: +
VariableRateCounter
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Emitter.html b/doc/doc++/osgParticle/Emitter.html new file mode 100644 index 000000000..0c80c46e2 --- /dev/null +++ b/doc/doc++/osgParticle/Emitter.html @@ -0,0 +1,181 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::Emitter + + + + +

class OSGPARTICLE_EXPORT osgParticle::Emitter

An abstract base class for particle emitters.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] Emitter() +
+[more] Emitter(const Emitter &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) +
+[more]virtual void accept(osg::NodeVisitor& nv) +
+[more]inline const Particle& getParticleTemplate() const +
Get the particle template +
+[more]inline void setParticleTemplate(const Particle &p) +
Set the particle template (particle is copied) +
+[more]inline bool getUseDefaultTemplate() const +
Return whether the particle system's default template should be used +
+[more]inline void setUseDefaultTemplate(bool v) +
Set whether the default particle template should be used. +
+[more]inline void process(double dt) +

+ +

+

Protected Methods

+[more]virtual ~Emitter() +
+[more]Emitter& operator=(const Emitter &) +
+[more]virtual void emit(double dt) = 0 +

+ +
+

Inherited from ParticleProcessor:

+
+

+

Public Methods

+oinline ReferenceFrame getReferenceFrame() const +
+ovoid traverse(osg::NodeVisitor &nv) +
+oinline ParticleProcessor::ReferenceFrame getReferenceFrame() const +
+oinline void setReferenceFrame(ReferenceFrame rf) +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +
+oinline ParticleSystem* getParticleSystem() +
+oinline const ParticleSystem* getParticleSystem() const +
+oinline void setParticleSystem(ParticleSystem* ps) +
+oinline const bool computeBound() const +
+oinline const osg::Matrix& getLocalToWorldMatrix() +
+oinline const osg::Matrix& getWorldToLocalMatrix() +
+oinline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P) +

+ +

+

Public Members

+oenum ReferenceFrame +

+ +
+ + +
+

Documentation

+
An abstract base class for particle emitters. +Descendant classes must override the emit() method to generate new particles by +calling the ParticleSystem::createParticle() method on the particle system associated +to the emitter.
+
+ + + +
o Emitter() +

+ + +

o Emitter(const Emitter &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) +

+ + +

ovirtual void accept(osg::NodeVisitor& nv) +

+ + +

ovirtual ~Emitter() +

+ + +

oEmitter& operator=(const Emitter &) +

+ + +

ovirtual void emit(double dt) = 0 +

+ + +

oinline const Particle& getParticleTemplate() const +
Get the particle template +

+ + +

oinline void setParticleTemplate(const Particle &p) +
Set the particle template (particle is copied) +

+ + +

oinline bool getUseDefaultTemplate() const +
Return whether the particle system's default template should be used +

+ + +

oinline void setUseDefaultTemplate(bool v) +
Set whether the default particle template should be used. +When this flag is true, the particle template is ignored, and the +particle system's default template is used instead. +

+ + +

oinline void process(double dt) +

+
+
Direct child classes: +
ModularEmitter
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/FluidFrictionOperator.html b/doc/doc++/osgParticle/FluidFrictionOperator.html new file mode 100644 index 000000000..116125b27 --- /dev/null +++ b/doc/doc++/osgParticle/FluidFrictionOperator.html @@ -0,0 +1,175 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::FluidFrictionOperator + + + + +

class OSGPARTICLE_EXPORT osgParticle::FluidFrictionOperator

An operator that simulates the friction of a fluid.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] FluidFrictionOperator() +
+[more] FluidFrictionOperator(const FluidFrictionOperator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Object(FluidFrictionOperator) +
+[more]void operate(Particle* P, double dt) +
Apply the friction forces to a particle. +
+[more]inline float getFluidDensity() const +
Get the density of the fluid +
+[more]inline float getFluidViscosity() const +
Get the viscosity of the fluid +
+[more]inline void setFluidDensity(float d) +
Set the density of the fluid +
+[more]inline void setFluidViscosity(float v) +
Set the viscosity of the fluid +
+[more]inline void setFluidToAir() +
Set the fluid parameters as for air (20°C temperature) +
+[more]inline void setFluidToWater() +
Set the fluid parameters as for pure water (20°C temperature) +
+[more]inline float getOverrideRadius() const +
Get the overriden radius value +
+[more]inline void setOverrideRadius(float r) +
Set the overriden radius value (pass 0 if you want to use particle's radius) +
+[more]inline void beginOperate(Program* prg) +
Perform some initializations. +

+ +

+

Protected Methods

+[more]virtual ~FluidFrictionOperator() +
+[more]FluidFrictionOperator& operator=(const FluidFrictionOperator &) +

+ +
+

Inherited from Operator:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +
+ovirtual void endOperate() +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +

+ +
+ + +
+

Documentation

+
An operator that simulates the friction of a fluid. +By using this operator you can let the particles move in a fluid of a given density +and viscosity. There are two functions to quickly setup the parameters for pure water +and air. You can decide whether to compute the forces using the particle's physical +radius or another value, by calling the setOverrideRadius() method.
+
+ + + +
o FluidFrictionOperator() +

+ + +

o FluidFrictionOperator(const FluidFrictionOperator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Object(FluidFrictionOperator) +

+ + +

ovoid operate(Particle* P, double dt) +
Apply the friction forces to a particle. Do not call this method manually. +

+ + +

ovirtual ~FluidFrictionOperator() +

+ + +

oFluidFrictionOperator& operator=(const FluidFrictionOperator &) +

+ + +

oinline float getFluidDensity() const +
Get the density of the fluid +

+ + +

oinline float getFluidViscosity() const +
Get the viscosity of the fluid +

+ + +

oinline void setFluidDensity(float d) +
Set the density of the fluid +

+ + +

oinline void setFluidViscosity(float v) +
Set the viscosity of the fluid +

+ + +

oinline void setFluidToAir() +
Set the fluid parameters as for air (20°C temperature) +

+ + +

oinline void setFluidToWater() +
Set the fluid parameters as for pure water (20°C temperature) +

+ + +

oinline float getOverrideRadius() const +
Get the overriden radius value +

+ + +

oinline void setOverrideRadius(float r) +
Set the overriden radius value (pass 0 if you want to use particle's radius) +

+ + +

oinline void beginOperate(Program* prg) +
Perform some initializations. Do not call this method manually. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ForceOperator.html b/doc/doc++/osgParticle/ForceOperator.html new file mode 100644 index 000000000..69a4da911 --- /dev/null +++ b/doc/doc++/osgParticle/ForceOperator.html @@ -0,0 +1,125 @@ + + + + + class osgParticle::ForceOperator + + + + +

class osgParticle::ForceOperator

An operator that applies a constant force to the particles.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(ForceOperator) +
+[more]inline ForceOperator() +
+[more]inline ForceOperator(const ForceOperator &copy, const osg::CopyOp &copyop) +
+[more]inline const osg::Vec3& getForce() const +
Get the force vector +
+[more]inline void setForce(const osg::Vec3 &v) +
Set the force vector +
+[more]inline void operate(Particle* P, double dt) +
Apply the force to a particle. +
+[more]inline void beginOperate(Program* prg) +
Perform some initialization. +

+ +

+

Protected Methods

+[more]virtual ~ForceOperator() +
+[more]ForceOperator& operator=(const ForceOperator &) +

+ +
+

Inherited from Operator:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +
+ovirtual void endOperate() +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +

+ +
+ + +
+

Documentation

+
An operator that applies a constant force to the particles. +Remember that if the mass of particles is expressed in kg and the lengths are +expressed in meters, then the force should be expressed in Newtons.
+
+ + + +
o META_Object(ForceOperator) +

+ + +

ovirtual ~ForceOperator() +

+ + +

oForceOperator& operator=(const ForceOperator &) +

+ + +

oinline ForceOperator() +

+ + +

oinline ForceOperator(const ForceOperator &copy, const osg::CopyOp &copyop) +

+ + +

oinline const osg::Vec3& getForce() const +
Get the force vector +

+ + +

oinline void setForce(const osg::Vec3 &v) +
Set the force vector +

+ + +

oinline void operate(Particle* P, double dt) +
Apply the force to a particle. Do not call this method manually. +

+ + +

oinline void beginOperate(Program* prg) +
Perform some initialization. Do not call this method manually. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/General.html b/doc/doc++/osgParticle/General.html new file mode 100644 index 000000000..88a7b3e58 --- /dev/null +++ b/doc/doc++/osgParticle/General.html @@ -0,0 +1,112 @@ + + + + + General Bits + + + + +
+
+ +o#define +OSGPARTICLE_ACCELOPERATOR_
+ +o#define +OSGPARTICLE_CENTEREDPLACER_
+ +o#define +OSGPARTICLE_COUNTER_
+ +o#define +OSGPARTICLE_EMITTER_
+ +o#define +OSGPARTICLE_EXPORT_
+ +o#define +OSGPARTICLE_EXPORT(dllexport)
+ +o#define +OSGPARTICLE_EXPORT(dllimport)
+ +o#define +OSGPARTICLE_EXPORT
+ +o#define +OSGPARTICLE_FLUIDFRICTIONOPERATOR_
+ +o#define +OSGPARTICLE_FORCEOPERATOR_
+ +o#define +OSGPARTICLE_INTERPOLATOR_
+ +o#define +OSGPARTICLE_LINEARINTERPOLATOR_
+ +o#define +OSGPARTICLE_MODULAREMITTER_
+ +o#define +OSGPARTICLE_MODULARPROGRAM_
+ +o#define +OSGPARTICLE_MULTISEGMENTPLACER_
+ +o#define +OSGPARTICLE_OPERATOR_
+ +o#define +OSGPARTICLE_PARTICLE_
+ +o#define +OSGPARTICLE_PARTICLEPROCESSOR_
+ +o#define +OSGPARTICLE_PARTICLESYSTEM_
+ +o#define +OSGPARTICLE_PARTICLESYSTEMUPDATER_
+ +o#define +OSGPARTICLE_PLACER_
+ +o#define +OSGPARTICLE_POINTPLACER_
+ +o#define +OSGPARTICLE_PROGRAM_
+ +o#define +OSGPARTICLE_RADIALSHOOTER_
+ +o#define +OSGPARTICLE_RANDOMRATECOUNTER_
+ +o#define +OSGPARTICLE_RANGE_
+ +o#define +OSGPARTICLE_SEGMENTPLACER_
+ +o#define +OSGPARTICLE_SHOOTER_
+ +o#define +OSGPARTICLE_VARIABLERATECOUNTER_
+ +o#define +OSGPARTICLE_VERSION_
+ +oOSGPARTICLE_EXPORT const char* +osgParticleGetVersion()
+ +oOSGPARTICLE_EXPORT const char* +osgParticleGetLibraryName()
+

Alphabetic index Hierarchy of classes


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/HIER.html b/doc/doc++/osgParticle/HIER.html new file mode 100644 index 000000000..eae34bc74 --- /dev/null +++ b/doc/doc++/osgParticle/HIER.html @@ -0,0 +1,61 @@ + + + + + Hierarchy of Classes + + + +

Hierarchy of Classes

+ +

Alphabetic index


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/HIERjava.html b/doc/doc++/osgParticle/HIERjava.html new file mode 100644 index 000000000..9f8422945 --- /dev/null +++ b/doc/doc++/osgParticle/HIERjava.html @@ -0,0 +1,79 @@ + + + + + Hierarchy of Classes + + + +

Hierarchy of classes

+
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ alphabetic index


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Interpolator.html b/doc/doc++/osgParticle/Interpolator.html new file mode 100644 index 000000000..dd0c3fcc2 --- /dev/null +++ b/doc/doc++/osgParticle/Interpolator.html @@ -0,0 +1,115 @@ + + + + + class osgParticle::Interpolator + + + + +

class osgParticle::Interpolator

An abstract base class for implementing interpolators
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] Interpolator() +
+[more] Interpolator(const Interpolator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]virtual float interpolate(float t, float y1, float y2) const = 0 +
Interpolate between floats. +
+[more]virtual osg::Vec2 interpolate(float t, const osg::Vec2 &y1, const osg::Vec2 &y2) const +
Interpolate between 2-dimensional vectors. +
+[more]virtual osg::Vec3 interpolate(float t, const osg::Vec3 &y1, const osg::Vec3 &y2) const +
Interpolate between 3-dimensional vectors. +
+[more]virtual osg::Vec4 interpolate(float t, const osg::Vec4 &y1, const osg::Vec4 &y2) const +
Interpolate between 4-dimensional vectors. +
+[more]template<class T_> T_ interpolate(float t, const range<T_> &r) const +

+ +

+

Protected Methods

+[more]virtual ~Interpolator() +

+ +
+ + +
+

Documentation

+
An abstract base class for implementing interpolators
+
+ + + +
o Interpolator() +

+ + +

o Interpolator(const Interpolator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual float interpolate(float t, float y1, float y2) const = 0 +
Interpolate between floats. Must be overriden in descendant classes. +

+ + +

ovirtual osg::Vec2 interpolate(float t, const osg::Vec2 &y1, const osg::Vec2 &y2) const +
Interpolate between 2-dimensional vectors. Default behavior is to interpolate each component separately. +

+ + +

ovirtual osg::Vec3 interpolate(float t, const osg::Vec3 &y1, const osg::Vec3 &y2) const +
Interpolate between 3-dimensional vectors. Default behavior is to interpolate each component separately. +

+ + +

ovirtual osg::Vec4 interpolate(float t, const osg::Vec4 &y1, const osg::Vec4 &y2) const +
Interpolate between 4-dimensional vectors. Default behavior is to interpolate each component separately. +

+ + +

otemplate<class T_> T_ interpolate(float t, const range<T_> &r) const +

+ + +

ovirtual ~Interpolator() +

+
+
Direct child classes: +
LinearInterpolator
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/LinearInterpolator.html b/doc/doc++/osgParticle/LinearInterpolator.html new file mode 100644 index 000000000..b3f4d709d --- /dev/null +++ b/doc/doc++/osgParticle/LinearInterpolator.html @@ -0,0 +1,85 @@ + + + + + class osgParticle::LinearInterpolator + + + + +

class osgParticle::LinearInterpolator

A linear interpolator
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] LinearInterpolator() +
+[more] LinearInterpolator(const LinearInterpolator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Object(LinearInterpolator) +
+[more]virtual float interpolate(float t, float y1, float y2) const +

+ +

+

Protected Methods

+[more]virtual ~LinearInterpolator() +

+ +
+

Inherited from Interpolator:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ +
+ + +
+

Documentation

+
A linear interpolator
+
+ + + +
o LinearInterpolator() +

+ + +

o LinearInterpolator(const LinearInterpolator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Object(LinearInterpolator) +

+ + +

ovirtual float interpolate(float t, float y1, float y2) const +

+ + +

ovirtual ~LinearInterpolator() +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ModularEmitter.html b/doc/doc++/osgParticle/ModularEmitter.html new file mode 100644 index 000000000..08a19237a --- /dev/null +++ b/doc/doc++/osgParticle/ModularEmitter.html @@ -0,0 +1,223 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::ModularEmitter + + + + +

class OSGPARTICLE_EXPORT osgParticle::ModularEmitter

An emitter class that holds three objects to control the creation of particles.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] ModularEmitter() +
+[more] ModularEmitter(const ModularEmitter &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Node(ModularEmitter) +
+[more]inline Counter* getCounter() +
Get the counter object +
+[more]inline const Counter* getCounter() const +
Get the const Counter object +
+[more]inline void setCounter(Counter* c) +
Set the Counter object +
+[more]inline Placer* getPlacer() +
Get the Placer object +
+[more]inline const Placer* getPlacer() const +
Get the const Placer object. +
+[more]inline void setPlacer(Placer* p) +
Set the Placer object +
+[more]inline Shooter* getShooter() +
Get the Shooter object +
+[more]inline const Shooter* getShooter() const +
Get the const Shooter object +
+[more]inline void setShooter(Shooter* s) +
Set the Shooter object +

+ +

+

Protected Methods

+[more]virtual ~ModularEmitter() +
+[more]ModularEmitter& operator=(const ModularEmitter &) +
+[more]void emit(double dt) +

+ +
+

Inherited from Emitter:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) +
+ovirtual void accept(osg::NodeVisitor& nv) +
+oinline const Particle& getParticleTemplate() const +
+oinline void setParticleTemplate(const Particle &p) +
+oinline bool getUseDefaultTemplate() const +
+oinline void setUseDefaultTemplate(bool v) +
+oinline void process(double dt) +

+ +
+

Inherited from ParticleProcessor:

+
+

+

Public Methods

+oinline ReferenceFrame getReferenceFrame() const +
+ovoid traverse(osg::NodeVisitor &nv) +
+oinline ParticleProcessor::ReferenceFrame getReferenceFrame() const +
+oinline void setReferenceFrame(ReferenceFrame rf) +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +
+oinline ParticleSystem* getParticleSystem() +
+oinline const ParticleSystem* getParticleSystem() const +
+oinline void setParticleSystem(ParticleSystem* ps) +
+oinline const bool computeBound() const +
+oinline const osg::Matrix& getLocalToWorldMatrix() +
+oinline const osg::Matrix& getWorldToLocalMatrix() +
+oinline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P) +

+ +

+

Public Members

+oenum ReferenceFrame +

+ +
+ + +
+

Documentation

+
An emitter class that holds three objects to control the creation of particles. +These objects are a counter, a placer and a shooter. +The counter controls the number of particles to be emitted at each frame; +the placer must initialize the particle's position vector, while the shooter initializes +its velocity vector. +You can use the predefined counter/placer/shooter classes, or you can create your own.
+
+ + + +
o ModularEmitter() +

+ + +

o ModularEmitter(const ModularEmitter &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Node(ModularEmitter) +

+ + +

ovirtual ~ModularEmitter() +

+ + +

oModularEmitter& operator=(const ModularEmitter &) +

+ + +

ovoid emit(double dt) +

+ + +

oinline Counter* getCounter() +
Get the counter object +

+ + +

oinline const Counter* getCounter() const +
Get the const Counter object +

+ + +

oinline void setCounter(Counter* c) +
Set the Counter object +

+ + +

oinline Placer* getPlacer() +
Get the Placer object +

+ + +

oinline const Placer* getPlacer() const +
Get the const Placer object. +

+ + +

oinline void setPlacer(Placer* p) +
Set the Placer object +

+ + +

oinline Shooter* getShooter() +
Get the Shooter object +

+ + +

oinline const Shooter* getShooter() const +
Get the const Shooter object +

+ + +

oinline void setShooter(Shooter* s) +
Set the Shooter object +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ModularProgram.html b/doc/doc++/osgParticle/ModularProgram.html new file mode 100644 index 000000000..9a811e9bd --- /dev/null +++ b/doc/doc++/osgParticle/ModularProgram.html @@ -0,0 +1,181 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::ModularProgram + + + + +

class OSGPARTICLE_EXPORT osgParticle::ModularProgram

A program class for performing operations on particles using a sequence of operators.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] ModularProgram() +
+[more] ModularProgram(const ModularProgram &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Node(ModularProgram) +
+[more]inline int numOperators() const +
Get the number of operators +
+[more]inline void addOperator(Operator* o) +
Add an operator to the list. +
+[more]inline Operator* getOperator(int i) +
Get a pointer to an operator in the list +
+[more]inline const Operator* getOperator(int i) const +
Get a const pointer to an operator in the list +
+[more]inline void removeOperator(int i) +
Remove an operator from the list +

+ +

+

Protected Methods

+[more]virtual ~ModularProgram() +
+[more]ModularProgram& operator=(const ModularProgram &) +
+[more]void execute(double dt) +

+ +
+

Inherited from Program:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) +
+ovirtual void accept(osg::NodeVisitor& nv) +
+oinline void process(double dt) +

+ +
+

Inherited from ParticleProcessor:

+
+

+

Public Methods

+oinline ReferenceFrame getReferenceFrame() const +
+ovoid traverse(osg::NodeVisitor &nv) +
+oinline ParticleProcessor::ReferenceFrame getReferenceFrame() const +
+oinline void setReferenceFrame(ReferenceFrame rf) +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +
+oinline ParticleSystem* getParticleSystem() +
+oinline const ParticleSystem* getParticleSystem() const +
+oinline void setParticleSystem(ParticleSystem* ps) +
+oinline const bool computeBound() const +
+oinline const osg::Matrix& getLocalToWorldMatrix() +
+oinline const osg::Matrix& getWorldToLocalMatrix() +
+oinline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P) +

+ +

+

Public Members

+oenum ReferenceFrame +

+ +
+ + +
+

Documentation

+
A program class for performing operations on particles using a sequence of operators. +To use a ModularProgram you have to create some Operator objects and +add them to the program. +All operators will be applied to each particle in the same order they've been added to the program.
+
+ + + +
o ModularProgram() +

+ + +

o ModularProgram(const ModularProgram &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Node(ModularProgram) +

+ + +

ovirtual ~ModularProgram() +

+ + +

oModularProgram& operator=(const ModularProgram &) +

+ + +

ovoid execute(double dt) +

+ + +

oinline int numOperators() const +
Get the number of operators +

+ + +

oinline void addOperator(Operator* o) +
Add an operator to the list. +

+ + +

oinline Operator* getOperator(int i) +
Get a pointer to an operator in the list +

+ + +

oinline const Operator* getOperator(int i) const +
Get a const pointer to an operator in the list +

+ + +

oinline void removeOperator(int i) +
Remove an operator from the list +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/MultiSegmentPlacer.html b/doc/doc++/osgParticle/MultiSegmentPlacer.html new file mode 100644 index 000000000..95ad68feb --- /dev/null +++ b/doc/doc++/osgParticle/MultiSegmentPlacer.html @@ -0,0 +1,151 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::MultiSegmentPlacer + + + + +

class OSGPARTICLE_EXPORT osgParticle::MultiSegmentPlacer

A polyline-shaped particle placer.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] MultiSegmentPlacer() +
+[more] MultiSegmentPlacer(const MultiSegmentPlacer &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Object(MultiSegmentPlacer) +
+[more]void place(Particle* P) const +
Place a partice. +
+[more]inline int numVertices() const +
Get the number of vertices which define the segments +
+[more]inline const osg::Vec3& getVertex(int i) const +
Get a vertex +
+[more]inline void setVertex(int i, const osg::Vec3 &v) +
Set a vertex +
+[more]inline void setVertex(int i, float x, float y, float z) +
Set a vertex +
+[more]inline void addVertex(const osg::Vec3 &v) +
Add a vertex +
+[more]inline void addVertex(float x, float y, float z) +
Add a vertex +
+[more]inline void removeVertex(int i) +
Remove a vertex +

+ +

+

Protected Methods

+[more]virtual ~MultiSegmentPlacer() +
+[more]MultiSegmentPlacer& operator=(const MultiSegmentPlacer &) +

+ +
+

Inherited from Placer:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ +
+ + +
+

Documentation

+
A polyline-shaped particle placer. +This placer class sets the position of incoming particles by choosing a random point on the +specified sequence of connected segments.
+
+ + + +
o MultiSegmentPlacer() +

+ + +

o MultiSegmentPlacer(const MultiSegmentPlacer &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Object(MultiSegmentPlacer) +

+ + +

ovoid place(Particle* P) const +
Place a partice. Called automatically by ModularEmitter, do not call this method manually. +

+ + +

ovirtual ~MultiSegmentPlacer() +

+ + +

oMultiSegmentPlacer& operator=(const MultiSegmentPlacer &) +

+ + +

oinline int numVertices() const +
Get the number of vertices which define the segments +

+ + +

oinline const osg::Vec3& getVertex(int i) const +
Get a vertex +

+ + +

oinline void setVertex(int i, const osg::Vec3 &v) +
Set a vertex +

+ + +

oinline void setVertex(int i, float x, float y, float z) +
Set a vertex +

+ + +

oinline void addVertex(const osg::Vec3 &v) +
Add a vertex +

+ + +

oinline void addVertex(float x, float y, float z) +
Add a vertex +

+ + +

oinline void removeVertex(int i) +
Remove a vertex +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/NavigatorButton.class b/doc/doc++/osgParticle/NavigatorButton.class new file mode 100644 index 000000000..fad9c3f2d Binary files /dev/null and b/doc/doc++/osgParticle/NavigatorButton.class differ diff --git a/doc/doc++/osgParticle/OSGPARTICLE_SECTORPLACER_.html b/doc/doc++/osgParticle/OSGPARTICLE_SECTORPLACER_.html new file mode 100644 index 000000000..4cd4167ae --- /dev/null +++ b/doc/doc++/osgParticle/OSGPARTICLE_SECTORPLACER_.html @@ -0,0 +1,20 @@ + + + + + #define OSGPARTICLE_SECTORPLACER_ + + + + +

#define OSGPARTICLE_SECTORPLACER_

Range of osg::Vec4s
+ + +
+

Documentation

+
Range of osg::Vec4s
+

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Operator.html b/doc/doc++/osgParticle/Operator.html new file mode 100644 index 000000000..ddfae931f --- /dev/null +++ b/doc/doc++/osgParticle/Operator.html @@ -0,0 +1,135 @@ + + + + + class osgParticle::Operator + + + + +

class osgParticle::Operator

An abstract base class used by ModularProgram to perform operations on particles before they are updated.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]virtual void operate(Particle* P, double dt) = 0 +
Do something on a particle. +
+[more]virtual void beginOperate(Program* ) +
Do something before processing particles via the operate() method. +
+[more]virtual void endOperate() +
Do something after all particles have been processed +
+[more]inline Operator() +
+[more]inline Operator(const Operator &copy, const osg::CopyOp &copyop) +
+[more]inline bool isEnabled() const +
Get whether this operator is enabled +
+[more]inline void setEnabled(bool v) +
Enable or disable this operator +

+ +

+

Protected Methods

+[more]virtual ~Operator() +
+[more]Operator& operator=(const Operator &) +

+ +
+ + +
+

Documentation

+
An abstract base class used by ModularProgram to perform operations on particles before they are updated. +To implement a new operator, derive from this class and override the operate() method. +You should also override the beginOperate() method to query the calling program for the reference frame +used, and initialize the right transformations if needed.
+
+ + + +
ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual void operate(Particle* P, double dt) = 0 +
Do something on a particle. +This method is called by ModularProgram objects to perform some operations +on the particles. You must override it in descendant classes. Common operations +consist of modifying the particle's velocity vector. The dt parameter is +the time elapsed from last operation. +

+ + +

ovirtual void beginOperate(Program* ) +
Do something before processing particles via the operate() method. +Overriding this method could be necessary to query the calling Program object +for the current reference frame. If the reference frame is RELATIVE_TO_PARENTS, then your +class should prepare itself to do all operations in local coordinates. +

+ + +

ovirtual void endOperate() +
Do something after all particles have been processed +

+ + +

ovirtual ~Operator() +

+ + +

oOperator& operator=(const Operator &) +

+ + +

oinline Operator() +

+ + +

oinline Operator(const Operator &copy, const osg::CopyOp &copyop) +

+ + +

oinline bool isEnabled() const +
Get whether this operator is enabled +

+ + +

oinline void setEnabled(bool v) +
Enable or disable this operator +

+
+
Direct child classes: +
ForceOperator
+FluidFrictionOperator
+AccelOperator
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Particle.html b/doc/doc++/osgParticle/Particle.html new file mode 100644 index 000000000..c26bff23b --- /dev/null +++ b/doc/doc++/osgParticle/Particle.html @@ -0,0 +1,377 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::Particle + + + + +

class OSGPARTICLE_EXPORT osgParticle::Particle

Implementation of a particle.
+
+ +
+

+

Public Methods

+[more] Particle() +
+[more]inline Shape getShape() const +
Get the shape of the particle +
+[more]bool update(double dt) +
Update the particle (don't call this method manually). +
+[more]void render(const osg::Matrix &modelview, float scale = 1.0f) const +
Render the particle. +
+[more]inline Particle::Shape getShape() const +
+[more]inline void setShape(Shape s) +
Set the shape of the particle +
+[more]inline bool isAlive() const +
Get whether the particle is still alive +
+[more]inline double getLifeTime() const +
Get the life time of the particle (in seconds) +
+[more]inline double getAge() const +
Get the age of the particle (in seconds) +
+[more]inline float getRadius() const +
Get the physical radius of the particle. +
+[more]inline void setRadius(float r) +
Set the physical radius of the particle. +
+[more]inline const rangef& getSizeRange() const +
Get the minimum and maximum values for polygon size +
+[more]inline const rangef& getAlphaRange() const +
Get the minimum and maximum values for alpha +
+[more]inline const rangev4& getColorRange() const +
Get the minimum and maximum values for color +
+[more]inline const Interpolator* getSizeInterpolator() const +
Get the interpolator for computing the size of polygons +
+[more]inline const Interpolator* getAlphaInterpolator() const +
Get the interpolator for computing alpha values +
+[more]inline const Interpolator* getColorInterpolator() const +
Get the interpolator for computing color values +
+[more]inline const osg::Vec3& getPosition() const +
Get the position vector +
+[more]inline const osg::Vec3& getVelocity() const +
Get the velocity vector. +
+[more]inline const osg::Vec3& getPreviousPosition() const +
Get the previous position (the position before last update) +
+[more]inline void kill() +
Kill the particle on next update NOTE: after calling this function, the isAlive() method will still return true until the particle is updated again +
+[more]inline void setLifeTime(double t) +
Set the life time of the particle +
+[more]inline void setSizeRange(const rangef &r) +
Set the minimum and maximum values for polygon size +
+[more]inline void setAlphaRange(const rangef &r) +
Set the minimum and maximum values for alpha +
+[more]inline void setColorRange(const rangev4 &r) +
Set the minimum and maximum values for color +
+[more]inline void setSizeInterpolator(Interpolator* ri) +
Set the interpolator for computing size values +
+[more]inline void setAlphaInterpolator(Interpolator* ai) +
Set the interpolator for computing alpha values. +
+[more]inline void setColorInterpolator(Interpolator* ci) +
Set the interpolator for computing color values +
+[more]inline void setPosition(const osg::Vec3 &p) +
Set the position vector. +
+[more]inline void setVelocity(const osg::Vec3 &v) +
Set the velocity vector. +
+[more]inline void addVelocity(const osg::Vec3 &v) +
Add a vector to the velocity vector +
+[more]inline void transformPositionVelocity(const osg::Matrix &xform) +
Transform position and velocity vectors by a matrix +
+[more]inline float getMass() const +
Get the mass of the particle. +
+[more]inline float getMassInv() const +
Get 1 / getMass() +
+[more]inline void setMass(float m) +
Set the mass of the particle. +
+[more]inline void beginRender() +
Perform some pre-rendering tasks. +
+[more]inline void endRender() +
Perform some post-rendering tasks. +

+ +

+

Public Members

+[more]enum Shape +

+ +
+ + +
+

Documentation

+
Implementation of a particle. +Objects of this class are particles, they have some graphical properties +and some physical properties. Particles are created by emitters and then placed +into Particle Systems, where they live and get updated at each frame. +Particles can either live forever (lifeTime < 0), or die after a specified +time (lifeTime >= 0). For each property which is defined as a range of values, a +"current" value will be evaluated at each frame by interpolating the min +and max values so that curr_value = min when t == 0, and +curr_value = max when t == lifeTime. +You may customize the interpolator objects to achieve any kind of transition. +If you want the particle to live forever, set its lifetime to any value <= 0; +in that case, no interpolation is done to compute real-time properties, and only +minimum values are used.
+
+ + + +
oenum Shape +

+ + + +
o POINT +

+ + +

o QUAD +

+ + +

o QUAD_TRIANGLESTRIP +

+ + +

o HEXAGON +

+ + + +
o Particle() +

+ + +

oinline Shape getShape() const +
Get the shape of the particle +

+ + +

obool update(double dt) +
Update the particle (don't call this method manually). +This method is called automatically by ParticleSystem::update(); it +updates the graphical properties of the particle for the current time, +checks whether the particle is still alive, and then updates its position +by computing P = P + V * dt (where P is the position and V is the velocity). +

+ + +

ovoid render(const osg::Matrix &modelview, float scale = 1.0f) const +
Render the particle. Called automatically by particle systems. +

+ + +

oinline Particle::Shape getShape() const +

+ + +

oinline void setShape(Shape s) +
Set the shape of the particle +

+ + +

oinline bool isAlive() const +
Get whether the particle is still alive +

+ + +

oinline double getLifeTime() const +
Get the life time of the particle (in seconds) +

+ + +

oinline double getAge() const +
Get the age of the particle (in seconds) +

+ + +

oinline float getRadius() const +
Get the physical radius of the particle. +For built-in operators to work correctly, lengths must be expressed in meters. +

+ + +

oinline void setRadius(float r) +
Set the physical radius of the particle. +For built-in operators to work correctly, lengths must be expressed in meters. +

+ + +

oinline const rangef& getSizeRange() const +
Get the minimum and maximum values for polygon size +

+ + +

oinline const rangef& getAlphaRange() const +
Get the minimum and maximum values for alpha +

+ + +

oinline const rangev4& getColorRange() const +
Get the minimum and maximum values for color +

+ + +

oinline const Interpolator* getSizeInterpolator() const +
Get the interpolator for computing the size of polygons +

+ + +

oinline const Interpolator* getAlphaInterpolator() const +
Get the interpolator for computing alpha values +

+ + +

oinline const Interpolator* getColorInterpolator() const +
Get the interpolator for computing color values +

+ + +

oinline const osg::Vec3& getPosition() const +
Get the position vector +

+ + +

oinline const osg::Vec3& getVelocity() const +
Get the velocity vector. +For built-in operators to work correctly, remember that velocity components are expressed +in meters per second. +

+ + +

oinline const osg::Vec3& getPreviousPosition() const +
Get the previous position (the position before last update) +

+ + +

oinline void kill() +
Kill the particle on next update +NOTE: after calling this function, the isAlive() method will still +return true until the particle is updated again +

+ + +

oinline void setLifeTime(double t) +
Set the life time of the particle +

+ + +

oinline void setSizeRange(const rangef &r) +
Set the minimum and maximum values for polygon size +

+ + +

oinline void setAlphaRange(const rangef &r) +
Set the minimum and maximum values for alpha +

+ + +

oinline void setColorRange(const rangev4 &r) +
Set the minimum and maximum values for color +

+ + +

oinline void setSizeInterpolator(Interpolator* ri) +
Set the interpolator for computing size values +

+ + +

oinline void setAlphaInterpolator(Interpolator* ai) +
Set the interpolator for computing alpha values. +

+ + +

oinline void setColorInterpolator(Interpolator* ci) +
Set the interpolator for computing color values +

+ + +

oinline void setPosition(const osg::Vec3 &p) +
Set the position vector. +

+ + +

oinline void setVelocity(const osg::Vec3 &v) +
Set the velocity vector. +For built-in operators to work correctly, remember that velocity components are expressed +in meters per second. +

+ + +

oinline void addVelocity(const osg::Vec3 &v) +
Add a vector to the velocity vector +

+ + +

oinline void transformPositionVelocity(const osg::Matrix &xform) +
Transform position and velocity vectors by a matrix +

+ + +

oinline float getMass() const +
Get the mass of the particle. +For built-in operators to work correctly, remember that the mass is expressed in kg. +

+ + +

oinline float getMassInv() const +
Get 1 / getMass() +

+ + +

oinline void setMass(float m) +
Set the mass of the particle. +For built-in operators to work correctly, remember that the mass is expressed in kg. +

+ + +

oinline void beginRender() +
Perform some pre-rendering tasks. Called automatically by particle systems. +

+ + +

oinline void endRender() +
Perform some post-rendering tasks. Called automatically by particle systems. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ParticleProcessor.html b/doc/doc++/osgParticle/ParticleProcessor.html new file mode 100644 index 000000000..9a78e2fde --- /dev/null +++ b/doc/doc++/osgParticle/ParticleProcessor.html @@ -0,0 +1,241 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::ParticleProcessor + + + + +

class OSGPARTICLE_EXPORT osgParticle::ParticleProcessor

A common base interface for those classes which need to do something on particles.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] ParticleProcessor() +
+[more] ParticleProcessor(const ParticleProcessor &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) +
+[more]virtual void accept(osg::NodeVisitor& nv) +
+[more]inline ReferenceFrame getReferenceFrame() const +
Get the reference frame +
+[more]void traverse(osg::NodeVisitor &nv) +
+[more]inline ParticleProcessor::ReferenceFrame getReferenceFrame() const +
+[more]inline void setReferenceFrame(ReferenceFrame rf) +
Set the reference frame +
+[more]inline bool isEnabled() const +
Get whether this processor is enabled or not +
+[more]inline void setEnabled(bool v) +
Set whether this processor is enabled or not +
+[more]inline ParticleSystem* getParticleSystem() +
Get a pointer to the destination particle system +
+[more]inline const ParticleSystem* getParticleSystem() const +
Get a const pointer to the destination particle system +
+[more]inline void setParticleSystem(ParticleSystem* ps) +
Set the destination particle system +
+[more]inline const bool computeBound() const +
+[more]inline const osg::Matrix& getLocalToWorldMatrix() +
Get the current local-to-world transformation matrix (valid only during cull traversal) +
+[more]inline const osg::Matrix& getWorldToLocalMatrix() +
Get the current world-to-local transformation matrix (valid only during cull traversal) +
+[more]inline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P) +
Transform a point from local to world coordinates (valid only during cull traversal) +
+[more]inline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P) +
Transform a point from world to local coordinates (valid only during cull traversal) +
+[more]inline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P) +
Transform a vector from local to world coordinates, discarding translation (valid only during cull traversal) +
+[more]inline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P) +
Transform a vector from world to local coordinates, discarding translation (valid only during cull traversal) +

+ +

+

Public Members

+[more]enum ReferenceFrame +

+ +

+

Protected Methods

+[more]virtual ~ParticleProcessor() +
+[more]ParticleProcessor& operator=(const ParticleProcessor &) +
+[more]virtual void process(double dt) = 0 +

+ +
+ + +
+

Documentation

+
A common base interface for those classes which need to do something on particles. Such classes +are, for example, Emitter (particle generation) and Program (particle animation). +This class holds some properties, like a reference frame and a reference to a ParticleSystem; +descendant classes should process the particles taking into account the reference frame, computing the right +transformations when needed.
+
+ + + +
oenum ReferenceFrame +

+ + + +
o RELATIVE_TO_PARENTS +

+ + +

o RELATIVE_TO_ABSOLUTE +

+ + + +
o ParticleProcessor() +

+ + +

o ParticleProcessor(const ParticleProcessor &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) +

+ + +

ovirtual void accept(osg::NodeVisitor& nv) +

+ + +

oinline ReferenceFrame getReferenceFrame() const +
Get the reference frame +

+ + +

ovoid traverse(osg::NodeVisitor &nv) +

+ + +

ovirtual ~ParticleProcessor() +

+ + +

oParticleProcessor& operator=(const ParticleProcessor &) +

+ + +

ovirtual void process(double dt) = 0 +

+ + +

oinline ParticleProcessor::ReferenceFrame getReferenceFrame() const +

+ + +

oinline void setReferenceFrame(ReferenceFrame rf) +
Set the reference frame +

+ + +

oinline bool isEnabled() const +
Get whether this processor is enabled or not +

+ + +

oinline void setEnabled(bool v) +
Set whether this processor is enabled or not +

+ + +

oinline ParticleSystem* getParticleSystem() +
Get a pointer to the destination particle system +

+ + +

oinline const ParticleSystem* getParticleSystem() const +
Get a const pointer to the destination particle system +

+ + +

oinline void setParticleSystem(ParticleSystem* ps) +
Set the destination particle system +

+ + +

oinline const bool computeBound() const +

+ + +

oinline const osg::Matrix& getLocalToWorldMatrix() +
Get the current local-to-world transformation matrix (valid only during cull traversal) +

+ + +

oinline const osg::Matrix& getWorldToLocalMatrix() +
Get the current world-to-local transformation matrix (valid only during cull traversal) +

+ + +

oinline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P) +
Transform a point from local to world coordinates (valid only during cull traversal) +

+ + +

oinline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P) +
Transform a point from world to local coordinates (valid only during cull traversal) +

+ + +

oinline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P) +
Transform a vector from local to world coordinates, discarding translation (valid only during cull traversal) +

+ + +

oinline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P) +
Transform a vector from world to local coordinates, discarding translation (valid only during cull traversal) +

+
+
Direct child classes: +
Program
+Emitter
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ParticleSystem.html b/doc/doc++/osgParticle/ParticleSystem.html new file mode 100644 index 000000000..429997e0f --- /dev/null +++ b/doc/doc++/osgParticle/ParticleSystem.html @@ -0,0 +1,311 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::ParticleSystem + + + + +

class OSGPARTICLE_EXPORT osgParticle::ParticleSystem

The heart of this class library; its purpose is to hold a set of particles and manage particle creation, update, rendering and destruction.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] ParticleSystem() +
+[more] ParticleSystem(const ParticleSystem &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Object(ParticleSystem) +
+[more]inline virtual Particle* createParticle(const Particle* ptemplate) +
Create a new particle from the specified template (or the default one if ptemplate is null) +
+[more]inline virtual void destroyParticle(int i) +
Destroy the i-th particle +
+[more]void setDefaultAttributes(const std::string &texturefile = "", bool emissive_particles = true, bool lighting = false) +
A useful method to set the most common StateAttribute's in one call. +
+[more]virtual void update(double dt) +
Update the particles. +
+[more]inline virtual bool getStats(osg::Statistics &stats) +
+[more]inline bool isFrozen() const +
Return true if the particle system is frozen +
+[more]inline void setFrozen(bool v) +
Set or reset the frozen state. +
+[more]inline const osg::BoundingBox& getDefaultBoundingBox() const +
Get the default bounding box +
+[more]inline void setDefaultBoundingBox(const osg::BoundingBox &bbox) +
Set the default bounding box. +
+[more]inline bool getDoublePassRendering() const +
Get the double pass rendering flag +
+[more]inline void setDoublePassRendering(bool v) +
Set the double pass rendering flag. +
+[more]inline int numParticles() const +
Get the number of allocated particles (alive + dead) +
+[more]inline int numDeadParticles() const +
Get the number of dead particles +
+[more]inline Particle* getParticle(int i) +
Get a pointer to the i-th particle +
+[more]inline const Particle* getParticle(int i) const +
Get a const pointer to the i-th particle +
+[more]inline void destroyParticle(int i) +
+[more]inline int getLastFrameNumber() const +
Get the last frame number +
+[more]inline const bool computeBound() const +
+[more]inline bool getStats(osg::Statistics &stats) +
+[more]inline void update_bounds(const osg::Vec3 &p) +
+[more]inline const Particle& getDefaultParticleTemplate() const +
Get a reference to the default particle template +
+[more]inline void setDefaultParticleTemplate(const Particle &p) +
Set the default particle template (particle is copied) +
+[more]inline bool getFreezeOnCull() const +
Get whether the particle system can freeze when culled +
+[more]inline void setFreezeOnCull(bool v) +
Set whether the particle system can freeze when culled (default is true) +
+[more]inline int getLevelOfDetail() const +
(EXPERIMENTAL) Get the level of detail +
+[more]inline void setLevelOfDetail(int v) +
(EXPERIMENTAL) Set the level of detail. +
+[more]inline Particle* createParticle(const Particle* ptemplate) +

+ +

+

Protected Methods

+[more]virtual ~ParticleSystem() +
+[more]ParticleSystem& operator=(const ParticleSystem &) +
+[more]inline virtual const bool computeBound() const +
+[more]virtual void drawImmediateMode(osg::State &state) +
+[more]void single_pass_render(const osg::Matrix &modelview) +

+ +
+ + +
+

Documentation

+
The heart of this class library; its purpose is to hold a set of particles and manage particle creation, update, rendering and destruction. +You can add this drawable to any Geode as you usually do with other +Drawable classes. Each instance of ParticleSystem is a separate set of +particles; it provides the interface for creating particles and iterating +through them (see the Emitter and Program classes).
+
+ + + +
o ParticleSystem() +

+ + +

o ParticleSystem(const ParticleSystem &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Object(ParticleSystem) +

+ + +

oinline virtual Particle* createParticle(const Particle* ptemplate) +
Create a new particle from the specified template (or the default one if ptemplate is null) +

+ + +

oinline virtual void destroyParticle(int i) +
Destroy the i-th particle +

+ + +

ovoid setDefaultAttributes(const std::string &texturefile = "", bool emissive_particles = true, bool lighting = false) +
A useful method to set the most common StateAttribute's in one call. +If texturefile is empty, then texturing is turned off. +

+ + +

ovirtual void update(double dt) +
Update the particles. Don't call this directly, use a ParticleSystemUpdater instead. +

+ + +

oinline virtual bool getStats(osg::Statistics &stats) +

+ + +

ovirtual ~ParticleSystem() +

+ + +

oParticleSystem& operator=(const ParticleSystem &) +

+ + +

oinline virtual const bool computeBound() const +

+ + +

ovirtual void drawImmediateMode(osg::State &state) +

+ + +

ovoid single_pass_render(const osg::Matrix &modelview) +

+ + +

oinline bool isFrozen() const +
Return true if the particle system is frozen +

+ + +

oinline void setFrozen(bool v) +
Set or reset the frozen state. +When the particle system is frozen, emitters and programs won't do anything on it. +

+ + +

oinline const osg::BoundingBox& getDefaultBoundingBox() const +
Get the default bounding box +

+ + +

oinline void setDefaultBoundingBox(const osg::BoundingBox &bbox) +
Set the default bounding box. +The default bounding box is used when a real bounding box cannot be computed, for example +because no particles has been updated yet. +

+ + +

oinline bool getDoublePassRendering() const +
Get the double pass rendering flag +

+ + +

oinline void setDoublePassRendering(bool v) +
Set the double pass rendering flag. +Double pass rendering avoids overdraw problems between particle systems +and other opaque objects. If you can render all the particle systems after +the opaque objects, then double pass is not necessary and can be turned off (best choice). +If you set the default attributes with setDefaultAttributes, then the particle +system will fall into a transparent bin. +

+ + +

oinline int numParticles() const +
Get the number of allocated particles (alive + dead) +

+ + +

oinline int numDeadParticles() const +
Get the number of dead particles +

+ + +

oinline Particle* getParticle(int i) +
Get a pointer to the i-th particle +

+ + +

oinline const Particle* getParticle(int i) const +
Get a const pointer to the i-th particle +

+ + +

oinline void destroyParticle(int i) +

+ + +

oinline int getLastFrameNumber() const +
Get the last frame number +

+ + +

oinline const bool computeBound() const +

+ + +

oinline bool getStats(osg::Statistics &stats) +

+ + +

oinline void update_bounds(const osg::Vec3 &p) +

+ + +

oinline const Particle& getDefaultParticleTemplate() const +
Get a reference to the default particle template +

+ + +

oinline void setDefaultParticleTemplate(const Particle &p) +
Set the default particle template (particle is copied) +

+ + +

oinline bool getFreezeOnCull() const +
Get whether the particle system can freeze when culled +

+ + +

oinline void setFreezeOnCull(bool v) +
Set whether the particle system can freeze when culled (default is true) +

+ + +

oinline int getLevelOfDetail() const +
(EXPERIMENTAL) Get the level of detail +

+ + +

oinline void setLevelOfDetail(int v) +
(EXPERIMENTAL) Set the level of detail. The total number of particles is divided by the detail value to +get the actual number of particles to be drawn. This value must be greater than zero. +

+ + +

oinline Particle* createParticle(const Particle* ptemplate) +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/ParticleSystemUpdater.html b/doc/doc++/osgParticle/ParticleSystemUpdater.html new file mode 100644 index 000000000..d27a75837 --- /dev/null +++ b/doc/doc++/osgParticle/ParticleSystemUpdater.html @@ -0,0 +1,152 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::ParticleSystemUpdater + + + + +

class OSGPARTICLE_EXPORT osgParticle::ParticleSystemUpdater

A useful node class for updating particle systems automatically.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] ParticleSystemUpdater() +
+[more] ParticleSystemUpdater(const ParticleSystemUpdater &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more] META_Node(ParticleSystemUpdater) +
+[more]virtual void traverse(osg::NodeVisitor &nv) +
+[more]inline const bool computeBound() const +
+[more]inline int numParticleSystems() const +
Return the number of particle systems on the list +
+[more]inline void addParticleSystem(ParticleSystem* ps) +
Add a particle system to the list +
+[more]inline const ParticleSystem* getParticleSystem(int i) const +
Get a const particle system from the list +
+[more]inline ParticleSystem* getParticleSystem(int i) +
Get a particle system from the list +
+[more]inline void removeParticleSystem(int i) +
Remove a particle system from the list (by index) +
+[more]inline int findParticleSystem(ParticleSystem* ps) const +
Find a particle system +
+[more]inline bool removeParticleSystem(ParticleSystem* ps) +
Remove a particle system from the list (by pointer) +

+ +

+

Protected Methods

+[more]virtual ~ParticleSystemUpdater() +
+[more]ParticleSystemUpdater& operator=(const ParticleSystemUpdater &) +
+[more]inline virtual const bool computeBound() const +

+ +
+ + +
+

Documentation

+
A useful node class for updating particle systems automatically. +When a ParticleSystemUpdater is traversed by a cull visitor, it calls the +update() method on the specified particle systems. You should place this updater +AFTER other nodes like emitters and programs.
+
+ + + +
o ParticleSystemUpdater() +

+ + +

o ParticleSystemUpdater(const ParticleSystemUpdater &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

o META_Node(ParticleSystemUpdater) +

+ + +

ovirtual void traverse(osg::NodeVisitor &nv) +

+ + +

ovirtual ~ParticleSystemUpdater() +

+ + +

oParticleSystemUpdater& operator=(const ParticleSystemUpdater &) +

+ + +

oinline virtual const bool computeBound() const +

+ + +

oinline const bool computeBound() const +

+ + +

oinline int numParticleSystems() const +
Return the number of particle systems on the list +

+ + +

oinline void addParticleSystem(ParticleSystem* ps) +
Add a particle system to the list +

+ + +

oinline const ParticleSystem* getParticleSystem(int i) const +
Get a const particle system from the list +

+ + +

oinline ParticleSystem* getParticleSystem(int i) +
Get a particle system from the list +

+ + +

oinline void removeParticleSystem(int i) +
Remove a particle system from the list (by index) +

+ + +

oinline int findParticleSystem(ParticleSystem* ps) const +
Find a particle system +

+ + +

oinline bool removeParticleSystem(ParticleSystem* ps) +
Remove a particle system from the list (by pointer) +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Placer.html b/doc/doc++/osgParticle/Placer.html new file mode 100644 index 000000000..d373f0acb --- /dev/null +++ b/doc/doc++/osgParticle/Placer.html @@ -0,0 +1,95 @@ + + + + + class osgParticle::Placer + + + + +

class osgParticle::Placer

An abstract base class for implementing particle placers.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]virtual void place(Particle* P) const = 0 +
Place a particle. +
+[more]inline Placer() +
+[more]inline Placer(const Placer &copy, const osg::CopyOp &copyop) +

+ +

+

Protected Methods

+[more] ~Placer() +
+[more]Placer& operator=(const Placer &) +

+ +
+ + +
+

Documentation

+
An abstract base class for implementing particle placers. A placer is an object which take +a particle as input, and places it somewhere by setting its position vector. Placer objects are +used by the ModularEmitter class as part of the particle emission process.
+
+ + + +
ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual void place(Particle* P) const = 0 +
Place a particle. Must be implemented in descendant classes. +

+ + +

o ~Placer() +

+ + +

oPlacer& operator=(const Placer &) +

+ + +

oinline Placer() +

+ + +

oinline Placer(const Placer &copy, const osg::CopyOp &copyop) +

+
+
Direct child classes: +
SegmentPlacer
+MultiSegmentPlacer
+CenteredPlacer
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/PointPlacer.html b/doc/doc++/osgParticle/PointPlacer.html new file mode 100644 index 000000000..16d226752 --- /dev/null +++ b/doc/doc++/osgParticle/PointPlacer.html @@ -0,0 +1,106 @@ + + + + + class osgParticle::PointPlacer + + + + +

class osgParticle::PointPlacer

A point-shaped particle placer.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(PointPlacer) +
+[more]inline PointPlacer() +
+[more]inline PointPlacer(const PointPlacer &copy, const osg::CopyOp &copyop) +
+[more]inline void place(Particle* P) const +
Place a particle. +

+ +

+

Protected Methods

+[more]virtual ~PointPlacer() +
+[more]PointPlacer& operator=(const PointPlacer &) +

+ +
+

Inherited from CenteredPlacer:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +
+oinline const osg::Vec3& getCenter() const +
+oinline void setCenter(const osg::Vec3 &v) +
+oinline void setCenter(float x, float y, float z) +

+ +
+

Inherited from Placer:

+
+
+ + +
+

Documentation

+
A point-shaped particle placer. +This placer class uses the center point defined in its base class CenteredPlacer +to place there all incoming particles.
+
+ + + +
o META_Object(PointPlacer) +

+ + +

ovirtual ~PointPlacer() +

+ + +

oPointPlacer& operator=(const PointPlacer &) +

+ + +

oinline PointPlacer() +

+ + +

oinline PointPlacer(const PointPlacer &copy, const osg::CopyOp &copyop) +

+ + +

oinline void place(Particle* P) const +
Place a particle. +This method is called automatically by ModularEmitter and should not be called +manually. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Program.html b/doc/doc++/osgParticle/Program.html new file mode 100644 index 000000000..c6fcf982d --- /dev/null +++ b/doc/doc++/osgParticle/Program.html @@ -0,0 +1,152 @@ + + + + + class OSGPARTICLE_EXPORT osgParticle::Program + + + + +

class OSGPARTICLE_EXPORT osgParticle::Program

An abstract ParticleProcessor descendant for modifying particles "on the fly" during the cull traversal.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] Program() +
+[more] Program(const Program &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +
+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) +
+[more]virtual void accept(osg::NodeVisitor& nv) +
+[more]inline void process(double dt) +
Implementation of ParticleProcessor::process(). +

+ +

+

Protected Methods

+[more]virtual ~Program() +
+[more]Program& operator=(const Program &) +
+[more]virtual void execute(double dt) = 0 +
Execute the program on the particle system. +

+ +
+

Inherited from ParticleProcessor:

+
+

+

Public Methods

+oinline ReferenceFrame getReferenceFrame() const +
+ovoid traverse(osg::NodeVisitor &nv) +
+oinline ParticleProcessor::ReferenceFrame getReferenceFrame() const +
+oinline void setReferenceFrame(ReferenceFrame rf) +
+oinline bool isEnabled() const +
+oinline void setEnabled(bool v) +
+oinline ParticleSystem* getParticleSystem() +
+oinline const ParticleSystem* getParticleSystem() const +
+oinline void setParticleSystem(ParticleSystem* ps) +
+oinline const bool computeBound() const +
+oinline const osg::Matrix& getLocalToWorldMatrix() +
+oinline const osg::Matrix& getWorldToLocalMatrix() +
+oinline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P) +
+oinline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P) +

+ +

+

Public Members

+oenum ReferenceFrame +

+ +
+ + +
+

Documentation

+
An abstract ParticleProcessor descendant for modifying particles "on the fly" +during the cull traversal. +Descendants of this class must implement the execute() method, which should iterate +through all particles in the linked particle system and modify them somehow +(usually updating their velocity vector).
+
+ + + +
o Program() +

+ + +

o Program(const Program &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY) +

+ + +

ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) +

+ + +

ovirtual void accept(osg::NodeVisitor& nv) +

+ + +

ovirtual ~Program() +

+ + +

oProgram& operator=(const Program &) +

+ + +

ovirtual void execute(double dt) = 0 +
Execute the program on the particle system. Must be overriden in descendant classes. +

+ + +

oinline void process(double dt) +
Implementation of ParticleProcessor::process(). Do not call this method by yourself. +

+
+
Direct child classes: +
ModularProgram
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/RadialShooter.html b/doc/doc++/osgParticle/RadialShooter.html new file mode 100644 index 000000000..09da7b6a1 --- /dev/null +++ b/doc/doc++/osgParticle/RadialShooter.html @@ -0,0 +1,170 @@ + + + + + class osgParticle::RadialShooter + + + + +

class osgParticle::RadialShooter

A shooter class that shoots particles radially.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(RadialShooter) +
+[more]inline RadialShooter() +
+[more]inline RadialShooter(const RadialShooter &copy, const osg::CopyOp &copyop) +
+[more]inline const rangef& getThetaRange() const +
Get the range of possible values for theta angle +
+[more]inline const rangef& getPhiRange() const +
Get the range of possible values for phi angle +
+[more]inline const rangef& getInitialSpeedRange() const +
Get the range of possible values for initial speed of particles +
+[more]inline void setThetaRange(const rangef &r) +
Set the range of possible values for theta angle +
+[more]inline void setThetaRange(float r1, float r2) +
Set the range of possible values for theta angle +
+[more]inline void setPhiRange(const rangef &r) +
Set the range of possible values for phi angle +
+[more]inline void setPhiRange(float r1, float r2) +
Set the range of possible values for phi angle +
+[more]inline void setInitialSpeedRange(const rangef &r) +
Set the range of possible values for initial speed of particles +
+[more]inline void setInitialSpeedRange(float r1, float r2) +
Set the range of possible values for initial speed of particles +
+[more]inline void shoot(Particle* P) const +
Shoot a particle. +

+ +

+

Protected Methods

+[more]virtual ~RadialShooter() +
+[more]RadialShooter& operator=(const RadialShooter &) +

+ +
+

Inherited from Shooter:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ +
+ + +
+

Documentation

+
A shooter class that shoots particles radially. +This shooter computes the velocity vector of incoming particles by choosing a +random direction and a random speed. Both direction and speed are chosen within +specified ranges. The direction is defined by two angles: theta, which +is the angle between the velocity vector and the Z axis, and phi, which is +the angle between the X axis and the velocity vector projected onto the X-Y plane.
+
+ + + +
o META_Object(RadialShooter) +

+ + +

ovirtual ~RadialShooter() +

+ + +

oRadialShooter& operator=(const RadialShooter &) +

+ + +

oinline RadialShooter() +

+ + +

oinline RadialShooter(const RadialShooter &copy, const osg::CopyOp &copyop) +

+ + +

oinline const rangef& getThetaRange() const +
Get the range of possible values for theta angle +

+ + +

oinline const rangef& getPhiRange() const +
Get the range of possible values for phi angle +

+ + +

oinline const rangef& getInitialSpeedRange() const +
Get the range of possible values for initial speed of particles +

+ + +

oinline void setThetaRange(const rangef &r) +
Set the range of possible values for theta angle +

+ + +

oinline void setThetaRange(float r1, float r2) +
Set the range of possible values for theta angle +

+ + +

oinline void setPhiRange(const rangef &r) +
Set the range of possible values for phi angle +

+ + +

oinline void setPhiRange(float r1, float r2) +
Set the range of possible values for phi angle +

+ + +

oinline void setInitialSpeedRange(const rangef &r) +
Set the range of possible values for initial speed of particles +

+ + +

oinline void setInitialSpeedRange(float r1, float r2) +
Set the range of possible values for initial speed of particles +

+ + +

oinline void shoot(Particle* P) const +
Shoot a particle. Do not call this method manually. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/RandomRateCounter.html b/doc/doc++/osgParticle/RandomRateCounter.html new file mode 100644 index 000000000..c660b86df --- /dev/null +++ b/doc/doc++/osgParticle/RandomRateCounter.html @@ -0,0 +1,99 @@ + + + + + class osgParticle::RandomRateCounter + + + + +

class osgParticle::RandomRateCounter


+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(RandomRateCounter) +
+[more]inline RandomRateCounter() +
+[more]inline RandomRateCounter(const RandomRateCounter &copy, const osg::CopyOp &copyop) +
+[more]inline int numParticlesToCreate(double dt) const +
Return the number of particles to be created in this frame +

+ +

+

Protected Methods

+[more]virtual ~RandomRateCounter() +

+ +
+

Inherited from VariableRateCounter:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +
+oinline const rangef& getRateRange() const +
+oinline void setRateRange(const rangef &r) +
+oinline void setRateRange(float minrange, float maxrange) +

+ +
+

Inherited from Counter:

+
+

+

Protected Methods

+oCounter& operator=(const Counter &) +

+ +
+ + +
+

Documentation

+
+ + + +
o META_Object(RandomRateCounter) +

+ + +

ovirtual ~RandomRateCounter() +

+ + +

oinline RandomRateCounter() +

+ + +

oinline RandomRateCounter(const RandomRateCounter &copy, const osg::CopyOp &copyop) +

+ + +

oinline int numParticlesToCreate(double dt) const +
Return the number of particles to be created in this frame +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/SectorPlacer.html b/doc/doc++/osgParticle/SectorPlacer.html new file mode 100644 index 000000000..a7ca2e509 --- /dev/null +++ b/doc/doc++/osgParticle/SectorPlacer.html @@ -0,0 +1,154 @@ + + + + + class osgParticle::SectorPlacer + + + + +

class osgParticle::SectorPlacer

A sector-shaped particle placer.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(SectorPlacer) +
+[more]inline SectorPlacer() +
+[more]inline SectorPlacer(const SectorPlacer &copy, const osg::CopyOp &copyop) +
+[more]inline const rangef& getRadiusRange() const +
Get the range of possible values for radius +
+[more]inline const rangef& getPhiRange() const +
Get the range of possible values for the central angle +
+[more]inline void setRadiusRange(const rangef &r) +
Set the range of possible values for radius +
+[more]inline void setRadiusRange(float r1, float r2) +
Set the range of possible values for radius +
+[more]inline void setPhiRange(const rangef &r) +
Set the range of possible values for the central angle +
+[more]inline void setPhiRange(float r1, float r2) +
Set the range of possible values for the central angle +
+[more]inline void place(Particle* P) const +
Place a particle. +

+ +

+

Protected Methods

+[more]virtual ~SectorPlacer() +
+[more]SectorPlacer& operator=(const SectorPlacer &) +

+ +
+

Inherited from CenteredPlacer:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +
+oinline const osg::Vec3& getCenter() const +
+oinline void setCenter(const osg::Vec3 &v) +
+oinline void setCenter(float x, float y, float z) +

+ +
+

Inherited from Placer:

+
+
+ + +
+

Documentation

+
A sector-shaped particle placer. +This placer sets the initial position of incoming particle by choosing a random position +within a circular sector; this sector is defined by three parameters: a center point, +which is inherited directly from osgParticle::CenteredPlacer, a range of values +for radius, and a range of values for the central angle (sometimes called phi).
+
+ + + +
o META_Object(SectorPlacer) +

+ + +

ovirtual ~SectorPlacer() +

+ + +

oSectorPlacer& operator=(const SectorPlacer &) +

+ + +

oinline SectorPlacer() +

+ + +

oinline SectorPlacer(const SectorPlacer &copy, const osg::CopyOp &copyop) +

+ + +

oinline const rangef& getRadiusRange() const +
Get the range of possible values for radius +

+ + +

oinline const rangef& getPhiRange() const +
Get the range of possible values for the central angle +

+ + +

oinline void setRadiusRange(const rangef &r) +
Set the range of possible values for radius +

+ + +

oinline void setRadiusRange(float r1, float r2) +
Set the range of possible values for radius +

+ + +

oinline void setPhiRange(const rangef &r) +
Set the range of possible values for the central angle +

+ + +

oinline void setPhiRange(float r1, float r2) +
Set the range of possible values for the central angle +

+ + +

oinline void place(Particle* P) const +
Place a particle. Do not call it manually. +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/SegmentPlacer.html b/doc/doc++/osgParticle/SegmentPlacer.html new file mode 100644 index 000000000..027a8ea22 --- /dev/null +++ b/doc/doc++/osgParticle/SegmentPlacer.html @@ -0,0 +1,152 @@ + + + + + class osgParticle::SegmentPlacer + + + + +

class osgParticle::SegmentPlacer

A segment-shaped particle placer.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more] META_Object(SegmentPlacer) +
+[more]inline SegmentPlacer() +
+[more]inline SegmentPlacer(const SegmentPlacer &copy, const osg::CopyOp &copyop) +
+[more]inline const osg::Vec3& getVertexA() const +
get vertex A +
+[more]inline const osg::Vec3& getVertexB() const +
get vertex B +
+[more]inline void setSegment(const osg::Vec3 &A, const osg::Vec3 &B) +
Set both vertices +
+[more]inline void place(Particle* P) const +
Place a particle. +
+[more]inline void setVertexA(const osg::Vec3 &v) +
Set vertex A of the segment as a vector +
+[more]inline void setVertexA(float x, float y, float z) +
Set vertex A of the segment as three floats +
+[more]inline void setVertexB(const osg::Vec3 &v) +
Set vertex B of the segment as a vector +
+[more]inline void setVertexB(float x, float y, float z) +
Set vertex B of the segment as three floats +

+ +

+

Protected Methods

+[more]virtual ~SegmentPlacer() +
+[more]SegmentPlacer& operator=(const SegmentPlacer &) +

+ +
+

Inherited from Placer:

+
+

+

Public Methods

+ovirtual const char* className() const +
+ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ +
+ + +
+

Documentation

+
A segment-shaped particle placer. +To use this placer you have to define a segment, by setting its two vertices (A and B); +when an emitter requests a SegmentPlacer to place a particle, the position is chosen randomly +within that segment.
+
+ + + +
o META_Object(SegmentPlacer) +

+ + +

ovirtual ~SegmentPlacer() +

+ + +

oSegmentPlacer& operator=(const SegmentPlacer &) +

+ + +

oinline SegmentPlacer() +

+ + +

oinline SegmentPlacer(const SegmentPlacer &copy, const osg::CopyOp &copyop) +

+ + +

oinline const osg::Vec3& getVertexA() const +
get vertex A +

+ + +

oinline const osg::Vec3& getVertexB() const +
get vertex B +

+ + +

oinline void setSegment(const osg::Vec3 &A, const osg::Vec3 &B) +
Set both vertices +

+ + +

oinline void place(Particle* P) const +
Place a particle. This method is called by ModularEmitter, do not call it manually. +

+ + +

oinline void setVertexA(const osg::Vec3 &v) +
Set vertex A of the segment as a vector +

+ + +

oinline void setVertexA(float x, float y, float z) +
Set vertex A of the segment as three floats +

+ + +

oinline void setVertexB(const osg::Vec3 &v) +
Set vertex B of the segment as a vector +

+ + +

oinline void setVertexB(float x, float y, float z) +
Set vertex B of the segment as three floats +

+ +
This class has no child classes.
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/Shooter.html b/doc/doc++/osgParticle/Shooter.html new file mode 100644 index 000000000..a7085030d --- /dev/null +++ b/doc/doc++/osgParticle/Shooter.html @@ -0,0 +1,94 @@ + + + + + class osgParticle::Shooter + + + + +

class osgParticle::Shooter

An abstract base class used by ModularEmitter to "shoot" the particles after they have been placed.
+
+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]virtual void shoot(Particle* P) const = 0 +
Shoot a particle. +
+[more]inline Shooter() +
+[more]inline Shooter(const Shooter &copy, const osg::CopyOp &copyop) +

+ +

+

Protected Methods

+[more]virtual ~Shooter() +
+[more]Shooter& operator=(const Shooter &) +

+ +
+ + +
+

Documentation

+
An abstract base class used by ModularEmitter to "shoot" the particles after they have been placed. +Descendants of this class must override the shoot() method.
+
+ + + +
ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual void shoot(Particle* P) const = 0 +
Shoot a particle. Must be overriden by descendants. +This method should only set the velocity vector of particle P, leaving other +attributes unchanged. +

+ + +

ovirtual ~Shooter() +

+ + +

oShooter& operator=(const Shooter &) +

+ + +

oinline Shooter() +

+ + +

oinline Shooter(const Shooter &copy, const osg::CopyOp &copyop) +

+
+
Direct child classes: +
RadialShooter
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/VariableRateCounter.html b/doc/doc++/osgParticle/VariableRateCounter.html new file mode 100644 index 000000000..34e6f504d --- /dev/null +++ b/doc/doc++/osgParticle/VariableRateCounter.html @@ -0,0 +1,106 @@ + + + + + class osgParticle::VariableRateCounter + + + + +

class osgParticle::VariableRateCounter


+ +

Inheritance:

+ + + + + + + +
+ +
+

+

Public Methods

+[more]virtual const char* className() const +
+[more]virtual bool isSameKindAs(const osg::Object* obj) const +
+[more]inline VariableRateCounter() +
+[more]inline VariableRateCounter(const VariableRateCounter &copy, const osg::CopyOp &copyop) +
+[more]inline const rangef& getRateRange() const +
+[more]inline void setRateRange(const rangef &r) +
+[more]inline void setRateRange(float minrange, float maxrange) +

+ +

+

Protected Methods

+[more]virtual ~VariableRateCounter() +

+ +
+

Inherited from Counter:

+
+

+

Public Methods

+ovirtual int numParticlesToCreate(double dt) const +

+ +

+

Protected Methods

+oCounter& operator=(const Counter &) +

+ +
+ + +
+

Documentation

+
+ + + +
ovirtual const char* className() const +

+ + +

ovirtual bool isSameKindAs(const osg::Object* obj) const +

+ + +

ovirtual ~VariableRateCounter() +

+ + +

oinline VariableRateCounter() +

+ + +

oinline VariableRateCounter(const VariableRateCounter &copy, const osg::CopyOp &copyop) +

+ + +

oinline const rangef& getRateRange() const +

+ + +

oinline void setRateRange(const rangef &r) +

+ + +

oinline void setRateRange(float minrange, float maxrange) +

+
+
Direct child classes: +
RandomRateCounter
+
+ +

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/icon1.gif b/doc/doc++/osgParticle/icon1.gif new file mode 100644 index 000000000..f78f30eb9 Binary files /dev/null and b/doc/doc++/osgParticle/icon1.gif differ diff --git a/doc/doc++/osgParticle/icon2.gif b/doc/doc++/osgParticle/icon2.gif new file mode 100644 index 000000000..6cbe01a83 Binary files /dev/null and b/doc/doc++/osgParticle/icon2.gif differ diff --git a/doc/doc++/osgParticle/index.html b/doc/doc++/osgParticle/index.html new file mode 100644 index 000000000..259425da5 --- /dev/null +++ b/doc/doc++/osgParticle/index.html @@ -0,0 +1,61 @@ + + + + + Table of Contents + + + + +

Table of Contents

+

Namespaces

+ +

Functions

+ +

Macros

+ +

Hierarchy of classes


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/osgParticle.html b/doc/doc++/osgParticle/osgParticle.html new file mode 100644 index 000000000..8b7568865 --- /dev/null +++ b/doc/doc++/osgParticle/osgParticle.html @@ -0,0 +1,109 @@ + + + + + namespace osgParticle + + + + +

namespace osgParticle

+
+

+
+class AccelOperator: public Operator +
An operator class that applies a constant acceleration to the particles +
+class CenteredPlacer: public Placer +
An abstract placer base class for placers which need a center point +
+class Counter: public osg::Object +
+class OSGPARTICLE_EXPORT Emitter: public ParticleProcessor +
An abstract base class for particle emitters. +
+class OSGPARTICLE_EXPORT FluidFrictionOperator: public Operator +
An operator that simulates the friction of a fluid. +
+class ForceOperator: public Operator +
An operator that applies a constant force to the particles. +
+class Interpolator: public osg::Object +
An abstract base class for implementing interpolators +
+class LinearInterpolator: public Interpolator +
A linear interpolator +
+class OSGPARTICLE_EXPORT ModularEmitter: public Emitter +
An emitter class that holds three objects to control the creation of particles. +
+class OSGPARTICLE_EXPORT ModularProgram: public Program +
A program class for performing operations on particles using a sequence of operators. +
+class OSGPARTICLE_EXPORT MultiSegmentPlacer: public Placer +
A polyline-shaped particle placer. +
+class Operator: public osg::Object +
An abstract base class used by ModularProgram to perform operations on particles before they are updated. +
+class OSGPARTICLE_EXPORT Particle +
Implementation of a particle. +
+class OSGPARTICLE_EXPORT ParticleProcessor: public osg::Node +
A common base interface for those classes which need to do something on particles. +
+class OSGPARTICLE_EXPORT ParticleSystem: public osg::Drawable +
The heart of this class library; its purpose is to hold a set of particles and manage particle creation, update, rendering and destruction. +
+class OSGPARTICLE_EXPORT ParticleSystemUpdater: public osg::Node +
A useful node class for updating particle systems automatically. +
+class Placer: public osg::Object +
An abstract base class for implementing particle placers. +
+class PointPlacer: public CenteredPlacer +
A point-shaped particle placer. +
+class OSGPARTICLE_EXPORT Program: public ParticleProcessor +
An abstract ParticleProcessor descendant for modifying particles "on the fly" during the cull traversal. +
+class RadialShooter: public Shooter +
A shooter class that shoots particles radially. +
+class RandomRateCounter: public VariableRateCounter +
+template<class T_> struct range +
A simple struct template useful to store ranges of values as min/max pairs. +
+typedef range<float> rangef +
Range of floats +
+typedef range<osg::Vec2> rangev2 +
Range of osg::Vec2s +
+typedef range<osg::Vec3> rangev3 +
Range of osg::Vec3s +
+class SectorPlacer: public CenteredPlacer +
A sector-shaped particle placer. +
+class SegmentPlacer: public Placer +
A segment-shaped particle placer. +
+class Shooter: public osg::Object +
An abstract base class used by ModularEmitter to "shoot" the particles after they have been placed. +
+class VariableRateCounter: public Counter +

+ + + +
+

Documentation

+
+
+

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/range.html b/doc/doc++/osgParticle/range.html new file mode 100644 index 000000000..240ee7e4b --- /dev/null +++ b/doc/doc++/osgParticle/range.html @@ -0,0 +1,81 @@ + + + + + template<class T_> struct osgParticle::range + + + + +

template<class T_> struct osgParticle::range

A simple struct template useful to store ranges of values as min/max pairs.
+ +
+

+
+[more]T_ min +
Lower bound +
+[more]T_ max +
Higher bound +
+[more] range() +
Construct the object by calling default constructors for min and max +
+[more] range(const T_ &mn, const T_ &mx) +
Construct and initialize min and max directly +
+[more]void set(const T_ &mn, const T_ &mx) +
Set min and max +
+[more]T_ get_random() const +
Get a random value between min and max +

+ + + +
+

Documentation

+
+A simple struct template useful to store ranges of values as min/max pairs. +This struct template helps storing min/max ranges for values of any kind; class T_ is +the type of values to be stored, and it must support operations T_ + T_, T_ - T_, +and T_ * float, otherwise the get_random() method will not compile. +This struct could be extended to customize the random number generator (now it uses only +std::rand()).
+
+ + + +
oT_ min +
Lower bound +

+ + +

oT_ max +
Higher bound +

+ + +

o range() +
Construct the object by calling default constructors for min and max +

+ + +

o range(const T_ &mn, const T_ &mx) +
Construct and initialize min and max directly +

+ + +

ovoid set(const T_ &mn, const T_ &mx) +
Set min and max +

+ + +

oT_ get_random() const +
Get a random value between min and max +

+

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/rangef.html b/doc/doc++/osgParticle/rangef.html new file mode 100644 index 000000000..b8ff0f3d1 --- /dev/null +++ b/doc/doc++/osgParticle/rangef.html @@ -0,0 +1,20 @@ + + + + + typedef range<float> osgParticle::rangef + + + + +

typedef range<float> osgParticle::rangef

Range of floats
+ + +
+

Documentation

+
Range of floats
+

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/rangev2.html b/doc/doc++/osgParticle/rangev2.html new file mode 100644 index 000000000..6b8584fa3 --- /dev/null +++ b/doc/doc++/osgParticle/rangev2.html @@ -0,0 +1,20 @@ + + + + + typedef range<osg::Vec2> osgParticle::rangev2 + + + + +

typedef range<osg::Vec2> osgParticle::rangev2

Range of osg::Vec2s
+ + +
+

Documentation

+
Range of osg::Vec2s
+

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/doc++/osgParticle/rangev3.html b/doc/doc++/osgParticle/rangev3.html new file mode 100644 index 000000000..c3b60d379 --- /dev/null +++ b/doc/doc++/osgParticle/rangev3.html @@ -0,0 +1,20 @@ + + + + + typedef range<osg::Vec3> osgParticle::rangev3 + + + + +

typedef range<osg::Vec3> osgParticle::rangev3

Range of osg::Vec3s
+ + +
+

Documentation

+
Range of osg::Vec3s
+

Alphabetic index HTML hierarchy of classes or Java


+
+This page was generated with the help of DOC++. + + diff --git a/doc/documentation.html b/doc/documentation.html index 8b3fa5550..4cfb1b14b 100644 --- a/doc/documentation.html +++ b/doc/documentation.html @@ -38,6 +38,8 @@ core scene graph reference guide. scene graph utilities reference guide.
osgDB/          scene graph database utilities reference guide. +
osgParticle/         +scene graph particle reference guide.
osgText/         scene graph text reference guide.
osgGLUT/      diff --git a/include/osgParticle/AccelOperator b/include/osgParticle/AccelOperator new file mode 100644 index 000000000..da70dbb4b --- /dev/null +++ b/include/osgParticle/AccelOperator @@ -0,0 +1,99 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_ACCELOPERATOR_ +#define OSGPARTICLE_ACCELOPERATOR_ 1 + +#include +#include +#include + +#include +#include +#include + +namespace osgParticle +{ + + /** An operator class that applies a constant acceleration to the particles. + */ + class AccelOperator: public Operator { + public: + inline AccelOperator(); + inline AccelOperator(const AccelOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(AccelOperator); + + /// Get the acceleration vector. + inline const osg::Vec3 &getAcceleration() const; + + /// Set the acceleration vector. + inline void setAcceleration(const osg::Vec3 &v); + + /** Quickly set the acceleration vector to the gravity on earth (0, 0, -9.81). + The acceleration will be multiplied by the scale parameter. + */ + inline void setToGravity(float scale = 1); + + /// Apply the acceleration to a particle. Do not call this method manually. + inline void operate(Particle *P, double dt); + + /// Perform some initializations. Do not call this method manually. + inline void beginOperate(Program *prg); + + protected: + virtual ~AccelOperator() {} + AccelOperator &operator=(const AccelOperator &) { return *this; } + + private: + osg::Vec3 accel_; + osg::Vec3 xf_accel_; + }; + + // INLINE FUNCTIONS + + inline AccelOperator::AccelOperator() + : Operator(), accel_(0, 0, 0) + { + } + + inline AccelOperator::AccelOperator(const AccelOperator ©, const osg::CopyOp ©op) + : Operator(copy, copyop), accel_(copy.accel_) + { + } + + inline const osg::Vec3 &AccelOperator::getAcceleration() const + { + return accel_; + } + + inline void AccelOperator::setAcceleration(const osg::Vec3 &v) + { + accel_ = v; + } + + inline void AccelOperator::setToGravity(float scale) + { + accel_.set(0, 0, -9.80665f * scale); + } + + inline void AccelOperator::operate(Particle *P, double dt) + { + P->addVelocity(xf_accel_ * dt); + } + + inline void AccelOperator::beginOperate(Program *prg) + { + if (prg->getReferenceFrame() == ModularProgram::RELATIVE_TO_PARENTS) { + xf_accel_ = prg->rotateLocalToWorld(accel_); + } else { + xf_accel_ = accel_; + } + } + +} + + +#endif diff --git a/include/osgParticle/CenteredPlacer b/include/osgParticle/CenteredPlacer new file mode 100644 index 000000000..b950f44e8 --- /dev/null +++ b/include/osgParticle/CenteredPlacer @@ -0,0 +1,74 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_CENTEREDPLACER_ +#define OSGPARTICLE_CENTEREDPLACER_ 1 + +#include + +#include +#include +#include + +namespace osgParticle +{ + + /** An abstract placer base class for placers which need a center point. + */ + class CenteredPlacer: public Placer { + public: + inline CenteredPlacer(); + inline CenteredPlacer(const CenteredPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "CenteredPlacer"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + /// Get the center point. + inline const osg::Vec3 &getCenter() const; + + /// Set the center point. + inline void setCenter(const osg::Vec3 &v); + + /// Set the center point. + inline void setCenter(float x, float y, float z); + + protected: + virtual ~CenteredPlacer() {} + + private: + osg::Vec3 center_; + }; + + // INLINE FUNCTIONS + + inline CenteredPlacer::CenteredPlacer() + : Placer(), center_(0, 0, 0) + { + } + + inline CenteredPlacer::CenteredPlacer(const CenteredPlacer ©, const osg::CopyOp ©op) + : Placer(copy, copyop), center_(copy.center_) + { + } + + inline const osg::Vec3 &CenteredPlacer::getCenter() const + { + return center_; + } + + inline void CenteredPlacer::setCenter(const osg::Vec3 &v) + { + center_ = v; + } + + inline void CenteredPlacer::setCenter(float x, float y, float z) + { + center_.set(x, y, z); + } + +} + + +#endif diff --git a/include/osgParticle/Counter b/include/osgParticle/Counter new file mode 100644 index 000000000..c75db1823 --- /dev/null +++ b/include/osgParticle/Counter @@ -0,0 +1,44 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_COUNTER_ +#define OSGPARTICLE_COUNTER_ 1 + +#include +#include + +namespace osgParticle +{ + + class Counter: public osg::Object { + public: + inline Counter(); + inline Counter(const Counter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "Counter"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + virtual int numParticlesToCreate(double dt) const = 0; + + protected: + ~Counter() {} + Counter &operator=(const Counter &) { return *this; } + }; + + // INLINE FUNCTIONS + + inline Counter::Counter() + : osg::Object() + { + } + + inline Counter::Counter(const Counter ©, const osg::CopyOp ©op) + : osg::Object(copy, copyop) + { + } + +} + +#endif diff --git a/include/osgParticle/Emitter b/include/osgParticle/Emitter new file mode 100644 index 000000000..2754985f8 --- /dev/null +++ b/include/osgParticle/Emitter @@ -0,0 +1,96 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_EMITTER_ +#define OSGPARTICLE_EMITTER_ 1 + +#include +#include +#include + +#include +#include +#include +#include + +namespace osgParticle +{ + + /** An abstract base class for particle emitters. + Descendant classes must override the emit() method to generate new particles by + calling the ParticleSystem::createParticle() method on the particle system associated + to the emitter. + */ + class OSGPARTICLE_EXPORT Emitter: public ParticleProcessor { + public: + Emitter(); + Emitter(const Emitter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "Emitter"; } + virtual bool isSameKindAs(const osg::Object *obj) { return dynamic_cast(obj) != 0; } + virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } } + + /// Get the particle template. + inline const Particle &getParticleTemplate() const; + + /// Set the particle template (particle is copied). + inline void setParticleTemplate(const Particle &p); + + /// Return whether the particle system's default template should be used. + inline bool getUseDefaultTemplate() const; + + /** Set whether the default particle template should be used. + When this flag is true, the particle template is ignored, and the + particle system's default template is used instead. + */ + inline void setUseDefaultTemplate(bool v); + + protected: + virtual ~Emitter() {} + Emitter &operator=(const Emitter &) { return *this; } + + inline void process(double dt); + + virtual void emit(double dt) = 0; + + private: + bool usedeftemp_; + Particle ptemp_; + }; + + // INLINE FUNCTIONS + + inline const Particle &Emitter::getParticleTemplate() const + { + return ptemp_; + } + + inline void Emitter::setParticleTemplate(const Particle &p) + { + ptemp_ = p; + usedeftemp_ = false; + } + + inline bool Emitter::getUseDefaultTemplate() const + { + return usedeftemp_; + } + + inline void Emitter::setUseDefaultTemplate(bool v) + { + usedeftemp_ = v; + } + + inline void Emitter::process(double dt) + { + emit(dt); + } + + +} + + +#endif + diff --git a/include/osgParticle/Export b/include/osgParticle/Export new file mode 100644 index 000000000..605fa23a3 --- /dev/null +++ b/include/osgParticle/Export @@ -0,0 +1,30 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_EXPORT_ +#define OSGPARTICLE_EXPORT_ 1 + +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) + #pragma warning( disable : 4244 ) + #pragma warning( disable : 4251 ) + #pragma warning( disable : 4275 ) + #pragma warning( disable : 4786 ) + #pragma warning( disable : 4290 ) +#endif + + +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) + # ifdef OSGPARTICLE_LIBRARY + # define OSGPARTICLE_EXPORT __declspec(dllexport) + # else + # define OSGPARTICLE_EXPORT __declspec(dllimport) + # endif /* OSGPARTICLE_LIBRARY */ +#else + # define OSGPARTICLE_EXPORT +#endif + + + +#endif diff --git a/include/osgParticle/FluidFrictionOperator b/include/osgParticle/FluidFrictionOperator new file mode 100644 index 000000000..fb2a681d9 --- /dev/null +++ b/include/osgParticle/FluidFrictionOperator @@ -0,0 +1,132 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_FLUIDFRICTIONOPERATOR_ +#define OSGPARTICLE_FLUIDFRICTIONOPERATOR_ 1 + +#include +#include + +#include +#include +#include + +namespace osgParticle +{ + + class Particle; + + /** An operator that simulates the friction of a fluid. + By using this operator you can let the particles move in a fluid of a given density + and viscosity. There are two functions to quickly setup the parameters for pure water + and air. You can decide whether to compute the forces using the particle's physical + radius or another value, by calling the setOverrideRadius() method. + */ + class OSGPARTICLE_EXPORT FluidFrictionOperator: public Operator { + public: + + FluidFrictionOperator(); + FluidFrictionOperator(const FluidFrictionOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(FluidFrictionOperator); + + /// Get the density of the fluid. + inline float getFluidDensity() const; + + /// Set the density of the fluid. + inline void setFluidDensity(float d); + + /// Get the viscosity of the fluid. + inline float getFluidViscosity() const; + + /// Set the viscosity of the fluid. + inline void setFluidViscosity(float v); + + /// Get the overriden radius value. + inline float getOverrideRadius() const; + + /// Set the overriden radius value (pass 0 if you want to use particle's radius). + inline void setOverrideRadius(float r); + + /// Set the fluid parameters as for air (20°C temperature). + inline void setFluidToAir(); + + /// Set the fluid parameters as for pure water (20°C temperature). + inline void setFluidToWater(); + + /// Apply the friction forces to a particle. Do not call this method manually. + void operate(Particle *P, double dt); + + /// Perform some initializations. Do not call this method manually. + inline void beginOperate(Program *prg); + + protected: + virtual ~FluidFrictionOperator() {} + FluidFrictionOperator &operator=(const FluidFrictionOperator &) { return *this; } + + private: + float A_; + float B_; + float density_; + float viscosity_; + float ovr_rad_; + Program *current_program_; + }; + + // INLINE FUNCTIONS + + inline float FluidFrictionOperator::getFluidDensity() const + { + return density_; + } + + inline float FluidFrictionOperator::getFluidViscosity() const + { + return viscosity_; + } + + inline void FluidFrictionOperator::setFluidDensity(float d) + { + density_ = d; + B_ = 0.2f * osg::PI * density_; + } + + inline void FluidFrictionOperator::setFluidViscosity(float v) + { + viscosity_ = v; + A_ = 6 * osg::PI * viscosity_; + } + + inline void FluidFrictionOperator::setFluidToAir() + { + setFluidViscosity(1.8e-5f); + setFluidDensity(1.2929f); + } + + inline void FluidFrictionOperator::setFluidToWater() + { + setFluidViscosity(1.002e-3f); + setFluidDensity(1.0f); + } + + inline float FluidFrictionOperator::getOverrideRadius() const + { + return ovr_rad_; + } + + inline void FluidFrictionOperator::setOverrideRadius(float r) + { + ovr_rad_ = r; + } + + inline void FluidFrictionOperator::beginOperate(Program *prg) + { + current_program_ = prg; + } + +} + + +#endif diff --git a/include/osgParticle/ForceOperator b/include/osgParticle/ForceOperator new file mode 100644 index 000000000..6da553c38 --- /dev/null +++ b/include/osgParticle/ForceOperator @@ -0,0 +1,89 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_FORCEOPERATOR_ +#define OSGPARTICLE_FORCEOPERATOR_ 1 + +#include +#include +#include + +#include +#include +#include + +namespace osgParticle +{ + + /** An operator that applies a constant force to the particles. + Remember that if the mass of particles is expressed in kg and the lengths are + expressed in meters, then the force should be expressed in Newtons. + */ + class ForceOperator: public Operator { + public: + inline ForceOperator(); + inline ForceOperator(const ForceOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(ForceOperator); + + /// Get the force vector. + inline const osg::Vec3 &getForce() const; + + /// Set the force vector. + inline void setForce(const osg::Vec3 &f); + + /// Apply the force to a particle. Do not call this method manually. + inline void operate(Particle *P, double dt); + + /// Perform some initialization. Do not call this method manually. + inline void beginOperate(Program *prg); + + protected: + virtual ~ForceOperator() {}; + ForceOperator &operator=(const ForceOperator &) { return *this; } + + private: + osg::Vec3 force_; + osg::Vec3 xf_force_; + }; + + // INLINE FUNCTIONS + + inline ForceOperator::ForceOperator() + : Operator(), force_(0, 0, 0) + { + } + + inline ForceOperator::ForceOperator(const ForceOperator ©, const osg::CopyOp ©op) + : Operator(copy, copyop), force_(copy.force_) + { + } + + inline const osg::Vec3 &ForceOperator::getForce() const + { + return force_; + } + + inline void ForceOperator::setForce(const osg::Vec3 &v) + { + force_ = v; + } + + inline void ForceOperator::operate(Particle *P, double dt) + { + P->addVelocity(xf_force_ * (P->getMassInv() * dt)); + } + + inline void ForceOperator::beginOperate(Program *prg) + { + if (prg->getReferenceFrame() == ModularProgram::RELATIVE_TO_PARENTS) { + xf_force_ = prg->rotateLocalToWorld(force_); + } else { + xf_force_ = force_; + } + } +} + +#endif diff --git a/include/osgParticle/Interpolator b/include/osgParticle/Interpolator new file mode 100644 index 000000000..a3bc28b31 --- /dev/null +++ b/include/osgParticle/Interpolator @@ -0,0 +1,77 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_INTERPOLATOR_ +#define OSGPARTICLE_INTERPOLATOR_ + +#include + +#include +#include +#include +#include +#include + +namespace osgParticle +{ + + /// An abstract base class for implementing interpolators. + class Interpolator : public osg::Object { + public: + Interpolator() + : osg::Object() {} + + Interpolator(const Interpolator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY) + : osg::Object(copy, copyop) {} + + virtual const char *className() const { return "Interpolator"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + /// Interpolate between floats. Must be overriden in descendant classes. + virtual float interpolate(float t, float y1, float y2) const = 0; + + /// Interpolate between 2-dimensional vectors. Default behavior is to interpolate each component separately. + virtual osg::Vec2 interpolate(float t, const osg::Vec2 &y1, const osg::Vec2 &y2) const + { + return osg::Vec2( + interpolate(t, y1.x(), y2.x()), + interpolate(t, y1.y(), y2.y()) + ); + } + + /// Interpolate between 3-dimensional vectors. Default behavior is to interpolate each component separately. + virtual osg::Vec3 interpolate(float t, const osg::Vec3 &y1, const osg::Vec3 &y2) const + { + return osg::Vec3( + interpolate(t, y1.x(), y2.x()), + interpolate(t, y1.y(), y2.y()), + interpolate(t, y1.z(), y2.z()) + ); + } + + /// Interpolate between 4-dimensional vectors. Default behavior is to interpolate each component separately. + virtual osg::Vec4 interpolate(float t, const osg::Vec4 &y1, const osg::Vec4 &y2) const + { + return osg::Vec4( + interpolate(t, y1.x(), y2.x()), + interpolate(t, y1.y(), y2.y()), + interpolate(t, y1.z(), y2.z()), + interpolate(t, y1.w(), y2.w()) + ); + } + + template + T_ interpolate(float t, const range &r) const + { + return interpolate(t, r.min, r.max); + } + + protected: + virtual ~Interpolator() {} + }; + +} + +#endif diff --git a/include/osgParticle/LinearInterpolator b/include/osgParticle/LinearInterpolator new file mode 100644 index 000000000..a31ff5c03 --- /dev/null +++ b/include/osgParticle/LinearInterpolator @@ -0,0 +1,41 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_LINEARINTERPOLATOR_ +#define OSGPARTICLE_LINEARINTERPOLATOR_ + +#include + +#include +#include +#include +#include + +namespace osgParticle +{ + + /// A linear interpolator. + class LinearInterpolator: public Interpolator { + public: + LinearInterpolator() + : Interpolator() {} + + LinearInterpolator(const LinearInterpolator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY) + : Interpolator(copy, copyop) {} + + META_Object(LinearInterpolator); + + virtual float interpolate(float t, float y1, float y2) const + { + return y1 + (y2 - y1) * t; + } + + protected: + virtual ~LinearInterpolator() {} + }; + +} + +#endif diff --git a/include/osgParticle/ModularEmitter b/include/osgParticle/ModularEmitter new file mode 100644 index 000000000..1c254ca87 --- /dev/null +++ b/include/osgParticle/ModularEmitter @@ -0,0 +1,130 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_MODULAREMITTER_ +#define OSGPARTICLE_MODULAREMITTER_ 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace osgParticle +{ + + /** An emitter class that holds three objects to control the creation of particles. + These objects are a counter, a placer and a shooter. + The counter controls the number of particles to be emitted at each frame; + the placer must initialize the particle's position vector, while the shooter initializes + its velocity vector. + You can use the predefined counter/placer/shooter classes, or you can create your own. + */ + class OSGPARTICLE_EXPORT ModularEmitter: public Emitter { + public: + ModularEmitter(); + ModularEmitter(const ModularEmitter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Node(ModularEmitter); + + /// Get the counter object. + inline Counter *getCounter(); + + /// Get the const Counter object. + inline const Counter *getCounter() const; + + /// Set the Counter object. + inline void setCounter(Counter *c); + + /// Get the Placer object. + inline Placer *getPlacer(); + + /// Get the const Placer object. + inline const Placer *getPlacer() const; + + /// Set the Placer object. + inline void setPlacer(Placer *p); + + /// Get the Shooter object. + inline Shooter *getShooter(); + + /// Get the const Shooter object. + inline const Shooter *getShooter() const; + + /// Set the Shooter object. + inline void setShooter(Shooter *s); + + protected: + virtual ~ModularEmitter() {} + ModularEmitter &operator=(const ModularEmitter &) { return *this; } + + void emit(double dt); + + private: + osg::ref_ptr counter_; + osg::ref_ptr placer_; + osg::ref_ptr shooter_; + }; + + // INLINE FUNCTIONS + + inline Counter *ModularEmitter::getCounter() + { + return counter_.get(); + } + + inline const Counter *ModularEmitter::getCounter() const + { + return counter_.get(); + } + + inline void ModularEmitter::setCounter(Counter *c) + { + counter_ = c; + } + + inline Placer *ModularEmitter::getPlacer() + { + return placer_.get(); + } + + inline const Placer *ModularEmitter::getPlacer() const + { + return placer_.get(); + } + + inline void ModularEmitter::setPlacer(Placer *p) + { + placer_ = p; + } + + inline Shooter *ModularEmitter::getShooter() + { + return shooter_.get(); + } + + inline const Shooter *ModularEmitter::getShooter() const + { + return shooter_.get(); + } + + inline void ModularEmitter::setShooter(Shooter *s) + { + shooter_ = s; + } + +} + +#endif diff --git a/include/osgParticle/ModularProgram b/include/osgParticle/ModularProgram new file mode 100644 index 000000000..f4da376c7 --- /dev/null +++ b/include/osgParticle/ModularProgram @@ -0,0 +1,90 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_MODULARPROGRAM_ +#define OSGPARTICLE_MODULARPROGRAM_ 1 + +#include +#include +#include + +#include +#include +#include +#include + +namespace osgParticle +{ + + /** A program class for performing operations on particles using a sequence of operators. + To use a ModularProgram you have to create some Operator objects and + add them to the program. + All operators will be applied to each particle in the same order they've been added to the program. + */ + class OSGPARTICLE_EXPORT ModularProgram: public Program { + public: + ModularProgram(); + ModularProgram(const ModularProgram ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Node(ModularProgram); + + /// Get the number of operators. + inline int numOperators() const; + + /// Add an operator to the list. + inline void addOperator(Operator *o); + + /// Get a pointer to an operator in the list. + inline Operator *getOperator(int i); + + /// Get a const pointer to an operator in the list. + inline const Operator *getOperator(int i) const; + + /// Remove an operator from the list. + inline void removeOperator(int i); + + protected: + virtual ~ModularProgram() {} + ModularProgram &operator=(const ModularProgram &) { return *this; } + + void execute(double dt); + + private: + typedef std::vector > Operator_vector; + + Operator_vector operators_; + }; + + // INLINE FUNCTIONS + + inline int ModularProgram::numOperators() const + { + return static_cast(operators_.size()); + } + + inline void ModularProgram::addOperator(Operator *o) + { + operators_.push_back(o); + } + + inline Operator *ModularProgram::getOperator(int i) + { + return operators_[i].get(); + } + + inline const Operator *ModularProgram::getOperator(int i) const + { + return operators_[i].get(); + } + + inline void ModularProgram::removeOperator(int i) + { + operators_.erase(operators_.begin()+i); + } + + +} + +#endif diff --git a/include/osgParticle/MultiSegmentPlacer b/include/osgParticle/MultiSegmentPlacer new file mode 100644 index 000000000..8ecbca9cb --- /dev/null +++ b/include/osgParticle/MultiSegmentPlacer @@ -0,0 +1,119 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_MULTISEGMENTPLACER_ +#define OSGPARTICLE_MULTISEGMENTPLACER_ 1 + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace osgParticle { + + /** A polyline-shaped particle placer. + This placer class sets the position of incoming particles by choosing a random point on the + specified sequence of connected segments. + */ + class OSGPARTICLE_EXPORT MultiSegmentPlacer: public Placer { + public: + MultiSegmentPlacer(); + MultiSegmentPlacer(const MultiSegmentPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(MultiSegmentPlacer); + + /// Get the number of vertices which define the segments. + inline int numVertices() const; + + /// Get a vertex. + inline const osg::Vec3 &getVertex(int i) const; + + /// Set a vertex. + inline void setVertex(int i, const osg::Vec3 &v); + + /// Set a vertex. + inline void setVertex(int i, float x, float y, float z); + + /// Add a vertex. + inline void addVertex(const osg::Vec3 &v); + + /// Add a vertex. + inline void addVertex(float x, float y, float z); + + /// Remove a vertex. + inline void removeVertex(int i); + + /// Place a partice. Called automatically by ModularEmitter, do not call this method manually. + void place(Particle *P) const; + + protected: + virtual ~MultiSegmentPlacer() {} + MultiSegmentPlacer &operator=(const MultiSegmentPlacer &) { return *this; } + + private: + typedef std::pair Vertex_data; + typedef std::vector Vertex_vector; + + Vertex_vector vx_; + float total_length_; + + void recompute_length(); + }; + + // INLINE FUNCTIONS + + + inline int MultiSegmentPlacer::numVertices() const + { + return static_cast(vx_.size()); + } + + inline const osg::Vec3 &MultiSegmentPlacer::getVertex(int i) const + { + return vx_[i].first; + } + + inline void MultiSegmentPlacer::setVertex(int i, const osg::Vec3 &v) + { + vx_[i].first = v; + recompute_length(); + } + + inline void MultiSegmentPlacer::setVertex(int i, float x, float y, float z) + { + vx_[i].first.set(x, y, z); + recompute_length(); + } + + inline void MultiSegmentPlacer::addVertex(const osg::Vec3 &v) + { + float l = 0; + if (vx_.size() > 0) { + l = (v - vx_.back().first).length(); + } + total_length_ += l; + vx_.push_back(std::make_pair(v, total_length_)); + } + + inline void MultiSegmentPlacer::addVertex(float x, float y, float z) + { + addVertex(osg::Vec3(x, y, z)); + } + + inline void MultiSegmentPlacer::removeVertex(int i) + { + vx_.erase(vx_.begin()+i); + recompute_length(); + } + +} +#endif diff --git a/include/osgParticle/Operator b/include/osgParticle/Operator new file mode 100644 index 000000000..09bc364cb --- /dev/null +++ b/include/osgParticle/Operator @@ -0,0 +1,91 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_OPERATOR_ +#define OSGPARTICLE_OPERATOR_ 1 + +#include + +#include +#include +#include + +namespace osgParticle +{ + + // forward declaration to avoid including the whole header file + class Particle; + + /** An abstract base class used by ModularProgram to perform operations on particles before they are updated. + To implement a new operator, derive from this class and override the operate() method. + You should also override the beginOperate() method to query the calling program for the reference frame + used, and initialize the right transformations if needed. + */ + class Operator: public osg::Object { + public: + inline Operator(); + inline Operator(const Operator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "Operator"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + /// Get whether this operator is enabled. + inline bool isEnabled() const; + + /// Enable or disable this operator. + inline void setEnabled(bool v); + + /** Do something on a particle. + This method is called by ModularProgram objects to perform some operations + on the particles. You must override it in descendant classes. Common operations + consist of modifying the particle's velocity vector. The dt parameter is + the time elapsed from last operation. + */ + virtual void operate(Particle *P, double dt) = 0; + + /** Do something before processing particles via the operate() method. + Overriding this method could be necessary to query the calling Program object + for the current reference frame. If the reference frame is RELATIVE_TO_PARENTS, then your + class should prepare itself to do all operations in local coordinates. + */ + virtual void beginOperate(Program *) {} + + /// Do something after all particles have been processed. + virtual void endOperate() {} + + protected: + virtual ~Operator() {} + Operator &operator=(const Operator &) { return *this; } + + private: + bool enabled_; + }; + + // INLINE FUNCTIONS + + inline Operator::Operator() + : osg::Object(), enabled_(true) + { + } + + inline Operator::Operator(const Operator ©, const osg::CopyOp ©op) + : osg::Object(copy, copyop), enabled_(copy.enabled_) + { + } + + inline bool Operator::isEnabled() const + { + return enabled_; + } + + inline void Operator::setEnabled(bool v) + { + enabled_ = v; + } + + +} + +#endif diff --git a/include/osgParticle/Particle b/include/osgParticle/Particle new file mode 100644 index 000000000..1de466d9e --- /dev/null +++ b/include/osgParticle/Particle @@ -0,0 +1,399 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_PARTICLE_ +#define OSGPARTICLE_PARTICLE_ 1 + +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace osgParticle +{ + + /** Implementation of a particle. + Objects of this class are particles, they have some graphical properties + and some physical properties. Particles are created by emitters and then placed + into Particle Systems, where they live and get updated at each frame. + Particles can either live forever (lifeTime < 0), or die after a specified + time (lifeTime >= 0). For each property which is defined as a range of values, a + "current" value will be evaluated at each frame by interpolating the min + and max values so that curr_value = min when t == 0, and + curr_value = max when t == lifeTime. + You may customize the interpolator objects to achieve any kind of transition. + If you want the particle to live forever, set its lifetime to any value <= 0; + in that case, no interpolation is done to compute real-time properties, and only + minimum values are used. + */ + class OSGPARTICLE_EXPORT Particle { + public: + + enum Shape { + POINT, // uses GL_POINTS as primitive + QUAD, // uses GL_QUADS as primitive + QUAD_TRIANGLESTRIP, // uses GL_TRIANGLE_STRIP as primitive, but each particle needs a glBegin/glEnd pair + HEXAGON // may save some filling time, but uses more triangles + }; + + Particle(); + + /// Get the shape of the particle. + inline Shape getShape() const; + + /// Set the shape of the particle. + inline void setShape(Shape s); + + /// Get whether the particle is still alive. + inline bool isAlive() const; + + /// Get the life time of the particle (in seconds). + inline double getLifeTime() const; + + /// Get the age of the particle (in seconds). + inline double getAge() const; + + /// Get the minimum and maximum values for polygon size. + inline const rangef &getSizeRange() const; + + /// Get the minimum and maximum values for alpha. + inline const rangef &getAlphaRange() const; + + /// Get the minimum and maximum values for color. + inline const rangev4 &getColorRange() const; + + /// Get the interpolator for computing the size of polygons. + inline const Interpolator *getSizeInterpolator() const; + + /// Get the interpolator for computing alpha values. + inline const Interpolator *getAlphaInterpolator() const; + + /// Get the interpolator for computing color values. + inline const Interpolator *getColorInterpolator() const; + + /** Get the physical radius of the particle. + For built-in operators to work correctly, lengths must be expressed in meters. + */ + inline float getRadius() const; + + /** Get the mass of the particle. + For built-in operators to work correctly, remember that the mass is expressed in kg. + */ + inline float getMass() const; + + /// Get 1 / getMass(). + inline float getMassInv() const; + + /// Get the position vector. + inline const osg::Vec3 &getPosition() const; + + /** Get the velocity vector. + For built-in operators to work correctly, remember that velocity components are expressed + in meters per second. + */ + inline const osg::Vec3 &getVelocity() const; + + /// Get the previous position (the position before last update). + inline const osg::Vec3 &getPreviousPosition() const; + + /** Kill the particle on next update + NOTE: after calling this function, the isAlive() method will still + return true until the particle is updated again. + */ + inline void kill(); + + /// Set the life time of the particle. + inline void setLifeTime(double t); + + /// Set the minimum and maximum values for polygon size. + inline void setSizeRange(const rangef &r); + + /// Set the minimum and maximum values for alpha. + inline void setAlphaRange(const rangef &r); + + /// Set the minimum and maximum values for color. + inline void setColorRange(const rangev4 &r); + + /// Set the interpolator for computing size values. + inline void setSizeInterpolator(Interpolator *ri); + + /// Set the interpolator for computing alpha values. + inline void setAlphaInterpolator(Interpolator *ai); + + /// Set the interpolator for computing color values. + inline void setColorInterpolator(Interpolator *ci); + + /** Set the physical radius of the particle. + For built-in operators to work correctly, lengths must be expressed in meters. + */ + inline void setRadius(float r); + + /** Set the mass of the particle. + For built-in operators to work correctly, remember that the mass is expressed in kg. + */ + inline void setMass(float m); + + /// Set the position vector. + inline void setPosition(const osg::Vec3 &p); + + /** Set the velocity vector. + For built-in operators to work correctly, remember that velocity components are expressed + in meters per second. + */ + inline void setVelocity(const osg::Vec3 &v); + + /// Add a vector to the velocity vector. + inline void addVelocity(const osg::Vec3 &dv); + + /// Transform position and velocity vectors by a matrix. + inline void transformPositionVelocity(const osg::Matrix &xform); + + /** Update the particle (don't call this method manually). + This method is called automatically by ParticleSystem::update(); it + updates the graphical properties of the particle for the current time, + checks whether the particle is still alive, and then updates its position + by computing P = P + V * dt (where P is the position and V is the velocity). + */ + bool update(double dt); + + /// Perform some pre-rendering tasks. Called automatically by particle systems. + inline void beginRender(); + + /// Render the particle. Called automatically by particle systems. + void render(const osg::Matrix &modelview, float scale = 1.0f) const; + + /// Perform some post-rendering tasks. Called automatically by particle systems. + inline void endRender(); + + private: + Shape shape_; + + rangef sr_; + rangef ar_; + rangev4 cr_; + + osg::ref_ptr si_; + osg::ref_ptr ai_; + osg::ref_ptr ci_; + + bool alive_; + bool mustdie_; + double lifetime_; + + float radius_; + float mass_; + float massinv_; + osg::Vec3 prev_pos_; + osg::Vec3 position_; + osg::Vec3 velocity_; + + double t0_; + + float current_size_; + float current_alpha_; + osg::Vec4 current_color_; + }; + + // INLINE FUNCTIONS + + inline Particle::Shape Particle::getShape() const + { + return shape_; + } + + inline void Particle::setShape(Shape s) + { + shape_ = s; + } + + inline bool Particle::isAlive() const + { + return alive_; + } + + inline double Particle::getLifeTime() const + { + return lifetime_; + } + + inline double Particle::getAge() const + { + return t0_; + } + + inline float Particle::getRadius() const + { + return radius_; + } + + inline void Particle::setRadius(float r) + { + radius_ = r; + } + + inline const rangef &Particle::getSizeRange() const + { + return sr_; + } + + inline const rangef &Particle::getAlphaRange() const + { + return ar_; + } + + inline const rangev4 &Particle::getColorRange() const + { + return cr_; + } + + inline const Interpolator *Particle::getSizeInterpolator() const + { + return si_.get(); + } + + inline const Interpolator *Particle::getAlphaInterpolator() const + { + return ai_.get(); + } + + inline const Interpolator *Particle::getColorInterpolator() const + { + return ci_.get(); + } + + inline const osg::Vec3 &Particle::getPosition() const + { + return position_; + } + + inline const osg::Vec3 &Particle::getVelocity() const + { + return velocity_; + } + + inline const osg::Vec3 &Particle::getPreviousPosition() const + { + return prev_pos_; + } + + inline void Particle::kill() + { + mustdie_ = true; + } + + inline void Particle::setLifeTime(double t) + { + lifetime_ = t; + } + + inline void Particle::setSizeRange(const rangef &r) + { + sr_ = r; + } + + inline void Particle::setAlphaRange(const rangef &r) + { + ar_ = r; + } + + inline void Particle::setColorRange(const rangev4 &r) + { + cr_ = r; + } + + inline void Particle::setSizeInterpolator(Interpolator *ri) + { + si_ = ri; + } + + inline void Particle::setAlphaInterpolator(Interpolator *ai) + { + ai_ = ai; + } + + inline void Particle::setColorInterpolator(Interpolator *ci) + { + ci_ = ci; + } + + inline void Particle::setPosition(const osg::Vec3 &p) + { + position_ = p; + } + + inline void Particle::setVelocity(const osg::Vec3 &v) + { + velocity_ = v; + } + + inline void Particle::addVelocity(const osg::Vec3 &v) + { + velocity_ += v; + } + + inline void Particle::transformPositionVelocity(const osg::Matrix &xform) + { + // this should be optimized! + + osg::Vec3 p1 = position_ + velocity_; + + position_ = xform.preMult(position_); + p1 = xform.preMult(p1); + + velocity_ = p1 - position_; + } + + inline float Particle::getMass() const + { + return mass_; + } + + inline float Particle::getMassInv() const + { + return massinv_; + } + + inline void Particle::setMass(float m) + { + mass_ = m; + massinv_ = 1 / m; + } + + inline void Particle::beginRender() + { + switch (shape_) + { + case POINT: + glBegin(GL_POINTS); + break; + case QUAD: + glBegin(GL_QUADS); + break; + default: ; + } + } + + inline void Particle::endRender() + { + switch (shape_) + { + case POINT: + case QUAD: + glEnd(); + break; + default: ; + } + } + + +} + +#endif + diff --git a/include/osgParticle/ParticleProcessor b/include/osgParticle/ParticleProcessor new file mode 100644 index 000000000..8a193100d --- /dev/null +++ b/include/osgParticle/ParticleProcessor @@ -0,0 +1,195 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_PARTICLEPROCESSOR_ +#define OSGPARTICLE_PARTICLEPROCESSOR_ 1 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace osgParticle +{ + + /** A common base interface for those classes which need to do something on particles. Such classes + are, for example, Emitter (particle generation) and Program (particle animation). + This class holds some properties, like a reference frame and a reference to a ParticleSystem; + descendant classes should process the particles taking into account the reference frame, computing the right + transformations when needed. + */ + class OSGPARTICLE_EXPORT ParticleProcessor: public osg::Node { + public: + + enum ReferenceFrame { + RELATIVE_TO_PARENTS, + RELATIVE_TO_ABSOLUTE + }; + + ParticleProcessor(); + ParticleProcessor(const ParticleProcessor ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "ParticleProcessor"; } + virtual bool isSameKindAs(const osg::Object *obj) { return dynamic_cast(obj) != 0; } + virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } } + + /// Get the reference frame. + inline ReferenceFrame getReferenceFrame() const; + + /// Set the reference frame. + inline void setReferenceFrame(ReferenceFrame rf); + + /// Get whether this processor is enabled or not. + inline bool isEnabled() const; + + /// Set whether this processor is enabled or not. + inline void setEnabled(bool v); + + /// Get a pointer to the destination particle system. + inline ParticleSystem *getParticleSystem(); + + /// Get a const pointer to the destination particle system. + inline const ParticleSystem *getParticleSystem() const; + + /// Set the destination particle system. + inline void setParticleSystem(ParticleSystem *ps); + + void traverse(osg::NodeVisitor &nv); + + /// Get the current local-to-world transformation matrix (valid only during cull traversal). + inline const osg::Matrix &getLocalToWorldMatrix(); + + /// Get the current world-to-local transformation matrix (valid only during cull traversal). + inline const osg::Matrix &getWorldToLocalMatrix(); + + /// Transform a point from local to world coordinates (valid only during cull traversal). + inline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P); + + /// Transform a vector from local to world coordinates, discarding translation (valid only during cull traversal). + inline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P); + + /// Transform a point from world to local coordinates (valid only during cull traversal). + inline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P); + + /// Transform a vector from world to local coordinates, discarding translation (valid only during cull traversal). + inline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P); + + protected: + virtual ~ParticleProcessor() {} + ParticleProcessor &operator=(const ParticleProcessor &) { return *this; } + + inline const bool computeBound() const; + + virtual void process(double dt) = 0; + + private: + ReferenceFrame rf_; + bool enabled_; + double t0_; + osg::ref_ptr ps_; + bool need_ltw_matrix_; + bool need_wtl_matrix_; + osg::Matrix ltw_matrix_; + osg::Matrix wtl_matrix_; + osg::NodeVisitor *current_nodevisitor_; + }; + + // INLINE FUNCTIONS + + inline ParticleProcessor::ReferenceFrame ParticleProcessor::getReferenceFrame() const + { + return rf_; + } + + inline void ParticleProcessor::setReferenceFrame(ReferenceFrame rf) + { + rf_ = rf; + } + + inline bool ParticleProcessor::isEnabled() const + { + return enabled_; + } + + inline void ParticleProcessor::setEnabled(bool v) + { + enabled_ = v; + if (enabled_) t0_ = -1; + } + + inline ParticleSystem *ParticleProcessor::getParticleSystem() + { + return ps_.get(); + } + + inline const ParticleSystem *ParticleProcessor::getParticleSystem() const + { + return ps_.get(); + } + + inline void ParticleProcessor::setParticleSystem(ParticleSystem *ps) + { + ps_ = ps; + } + + inline const bool ParticleProcessor::computeBound() const + { + _bsphere.init(); + _bsphere_computed = true; + return true; + } + + inline const osg::Matrix &ParticleProcessor::getLocalToWorldMatrix() + { + if (need_ltw_matrix_) { + ltw_matrix_ = osg::Matrix::identity(); + current_nodevisitor_->getLocalToWorldMatrix(ltw_matrix_, this); + need_ltw_matrix_ = false; + } + return ltw_matrix_; + } + + inline const osg::Matrix &ParticleProcessor::getWorldToLocalMatrix() + { + if (need_wtl_matrix_) { + wtl_matrix_ = osg::Matrix::identity(); + current_nodevisitor_->getWorldToLocalMatrix(wtl_matrix_, this); + need_wtl_matrix_ = false; + } + return wtl_matrix_; + } + + inline osg::Vec3 ParticleProcessor::transformLocalToWorld(const osg::Vec3 &P) + { + return getLocalToWorldMatrix().preMult(P); + } + + inline osg::Vec3 ParticleProcessor::transformWorldToLocal(const osg::Vec3 &P) + { + return getWorldToLocalMatrix().preMult(P); + } + + inline osg::Vec3 ParticleProcessor::rotateLocalToWorld(const osg::Vec3 &P) + { + return getLocalToWorldMatrix().preMult(P) - + getLocalToWorldMatrix().preMult(osg::Vec3(0, 0, 0)); + } + + inline osg::Vec3 ParticleProcessor::rotateWorldToLocal(const osg::Vec3 &P) + { + return getWorldToLocalMatrix().preMult(P) - + getWorldToLocalMatrix().preMult(osg::Vec3(0, 0, 0)); + } + +} + + +#endif diff --git a/include/osgParticle/ParticleSystem b/include/osgParticle/ParticleSystem new file mode 100644 index 000000000..a06d3a7c7 --- /dev/null +++ b/include/osgParticle/ParticleSystem @@ -0,0 +1,318 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_PARTICLESYSTEM_ +#define OSGPARTICLE_PARTICLESYSTEM_ 1 + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace osgParticle +{ + + /** The heart of this class library; its purpose is to hold a set of particles and manage particle creation, update, rendering and destruction. + You can add this drawable to any Geode as you usually do with other + Drawable classes. Each instance of ParticleSystem is a separate set of + particles; it provides the interface for creating particles and iterating + through them (see the Emitter and Program classes). + */ + class OSGPARTICLE_EXPORT ParticleSystem: public osg::Drawable { + public: + + ParticleSystem(); + ParticleSystem(const ParticleSystem ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(ParticleSystem); + + /// Get the default bounding box + inline const osg::BoundingBox &getDefaultBoundingBox() const; + + /** Set the default bounding box. + The default bounding box is used when a real bounding box cannot be computed, for example + because no particles has been updated yet. + */ + inline void setDefaultBoundingBox(const osg::BoundingBox &bbox); + + /// Get the double pass rendering flag. + inline bool getDoublePassRendering() const; + + /** Set the double pass rendering flag. + Double pass rendering avoids overdraw problems between particle systems + and other opaque objects. If you can render all the particle systems after + the opaque objects, then double pass is not necessary and can be turned off (best choice). + If you set the default attributes with setDefaultAttributes, then the particle + system will fall into a transparent bin. + */ + inline void setDoublePassRendering(bool v); + + /// Return true if the particle system is frozen. + inline bool isFrozen() const; + + /** Set or reset the frozen state. + When the particle system is frozen, emitters and programs won't do anything on it. + */ + inline void setFrozen(bool v); + + /// Get the number of allocated particles (alive + dead). + inline int numParticles() const; + + /// Get the number of dead particles. + inline int numDeadParticles() const; + + /// Get a pointer to the i-th particle. + inline Particle *getParticle(int i); + + /// Get a const pointer to the i-th particle. + inline const Particle *getParticle(int i) const; + + /// Create a new particle from the specified template (or the default one if ptemplate is null). + inline virtual Particle *createParticle(const Particle *ptemplate); + + /// Destroy the i-th particle. + inline virtual void destroyParticle(int i); + + /// Get the last frame number. + inline int getLastFrameNumber() const; + + /// Get a reference to the default particle template. + inline const Particle &getDefaultParticleTemplate() const; + + /// Set the default particle template (particle is copied). + inline void setDefaultParticleTemplate(const Particle &p); + + /// Get whether the particle system can freeze when culled + inline bool getFreezeOnCull() const; + + /// Set whether the particle system can freeze when culled (default is true) + inline void setFreezeOnCull(bool v); + + /** A useful method to set the most common StateAttribute's in one call. + If texturefile is empty, then texturing is turned off. + */ + void setDefaultAttributes(const std::string &texturefile = "", bool emissive_particles = true, bool lighting = false); + + /// (EXPERIMENTAL) Get the level of detail. + inline int getLevelOfDetail() const; + + /** (EXPERIMENTAL) Set the level of detail. The total number of particles is divided by the detail value to + get the actual number of particles to be drawn. This value must be greater than zero. + */ + inline void setLevelOfDetail(int v); + + /// Update the particles. Don't call this directly, use a ParticleSystemUpdater instead. + virtual void update(double dt); + + inline virtual bool getStats(osg::Statistics &stats); + + protected: + virtual ~ParticleSystem(); + + ParticleSystem &operator=(const ParticleSystem &) { return *this; } + + inline virtual const bool computeBound() const; + virtual void drawImmediateMode(osg::State &state); + inline void update_bounds(const osg::Vec3 &p); + void single_pass_render(const osg::Matrix &modelview); + + private: + typedef std::vector Particle_vector; + typedef std::stack Death_stack; + + Particle_vector particles_; + Death_stack deadparts_; + + osg::BoundingBox def_bbox_; + + bool doublepass_; + bool frozen_; + int display_list_id_; + + osg::Vec3 bmin_; + osg::Vec3 bmax_; + + bool reset_bounds_flag_; + bool bounds_computed_; + + Particle def_ptemp_; + int last_frame_; + bool freeze_on_cull_; + + int detail_; + int draw_count_; + + }; + + // INLINE FUNCTIONS + + inline bool ParticleSystem::isFrozen() const + { + return frozen_; + } + + inline void ParticleSystem::setFrozen(bool v) + { + frozen_ = v; + } + + inline const osg::BoundingBox &ParticleSystem::getDefaultBoundingBox() const + { + return def_bbox_; + } + + inline void ParticleSystem::setDefaultBoundingBox(const osg::BoundingBox &bbox) + { + def_bbox_ = bbox; + } + + inline bool ParticleSystem::getDoublePassRendering() const + { + return doublepass_; + } + + inline void ParticleSystem::setDoublePassRendering(bool v) + { + doublepass_ = v; + } + + inline int ParticleSystem::numParticles() const + { + return static_cast(particles_.size()); + } + + inline int ParticleSystem::numDeadParticles() const + { + return static_cast(deadparts_.size()); + } + + inline Particle *ParticleSystem::getParticle(int i) + { + return &particles_[i]; + } + + inline const Particle *ParticleSystem::getParticle(int i) const + { + return &particles_[i]; + } + + inline void ParticleSystem::destroyParticle(int i) + { + particles_[i].kill(); + } + + inline int ParticleSystem::getLastFrameNumber() const + { + return last_frame_; + } + + inline const bool ParticleSystem::computeBound() const + { + if (!bounds_computed_) { + _bbox = def_bbox_; + } else { + _bbox._min = bmin_; + _bbox._max = bmax_; + } + _bbox_computed = true; + return true; + } + + inline bool ParticleSystem::getStats(osg::Statistics &stats) + { + stats.addNumPrims(draw_count_); + return true; + } + + inline void ParticleSystem::update_bounds(const osg::Vec3 &p) + { + if (reset_bounds_flag_) { + reset_bounds_flag_ = false; + bmin_ = p; + bmax_ = p; + } else { + if (p.x() < bmin_.x()) bmin_.x() = p.x(); + if (p.y() < bmin_.y()) bmin_.y() = p.y(); + if (p.z() < bmin_.z()) bmin_.z() = p.z(); + if (p.x() > bmax_.x()) bmax_.x() = p.x(); + if (p.y() > bmax_.y()) bmax_.y() = p.y(); + if (p.z() > bmax_.z()) bmax_.z() = p.z(); + + if (!bounds_computed_) + bounds_computed_ = true; + } + } + + inline const Particle &ParticleSystem::getDefaultParticleTemplate() const + { + return def_ptemp_; + } + + inline void ParticleSystem::setDefaultParticleTemplate(const Particle &p) + { + def_ptemp_ = p; + } + + inline bool ParticleSystem::getFreezeOnCull() const + { + return freeze_on_cull_; + } + + inline void ParticleSystem::setFreezeOnCull(bool v) + { + freeze_on_cull_ = v; + } + + inline int ParticleSystem::getLevelOfDetail() const + { + return detail_; + } + + inline void ParticleSystem::setLevelOfDetail(int v) + { + if (v < 1) v = 1; + detail_ = v; + } + + // I'm not sure this function should be inlined... + + inline Particle *ParticleSystem::createParticle(const Particle *ptemplate) + { + // is there any dead particle? + if (!deadparts_.empty()) { + + // retrieve a pointer to the last dead particle + Particle *P = deadparts_.top(); + + // create a new (alive) particle in the same place + *P = Particle(ptemplate? *ptemplate: def_ptemp_); + + // remove the pointer from the death stack + deadparts_.pop(); + return P; + + } else { + + // add a new particle to the vector + particles_.push_back(Particle(ptemplate? *ptemplate: def_ptemp_)); + return &particles_.back(); + } + } + + +} + +#endif diff --git a/include/osgParticle/ParticleSystemUpdater b/include/osgParticle/ParticleSystemUpdater new file mode 100644 index 000000000..2f23341b1 --- /dev/null +++ b/include/osgParticle/ParticleSystemUpdater @@ -0,0 +1,128 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_PARTICLESYSTEMUPDATER_ +#define OSGPARTICLE_PARTICLESYSTEMUPDATER_ 1 + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +namespace osgParticle +{ + + /** A useful node class for updating particle systems automatically. + When a ParticleSystemUpdater is traversed by a cull visitor, it calls the + update() method on the specified particle systems. You should place this updater + AFTER other nodes like emitters and programs. + */ + class OSGPARTICLE_EXPORT ParticleSystemUpdater: public osg::Node { + public: + ParticleSystemUpdater(); + ParticleSystemUpdater(const ParticleSystemUpdater ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Node(ParticleSystemUpdater); + + /// Return the number of particle systems on the list. + inline int numParticleSystems() const; + + /// Add a particle system to the list. + inline void addParticleSystem(ParticleSystem *ps); + + /// Get a const particle system from the list. + inline const ParticleSystem *getParticleSystem(int i) const; + + /// Get a particle system from the list. + inline ParticleSystem *getParticleSystem(int i); + + /// Find a particle system. + inline int findParticleSystem(ParticleSystem *ps) const; + + /// Remove a particle system from the list (by index). + inline void removeParticleSystem(int i); + + /// Remove a particle system from the list (by pointer). + inline bool removeParticleSystem(ParticleSystem *ps); + + virtual void traverse(osg::NodeVisitor &nv); + + protected: + virtual ~ParticleSystemUpdater() {} + ParticleSystemUpdater &operator=(const ParticleSystemUpdater &) { return *this; } + + inline virtual const bool computeBound() const; + + private: + typedef std::vector > ParticleSystem_Vector; + + ParticleSystem_Vector psv_; + double t0_; + }; + + // INLINE FUNCTIONS + + inline const bool ParticleSystemUpdater::computeBound() const + { + _bsphere.init(); + _bsphere_computed = true; + return true; + } + + inline int ParticleSystemUpdater::numParticleSystems() const + { + return static_cast(psv_.size()); + } + + inline void ParticleSystemUpdater::addParticleSystem(ParticleSystem *ps) + { + psv_.push_back(ps); + } + + inline const ParticleSystem *ParticleSystemUpdater::getParticleSystem(int i) const + { + return psv_[i].get(); + } + + inline ParticleSystem *ParticleSystemUpdater::getParticleSystem(int i) + { + return psv_[i].get(); + } + + inline void ParticleSystemUpdater::removeParticleSystem(int i) + { + psv_.erase(psv_.begin()+i); + } + + inline int ParticleSystemUpdater::findParticleSystem(ParticleSystem *ps) const + { + ParticleSystem_Vector::const_iterator i; + int j = 0; + for (i=psv_.begin(); i!=psv_.end(); ++i, ++j) { + if (i->get() == ps) return j; + } + return -1; + } + + inline bool ParticleSystemUpdater::removeParticleSystem(ParticleSystem *ps) + { + int i = findParticleSystem(ps); + if (i == -1) return false; + removeParticleSystem(i); + return true; + } + + +} + +#endif diff --git a/include/osgParticle/Placer b/include/osgParticle/Placer new file mode 100644 index 000000000..d96dbf90e --- /dev/null +++ b/include/osgParticle/Placer @@ -0,0 +1,51 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_PLACER_ +#define OSGPARTICLE_PLACER_ 1 + +#include +#include + +namespace osgParticle +{ + + class Particle; + + /** An abstract base class for implementing particle placers. A placer is an object which take + a particle as input, and places it somewhere by setting its position vector. Placer objects are + used by the ModularEmitter class as part of the particle emission process. + */ + class Placer: public osg::Object { + public: + inline Placer(); + inline Placer(const Placer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "Placer"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + /// Place a particle. Must be implemented in descendant classes. + virtual void place(Particle *P) const = 0; + + protected: + ~Placer() {} + Placer &operator=(const Placer &) { return *this; } + }; + + // INLINE FUNCTIONS + + inline Placer::Placer() + : osg::Object() + { + } + + inline Placer::Placer(const Placer ©, const osg::CopyOp ©op) + : osg::Object(copy, copyop) + { + } + +} + +#endif diff --git a/include/osgParticle/PointPlacer b/include/osgParticle/PointPlacer new file mode 100644 index 000000000..1143712c3 --- /dev/null +++ b/include/osgParticle/PointPlacer @@ -0,0 +1,61 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_POINTPLACER_ +#define OSGPARTICLE_POINTPLACER_ 1 + +#include +#include + +#include +#include + +namespace osgParticle +{ + + /** A point-shaped particle placer. + This placer class uses the center point defined in its base class CenteredPlacer + to place there all incoming particles. + */ + class PointPlacer: public CenteredPlacer { + public: + inline PointPlacer(); + inline PointPlacer(const PointPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(PointPlacer); + + /** Place a particle. + This method is called automatically by ModularEmitter and should not be called + manually. + */ + inline void place(Particle *P) const; + + protected: + virtual ~PointPlacer() {} + PointPlacer &operator=(const PointPlacer &) { return *this; } + }; + + // INLINE FUNCTIONS + + inline PointPlacer::PointPlacer() + : CenteredPlacer() + { + } + + inline PointPlacer::PointPlacer(const PointPlacer ©, const osg::CopyOp ©op) + : CenteredPlacer(copy, copyop) + { + } + + inline void PointPlacer::place(Particle *P) const + { + P->setPosition(getCenter()); + } + + +} + + +#endif diff --git a/include/osgParticle/Program b/include/osgParticle/Program new file mode 100644 index 000000000..cfce7ff8b --- /dev/null +++ b/include/osgParticle/Program @@ -0,0 +1,57 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_PROGRAM_ +#define OSGPARTICLE_PROGRAM_ 1 + +#include +#include + +#include +#include +#include +#include + +namespace osgParticle +{ + + /** An abstract ParticleProcessor descendant for modifying particles "on the fly" + during the cull traversal. + Descendants of this class must implement the execute() method, which should iterate + through all particles in the linked particle system and modify them somehow + (usually updating their velocity vector). + */ + class OSGPARTICLE_EXPORT Program: public ParticleProcessor { + public: + Program(); + Program(const Program ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "Program"; } + virtual bool isSameKindAs(const osg::Object *obj) { return dynamic_cast(obj) != 0; } + virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } } + + protected: + virtual ~Program() {} + Program &operator=(const Program &) { return *this; } + + /// Implementation of ParticleProcessor::process(). Do not call this method by yourself. + inline void process(double dt); + + /// Execute the program on the particle system. Must be overriden in descendant classes. + virtual void execute(double dt) = 0; + + private: + }; + + // INLINE FUNCTIONS + + inline void Program::process(double dt) + { + execute(dt); + } + +} + +#endif diff --git a/include/osgParticle/RadialShooter b/include/osgParticle/RadialShooter new file mode 100644 index 000000000..4bb851f40 --- /dev/null +++ b/include/osgParticle/RadialShooter @@ -0,0 +1,156 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_RADIALSHOOTER_ +#define OSGPARTICLE_RADIALSHOOTER_ 1 + +#include +#include +#include + +#include +#include +#include + +namespace osgParticle +{ + + /** A shooter class that shoots particles radially. + This shooter computes the velocity vector of incoming particles by choosing a + random direction and a random speed. Both direction and speed are chosen within + specified ranges. The direction is defined by two angles: theta, which + is the angle between the velocity vector and the Z axis, and phi, which is + the angle between the X axis and the velocity vector projected onto the X-Y plane. + */ + class RadialShooter: public Shooter { + public: + inline RadialShooter(); + inline RadialShooter(const RadialShooter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(RadialShooter); + + /// Get the range of possible values for theta angle. + inline const rangef &getThetaRange() const; + + /// Set the range of possible values for theta angle. + inline void setThetaRange(const rangef &r); + + /// Set the range of possible values for theta angle. + inline void setThetaRange(float r1, float r2); + + /// Get the range of possible values for phi angle. + inline const rangef &getPhiRange() const; + + /// Set the range of possible values for phi angle. + inline void setPhiRange(const rangef &r); + + /// Set the range of possible values for phi angle. + inline void setPhiRange(float r1, float r2); + + /// Get the range of possible values for initial speed of particles. + inline const rangef &getInitialSpeedRange() const; + + /// Set the range of possible values for initial speed of particles. + inline void setInitialSpeedRange(const rangef &r); + + /// Set the range of possible values for initial speed of particles. + inline void setInitialSpeedRange(float r1, float r2); + + /// Shoot a particle. Do not call this method manually. + inline void shoot(Particle *P) const; + + protected: + virtual ~RadialShooter() {} + RadialShooter &operator=(const RadialShooter &) { return *this; } + + private: + rangef theta_range_; + rangef phi_range_; + rangef speed_range_; + }; + + // INLINE FUNCTIONS + + inline RadialShooter::RadialShooter() + : Shooter(), + theta_range_(0, 0.5f*osg::PI_4), + phi_range_(0, 2*osg::PI), + speed_range_(10, 10) + { + } + + inline RadialShooter::RadialShooter(const RadialShooter ©, const osg::CopyOp ©op) + : Shooter(copy, copyop), + theta_range_(copy.theta_range_), + phi_range_(copy.phi_range_), + speed_range_(copy.speed_range_) + { + } + + inline const rangef &RadialShooter::getThetaRange() const + { + return theta_range_; + } + + inline const rangef &RadialShooter::getPhiRange() const + { + return phi_range_; + } + + inline const rangef &RadialShooter::getInitialSpeedRange() const + { + return speed_range_; + } + + inline void RadialShooter::setThetaRange(const rangef &r) + { + theta_range_ = r; + } + + inline void RadialShooter::setThetaRange(float r1, float r2) + { + theta_range_.min = r1; + theta_range_.max = r2; + } + + inline void RadialShooter::setPhiRange(const rangef &r) + { + phi_range_ = r; + } + + inline void RadialShooter::setPhiRange(float r1, float r2) + { + phi_range_.min = r1; + phi_range_.max = r2; + } + + inline void RadialShooter::setInitialSpeedRange(const rangef &r) + { + speed_range_ = r; + } + + inline void RadialShooter::setInitialSpeedRange(float r1, float r2) + { + speed_range_.min = r1; + speed_range_.max = r2; + } + + inline void RadialShooter::shoot(Particle *P) const + { + float theta = theta_range_.get_random(); + float phi = phi_range_.get_random(); + float speed = speed_range_.get_random(); + + P->setVelocity(osg::Vec3( + speed * sinf(theta) * cosf(phi), + speed * sinf(theta) * sinf(phi), + speed * cosf(theta) + )); + } + +} + + +#endif diff --git a/include/osgParticle/RandomRateCounter b/include/osgParticle/RandomRateCounter new file mode 100644 index 000000000..937017420 --- /dev/null +++ b/include/osgParticle/RandomRateCounter @@ -0,0 +1,57 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_RANDOMRATECOUNTER_ +#define OSGPARTICLE_RANDOMRATECOUNTER_ 1 + +#include + +#include +#include + +namespace osgParticle +{ + + class RandomRateCounter: public VariableRateCounter { + public: + inline RandomRateCounter(); + inline RandomRateCounter(const RandomRateCounter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(RandomRateCounter); + + /// Return the number of particles to be created in this frame + inline int numParticlesToCreate(double dt) const; + + protected: + virtual ~RandomRateCounter() {} + + private: + mutable float np_; + }; + + // INLINE FUNCTIONS + + inline RandomRateCounter::RandomRateCounter() + : VariableRateCounter(), np_(0) + { + } + + inline RandomRateCounter::RandomRateCounter(const RandomRateCounter ©, const osg::CopyOp ©op) + : VariableRateCounter(copy, copyop), np_(copy.np_) + { + } + + inline int RandomRateCounter::numParticlesToCreate(double dt) const + { + np_ += dt * getRateRange().get_random(); + int n = static_cast(np_); + np_ -= n; + return n; + } + +} + + +#endif diff --git a/include/osgParticle/SectorPlacer b/include/osgParticle/SectorPlacer new file mode 100644 index 000000000..225f09dac --- /dev/null +++ b/include/osgParticle/SectorPlacer @@ -0,0 +1,124 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_SECTORPLACER_ +#define OSGPARTICLE_SECTORPLACER_ 1 + +#include +#include +#include + +#include +#include +#include +#include + +namespace osgParticle +{ + + /** A sector-shaped particle placer. + This placer sets the initial position of incoming particle by choosing a random position + within a circular sector; this sector is defined by three parameters: a center point, + which is inherited directly from osgParticle::CenteredPlacer, a range of values + for radius, and a range of values for the central angle (sometimes called phi). + */ + class SectorPlacer: public CenteredPlacer { + public: + inline SectorPlacer(); + inline SectorPlacer(const SectorPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + /// Get the range of possible values for radius. + inline const rangef &getRadiusRange() const; + + /// Set the range of possible values for radius. + inline void setRadiusRange(const rangef &r); + + /// Set the range of possible values for radius. + inline void setRadiusRange(float r1, float r2); + + /// Get the range of possible values for the central angle. + inline const rangef &getPhiRange() const; + + /// Set the range of possible values for the central angle. + inline void setPhiRange(const rangef &r); + + /// Set the range of possible values for the central angle. + inline void setPhiRange(float r1, float r2); + + META_Object(SectorPlacer); + + /// Place a particle. Do not call it manually. + inline void place(Particle *P) const; + + protected: + virtual ~SectorPlacer() {} + SectorPlacer &operator=(const SectorPlacer &) { return *this; } + + private: + rangef rad_range_; + rangef phi_range_; + }; + + // INLINE FUNCTIONS + + inline SectorPlacer::SectorPlacer() + : CenteredPlacer(), rad_range_(0, 1), phi_range_(0, osg::PI*2) + { + } + + inline SectorPlacer::SectorPlacer(const SectorPlacer ©, const osg::CopyOp ©op) + : CenteredPlacer(copy, copyop), rad_range_(copy.rad_range_), phi_range_(copy.phi_range_) + { + } + + inline const rangef &SectorPlacer::getRadiusRange() const + { + return rad_range_; + } + + inline const rangef &SectorPlacer::getPhiRange() const + { + return phi_range_; + } + + inline void SectorPlacer::setRadiusRange(const rangef &r) + { + rad_range_ = r; + } + + inline void SectorPlacer::setRadiusRange(float r1, float r2) + { + rad_range_.min = r1; + rad_range_.max = r2; + } + + inline void SectorPlacer::setPhiRange(const rangef &r) + { + phi_range_ = r; + } + + inline void SectorPlacer::setPhiRange(float r1, float r2) + { + phi_range_.min = r1; + phi_range_.max = r2; + } + + inline void SectorPlacer::place(Particle *P) const + { + float rad = rad_range_.get_random(); + float phi = phi_range_.get_random(); + + osg::Vec3 pos( + getCenter().x() + rad * cosf(phi), + getCenter().y() + rad * sinf(phi), + getCenter().z()); + + P->setPosition(pos); + } + + +} + +#endif diff --git a/include/osgParticle/SegmentPlacer b/include/osgParticle/SegmentPlacer new file mode 100644 index 000000000..381bcd1c8 --- /dev/null +++ b/include/osgParticle/SegmentPlacer @@ -0,0 +1,118 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_SEGMENTPLACER_ +#define OSGPARTICLE_SEGMENTPLACER_ 1 + +#include +#include + +#include +#include +#include + +namespace osgParticle { + + /** A segment-shaped particle placer. + To use this placer you have to define a segment, by setting its two vertices (A and B); + when an emitter requests a SegmentPlacer to place a particle, the position is chosen randomly + within that segment. + */ + class SegmentPlacer: public Placer { + public: + inline SegmentPlacer(); + inline SegmentPlacer(const SegmentPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + META_Object(SegmentPlacer); + + /// get vertex A. + inline const osg::Vec3 &getVertexA() const; + + /// Set vertex A of the segment as a vector. + inline void setVertexA(const osg::Vec3 &v); + + /// Set vertex A of the segment as three floats. + inline void setVertexA(float x, float y, float z); + + /// get vertex B. + inline const osg::Vec3 &getVertexB() const; + + /// Set vertex B of the segment as a vector. + inline void setVertexB(const osg::Vec3 &v); + + /// Set vertex B of the segment as three floats. + inline void setVertexB(float x, float y, float z); + + /// Set both vertices. + inline void setSegment(const osg::Vec3 &A, const osg::Vec3 &B); + + /// Place a particle. This method is called by ModularEmitter, do not call it manually. + inline void place(Particle *P) const; + + protected: + virtual ~SegmentPlacer() {} + SegmentPlacer &operator=(const SegmentPlacer &) { return *this; } + + private: + osg::Vec3 A_; + osg::Vec3 B_; + }; + + // INLINE FUNCTIONS + + inline SegmentPlacer::SegmentPlacer() + : Placer(), A_(-1, 0, 0), B_(1, 0, 0) + { + } + + inline SegmentPlacer::SegmentPlacer(const SegmentPlacer ©, const osg::CopyOp ©op) + : Placer(copy, copyop), A_(copy.A_), B_(copy.B_) + { + } + + inline const osg::Vec3 &SegmentPlacer::getVertexA() const + { + return A_; + } + + inline const osg::Vec3 &SegmentPlacer::getVertexB() const + { + return B_; + } + + inline void SegmentPlacer::setSegment(const osg::Vec3 &A, const osg::Vec3 &B) + { + A_ = A; + B_ = B; + } + + inline void SegmentPlacer::place(Particle *P) const + { + P->setPosition(rangev3(A_, B_).get_random()); + } + + inline void SegmentPlacer::setVertexA(const osg::Vec3 &v) + { + A_ = v; + } + + inline void SegmentPlacer::setVertexA(float x, float y, float z) + { + A_.set(x, y, z); + } + + inline void SegmentPlacer::setVertexB(const osg::Vec3 &v) + { + B_ = v; + } + + inline void SegmentPlacer::setVertexB(float x, float y, float z) + { + B_.set(x, y, z); + } + +} + +#endif diff --git a/include/osgParticle/Shooter b/include/osgParticle/Shooter new file mode 100644 index 000000000..b1ee010e2 --- /dev/null +++ b/include/osgParticle/Shooter @@ -0,0 +1,53 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_SHOOTER_ +#define OSGPARTICLE_SHOOTER_ 1 + +#include +#include + +namespace osgParticle +{ + + class Particle; + + /** An abstract base class used by ModularEmitter to "shoot" the particles after they have been placed. + Descendants of this class must override the shoot() method. + */ + class Shooter: public osg::Object { + public: + inline Shooter(); + inline Shooter(const Shooter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "Shooter"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + /** Shoot a particle. Must be overriden by descendants. + This method should only set the velocity vector of particle P, leaving other + attributes unchanged. + */ + virtual void shoot(Particle *P) const = 0; + + protected: + virtual ~Shooter() {} + Shooter &operator=(const Shooter &) { return *this; } + }; + + // INLINE FUNCTIONS + + inline Shooter::Shooter() + : osg::Object() + { + } + + inline Shooter::Shooter(const Shooter ©, const osg::CopyOp ©op) + : osg::Object(copy, copyop) + { + } + +} + +#endif diff --git a/include/osgParticle/VariableRateCounter b/include/osgParticle/VariableRateCounter new file mode 100644 index 000000000..727b7ba0e --- /dev/null +++ b/include/osgParticle/VariableRateCounter @@ -0,0 +1,67 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_VARIABLERATECOUNTER_ +#define OSGPARTICLE_VARIABLERATECOUNTER_ 1 + +#include +#include + +#include +#include + +namespace osgParticle +{ + + class VariableRateCounter: public Counter { + public: + inline VariableRateCounter(); + inline VariableRateCounter(const VariableRateCounter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); + + virtual const char *className() const { return "VariableRateCounter"; } + virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast(obj) != 0; } + + inline const rangef &getRateRange() const; + inline void setRateRange(const rangef &r); + inline void setRateRange(float minrange, float maxrange); + + protected: + virtual ~VariableRateCounter() {} + + private: + rangef rate_range_; + }; + + // INLINE FUNCTIONS + + inline VariableRateCounter::VariableRateCounter() + : Counter(), rate_range_(1, 1) + { + } + + inline VariableRateCounter::VariableRateCounter(const VariableRateCounter ©, const osg::CopyOp ©op) + : Counter(copy, copyop), rate_range_(copy.rate_range_) + { + } + + inline const rangef &VariableRateCounter::getRateRange() const + { + return rate_range_; + } + + inline void VariableRateCounter::setRateRange(const rangef &r) + { + rate_range_ = r; + } + + inline void VariableRateCounter::setRateRange(float minrange, float maxrange) + { + rate_range_.set(minrange, maxrange); + } + +} + + +#endif diff --git a/include/osgParticle/Version b/include/osgParticle/Version new file mode 100644 index 000000000..5ff598bc6 --- /dev/null +++ b/include/osgParticle/Version @@ -0,0 +1,19 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_VERSION_ +#define OSGPARTICLE_VERSION_ 1 + +#include + +extern "C" { + +OSGPARTICLE_EXPORT const char* osgParticleGetVersion(); +OSGPARTICLE_EXPORT const char* osgParticleGetLibraryName(); + +} + +#endif + diff --git a/include/osgParticle/range b/include/osgParticle/range new file mode 100644 index 000000000..d3bc93a4c --- /dev/null +++ b/include/osgParticle/range @@ -0,0 +1,65 @@ +//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield +//Distributed under the terms of the GNU Library General Public License (LGPL) +//as published by the Free Software Foundation. +//osgParticle - Copyright (C) 2002 Marco Jez + +#ifndef OSGPARTICLE_RANGE_ +#define OSGPARTICLE_RANGE_ 1 + +#include + +#include +#include +#include + +namespace osgParticle +{ + + /** + A simple struct template useful to store ranges of values as min/max pairs. + This struct template helps storing min/max ranges for values of any kind; class T_ is + the type of values to be stored, and it must support operations T_ + T_, T_ - T_, + and T_ * float, otherwise the get_random() method will not compile. + This struct could be extended to customize the random number generator (now it uses only + std::rand()). + */ + template struct range { + + /// Lower bound. + T_ min; + + /// Higher bound. + T_ max; + + /// Construct the object by calling default constructors for min and max. + range() : min(T_()), max(T_()) {} + + /// Construct and initialize min and max directly. + range(const T_ &mn, const T_ &mx) : min(mn), max(mx) {} + + /// Set min and max. + void set(const T_ &mn, const T_ &mx) { min = mn; max = mx; } + + /// Get a random value between min and max. + T_ get_random() const + { + return min + (max - min) * std::rand() / RAND_MAX; + } + + }; + + /// Range of floats. + typedef range rangef; + + /// Range of osg::Vec2s. + typedef range rangev2; + + /// Range of osg::Vec3s. + typedef range rangev3; + + /// Range of osg::Vec4s. + typedef range rangev4; + +} + +#endif diff --git a/src/Demos/osgparticle/Makefile b/src/Demos/osgparticle/Makefile new file mode 100644 index 000000000..648e825cd --- /dev/null +++ b/src/Demos/osgparticle/Makefile @@ -0,0 +1,16 @@ +TOPDIR = ../../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + osgparticle.cpp\ + +LIBS += $(OSG_LIBS) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -losgParticle + +INSTFILES = \ + $(CXXFILES)\ + Makefile.inst=Makefile + +EXEC = osgparticle + +include $(TOPDIR)/Make/makerules + diff --git a/src/Demos/osgparticle/Makefile.inst b/src/Demos/osgparticle/Makefile.inst new file mode 100644 index 000000000..066678e60 --- /dev/null +++ b/src/Demos/osgparticle/Makefile.inst @@ -0,0 +1,13 @@ +TOPDIR = ../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + osgparticle.cpp\ + +LIBS += $(OSG_LIBS) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -losgParticle + +EXEC = osgparticle + + +include $(TOPDIR)/Make/makerules + diff --git a/src/Demos/osgparticle/osgparticle.cpp b/src/Demos/osgparticle/osgparticle.cpp new file mode 100644 index 000000000..79194b794 --- /dev/null +++ b/src/Demos/osgparticle/osgparticle.cpp @@ -0,0 +1,120 @@ +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +// ---------------------------------------------------------------------------------- +// These lines are necessary under Windows because if we don't instantiate at least +// one object of osgParticle, the library will not be linked to the exe even if we +// add it to the dependancies list, leading to failure when importing .osg files. + +#ifdef WIN32 + +#include +osgParticle::Particle dummy_Particle__; + +#endif + +// ---------------------------------------------------------------------------------- + +void write_usage(std::ostream& out,const std::string& name) +{ + out << std::endl; + out <<"usage:"<< std::endl; + out <<" "< commandLine; + for(int i=1;i +#include + +#include + +osgParticle::Emitter::Emitter() +: ParticleProcessor(), + usedeftemp_(true) +{ +} + +osgParticle::Emitter::Emitter(const Emitter ©, const osg::CopyOp ©op) +: ParticleProcessor(copy, copyop), + usedeftemp_(copy.usedeftemp_), + ptemp_(copy.ptemp_) +{ +} diff --git a/src/osgParticle/FluidFrictionOperator.cpp b/src/osgParticle/FluidFrictionOperator.cpp new file mode 100644 index 000000000..6ac4309d9 --- /dev/null +++ b/src/osgParticle/FluidFrictionOperator.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +osgParticle::FluidFrictionOperator::FluidFrictionOperator() +: Operator(), ovr_rad_(0) +{ + setFluidToAir(); +} + +osgParticle::FluidFrictionOperator::FluidFrictionOperator(const FluidFrictionOperator ©, const osg::CopyOp ©op) +: Operator(copy, copyop), + A_(copy.A_), + B_(copy.B_), + density_(copy.density_), + viscosity_(copy.viscosity_), + ovr_rad_(copy.ovr_rad_) +{ +} + +void osgParticle::FluidFrictionOperator::operate(Particle *P, double dt) +{ + float r = (ovr_rad_ > 0)? ovr_rad_ : P->getRadius(); + osg::Vec3 v = P->getVelocity(); + + float vm = v.normalize(); + float R = A_ * r * vm + B_ * r * r * vm * vm; + + osg::Vec3 Fr(-R * v.x(), -R * v.y(), -R * v.z()); + + if (current_program_->getReferenceFrame() == ModularProgram::RELATIVE_TO_PARENTS) { + Fr = current_program_->rotateLocalToWorld(Fr); + } + + P->addVelocity(Fr * (P->getMassInv() * dt)); +} diff --git a/src/osgParticle/IO_AccelOperator.cpp b/src/osgParticle/IO_AccelOperator.cpp new file mode 100644 index 000000000..dbde4c3de --- /dev/null +++ b/src/osgParticle/IO_AccelOperator.cpp @@ -0,0 +1,48 @@ + +#include + +#include +#include +#include + +#include + +#include + +bool AccelOperator_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool AccelOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy AccelOperator_Proxy +( + osgNew osgParticle::AccelOperator, + "AccelOperator", + "Object Operator AccelOperator", + AccelOperator_readLocalData, + AccelOperator_writeLocalData +); + +bool AccelOperator_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::AccelOperator &aop = static_cast(obj); + bool itAdvanced = false; + + osg::Vec3 a; + + if (fr[0].matchWord("acceleration")) { + if (fr[1].getFloat(a.x()) && fr[2].getFloat(a.y()) && fr[3].getFloat(a.z())) { + aop.setAcceleration(a); + fr += 4; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool AccelOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::AccelOperator &aop = static_cast(obj); + osg::Vec3 a = aop.getAcceleration(); + fw.indent() << "acceleration " << a.x() << " " << a.y() << " " << a.z() << std::endl; + return true; +} diff --git a/src/osgParticle/IO_CenteredPlacer.cpp b/src/osgParticle/IO_CenteredPlacer.cpp new file mode 100644 index 000000000..498dc06e6 --- /dev/null +++ b/src/osgParticle/IO_CenteredPlacer.cpp @@ -0,0 +1,49 @@ + +#include + +#include +#include +#include + +#include + +#include + +bool CenteredPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool CenteredPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy CenteredPlacer_Proxy +( + 0, + "CenteredPlacer", + "Object Placer CenteredPlacer", + CenteredPlacer_readLocalData, + CenteredPlacer_writeLocalData +); + +bool CenteredPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::CenteredPlacer &myobj = static_cast(obj); + bool itAdvanced = false; + + osg::Vec3 v; + if (fr[0].matchWord("center")) { + if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) { + myobj.setCenter(v); + fr += 4; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool CenteredPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::CenteredPlacer &myobj = static_cast(obj); + + osg::Vec3 v = myobj.getCenter(); + fw.indent() << "center " << v.x() << " " << v.y() << " " << v.z() << std::endl; + + return true; +} diff --git a/src/osgParticle/IO_Emitter.cpp b/src/osgParticle/IO_Emitter.cpp new file mode 100644 index 000000000..c197acd9d --- /dev/null +++ b/src/osgParticle/IO_Emitter.cpp @@ -0,0 +1,70 @@ + +#include + +#include + +#include +#include +#include + +extern bool read_particle(osgDB::Input &fr, osgParticle::Particle &P); +extern void write_particle(const osgParticle::Particle &P, osgDB::Output &fw); + +bool Emitter_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool Emitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy Emitter_Proxy +( + 0, + "Emitter", + "Object Node ParticleProcessor Emitter", + Emitter_readLocalData, + Emitter_writeLocalData +); + +bool Emitter_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::Emitter &myobj = static_cast(obj); + bool itAdvanced = false; + + if (fr[0].matchWord("useDefaultTemplate")) { + if (fr[1].matchWord("TRUE")) { + myobj.setUseDefaultTemplate(true); + fr += 2; + itAdvanced = true; + } + if (fr[1].matchWord("FALSE")) { + myobj.setUseDefaultTemplate(false); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("particleTemplate")) { + ++fr; + itAdvanced = true; + osgParticle::Particle P; + if (read_particle(fr, P)) { + myobj.setParticleTemplate(P); + } + } + + return itAdvanced; +} + +bool Emitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::Emitter &myobj = static_cast(obj); + + fw.indent() << "useDefaultTemplate "; + if (!myobj.getUseDefaultTemplate()) { + fw << "FALSE" << std::endl; + fw.indent() << "particleTemplate "; + write_particle(myobj.getParticleTemplate(), fw); + fw << std::endl; + } else { + fw << "TRUE" << std::endl; + } + + return true; +} diff --git a/src/osgParticle/IO_FluidFrictionOperator.cpp b/src/osgParticle/IO_FluidFrictionOperator.cpp new file mode 100644 index 000000000..8a9de1b43 --- /dev/null +++ b/src/osgParticle/IO_FluidFrictionOperator.cpp @@ -0,0 +1,63 @@ + +#include + +#include +#include +#include + +#include + +bool FluidFrictionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool FluidFrictionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy FluidFrictionOperator_Proxy +( + osgNew osgParticle::FluidFrictionOperator, + "FluidFrictionOperator", + "Object Operator FluidFrictionOperator", + FluidFrictionOperator_readLocalData, + FluidFrictionOperator_writeLocalData +); + +bool FluidFrictionOperator_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::FluidFrictionOperator &aop = static_cast(obj); + bool itAdvanced = false; + + float f; + + if (fr[0].matchWord("fluidDensity")) { + if (fr[1].getFloat(f)) { + aop.setFluidDensity(f); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("fluidViscosity")) { + if (fr[1].getFloat(f)) { + aop.setFluidViscosity(f); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("overrideRadius")) { + if (fr[1].getFloat(f)) { + aop.setOverrideRadius(f); + fr += 2; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool FluidFrictionOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::FluidFrictionOperator &aop = static_cast(obj); + fw.indent() << "fluidDensity " << aop.getFluidDensity() << std::endl; + fw.indent() << "fluidViscosity " << aop.getFluidViscosity() << std::endl; + fw.indent() << "overrideRadius " << aop.getOverrideRadius(); + return true; +} diff --git a/src/osgParticle/IO_ForceOperator.cpp b/src/osgParticle/IO_ForceOperator.cpp new file mode 100644 index 000000000..220f6aea0 --- /dev/null +++ b/src/osgParticle/IO_ForceOperator.cpp @@ -0,0 +1,48 @@ + +#include + +#include +#include +#include + +#include + +#include + +bool ForceOperator_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool ForceOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy ForceOperator_Proxy +( + osgNew osgParticle::ForceOperator, + "ForceOperator", + "Object Operator ForceOperator", + ForceOperator_readLocalData, + ForceOperator_writeLocalData +); + +bool ForceOperator_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::ForceOperator &fop = static_cast(obj); + bool itAdvanced = false; + + osg::Vec3 f; + + if (fr[0].matchWord("force")) { + if (fr[1].getFloat(f.x()) && fr[2].getFloat(f.y()) && fr[3].getFloat(f.z())) { + fop.setForce(f); + fr += 4; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool ForceOperator_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::ForceOperator &fop = static_cast(obj); + osg::Vec3 f = fop.getForce(); + fw.indent() << "force " << f.x() << " " << f.y() << " " << f.z() << std::endl; + return true; +} diff --git a/src/osgParticle/IO_LinearInterpolator.cpp b/src/osgParticle/IO_LinearInterpolator.cpp new file mode 100644 index 000000000..5f5954b8d --- /dev/null +++ b/src/osgParticle/IO_LinearInterpolator.cpp @@ -0,0 +1,28 @@ + +#include + +#include +#include +#include + +bool LinearInterpolator_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool LinearInterpolator_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy LinearInterpolator_Proxy +( + osgNew osgParticle::LinearInterpolator, + "LinearInterpolator", + "Object Interpolator LinearInterpolator", + LinearInterpolator_readLocalData, + LinearInterpolator_writeLocalData +); + +bool LinearInterpolator_readLocalData(osg::Object &, osgDB::Input &) +{ + return false; +} + +bool LinearInterpolator_writeLocalData(const osg::Object &, osgDB::Output &) +{ + return false; +} diff --git a/src/osgParticle/IO_ModularEmitter.cpp b/src/osgParticle/IO_ModularEmitter.cpp new file mode 100644 index 000000000..0fd0f0496 --- /dev/null +++ b/src/osgParticle/IO_ModularEmitter.cpp @@ -0,0 +1,62 @@ + +#include +#include +#include +#include + +#include +#include +#include + +bool ModularEmitter_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool ModularEmitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy ModularEmitter_Proxy +( + osgNew osgParticle::ModularEmitter, + "ModularEmitter", + "Object Node ParticleProcessor Emitter ModularEmitter", + ModularEmitter_readLocalData, + ModularEmitter_writeLocalData +); + +bool ModularEmitter_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::ModularEmitter &myobj = static_cast(obj); + bool itAdvanced = false; + + // we cannot use readObjectOfType() because the Coutner, Placer and Shooter classes are + // abstract and we can't create instances to use as prototypes. + // So, we call readObject() and then dynamic cast to the desired class. + + osgParticle::Counter *counter = dynamic_cast(fr.readObject()); + if (counter) { + myobj.setCounter(counter); + itAdvanced = true; + } + + osgParticle::Placer *placer = dynamic_cast(fr.readObject()); + if (placer) { + myobj.setPlacer(placer); + itAdvanced = true; + } + + osgParticle::Shooter *shooter = dynamic_cast(fr.readObject()); + if (shooter) { + myobj.setShooter(shooter); + itAdvanced = true; + } + + return itAdvanced; +} + +bool ModularEmitter_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::ModularEmitter &myobj = static_cast(obj); + + fw.writeObject(*myobj.getCounter()); + fw.writeObject(*myobj.getPlacer()); + fw.writeObject(*myobj.getShooter()); + + return true; +} diff --git a/src/osgParticle/IO_ModularProgram.cpp b/src/osgParticle/IO_ModularProgram.cpp new file mode 100644 index 000000000..9f2ea2953 --- /dev/null +++ b/src/osgParticle/IO_ModularProgram.cpp @@ -0,0 +1,46 @@ + +#include +#include + +#include + +#include +#include +#include + +bool ModularProgram_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool ModularProgram_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy ModularProgram_Proxy +( + osgNew osgParticle::ModularProgram, + "ModularProgram", + "Object Node ParticleProcessor Program ModularProgram", + ModularProgram_readLocalData, + ModularProgram_writeLocalData +); + +bool ModularProgram_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::ModularProgram &myobj = static_cast(obj); + bool itAdvanced = false; + + osgParticle::Operator *op = dynamic_cast(fr.readObject()); + if (op) { + myobj.addOperator(op); + itAdvanced = true; + } + + return itAdvanced; +} + +bool ModularProgram_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::ModularProgram &myobj = static_cast(obj); + + for (int i=0; i + +#include +#include +#include + +#include + +#include + +bool MultiSegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool MultiSegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy MultiSegmentPlacer_Proxy +( + osgNew osgParticle::MultiSegmentPlacer, + "MultiSegmentPlacer", + "Object Placer MultiSegmentPlacer", + MultiSegmentPlacer_readLocalData, + MultiSegmentPlacer_writeLocalData +); + +bool MultiSegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::MultiSegmentPlacer &myobj = static_cast(obj); + bool itAdvanced = false; + + osg::Vec3 v; + + if (fr[0].matchWord("vertex")) { + if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) { + myobj.addVertex(v); + fr += 4; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool MultiSegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::MultiSegmentPlacer &myobj = static_cast(obj); + + int n = myobj.numVertices(); + + for (int i=0; i +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +bool read_particle(osgDB::Input &fr, osgParticle::Particle &P) +{ + if (fr[0].matchString("{")) { + ++fr; + int entry = fr[0].getNoNestedBrackets(); + bool itAdvanced = true; + while (!fr.eof() && fr[0].getNoNestedBrackets() >= entry && itAdvanced) { + itAdvanced = false; + if (fr[0].matchWord("shape")) { + const char *ptstr = fr[1].getStr(); + if (ptstr) { + if (std::string(ptstr) == "QUAD") { + P.setShape(osgParticle::Particle::QUAD); + } else if (std::string(ptstr) == "HEXAGON") { + P.setShape(osgParticle::Particle::HEXAGON); + } else if (std::string(ptstr) == "POINT") { + P.setShape(osgParticle::Particle::POINT); + } else if (std::string(ptstr) == "QUAD_TRIANGLESTRIP") { + P.setShape(osgParticle::Particle::QUAD_TRIANGLESTRIP); + } else { + osg::notify(osg::WARN) << "Particle reader warning: invalid shape: " << ptstr << std::endl; + } + fr += 2; + itAdvanced = true; + } + } + if (fr[0].matchWord("lifeTime")) { + float lt; + if (fr[1].getFloat(lt)) { + P.setLifeTime(lt); + fr += 2; + itAdvanced = true; + } + } + if (fr[0].matchWord("sizeRange")) { + osgParticle::rangef r; + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + P.setSizeRange(r); + fr += 3; + itAdvanced = true; + } + } + if (fr[0].matchWord("alphaRange")) { + osgParticle::rangef r; + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + P.setAlphaRange(r); + fr += 3; + itAdvanced = true; + } + } + if (fr[0].matchWord("colorRange")) { + osgParticle::rangev4 r; + if (fr[1].getFloat(r.min.x()) && fr[2].getFloat(r.min.y()) && fr[3].getFloat(r.min.z()) && fr[4].getFloat(r.min.w()) && + fr[5].getFloat(r.max.x()) && fr[6].getFloat(r.max.y()) && fr[7].getFloat(r.max.z()) && fr[8].getFloat(r.max.w())) { + P.setColorRange(r); + fr += 9; + itAdvanced = true; + } + } + if (fr[0].matchWord("position")) { + osg::Vec3 v; + if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) { + P.setPosition(v); + fr += 4; + itAdvanced = true; + } + } + if (fr[0].matchWord("velocity")) { + osg::Vec3 v; + if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) { + P.setVelocity(v); + fr += 4; + itAdvanced = true; + } + } + if (fr[0].matchWord("radius")) { + float f; + if (fr[1].getFloat(f)) { + P.setRadius(f); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("mass")) { + float f; + if (fr[1].getFloat(f)) { + P.setMass(f); + fr += 2; + itAdvanced = true; + } + } + + // interpolators + + if (fr[0].matchWord("sizeInterpolator") && fr[1].matchString("{")) { + fr += 2; + itAdvanced = true; + osgParticle::Interpolator *ip = dynamic_cast(fr.readObject()); + if (ip) { + P.setSizeInterpolator(ip); + } + ++fr; + } + if (fr[0].matchWord("alphaInterpolator") && fr[1].matchString("{")) { + fr += 2; + itAdvanced = true; + osgParticle::Interpolator *ip = dynamic_cast(fr.readObject()); + if (ip) { + P.setAlphaInterpolator(ip); + } + ++fr; + } + if (fr[0].matchWord("colorInterpolator") && fr[1].matchString("{")) { + fr += 2; + itAdvanced = true; + osgParticle::Interpolator *ip = dynamic_cast(fr.readObject()); + if (ip) { + P.setColorInterpolator(ip); + } + ++fr; + } + } + return true; + } + return false; +} + +void write_particle(const osgParticle::Particle &P, osgDB::Output &fw) +{ + fw << "{" << std::endl; + fw.moveIn(); + + fw.indent() << "shape "; + switch (P.getShape()) + { + case osgParticle::Particle::POINT: fw << "POINT" << std::endl; break; + case osgParticle::Particle::HEXAGON: fw << "HEXAGON" << std::endl; break; + case osgParticle::Particle::QUAD_TRIANGLESTRIP: fw << "QUAD_TRIANGLESTRIP" << std::endl; break; + case osgParticle::Particle::QUAD: + default: fw << "QUAD" << std::endl; break; + } + + fw.indent() << "lifeTime " << P.getLifeTime() << std::endl; + + osgParticle::rangef rf = P.getSizeRange(); + fw.indent() << "sizeRange " << rf.min << " " << rf.max << std::endl; + + rf = P.getAlphaRange(); + fw.indent() << "alphaRange " << rf.min << " " << rf.max << std::endl; + + osgParticle::rangev4 rv4 = P.getColorRange(); + fw.indent() << "colorRange "; + fw << rv4.min.x() << " " << rv4.min.y() << " " << rv4.min.z() << " " << rv4.min.w() << " "; + fw << rv4.max.x() << " " << rv4.max.y() << " " << rv4.max.z() << " " << rv4.max.w() << std::endl; + + osg::Vec3 v = P.getPosition(); + fw.indent() << "position "; + fw << v.x() << " " << v.y() << " " << v.z() << std::endl; + + v = P.getVelocity(); + fw.indent() << "velocity "; + fw << v.x() << " " << v.y() << " " << v.z() << std::endl; + + fw.indent() << "mass " << P.getMass() << std::endl; + fw.indent() << "radius " << P.getRadius() << std::endl; + + // interpolators + + fw.indent() << "sizeInterpolator {" << std::endl; + fw.moveIn(); + fw.writeObject(*P.getSizeInterpolator()); + fw.moveOut(); + fw.indent() << "}" << std::endl; + + fw.indent() << "alphaInterpolator {" << std::endl; + fw.moveIn(); + fw.writeObject(*P.getAlphaInterpolator()); + fw.moveOut(); + fw.indent() << "}" << std::endl; + + fw.indent() << "colorInterpolator {" << std::endl; + fw.moveIn(); + fw.writeObject(*P.getColorInterpolator()); + fw.moveOut(); + fw.indent() << "}" << std::endl; + + fw.moveOut(); + fw.indent() << "}" << std::endl; +} diff --git a/src/osgParticle/IO_ParticleProcessor.cpp b/src/osgParticle/IO_ParticleProcessor.cpp new file mode 100644 index 000000000..f349e66f7 --- /dev/null +++ b/src/osgParticle/IO_ParticleProcessor.cpp @@ -0,0 +1,93 @@ + +#include +#include + +#include + +#include + +#include +#include +#include + +extern bool read_particle(osgDB::Input &fr, osgParticle::Particle &P); +extern void write_particle(const osgParticle::Particle &P, osgDB::Output &fw); + +bool ParticleProcessor_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool ParticleProcessor_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy ParticleProcessor_Proxy +( + 0, + "ParticleProcessor", + "Object Node ParticleProcessor", + ParticleProcessor_readLocalData, + ParticleProcessor_writeLocalData +); + +bool ParticleProcessor_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::ParticleProcessor &myobj = static_cast(obj); + bool itAdvanced = false; + + osg::ref_ptr ps_proto = osgNew osgParticle::ParticleSystem; + + osgParticle::ParticleSystem *ps = static_cast(fr.readObjectOfType(*ps_proto)); + if (ps) { + myobj.setParticleSystem(ps); + itAdvanced = true; + } + + if (fr[0].matchWord("enabled")) { + if (fr[1].matchWord("TRUE")) { + myobj.setEnabled(true); + fr += 2; + itAdvanced = true; + } else if (fr[1].matchWord("FALSE")) { + myobj.setEnabled(false); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("referenceFrame")) { + if (fr[1].matchWord("RELATIVE_TO_ABSOLUTE")) { + myobj.setReferenceFrame(osgParticle::ParticleProcessor::RELATIVE_TO_ABSOLUTE); + fr += 2; + itAdvanced = true; + } + if (fr[1].matchWord("RELATIVE_TO_PARENTS")) { + myobj.setReferenceFrame(osgParticle::ParticleProcessor::RELATIVE_TO_PARENTS); + fr += 2; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool ParticleProcessor_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::ParticleProcessor &myobj = static_cast(obj); + + fw.writeObject(*myobj.getParticleSystem()); + + fw.indent() << "enabled "; + if (myobj.isEnabled()) + fw << "TRUE" << std::endl; + else + fw << "FALSE" << std::endl; + + fw.indent() << "referenceFrame "; + switch (myobj.getReferenceFrame()) + { + case osgParticle::ParticleProcessor::RELATIVE_TO_ABSOLUTE: + fw << "RELATIVE_TO_ABSOLUTE" << std::endl; + break; + case osgParticle::ParticleProcessor::RELATIVE_TO_PARENTS: + default: + fw << "RELATIVE_TO_PARENTS" << std::endl; + } + + return true; +} diff --git a/src/osgParticle/IO_ParticleSystem.cpp b/src/osgParticle/IO_ParticleSystem.cpp new file mode 100644 index 000000000..371399987 --- /dev/null +++ b/src/osgParticle/IO_ParticleSystem.cpp @@ -0,0 +1,126 @@ + +#include + +#include + +#include +#include +#include + +#include +#include + +extern bool read_particle(osgDB::Input &fr, osgParticle::Particle &P); +extern void write_particle(const osgParticle::Particle &P, osgDB::Output &fw); + +bool ParticleSystem_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool ParticleSystem_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy ParticleSystem_Proxy +( + osgNew osgParticle::ParticleSystem, + "ParticleSystem", + "Object Drawable ParticleSystem", + ParticleSystem_readLocalData, + ParticleSystem_writeLocalData +); + +bool ParticleSystem_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::ParticleSystem &myobj = static_cast(obj); + bool itAdvanced = false; + + if (fr[0].matchWord("DoublePassRendering")) { + if (fr[1].matchWord("TRUE")) { + myobj.setDoublePassRendering(true); + fr += 2; + itAdvanced = true; + } else if (fr[1].matchWord("FALSE")) { + myobj.setDoublePassRendering(false); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("frozen")) { + if (fr[1].matchWord("TRUE")) { + myobj.setFrozen(true); + fr += 2; + itAdvanced = true; + } else if (fr[1].matchWord("FALSE")) { + myobj.setFrozen(false); // this might not be necessary + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("freezeOnCull")) { + if (fr[1].matchWord("TRUE")) { + myobj.setFreezeOnCull(true); + fr += 2; + itAdvanced = true; + } else if (fr[1].matchWord("FALSE")) { + myobj.setFreezeOnCull(false); + fr += 2; + itAdvanced = true; + } + } + + if (fr[0].matchWord("defaultBoundingBox")) { + osg::BoundingBox bbox; + if ( fr[1].getFloat(bbox.xMin()) && + fr[2].getFloat(bbox.yMin()) && + fr[3].getFloat(bbox.zMin()) && + fr[4].getFloat(bbox.xMax()) && + fr[5].getFloat(bbox.yMax()) && + fr[6].getFloat(bbox.zMax()) ) { + myobj.setDefaultBoundingBox(bbox); + fr += 7; + itAdvanced = true; + } + } + + if (fr[0].matchWord("particleTemplate")) { + ++fr; + itAdvanced = true; + osgParticle::Particle P; + if (read_particle(fr, P)) { + myobj.setDefaultParticleTemplate(P); + } + } + + return itAdvanced; +} + +bool ParticleSystem_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::ParticleSystem &myobj = static_cast(obj); + + fw.indent() << "DoublePassRendering "; + if (myobj.getDoublePassRendering()) + fw << "TRUE" << std::endl; + else + fw << "FALSE" << std::endl; + + fw.indent() << "frozen "; + if (myobj.isFrozen()) + fw << "TRUE" << std::endl; + else + fw << "FALSE" << std::endl; + + fw.indent() << "freezeOnCull "; + if (myobj.getFreezeOnCull()) + fw << "TRUE" << std::endl; + else + fw << "FALSE" << std::endl; + + osg::BoundingBox bbox = myobj.getDefaultBoundingBox(); + fw.indent() << "defaultBoundingBox "; + fw << bbox.xMin() << " " << bbox.yMin() << " " << bbox.zMin() << " "; + fw << bbox.xMax() << " " << bbox.yMax() << " " << bbox.zMax() << std::endl; + + fw.indent() << "particleTemplate "; + write_particle(myobj.getDefaultParticleTemplate(), fw); + + return true; +} diff --git a/src/osgParticle/IO_ParticleSystemUpdater.cpp b/src/osgParticle/IO_ParticleSystemUpdater.cpp new file mode 100644 index 000000000..084d11234 --- /dev/null +++ b/src/osgParticle/IO_ParticleSystemUpdater.cpp @@ -0,0 +1,45 @@ + +#include + +#include +#include +#include +#include + +bool PSU_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool PSU_writeLocalData(const osg::Object &obj, osgDB::Output &fr); + +osgDB::RegisterDotOsgWrapperProxy PSU_Proxy +( + osgNew osgParticle::ParticleSystemUpdater, + "ParticleSystemUpdater", + "Object Node ParticleSystemUpdater", + PSU_readLocalData, + PSU_writeLocalData +); + +bool PSU_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::ParticleSystemUpdater &myobj = static_cast(obj); + bool itAdvanced = false; + + osg::ref_ptr proto = osgNew osgParticle::ParticleSystem; + osgParticle::ParticleSystem *ps = static_cast(fr.readObjectOfType(*proto)); + if (ps) { + myobj.addParticleSystem(ps); + itAdvanced = true; + } + + return itAdvanced; +} + +bool PSU_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::ParticleSystemUpdater &myobj = static_cast(obj); + + for (int i=0; i + +#include +#include +#include + +bool PointPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool PointPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy PointPlacer_Proxy +( + osgNew osgParticle::PointPlacer, + "PointPlacer", + "Object Placer CenteredPlacer PointPlacer", + PointPlacer_readLocalData, + PointPlacer_writeLocalData +); + +bool PointPlacer_readLocalData(osg::Object &, osgDB::Input &) +{ + return false; +} + +bool PointPlacer_writeLocalData(const osg::Object &, osgDB::Output &) +{ + return false; +} diff --git a/src/osgParticle/IO_Program.cpp b/src/osgParticle/IO_Program.cpp new file mode 100644 index 000000000..d4450177a --- /dev/null +++ b/src/osgParticle/IO_Program.cpp @@ -0,0 +1,28 @@ + +#include + +#include +#include +#include + +bool Program_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool Program_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy Program_Proxy +( + 0, + "Program", + "Object Node ParticleProcessor Program", + Program_readLocalData, + Program_writeLocalData +); + +bool Program_readLocalData(osg::Object &, osgDB::Input &) +{ + return false; +} + +bool Program_writeLocalData(const osg::Object &, osgDB::Output &) +{ + return false; +} diff --git a/src/osgParticle/IO_RadialShooter.cpp b/src/osgParticle/IO_RadialShooter.cpp new file mode 100644 index 000000000..48d35d268 --- /dev/null +++ b/src/osgParticle/IO_RadialShooter.cpp @@ -0,0 +1,68 @@ + +#include +#include + +#include +#include +#include + +bool RadialShooter_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool RadialShooter_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy RadialShooter_Proxy +( + osgNew osgParticle::RadialShooter, + "RadialShooter", + "Object Shooter RadialShooter", + RadialShooter_readLocalData, + RadialShooter_writeLocalData +); + +bool RadialShooter_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::RadialShooter &myobj = static_cast(obj); + bool itAdvanced = false; + + osgParticle::rangef r; + + if (fr[0].matchWord("thetaRange")) { + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + myobj.setThetaRange(r); + fr += 3; + itAdvanced = true; + } + } + + if (fr[0].matchWord("phiRange")) { + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + myobj.setPhiRange(r); + fr += 3; + itAdvanced = true; + } + } + + if (fr[0].matchWord("initialSpeedRange")) { + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + myobj.setInitialSpeedRange(r); + fr += 3; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool RadialShooter_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::RadialShooter &myobj = static_cast(obj); + osgParticle::rangef r; + + r = myobj.getThetaRange(); + fw.indent() << "thetaRange " << r.min << " " << r.max << std::endl; + r = myobj.getPhiRange(); + fw.indent() << "phiRange " << r.min << " " << r.max << std::endl; + r = myobj.getInitialSpeedRange(); + fw.indent() << "initialSpeedRange " << r.min << " " << r.max << std::endl; + + return true; +} diff --git a/src/osgParticle/IO_RandomRateCounter.cpp b/src/osgParticle/IO_RandomRateCounter.cpp new file mode 100644 index 000000000..98244aee4 --- /dev/null +++ b/src/osgParticle/IO_RandomRateCounter.cpp @@ -0,0 +1,30 @@ + +#include + +#include + +#include +#include +#include + +bool RandomRateCounter_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool RandomRateCounter_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy RandomRateCounter_Proxy +( + osgNew osgParticle::RandomRateCounter, + "RandomRateCounter", + "Object Counter VariableRateCounter RandomRateCounter", + RandomRateCounter_readLocalData, + RandomRateCounter_writeLocalData +); + +bool RandomRateCounter_readLocalData(osg::Object &, osgDB::Input &) +{ + return false; +} + +bool RandomRateCounter_writeLocalData(const osg::Object &, osgDB::Output &) +{ + return false; +} diff --git a/src/osgParticle/IO_SectorPlacer.cpp b/src/osgParticle/IO_SectorPlacer.cpp new file mode 100644 index 000000000..522229ffe --- /dev/null +++ b/src/osgParticle/IO_SectorPlacer.cpp @@ -0,0 +1,59 @@ + +#include + +#include + +#include +#include +#include + +bool SectorPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool SectorPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy SectorPlacer_Proxy +( + osgNew osgParticle::SectorPlacer, + "SectorPlacer", + "Object Placer CenteredPlacer SectorPlacer", + SectorPlacer_readLocalData, + SectorPlacer_writeLocalData +); + +bool SectorPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::SectorPlacer &myobj = static_cast(obj); + bool itAdvanced = false; + + osgParticle::rangef r; + if (fr[0].matchWord("radiusRange")) { + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + myobj.setRadiusRange(r); + fr += 3; + itAdvanced = true; + } + } + + if (fr[0].matchWord("phiRange")) { + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + myobj.setPhiRange(r); + fr += 3; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool SectorPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::SectorPlacer &myobj = static_cast(obj); + + osgParticle::rangef r; + + r = myobj.getRadiusRange(); + fw.indent() << "radiusRange " << r.min << " " << r.max << std::endl; + r = myobj.getPhiRange(); + fw.indent() << "phiRange " << r.min << " " << r.max << std::endl; + + return true; +} diff --git a/src/osgParticle/IO_SegmentPlacer.cpp b/src/osgParticle/IO_SegmentPlacer.cpp new file mode 100644 index 000000000..5104936e6 --- /dev/null +++ b/src/osgParticle/IO_SegmentPlacer.cpp @@ -0,0 +1,60 @@ + +#include + +#include +#include +#include + +#include + +#include + +bool SegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool SegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy SegmentPlacer_Proxy +( + osgNew osgParticle::SegmentPlacer, + "SegmentPlacer", + "Object Placer SegmentPlacer", + SegmentPlacer_readLocalData, + SegmentPlacer_writeLocalData +); + +bool SegmentPlacer_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::SegmentPlacer &myobj = static_cast(obj); + bool itAdvanced = false; + + osg::Vec3 v; + + if (fr[0].matchWord("vertex_A")) { + if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) { + myobj.setVertexA(v); + fr += 4; + itAdvanced = true; + } + } + + if (fr[0].matchWord("vertex_B")) { + if (fr[1].getFloat(v.x()) && fr[2].getFloat(v.y()) && fr[3].getFloat(v.z())) { + myobj.setVertexB(v); + fr += 4; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool SegmentPlacer_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::SegmentPlacer &myobj = static_cast(obj); + + osg::Vec3 v = myobj.getVertexA(); + fw.indent() << "vertex_A " << v.x() << " " << v.y() << " " << v.z() << std::endl; + v = myobj.getVertexB(); + fw.indent() << "vertex_B " << v.x() << " " << v.y() << " " << v.z() << std::endl; + + return true; +} diff --git a/src/osgParticle/IO_VariableRateCounter.cpp b/src/osgParticle/IO_VariableRateCounter.cpp new file mode 100644 index 000000000..eedeac02f --- /dev/null +++ b/src/osgParticle/IO_VariableRateCounter.cpp @@ -0,0 +1,47 @@ + +#include + +#include + +#include +#include +#include + +bool VariableRateCounter_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool VariableRateCounter_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy VariableRateCounter_Proxy +( + 0, + "VariableRateCounter", + "Object Counter VariableRateCounter", + VariableRateCounter_readLocalData, + VariableRateCounter_writeLocalData +); + +bool VariableRateCounter_readLocalData(osg::Object &obj, osgDB::Input &fr) +{ + osgParticle::VariableRateCounter &myobj = static_cast(obj); + bool itAdvanced = false; + + osgParticle::rangef r; + if (fr[0].matchWord("rateRange")) { + if (fr[1].getFloat(r.min) && fr[2].getFloat(r.max)) { + myobj.setRateRange(r); + fr += 3; + itAdvanced = true; + } + } + + return itAdvanced; +} + +bool VariableRateCounter_writeLocalData(const osg::Object &obj, osgDB::Output &fw) +{ + const osgParticle::VariableRateCounter &myobj = static_cast(obj); + + osgParticle::rangef r = myobj.getRateRange(); + fw.indent() << "rateRange " << r.min << " " << r.max << std::endl; + + return true; +} diff --git a/src/osgParticle/Makefile b/src/osgParticle/Makefile new file mode 100644 index 000000000..b96fe9c1d --- /dev/null +++ b/src/osgParticle/Makefile @@ -0,0 +1,45 @@ +TOPDIR = ../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + Emitter.cpp\ + FluidFrictionOperator.cpp\ + IO_AccelOperator.cpp\ + IO_CenteredPlacer.cpp\ + IO_Emitter.cpp\ + IO_FluidFrictionOperator.cpp\ + IO_ForceOperator.cpp\ + IO_LinearInterpolator.cpp\ + IO_ModularEmitter.cpp\ + IO_ModularProgram.cpp\ + IO_MultiSegmentPlacer.cpp\ + IO_Particle.cpp\ + IO_ParticleProcessor.cpp\ + IO_ParticleSystem.cpp\ + IO_ParticleSystemUpdater.cpp\ + IO_PointPlacer.cpp\ + IO_Program.cpp\ + IO_RadialShooter.cpp\ + IO_RandomRateCounter.cpp\ + IO_SectorPlacer.cpp\ + IO_SegmentPlacer.cpp\ + IO_VariableRateCounter.cpp\ + ModularEmitter.cpp\ + ModularProgram.cpp\ + MultiSegmentPlacer.cpp\ + Particle.cpp\ + ParticleProcessor.cpp\ + ParticleSystem.cpp\ + ParticleSystemUpdater.cpp\ + Program.cpp\ + Version.cpp\ + + + +LIBS += -losg $(OTHER_LIBS) $(DYNAMICLIBRARYLIB) +DEF += -DOSGPARTICLE_LIBRARY + +TARGET_BASENAME = osgParticle +LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT) + +include $(TOPDIR)/Make/makerules diff --git a/src/osgParticle/ModularEmitter.cpp b/src/osgParticle/ModularEmitter.cpp new file mode 100644 index 000000000..31c21a059 --- /dev/null +++ b/src/osgParticle/ModularEmitter.cpp @@ -0,0 +1,33 @@ +#include +#include + +osgParticle::ModularEmitter::ModularEmitter() +: Emitter(), + counter_(osgNew RandomRateCounter), + placer_(osgNew PointPlacer), + shooter_(osgNew RadialShooter) +{ +} + +osgParticle::ModularEmitter::ModularEmitter(const ModularEmitter ©, const osg::CopyOp ©op) +: Emitter(copy, copyop), + counter_(static_cast(copyop(copy.counter_.get()))), + placer_(static_cast(copyop(copy.placer_.get()))), + shooter_(static_cast(copyop(copy.shooter_.get()))) +{ +} + +void osgParticle::ModularEmitter::emit(double dt) +{ + int n = counter_->numParticlesToCreate(dt); + for (int i=0; icreateParticle(getUseDefaultTemplate()? 0: &getParticleTemplate()); + if (P) { + placer_->place(P); + shooter_->shoot(P); + if (getReferenceFrame() == RELATIVE_TO_PARENTS) { + P->transformPositionVelocity(getLocalToWorldMatrix()); + } + } + } +} diff --git a/src/osgParticle/ModularProgram.cpp b/src/osgParticle/ModularProgram.cpp new file mode 100644 index 000000000..6001c707c --- /dev/null +++ b/src/osgParticle/ModularProgram.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +osgParticle::ModularProgram::ModularProgram() +: Program() +{ +} + +osgParticle::ModularProgram::ModularProgram(const ModularProgram ©, const osg::CopyOp ©op) +: Program(copy, copyop) +{ + Operator_vector::const_iterator ci; + for (ci=copy.operators_.begin(); ci!=copy.operators_.end(); ++ci) { + operators_.push_back(static_cast(copyop(ci->get()))); + } +} + +void osgParticle::ModularProgram::execute(double dt) +{ + Operator_vector::iterator ci; + Operator_vector::iterator ci_end = operators_.end(); + + ParticleSystem *ps = getParticleSystem(); + for (ci=operators_.begin(); ci!=ci_end; ++ci) { + (*ci)->beginOperate(this); + int n = ps->numParticles(); + for (int i=0; igetParticle(i); + if (P->isAlive() && (*ci)->isEnabled()) { + (*ci)->operate(P, dt); + } + } + (*ci)->endOperate(); + } +} diff --git a/src/osgParticle/MultiSegmentPlacer.cpp b/src/osgParticle/MultiSegmentPlacer.cpp new file mode 100644 index 000000000..cff971d19 --- /dev/null +++ b/src/osgParticle/MultiSegmentPlacer.cpp @@ -0,0 +1,51 @@ +#include +#include + +#include +#include + +osgParticle::MultiSegmentPlacer::MultiSegmentPlacer() +: Placer(), total_length_(0) +{ +} + +osgParticle::MultiSegmentPlacer::MultiSegmentPlacer(const MultiSegmentPlacer ©, const osg::CopyOp ©op) +: Placer(copy, copyop), vx_(copy.vx_), total_length_(copy.total_length_) +{ +} + +void osgParticle::MultiSegmentPlacer::recompute_length() +{ + Vertex_vector::iterator i; + Vertex_vector::iterator i0 = vx_.begin(); + + total_length_ = 0; + for (i=vx_.begin(); i!=vx_.end(); ++i) { + total_length_ += (i->first - i0->first).length(); + i->second = total_length_; + i0 = i; + } +} + +void osgParticle::MultiSegmentPlacer::place(Particle *P) const +{ + if (vx_.size() >= 2) { + float x = rangef(0, total_length_).get_random(); + + Vertex_vector::const_iterator i; + Vertex_vector::const_iterator i0 = vx_.begin(); + const Vertex_vector::const_iterator vend = vx_.end(); + + for (i=vx_.begin(); i!=vend; ++i) { + if (x <= i->second) { + float t = (x - i0->second) / (i->second - i0->second); + P->setPosition(i0->first + (i->first - i0->first) * t); + return; + } + i0 = i; + } + } else { + osg::notify(osg::WARN) << "this MultiSegmentPlacer has less than 2 vertices\n"; + } +} + diff --git a/src/osgParticle/Particle.cpp b/src/osgParticle/Particle.cpp new file mode 100644 index 000000000..8162e8126 --- /dev/null +++ b/src/osgParticle/Particle.cpp @@ -0,0 +1,146 @@ +#include +#include + +#include +#include +#include +#include +#include + +namespace +{ + + const float cosPI3 = cosf(osg::PI / 3.0f); + const float sinPI3 = sinf(osg::PI / 3.0f); + const float hex_texcoord_x1 = 0.5f + 0.5f * cosPI3; + const float hex_texcoord_x2 = 0.5f - 0.5f * cosPI3; + const float hex_texcoord_y1 = 0.5f + 0.5f * sinPI3; + const float hex_texcoord_y2 = 0.5f - 0.5f * sinPI3; + +} + +osgParticle::Particle::Particle() +: shape_(QUAD), + sr_(0.2f, 0.2f), + ar_(1, 0), + cr_(osg::Vec4(1, 1, 1, 1), osg::Vec4(1, 1, 1, 1)), + si_(osgNew LinearInterpolator), + ai_(osgNew LinearInterpolator), + ci_(osgNew LinearInterpolator), + alive_(true), + mustdie_(false), + lifetime_(2), + radius_(0.2f), + mass_(0.1f), + massinv_(10.0f), + prev_pos_(0, 0, 0), + position_(0, 0, 0), + velocity_(0, 0, 0), + t0_(0) +{ +} + +bool osgParticle::Particle::update(double dt) +{ + // this method should return false when the particle dies; + // so, if we were instructed to die, do it now and return. + if (mustdie_) { + alive_ = false; + return false; + } + + double x = 0; + + // if we don't live forever, compute our normalized age. + if (lifetime_ > 0) { + x = t0_ / lifetime_; + } + + t0_ += dt; + + // if our age is over the lifetime limit, then die and return. + if (x > 1) { + alive_ = false; + return false; + } + + // compute the current values for size, alpha and color. + current_size_ = si_.get()->interpolate(x, sr_); + current_alpha_ = ai_.get()->interpolate(x, ar_); + current_color_ = ci_.get()->interpolate(x, cr_); + + // update position + prev_pos_ = position_; + position_ += velocity_ * dt; + + return true; +} + +void osgParticle::Particle::render(const osg::Matrix &modelview, float scale) const +{ + osg::Vec3 xpos = modelview.preMult(position_); + + glColor4f( current_color_.x(), + current_color_.y(), + current_color_.z(), + current_color_.w() * current_alpha_); + + float cs = current_size_ * scale; + + switch (shape_) + { + case POINT: + glVertex3f(xpos.x(), xpos.y(), xpos.z()); + break; + + case QUAD: + glTexCoord2f(0, 0); + glVertex3f(xpos.x() - cs, xpos.y() - cs, xpos.z()); + glTexCoord2f(1, 0); + glVertex3f(xpos.x() + cs, xpos.y() - cs, xpos.z()); + glTexCoord2f(1, 1); + glVertex3f(xpos.x() + cs, xpos.y() + cs, xpos.z()); + glTexCoord2f(0, 1); + glVertex3f(xpos.x() - cs, xpos.y() + cs, xpos.z()); + break; + + case QUAD_TRIANGLESTRIP: + // we must glBegin() and glEnd() here, because each particle is a single strip + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(1, 1); + glVertex3f(xpos.x() + cs, xpos.y() + cs, xpos.z()); + glTexCoord2f(0, 1); + glVertex3f(xpos.x() - cs, xpos.y() + cs, xpos.z()); + glTexCoord2f(1, 0); + glVertex3f(xpos.x() + cs, xpos.y() - cs, xpos.z()); + glTexCoord2f(0, 0); + glVertex3f(xpos.x() - cs, xpos.y() - cs, xpos.z()); + glEnd(); + break; + + case HEXAGON: + // we must glBegin() and glEnd() here, because each particle is a single fan + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(0.5f, 0.5f); + glVertex3f(xpos.x(), xpos.y(), xpos.z()); + glTexCoord2f(hex_texcoord_x1, hex_texcoord_y1); + glVertex3f(xpos.x() + cs * cosPI3, xpos.y() + cs * sinPI3, xpos.z()); + glTexCoord2f(hex_texcoord_x2, hex_texcoord_y1); + glVertex3f(xpos.x() - cs * cosPI3, xpos.y() + cs * sinPI3, xpos.z()); + glTexCoord2f(0, 0.5f); + glVertex3f(xpos.x() - cs, xpos.y(), xpos.z()); + glTexCoord2f(hex_texcoord_x2, hex_texcoord_y2); + glVertex3f(xpos.x() - cs * cosPI3, xpos.y() - cs * sinPI3, xpos.z()); + glTexCoord2f(hex_texcoord_x1, hex_texcoord_y2); + glVertex3f(xpos.x() + cs * cosPI3, xpos.y() - cs * sinPI3, xpos.z()); + glTexCoord2f(1, 0.5f); + glVertex3f(xpos.x() + cs, xpos.y(), xpos.z()); + glTexCoord2f(hex_texcoord_x1, hex_texcoord_y1); + glVertex3f(xpos.x() + cs * cosPI3, xpos.y() + cs * sinPI3, xpos.z()); + glEnd(); + break; + + default: + osg::notify(osg::WARN) << "Invalid shape for particles\n"; + } +} diff --git a/src/osgParticle/ParticleProcessor.cpp b/src/osgParticle/ParticleProcessor.cpp new file mode 100644 index 000000000..bed8184d5 --- /dev/null +++ b/src/osgParticle/ParticleProcessor.cpp @@ -0,0 +1,75 @@ +#include + +#include +#include +#include +#include +#include + +#include + +osgParticle::ParticleProcessor::ParticleProcessor() +: osg::Node(), + rf_(RELATIVE_TO_PARENTS), + enabled_(true), + t0_(-1), + ps_(0) +{ + setCullingActive(false); +} + +osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor ©, const osg::CopyOp ©op) +: osg::Node(copy, copyop), + rf_(copy.rf_), + enabled_(copy.enabled_), + t0_(copy.t0_), + ps_(static_cast(copyop(copy.ps_.get()))) +{ +} + +void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv) +{ + // continue only if enabled + if (enabled_) { + + // typecast the NodeVisitor to CullVisitor + osgUtil::CullVisitor *cv = dynamic_cast(&nv); + + // continue only if the visitor actually is a cull visitor + if (cv) { + + // continue only if the particle system is valid + if (ps_.valid()) { + + // retrieve the current time + double t = nv.getFrameStamp()->getReferenceTime(); + + // skip if we haven't initialized t0_ yet + if (t0_ != -1) { + + // check whether the particle system is frozen/culled + if (!ps_->isFrozen() && (ps_->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps_->getFreezeOnCull())) { + + // initialize matrix flags + need_ltw_matrix_ = true; + need_wtl_matrix_ = true; + current_nodevisitor_ = &nv; + + // do some process (unimplemented in this base class) + process(t - t0_); + } + } + + // update t0_ + t0_ = t; + + } else { + osg::notify(osg::WARN) << "ParticleProcessor \"" << getName() << "\": invalid particle system\n"; + } + } + + } + + // call the inherited method + osg::Node::traverse(nv); +} diff --git a/src/osgParticle/ParticleSystem.cpp b/src/osgParticle/ParticleSystem.cpp new file mode 100644 index 000000000..dd3e50e2c --- /dev/null +++ b/src/osgParticle/ParticleSystem.cpp @@ -0,0 +1,201 @@ +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +osgParticle::ParticleSystem::ParticleSystem() +: osg::Drawable(), + def_bbox_(osg::Vec3(-10, -10, -10), osg::Vec3(10, 10, 10)), + doublepass_(false), + frozen_(false), + display_list_id_(-1), + bmin_(0, 0, 0), + bmax_(0, 0, 0), + bounds_computed_(false), + def_ptemp_(Particle()), + last_frame_(0), + freeze_on_cull_(true), + detail_(1), + draw_count_(0) +{ + // we don't support display lists because particle systems + // are dynamic, and they always changes between frames + setSupportsDisplayList(false); +} + +osgParticle::ParticleSystem::ParticleSystem(const ParticleSystem ©, const osg::CopyOp ©op) +: osg::Drawable(copy, copyop), + def_bbox_(copy.def_bbox_), + doublepass_(copy.doublepass_), + frozen_(copy.frozen_), + display_list_id_(-1), + bmin_(copy.bmin_), + bmax_(copy.bmax_), + bounds_computed_(copy.bounds_computed_), + def_ptemp_(copy.def_ptemp_), + last_frame_(copy.last_frame_), + freeze_on_cull_(copy.freeze_on_cull_), + detail_(copy.detail_), + draw_count_(0) +{ +} + +osgParticle::ParticleSystem::~ParticleSystem() +{ +} + +void osgParticle::ParticleSystem::update(double dt) +{ + // reset bounds + reset_bounds_flag_ = true; + + // set up iterators for particles + Particle_vector::iterator i; + Particle_vector::iterator end = particles_.end(); + + // update particles + for (i=particles_.begin(); i!=end; ++i) { + if (i->isAlive()) { + if (i->update(dt)) { + update_bounds(i->getPosition()); + } else { + deadparts_.push(&(*i)); + } + } + } + + // force recomputing of bounding box on next frame + dirtyBound(); +} + +void osgParticle::ParticleSystem::drawImmediateMode(osg::State &state) +{ + // update the frame count, so other objects can detect when + // this particle system is culled + last_frame_ = state.getFrameStamp()->getFrameNumber(); + + // get the current modelview matrix + const osg::Matrix &modelview = state.getModelViewMatrix(); + + // set modelview = identity + state.applyModelViewMatrix(0); + + // set up depth mask for first rendering pass + glPushAttrib(GL_DEPTH_BUFFER_BIT); + glDepthMask(GL_FALSE); + + // render, first pass + if (doublepass_) { + + // generate a display list ID if necessary + if (display_list_id_ == -1) { + display_list_id_ = glGenLists(1); + } + + #ifdef USE_SEPERATE_COMPILE_AND_EXECUTE + glNewList(display_list_id_, GL_COMPILE); + single_pass_render(modelview); + glEndList(); + glCallList(display_list_id_); + #else + glNewList(display_list_id_, GL_COMPILE_AND_EXECUTE); + single_pass_render(modelview); + glEndList(); + #endif + + } else { + single_pass_render(modelview); + } + + // restore depth mask settings + glPopAttrib(); + + // render, second pass + if (doublepass_) { + // set up color mask for second rendering pass + glPushAttrib(GL_COLOR_BUFFER_BIT); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + // call the display list to render the particles onto the depth buffer + glCallList(display_list_id_); + + // restore color mask settings + glPopAttrib(); + } +} + +void osgParticle::ParticleSystem::setDefaultAttributes(const std::string &texturefile, bool emissive_particles, bool lighting) +{ + osg::StateSet *stateset = osgNew osg::StateSet; + + stateset->setMode(GL_LIGHTING, lighting? osg::StateAttribute::ON: osg::StateAttribute::OFF); + stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); + + osg::Material *material = osgNew osg::Material; + material->setSpecular(osg::Material::FRONT, osg::Vec4(0, 0, 0, 1)); + material->setEmission(osg::Material::FRONT, osg::Vec4(0, 0, 0, 1)); + material->setColorMode(lighting? osg::Material::AMBIENT_AND_DIFFUSE : osg::Material::OFF); + stateset->setAttributeAndModes(material, osg::StateAttribute::ON); + + if (!texturefile.empty()) { + osg::Texture *texture = osgNew osg::Texture; + texture->setImage(osgDB::readImageFile(texturefile)); + texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); + texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); + stateset->setAttributeAndModes(texture, osg::StateAttribute::ON); + + osg::TexEnv *texenv = osgNew osg::TexEnv; + texenv->setMode(osg::TexEnv::MODULATE); + stateset->setAttribute(texenv); + } + + osg::Transparency *transparency = osgNew osg::Transparency; + if (emissive_particles) { + transparency->setFunction(osg::Transparency::SRC_ALPHA, osg::Transparency::ONE); + } else { + transparency->setFunction(osg::Transparency::SRC_ALPHA, osg::Transparency::ONE_MINUS_SRC_ALPHA); + } + stateset->setAttributeAndModes(transparency, osg::StateAttribute::ON); + + setStateSet(stateset); +} + + +void osgParticle::ParticleSystem::single_pass_render(const osg::Matrix &modelview) +{ + draw_count_ = 0; + if (particles_.size() <= 0) return; + + Particle_vector::iterator i; + Particle_vector::iterator i0 = particles_.begin(); + Particle_vector::iterator end = particles_.end(); + + i0->beginRender(); + + for (i=i0; iisAlive()) { + if (i->getShape() != i0->getShape()) { + i0->endRender(); + i->beginRender(); + i0 = i; + } + ++draw_count_; + i->render(modelview, sqrtf(static_cast(detail_))); + } + } + + i0->endRender(); + +} diff --git a/src/osgParticle/ParticleSystemUpdater.cpp b/src/osgParticle/ParticleSystemUpdater.cpp new file mode 100644 index 000000000..85cb96bff --- /dev/null +++ b/src/osgParticle/ParticleSystemUpdater.cpp @@ -0,0 +1,37 @@ +#include + +#include +#include + +osgParticle::ParticleSystemUpdater::ParticleSystemUpdater() +: osg::Node(), t0_(-1) +{ + setCullingActive(false); +} + +osgParticle::ParticleSystemUpdater::ParticleSystemUpdater(const ParticleSystemUpdater ©, const osg::CopyOp ©op) +: osg::Node(copy, copyop), t0_(copy.t0_) +{ + ParticleSystem_Vector::const_iterator i; + for (i=copy.psv_.begin(); i!=copy.psv_.end(); ++i) { + psv_.push_back(static_cast(copyop(i->get()))); + } +} + +void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor &nv) +{ + osgUtil::CullVisitor *cv = dynamic_cast(&nv); + if (cv) { + double t = nv.getFrameStamp()->getReferenceTime(); + if (t0_ != -1) { + ParticleSystem_Vector::iterator i; + for (i=psv_.begin(); i!=psv_.end(); ++i) { + if (!i->get()->isFrozen() && (i->get()->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !i->get()->getFreezeOnCull())) { + i->get()->update(t - t0_); + } + } + } + t0_ = t; + } + osg::Node::traverse(nv); +} diff --git a/src/osgParticle/Program.cpp b/src/osgParticle/Program.cpp new file mode 100644 index 000000000..b791735e2 --- /dev/null +++ b/src/osgParticle/Program.cpp @@ -0,0 +1,14 @@ +#include +#include + +#include + +osgParticle::Program::Program() +: ParticleProcessor() +{ +} + +osgParticle::Program::Program(const Program ©, const osg::CopyOp ©op) +: ParticleProcessor(copy, copyop) +{ +} diff --git a/src/osgParticle/Version.cpp b/src/osgParticle/Version.cpp new file mode 100644 index 000000000..f63ecd6a1 --- /dev/null +++ b/src/osgParticle/Version.cpp @@ -0,0 +1,12 @@ +#include + +const char* osgParticleGetVersion() +{ + return "0.8.45"; +} + + +const char* osgParticleGetLibraryName() +{ + return "Open Scene Graph Particle Library"; +}