From Gideon May, added support for osgSim into .osg file format.
This commit is contained in:
parent
0c662e596c
commit
e95768417c
@ -38,6 +38,7 @@ PLUGIN_DIRS = \
|
||||
obj\
|
||||
osgParticle\
|
||||
osgText\
|
||||
osgSim\
|
||||
osg\
|
||||
osgtgz\
|
||||
pic\
|
||||
|
@ -1711,6 +1711,28 @@ Package=<4>
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin osgSim"=.\osgPlugins\osgSim\dot_osgSim.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 osgSim
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin osgtgz"=.\osgPlugins\osgtgz\osgtgz.dsp - Package Owner=<4>
|
||||
|
242
VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp
Normal file
242
VisualStudio/osgPlugins/osgSim/dot_osgSim.dsp
Normal file
@ -0,0 +1,242 @@
|
||||
# Microsoft Developer Studio Project File - Name="osgPlugin osgSim" - Package Owner=<4>
|
||||
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
|
||||
|
||||
CFG=osgPlugin osgSim - 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 "dot_osgSim.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 "dot_osgSim.mak" CFG="osgPlugin osgSim - Win32 Release"
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
|
||||
!MESSAGE
|
||||
|
||||
!MESSAGE "osgPlugin osgSim - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
|
||||
!MESSAGE "osgPlugin osgSim - 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)" == "osgPlugin osgSim - 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 "../../../lib"
|
||||
|
||||
# PROP Intermediate_Dir "Release"
|
||||
|
||||
# PROP Ignore_Export_Lib 0
|
||||
|
||||
# PROP Target_Dir ""
|
||||
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /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 /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_osgSim.dll" /libpath:"../../../lib"
|
||||
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin osgSim - 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 "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 "_WINDOWS" /D "_MBCS" /D "_USRDLL" /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 /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_osgSim.dll" /pdbtype:sept /libpath:"../../../lib"
|
||||
|
||||
# SUBTRACT LINK32 /pdb:none /nodefaultlib
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
|
||||
# Begin Target
|
||||
|
||||
|
||||
|
||||
# Name "osgPlugin osgSim - Win32 Release"
|
||||
|
||||
# Name "osgPlugin osgSim - Win32 Debug"
|
||||
|
||||
# Begin Group "Source Files"
|
||||
|
||||
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osgSim\IO_LightPointNode.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osgSim\IO_LightPoint.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osgSim\IO_Sector.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\osgSim\IO_BlinkSequence.cpp
|
||||
|
||||
# End Source File
|
||||
|
||||
# End Group
|
||||
|
||||
# Begin Group "Header Files"
|
||||
|
||||
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
|
||||
# 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
|
||||
|
1
dist/RPM/OpenSceneGraph.spec
vendored
1
dist/RPM/OpenSceneGraph.spec
vendored
@ -57,6 +57,7 @@ tar cvf - . | tar xvfC - /
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_osgParticle.so
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_osg.so
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_osgText.so
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_osgSim.so
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_osgtgz.so
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_pfb.so
|
||||
%attr(755, root, root) /usr/local/lib/osgPlugins/osgdb_pic.so
|
||||
|
@ -30,13 +30,16 @@ class OSGSIM_EXPORT BlinkSequence : public osg::Object
|
||||
public:
|
||||
|
||||
/** sequence group which can be used to synchronize related blink sequences.*/
|
||||
class OSGSIM_EXPORT SequenceGroup : public osg::Referenced
|
||||
class OSGSIM_EXPORT SequenceGroup : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
SequenceGroup();
|
||||
SequenceGroup(const SequenceGroup& bs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
SequenceGroup(double baseTime);
|
||||
|
||||
META_Object(osgSim,SequenceGroup);
|
||||
|
||||
double _baseTime;
|
||||
};
|
||||
|
||||
@ -44,22 +47,27 @@ class OSGSIM_EXPORT BlinkSequence : public osg::Object
|
||||
BlinkSequence();
|
||||
|
||||
BlinkSequence(const BlinkSequence& bs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
|
||||
META_Object(osgSim,BlinkSequence);
|
||||
|
||||
|
||||
/** add a pulse of specified color and duration to the BlinkSequence.*/
|
||||
inline void addPulse(double length,const osg::Vec4& color);
|
||||
|
||||
/** return the number of pulses. */
|
||||
inline int getNumPulses() const { return _pulseData.size(); }
|
||||
|
||||
/** return the pulse data at position i. */
|
||||
inline void getPulse(unsigned int i, double& length,osg::Vec4& color) const;
|
||||
|
||||
/** get the total pulse period of the blink sequence, which is equal to the sum of all the pulse periods.*/
|
||||
inline double getPulsePeriod() const { return _pulsePeriod; }
|
||||
|
||||
/** set the sequence group which can be used to synchronize related blink sequences.*/
|
||||
inline void setSequenceGroup(SequenceGroup* sg) { _sequenceGroup = sg; }
|
||||
|
||||
|
||||
/** get the non const sequence group.*/
|
||||
inline SequenceGroup* getSequenceGroup() { return _sequenceGroup.get(); }
|
||||
|
||||
|
||||
/** get the const sequence group.*/
|
||||
inline const SequenceGroup* getSequenceGroup() const { return _sequenceGroup.get(); }
|
||||
|
||||
@ -68,8 +76,6 @@ class OSGSIM_EXPORT BlinkSequence : public osg::Object
|
||||
|
||||
/** get the pahse shift.*/
|
||||
inline double getPhaseShift() const { return _phaseShift; }
|
||||
|
||||
|
||||
|
||||
/** compute the local time clamped to this BlinkSequences period, and accounting for the phase shift and sequence group.*/
|
||||
inline double localTime(double time) const;
|
||||
@ -104,6 +110,13 @@ inline void BlinkSequence::addPulse(double length,const osg::Vec4& color)
|
||||
_pulsePeriod += length;
|
||||
}
|
||||
|
||||
inline void BlinkSequence::getPulse(unsigned int i, double& length, osg::Vec4& color) const
|
||||
{
|
||||
const IntervalColor& ic = _pulseData[i];
|
||||
length = ic.first;
|
||||
color = ic.second;
|
||||
}
|
||||
|
||||
inline osg::Vec4 BlinkSequence::color(double time,double length) const
|
||||
{
|
||||
if (_pulseData.empty()) return osg::Vec4(1.0f,1.0f,1.0f,1.0f);
|
||||
|
@ -73,9 +73,9 @@ class OSGSIM_EXPORT LightPointNode : public osg::Node
|
||||
|
||||
float getMaxPixelSize() const { return _maxPixelSize; }
|
||||
|
||||
void setMaxVisableDistance2(float maxVisableDistance2) { _maxVisableDistance2 = maxVisableDistance2; }
|
||||
void setMaxVisibleDistance2(float maxVisibleDistance2) { _maxVisibleDistance2 = maxVisibleDistance2; }
|
||||
|
||||
float setMaxVisableDistance2() const { return _maxVisableDistance2; }
|
||||
float getMaxVisibleDistance2() const { return _maxVisibleDistance2; }
|
||||
|
||||
protected:
|
||||
|
||||
@ -91,7 +91,7 @@ class OSGSIM_EXPORT LightPointNode : public osg::Node
|
||||
|
||||
float _minPixelSize;
|
||||
float _maxPixelSize;
|
||||
float _maxVisableDistance2;
|
||||
float _maxVisibleDistance2;
|
||||
|
||||
|
||||
};
|
||||
|
@ -54,6 +54,7 @@ class OSGSIM_EXPORT AzimRange
|
||||
_cosFadeAngle(-1.0f) {}
|
||||
|
||||
void setAzimuthRange(float minAzimuth,float maxAzimuth,float fadeAngle=0.0f);
|
||||
void getAzimuthRange(float& minAzimuth, float& maxAzimuth, float& fadeAngle) const;
|
||||
|
||||
|
||||
inline float azimSector(const osg::Vec3& eyeLocal) const
|
||||
@ -91,6 +92,8 @@ class OSGSIM_EXPORT ElevationRange
|
||||
|
||||
float getMaxElevation() const;
|
||||
|
||||
float getFadeAngle() const;
|
||||
|
||||
inline float elevationSector(const osg::Vec3& eyeLocal) const
|
||||
{
|
||||
float dotproduct = eyeLocal.z(); // against z axis - eyeLocal*(0,0,1).
|
||||
|
120
src/osgPlugins/osgSim/IO_BlinkSequence.cpp
Normal file
120
src/osgPlugins/osgSim/IO_BlinkSequence.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
#include <osgSim/BlinkSequence>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
using namespace osgSim;
|
||||
|
||||
bool BlinkSequence_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool BlinkSequence_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy BlinkSequence_Proxy
|
||||
(
|
||||
new BlinkSequence,
|
||||
"BlinkSequence",
|
||||
"Object BlinkSequence",
|
||||
&BlinkSequence_readLocalData,
|
||||
&BlinkSequence_writeLocalData,
|
||||
osgDB::DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool BlinkSequence_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
BlinkSequence &seq = static_cast<BlinkSequence &>(obj);
|
||||
|
||||
if (fr.matchSequence("phaseShift %f"))
|
||||
{
|
||||
double ps;
|
||||
fr[1].getDouble(ps);
|
||||
fr += 2;
|
||||
seq.setPhaseShift(ps);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
if (fr.matchSequence("pulse %f %f %f %f %f"))
|
||||
{
|
||||
double length;
|
||||
float r, g, b, a;
|
||||
fr[1].getDouble(length);
|
||||
fr[2].getFloat(r);
|
||||
fr[3].getFloat(g);
|
||||
fr[4].getFloat(b);
|
||||
fr[5].getFloat(a);
|
||||
fr += 6;
|
||||
|
||||
seq.addPulse(length, osg::Vec4(r, g, b, a));
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
BlinkSequence::SequenceGroup * sg = static_cast<BlinkSequence::SequenceGroup *>
|
||||
(fr.readObjectOfType(osgDB::type_wrapper<BlinkSequence::SequenceGroup>()));
|
||||
|
||||
if (sg) {
|
||||
seq.setSequenceGroup(sg);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool BlinkSequence_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const BlinkSequence &seq = static_cast<const BlinkSequence &>(obj);
|
||||
|
||||
fw.indent()<<"phaseShift "<< seq.getPhaseShift() << std::endl;
|
||||
|
||||
if (seq.getSequenceGroup() != NULL) {
|
||||
fw.writeObject(*seq.getSequenceGroup());
|
||||
}
|
||||
for (int i=0; i<seq.getNumPulses(); i++) {
|
||||
double length;
|
||||
osg::Vec4 color;
|
||||
seq.getPulse(i, length, color);
|
||||
fw.indent()<<"pulse " << length << " " << color << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
bool BlinkSequence_SequenceGroup_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool BlinkSequence_SequenceGroup_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy BlinkSequence_SequenceGroup_Proxy
|
||||
(
|
||||
new BlinkSequence::SequenceGroup,
|
||||
"BlinkSequence::SequenceGroup",
|
||||
"Object BlinkSequence::SequenceGroup",
|
||||
&BlinkSequence_SequenceGroup_readLocalData,
|
||||
&BlinkSequence_SequenceGroup_writeLocalData,
|
||||
osgDB::DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool BlinkSequence_SequenceGroup_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
BlinkSequence::SequenceGroup &sg = static_cast<BlinkSequence::SequenceGroup &>(obj);
|
||||
|
||||
if (fr.matchSequence("baseTime %f"))
|
||||
{
|
||||
fr[1].getDouble(sg._baseTime);
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool BlinkSequence_SequenceGroup_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const BlinkSequence::SequenceGroup &sg = static_cast<const BlinkSequence::SequenceGroup &>(obj);
|
||||
|
||||
fw.indent()<<"baseTime "<< sg._baseTime << std::endl;
|
||||
return true;
|
||||
}
|
119
src/osgPlugins/osgSim/IO_LightPoint.cpp
Normal file
119
src/osgPlugins/osgSim/IO_LightPoint.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include <osg/Notify>
|
||||
#include <osgDB/Registry>
|
||||
#include "IO_LightPoint.h"
|
||||
|
||||
using namespace osgSim;
|
||||
|
||||
bool readLightPoint(LightPoint & lp, osgDB::Input &fr)
|
||||
{
|
||||
if (fr.matchSequence("lightPoint {"))
|
||||
{
|
||||
fr += 2;
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
bool itAdvanced = true;
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets() >= entry && itAdvanced) {
|
||||
itAdvanced = false;
|
||||
if (fr[0].matchWord("isOn")) {
|
||||
const char * ptstr = fr[1].getStr();
|
||||
if (ptstr) {
|
||||
if (std::string(ptstr) == "TRUE") {
|
||||
lp._on = true;
|
||||
} else if (std::string(ptstr) == "FALSE") {
|
||||
lp._on = false;
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "osg::Sim reader warning: invalid isOn: " << ptstr << std::endl;
|
||||
}
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("position")) {
|
||||
float x, y, z;
|
||||
if (fr[1].getFloat(x) && fr[2].getFloat(y) && fr[3].getFloat(z)) {
|
||||
lp._position.set(x, y, z);
|
||||
fr += 4;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("color")) {
|
||||
float r, g, b, a;
|
||||
if (fr[1].getFloat(r) && fr[2].getFloat(g) && fr[3].getFloat(b) && fr[4].getFloat(a)) {
|
||||
lp._color.set(r, g, b, a);
|
||||
fr += 5;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("intensity")) {
|
||||
if (fr[1].getFloat(lp._intensity)) {
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("radius")) {
|
||||
if (fr[1].getFloat(lp._radius)) {
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr[0].matchWord("blendingMode")) {
|
||||
const char * ptstr = fr[1].getStr();
|
||||
if (ptstr) {
|
||||
if (std::string(ptstr) == "ADDITIVE") {
|
||||
lp._blendingMode = LightPoint::ADDITIVE;
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
} else if (std::string(ptstr) == "BLENDED") {
|
||||
lp._blendingMode = LightPoint::BLENDED;
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "osg::Sim reader warning: invalid blendingMode: " << ptstr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
Sector * sector = static_cast<Sector *>(fr.readObjectOfType(osgDB::type_wrapper<Sector>()));
|
||||
if (sector) {
|
||||
lp._sector = sector;
|
||||
itAdvanced = true;
|
||||
}
|
||||
BlinkSequence * seq = static_cast<BlinkSequence *>(fr.readObjectOfType(osgDB::type_wrapper<BlinkSequence>()));
|
||||
if (seq) {
|
||||
lp._blinkSequence = seq;
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool writeLightPoint(const LightPoint & lp, osgDB::Output &fw)
|
||||
{
|
||||
fw.indent() << "lightPoint {" << std::endl;
|
||||
fw.moveIn();
|
||||
fw.indent() << "isOn " << ( lp._on ? "TRUE" : "FALSE") << std::endl;
|
||||
fw.indent() << "position " << lp._position << std::endl;
|
||||
fw.indent() << "color " << lp._color << std::endl;
|
||||
fw.indent() << "intensity " << lp._intensity << std::endl;
|
||||
fw.indent() << "radius " << lp._radius << std::endl;
|
||||
fw.indent() << "blendingMode ";
|
||||
switch (lp._blendingMode) {
|
||||
case LightPoint::ADDITIVE:
|
||||
fw << "ADDITIVE" << std::endl;
|
||||
break;
|
||||
case LightPoint::BLENDED:
|
||||
default :
|
||||
fw << "BLENDED" << std::endl;
|
||||
break;
|
||||
}
|
||||
if (lp._sector.valid()) {
|
||||
fw.writeObject(*lp._sector);
|
||||
}
|
||||
if (lp._blinkSequence.valid()) {
|
||||
fw.writeObject(*lp._blinkSequence);
|
||||
}
|
||||
|
||||
fw.moveOut();
|
||||
fw.indent() << "}" << std::endl;
|
||||
return true;
|
||||
}
|
11
src/osgPlugins/osgSim/IO_LightPoint.h
Normal file
11
src/osgPlugins/osgSim/IO_LightPoint.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef DOTOSGSIM_LIGHTPOINT
|
||||
#define DOTOSGSIM_LIGHTPOINT
|
||||
|
||||
#include <osgSim/LightPoint>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
extern bool readLightPoint(osgSim::LightPoint & lp, osgDB::Input &fr);
|
||||
extern bool writeLightPoint(const osgSim::LightPoint & lp, osgDB::Output &fw);
|
||||
|
||||
#endif
|
98
src/osgPlugins/osgSim/IO_LightPointNode.cpp
Normal file
98
src/osgPlugins/osgSim/IO_LightPointNode.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include <osgSim/LightPointNode>
|
||||
#include <osgSim/LightPoint>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include "IO_LightPoint.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
using namespace osgSim;
|
||||
|
||||
bool LightPointNode_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool LightPointNode_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy LightPointNode_Proxy
|
||||
(
|
||||
new LightPointNode,
|
||||
"LightPointNode",
|
||||
"Object Node LightPointNode",
|
||||
&LightPointNode_readLocalData,
|
||||
&LightPointNode_writeLocalData
|
||||
);
|
||||
|
||||
bool LightPointNode_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
LightPointNode &lightpointnode = static_cast<LightPointNode &>(obj);
|
||||
bool itAdvanced = false;
|
||||
|
||||
if (fr.matchSequence("num_lightpoints %d")) {
|
||||
// Could allocate space for lightpoints here
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("minPixelSize %f")) {
|
||||
float size = 0.0f;
|
||||
fr[1].getFloat(size);
|
||||
lightpointnode.setMinPixelSize(size);
|
||||
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("maxPixelSize %f")) {
|
||||
float size = 30.0f;
|
||||
fr[1].getFloat(size);
|
||||
lightpointnode.setMaxPixelSize(size);
|
||||
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("maxVisibleDistance2 %f")) {
|
||||
float distance = FLT_MAX;
|
||||
fr[1].getFloat(distance);
|
||||
lightpointnode.setMaxVisibleDistance2(distance);
|
||||
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("lightPoint")) {
|
||||
LightPoint lp;
|
||||
if (readLightPoint(lp, fr)) {
|
||||
lightpointnode.addLightPoint(lp);
|
||||
itAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
return itAdvanced;
|
||||
}
|
||||
|
||||
bool LightPointNode_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const LightPointNode &lightpointnode = static_cast<const LightPointNode &>(obj);
|
||||
|
||||
fw.indent() << "num_lightpoints " << lightpointnode.getNumLightPoints() << std::endl;
|
||||
|
||||
fw.indent() << "minPixelSize " << lightpointnode.getMinPixelSize() << std::endl;
|
||||
|
||||
fw.indent() << "maxPixelSize " << lightpointnode.getMaxPixelSize() << std::endl;
|
||||
|
||||
fw.indent() << "maxVisibleDistance2 " << lightpointnode.getMaxVisibleDistance2() << std::endl;
|
||||
|
||||
LightPointNode::LightPointList const lightpointlist = lightpointnode.getLightPointList();
|
||||
LightPointNode::LightPointList::const_iterator itr;
|
||||
|
||||
for (itr = lightpointlist.begin(); itr != lightpointlist.end(); itr++) {
|
||||
writeLightPoint((*itr), fw);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
223
src/osgPlugins/osgSim/IO_Sector.cpp
Normal file
223
src/osgPlugins/osgSim/IO_Sector.cpp
Normal file
@ -0,0 +1,223 @@
|
||||
#include <osgSim/Sector>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
bool AzimSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool AzimSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy AzimSector_Proxy
|
||||
(
|
||||
new osgSim::AzimSector,
|
||||
"AzimSector",
|
||||
"Object AzimSector",
|
||||
&AzimSector_readLocalData,
|
||||
&AzimSector_writeLocalData,
|
||||
osgDB::DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool AzimSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
osgSim::AzimSector §or = static_cast<osgSim::AzimSector &>(obj);
|
||||
|
||||
if (fr.matchSequence("azimuthRange %f %f %f"))
|
||||
{
|
||||
float minAzimuth;
|
||||
float maxAzimuth;
|
||||
float fadeRange;
|
||||
fr[1].getFloat(minAzimuth);
|
||||
fr[2].getFloat(maxAzimuth);
|
||||
fr[3].getFloat(fadeRange);
|
||||
fr += 4;
|
||||
sector.setAzimuthRange(minAzimuth, maxAzimuth, fadeRange);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool AzimSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
float minAzimuth, maxAzimuth, fadeAngle;
|
||||
|
||||
const osgSim::AzimSector §or = static_cast<const osgSim::AzimSector &>(obj);
|
||||
sector.getAzimuthRange(minAzimuth, maxAzimuth, fadeAngle);
|
||||
fw.indent()<<"azimuthRange "<<minAzimuth<< " "<<maxAzimuth<< " "<<fadeAngle<<std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
bool ElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool ElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy ElevationSector_Proxy
|
||||
(
|
||||
new osgSim::ElevationSector,
|
||||
"ElevationSector",
|
||||
"Object ElevationSector",
|
||||
&ElevationSector_readLocalData,
|
||||
&ElevationSector_writeLocalData,
|
||||
osgDB::DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool ElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
osgSim::ElevationSector §or = static_cast<osgSim::ElevationSector &>(obj);
|
||||
|
||||
if (fr.matchSequence("elevationRange %f %f %f"))
|
||||
{
|
||||
float minElevation;
|
||||
float maxElevation;
|
||||
float fadeAngle;
|
||||
|
||||
fr[1].getFloat(minElevation);
|
||||
fr[2].getFloat(maxElevation);
|
||||
fr[3].getFloat(fadeAngle);
|
||||
fr += 4;
|
||||
sector.setElevationRange(minElevation, maxElevation, fadeAngle);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool ElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
|
||||
const osgSim::ElevationSector §or = static_cast<const osgSim::ElevationSector &>(obj);
|
||||
|
||||
float minElevation = sector.getMinElevation();
|
||||
float maxElevation = sector.getMaxElevation();
|
||||
float fadeAngle = sector.getFadeAngle();
|
||||
fw.indent()<<"elevationRange "<<minElevation<< " "<<maxElevation<< " "<<fadeAngle<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
bool AzimElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool AzimElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy AzimElevationSector_Proxy
|
||||
(
|
||||
new osgSim::AzimElevationSector,
|
||||
"AzimElevationSector",
|
||||
"Object AzimElevationSector",
|
||||
&AzimElevationSector_readLocalData,
|
||||
&AzimElevationSector_writeLocalData,
|
||||
osgDB::DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool AzimElevationSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
osgSim::AzimElevationSector §or = static_cast<osgSim::AzimElevationSector &>(obj);
|
||||
|
||||
if (fr.matchSequence("azimuthRange %f %f %f"))
|
||||
{
|
||||
float minAzimuth;
|
||||
float maxAzimuth;
|
||||
float fadeAngle;
|
||||
fr[1].getFloat(minAzimuth);
|
||||
fr[2].getFloat(maxAzimuth);
|
||||
fr[3].getFloat(fadeAngle);
|
||||
fr += 4;
|
||||
sector.setAzimuthRange(minAzimuth, maxAzimuth, fadeAngle);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
if (fr.matchSequence("elevationRange %f %f %f"))
|
||||
{
|
||||
float minElevation;
|
||||
float maxElevation;
|
||||
float fadeAngle;
|
||||
|
||||
fr[1].getFloat(minElevation);
|
||||
fr[2].getFloat(maxElevation);
|
||||
fr[3].getFloat(fadeAngle);
|
||||
fr += 4;
|
||||
sector.setElevationRange(minElevation, maxElevation, fadeAngle);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool AzimElevationSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
|
||||
const osgSim::AzimElevationSector §or = static_cast<const osgSim::AzimElevationSector &>(obj);
|
||||
|
||||
float minElevation = sector.getMinElevation();
|
||||
float maxElevation = sector.getMaxElevation();
|
||||
float fadeAngle = sector.getFadeAngle();
|
||||
fw.indent()<<"elevationRange "<<minElevation<< " "<<maxElevation<< " "<<fadeAngle<<std::endl;
|
||||
|
||||
float minAzimuth, maxAzimuth;
|
||||
sector.getAzimuthRange(minAzimuth, maxAzimuth, fadeAngle);
|
||||
fw.indent()<<"azimuthRange "<<minAzimuth<< " "<<maxAzimuth<< " "<<fadeAngle<<std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
bool ConeSector_readLocalData(osg::Object &obj, osgDB::Input &fr);
|
||||
bool ConeSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
|
||||
|
||||
osgDB::RegisterDotOsgWrapperProxy ConeSector_Proxy
|
||||
(
|
||||
new osgSim::ConeSector,
|
||||
"ConeSector",
|
||||
"Object ConeSector",
|
||||
&ConeSector_readLocalData,
|
||||
&ConeSector_writeLocalData,
|
||||
osgDB::DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool ConeSector_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
osgSim::ConeSector §or = static_cast<osgSim::ConeSector &>(obj);
|
||||
|
||||
if (fr.matchSequence("axis %f %f %f"))
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
fr[1].getFloat(x);
|
||||
fr[2].getFloat(y);
|
||||
fr[3].getFloat(z);
|
||||
fr += 4;
|
||||
sector.setAxis(osg::Vec3(x, y, z));
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
if (fr.matchSequence("angle %f %f"))
|
||||
{
|
||||
float angle;
|
||||
float fadeangle;
|
||||
fr[1].getFloat(angle);
|
||||
fr[2].getFloat(fadeangle);
|
||||
fr += 3;
|
||||
sector.setAngle(angle, fadeangle);
|
||||
iteratorAdvanced;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool ConeSector_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
{
|
||||
const osgSim::ConeSector §or = static_cast<const osgSim::ConeSector &>(obj);
|
||||
|
||||
const osg::Vec3& axis = sector.getAxis();
|
||||
fw.indent()<<"axis "<<axis<<std::endl;
|
||||
|
||||
float angle = sector.getAngle();
|
||||
float fadeangle = sector.getFadeAngle();
|
||||
fw.indent()<<"angle "<<angle<<" "<<fadeangle<<std::endl;
|
||||
return true;
|
||||
}
|
||||
|
@ -41,6 +41,12 @@ BlinkSequence::SequenceGroup::SequenceGroup()
|
||||
_baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
|
||||
}
|
||||
|
||||
BlinkSequence::SequenceGroup::SequenceGroup(const BlinkSequence::SequenceGroup& sg, const osg::CopyOp& copyop):
|
||||
osg::Object(sg, copyop),
|
||||
_baseTime(sg._baseTime)
|
||||
{
|
||||
}
|
||||
|
||||
BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
|
||||
_baseTime(baseTime)
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ osg::StateSet* getSingletonLightPointStateSet()
|
||||
LightPointNode::LightPointNode():
|
||||
_minPixelSize(0.0f),
|
||||
_maxPixelSize(30.0f),
|
||||
_maxVisableDistance2(FLT_MAX)
|
||||
_maxVisibleDistance2(FLT_MAX)
|
||||
{
|
||||
setStateSet(getSingletonLightPointStateSet());
|
||||
}
|
||||
@ -55,7 +55,7 @@ LightPointNode::LightPointNode(const LightPointNode& lpn,const osg::CopyOp& copy
|
||||
_lightPointList(lpn._lightPointList),
|
||||
_minPixelSize(lpn._minPixelSize),
|
||||
_maxPixelSize(lpn._maxPixelSize),
|
||||
_maxVisableDistance2(lpn._maxVisableDistance2)
|
||||
_maxVisibleDistance2(lpn._maxVisibleDistance2)
|
||||
{
|
||||
}
|
||||
|
||||
@ -267,9 +267,9 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
|
||||
if (intensity<=minimumIntensity) continue;
|
||||
|
||||
|
||||
if (_maxVisableDistance2!=FLT_MAX)
|
||||
if (_maxVisibleDistance2!=FLT_MAX)
|
||||
{
|
||||
if (dv.length2()>_maxVisableDistance2) continue;
|
||||
if (dv.length2()>_maxVisibleDistance2) continue;
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,6 +42,19 @@ void AzimRange::setAzimuthRange(float minAzimuth,float maxAzimuth,float fadeAngl
|
||||
|
||||
}
|
||||
|
||||
void AzimRange::getAzimuthRange(float& minAzimuth, float& maxAzimuth, float& fadeAngle) const
|
||||
{
|
||||
float centerAzim = atan2(_sinAzim, _cosAzim);
|
||||
float angle = acos(_cosAngle);
|
||||
minAzimuth = centerAzim - angle;
|
||||
maxAzimuth = centerAzim + angle;
|
||||
if (_cosFadeAngle == -1.0f) {
|
||||
fadeAngle = 2.0f * osg::PI;
|
||||
} else {
|
||||
fadeAngle = acos(_cosFadeAngle) - angle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Elevation Range
|
||||
@ -83,6 +96,25 @@ float ElevationRange::getMaxElevation() const
|
||||
return osg::PI_2-acos(_cosMaxElevation);
|
||||
}
|
||||
|
||||
float ElevationRange::getFadeAngle() const
|
||||
{
|
||||
float fadeAngle = 0.0;
|
||||
|
||||
// Take the appropriate (unclipped) elevation angle to calculate the fade angle
|
||||
if (_cosMinFadeElevation != -1.0f) {
|
||||
float minFadeAngle = acos(_cosMinFadeElevation);
|
||||
float minElevation = osg::PI_2 - acos(_cosMinElevation);
|
||||
fadeAngle = minFadeAngle + minElevation - osg::PI_2;
|
||||
|
||||
} else if (_cosMaxFadeElevation != 1.0f) {
|
||||
float maxFadeAngle = acos(_cosMaxFadeElevation);
|
||||
float maxElevation = osg::PI_2 - acos(_cosMaxElevation);
|
||||
fadeAngle = osg::PI_2 - maxFadeAngle - maxElevation;
|
||||
}
|
||||
|
||||
return fadeAngle;
|
||||
}
|
||||
|
||||
//
|
||||
// ElevationSector
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user