Added support for min pixel size, max pixel size and max visable distance to

osgSim::LightPointNode, the max pixel size from was originally in osg::LightPoint.

Added additional get/set methods to osg::LightPointNode.

Increased the compute pixel size by a ratio 1.41 (sqrtf(2)) to correlate the
computed size with the actual size seen on screen.
This commit is contained in:
Robert Osfield
2003-04-02 10:50:15 +00:00
parent d3d32edfcd
commit 7aab621405
7 changed files with 62 additions and 39 deletions

View File

@@ -26,14 +26,20 @@
using namespace osgSim;
LightPointNode::LightPointNode()
LightPointNode::LightPointNode():
_minPixelSize(0.0f),
_maxPixelSize(30.0f),
_maxVisableDistance2(FLT_MAX)
{
}
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
LightPointNode::LightPointNode(const LightPointNode& lpn,const osg::CopyOp& copyop):
osg::Node(lpn,copyop),
_lightPointList(lpn._lightPointList)
_lightPointList(lpn._lightPointList),
_minPixelSize(lpn._minPixelSize),
_maxPixelSize(lpn._maxPixelSize),
_maxVisableDistance2(lpn._maxVisableDistance2)
{
}
@@ -55,11 +61,6 @@ void LightPointNode::removeLightPoint(unsigned int pos)
dirtyBound();
}
void LightPointNode::removeLightPoints(LightPointList::iterator start,LightPointList::iterator end)
{
_lightPointList.erase(start,end);
}
bool LightPointNode::computeBound() const
{
_bsphere.init();
@@ -81,9 +82,13 @@ bool LightPointNode::computeBound() const
itr!=_lightPointList.end();
++itr)
{
_bsphere.expandRadiusBy(itr->_position);
osg::Vec3 dv(itr->_position-_bsphere.center());
float radius = dv.length()+itr->_radius;
if (_bsphere.radius()<radius) _bsphere.radius()=radius;
}
_bsphere.radius()+=1.0f;
_bsphere_computed=true;
return true;
}
@@ -231,6 +236,13 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
// slip light point if it is intensity is 0.0 or negative.
if (intensity<=minimumIntensity) continue;
if (_maxVisableDistance2!=FLT_MAX)
{
if (dv.length2()>_maxVisableDistance2) continue;
}
osg::Vec4 color = lp._color;
// check the sector.
@@ -265,7 +277,9 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
// adjust pixel size to account for intensity.
if (intensity!=1.0) pixelSize *= sqrt(intensity);
// round up to the minimum pixel size if required.
if (pixelSize<_minPixelSize) pixelSize = _minPixelSize;
osg::Vec3 xpos(position*matrix);
@@ -281,7 +295,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
drawable->addBlendedLightPoint(0, xpos,color);
}
else if (pixelSize<lp._maxPixelSize)
else if (pixelSize<_maxPixelSize)
{
unsigned int lowerBoundPixelSize = (unsigned int)pixelSize;
@@ -295,7 +309,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
}
else // use a billboard geometry.
{
drawable->addBlendedLightPoint((unsigned int)(lp._maxPixelSize-1.0), xpos,color);
drawable->addBlendedLightPoint((unsigned int)(_maxPixelSize-1.0), xpos,color);
}
}
else // ADDITIVE blending.
@@ -310,7 +324,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
drawable->addAdditiveLightPoint(0, xpos,color);
}
else if (pixelSize<lp._maxPixelSize)
else if (pixelSize<_maxPixelSize)
{
unsigned int lowerBoundPixelSize = (unsigned int)pixelSize;
@@ -325,7 +339,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
}
else // use a billboard geometry.
{
drawable->addAdditiveLightPoint((unsigned int)(lp._maxPixelSize-1.0), xpos,color);
drawable->addAdditiveLightPoint((unsigned int)(_maxPixelSize-1.0), xpos,color);
}
}
}