Re: [osg-users] Lightpoint behavior with DirectionalSector

2016-02-23 Thread Robert Osfield
On 23 February 2016 at 12:08, Renato Semadeni  wrote:

> Hi Robert
>
> Thanks a lot for point me to the source code responsible of handling the
> lights. I will take a look at it later on.
>
> Just another question: Would it be possible to control multiple lights
> with the same directional sector?
>

The LightPoint::_sector is just a ref_ptr<> so can happily share a single
Sector instance between multiple LightPoint.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Lightpoint behavior with DirectionalSector

2016-02-23 Thread Renato Semadeni
Hi Robert

Thanks a lot for point me to the source code responsible of handling the 
lights. I will take a look at it later on.

Just another question: Would it be possible to control multiple lights with the 
same directional sector?

Kind regards,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66395#66395





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Lightpoint behavior with DirectionalSector

2016-02-23 Thread Robert Osfield
On 23 February 2016 at 09:13, Renato Semadeni  wrote:

> Hi Robert
>
> Thanks a lot for the quick answer. And yes, I forgot that I could change
> the osg code and recompile it from scratch.
>
> The behavior was just bizarre, since there was no symmetrie between the
> behavior on the left side of the two lights compared to the right side.
> Since it would be obvious that it could be a geometric problem. But what we
> found was that the position in the frustum seems to be the souce of the
> behavior.
>

The direction vector between the eye point and the light point is used to
calculator intensity of the light point in the sector calculation, so one
would expect the things to change as the light point moves within the
frustum.  The code that does this is in LightPointNode.cpp, note the if
(lp._sector.valid()) block at the bottom of the extract I've posted below.


// delta vector between eyepoint and light point.
osg::Vec3 dv(eyePoint-position);

float intensity = (_lightSystem.valid()) ?
_lightSystem->getIntensity() : lp._intensity;

// slip light point if its intensity is 0.0 or negative.
if (intensity<=minimumIntensity) continue;

// (SIB) Clip on distance, if close to limit, add transparancy
float distanceFactor = 1.0f;
if (_maxVisibleDistance2!=FLT_MAX)
{
if (dv.length2()>_maxVisibleDistance2) continue;
else if (_maxVisibleDistance2 > 0)
distanceFactor = 1.0f - osg::square(dv.length2() /
_maxVisibleDistance2);
}

osg::Vec4 color = lp._color;

// check the sector.
if (lp._sector.valid())
{
intensity *= (*lp._sector)(dv);

// skip light point if it is intensity is 0.0 or negative.
if (intensity<=minimumIntensity) continue;

}


Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Lightpoint behavior with DirectionalSector

2016-02-23 Thread Renato Semadeni
Hi Robert

Thanks a lot for the quick answer. And yes, I forgot that I could change the 
osg code and recompile it from scratch.

The behavior was just bizarre, since there was no symmetrie between the 
behavior on the left side of the two lights compared to the right side. Since 
it would be obvious that it could be a geometric problem. But what we found was 
that the position in the frustum seems to be the souce of the behavior.

Kind regards,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66391#66391





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Lightpoint behavior with DirectionalSector

2016-02-23 Thread Robert Osfield
Hi Renato,

The light point functionality was indeed written a long time ago, over a
decade me thinks, so I'm rather rusty on the topic.

Having a near light point appear/disappear at different times to a distant
one would be a function of the sector you define for it, so if this is not
happening how you'd expect my guess would be a problem in the values of the
sectors.  The easiest way to understand what's going on would be to add
some debugging code to light point code that tests the sector whether the
eye point is within the sector or not and see if the behaviour is what you
are expecting.

Robert.

On 22 February 2016 at 13:49, Renato Semadeni  wrote:

> Hi,
>
> I'm looking into an older implementation of osg. I struggling with some
> lightpoint which have directionsectors defined.
>
> I have lightpoints which change their appearance due to viewing position
> of the eyepoint. As you can see below, we are defining some lights in a
> .osg file, this is loaded by our engine and the lights are displayed.
>
>
> Code:
>
> Group {
>  name "Lights_PAPI"
>  nodeMask 0x
>  cullingActive FALSE
>  num_children 2
>osgSim::LightPointNode {
>nodeMask 0x
>cullingActive FALSE
>num_lightpoints 1
>minPixelSize 0
>maxPixelSize 10
>maxVisibleDistance2 20e+010
>pointSprite FALSE
>lightPoint {
>   isOn TRUE
>   position -21.5745 -336.3172 0.8935
>   color 1 0 0 1
>   intensity 0.04
>   radius 5.5
>   blendingMode BLENDED
>   osgSim::DirectionalSector {
>  direction -0.572689 -0.819772 0
>  angles 6.28318 0.13614 6.28318 0
>   }
>}
>  }
>   osgSim::LightPointNode {
>nodeMask 0x
>cullingActive FALSE
>num_lightpoints 2
>minPixelSize 0
>maxPixelSize 10
>maxVisibleDistance2 20e+010
>pointSprite FALSE
>lightPoint {
>   isOn TRUE
>   position 44.2707 -379.8886 0.8936
>   color 1 0 0 1
>   intensity 0.04
>   radius 5.5
>   blendingMode BLENDED
>   osgSim::DirectionalSector {
>  direction -0.572689 -0.819772 0
>  angles 6.28318 0.13614 6.28318 0
>   }
>}
>  }
> }
>
>
>
>
> We observe now, that even if the lights are only at different positions,
> that always the one on closer on the x-axis gets turned off earlier than
> the other one.
>
> I was looking for an error in our code, but even in the osgviewer the same
> behavior is present. Secondly I tried to find an approach to define the
> directionsector once for both lightpoint. But unfortunately without any
> success.
>
> We can't include the light behavior into our engine, without larger
> effort, therefore we are looking for a solution base on the osg file format.
>
> I really hoping to find some help!
>
> Thank you!
>
> kind regards,
> Renato
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=66383#66383
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Lightpoint behavior with DirectionalSector

2016-02-22 Thread Renato Semadeni
Hi,

I'm looking into an older implementation of osg. I struggling with some 
lightpoint which have directionsectors defined.

I have lightpoints which change their appearance due to viewing position of the 
eyepoint. As you can see below, we are defining some lights in a .osg file, 
this is loaded by our engine and the lights are displayed.


Code:

Group {
 name "Lights_PAPI"
 nodeMask 0x
 cullingActive FALSE
 num_children 2
   osgSim::LightPointNode {
   nodeMask 0x
   cullingActive FALSE
   num_lightpoints 1
   minPixelSize 0
   maxPixelSize 10
   maxVisibleDistance2 20e+010
   pointSprite FALSE
   lightPoint {
  isOn TRUE
  position -21.5745 -336.3172 0.8935
  color 1 0 0 1
  intensity 0.04
  radius 5.5
  blendingMode BLENDED
  osgSim::DirectionalSector {
 direction -0.572689 -0.819772 0
 angles 6.28318 0.13614 6.28318 0
  }
   }
 }
  osgSim::LightPointNode {
   nodeMask 0x
   cullingActive FALSE
   num_lightpoints 2
   minPixelSize 0
   maxPixelSize 10
   maxVisibleDistance2 20e+010
   pointSprite FALSE
   lightPoint {
  isOn TRUE
  position 44.2707 -379.8886 0.8936
  color 1 0 0 1
  intensity 0.04
  radius 5.5
  blendingMode BLENDED
  osgSim::DirectionalSector {
 direction -0.572689 -0.819772 0
 angles 6.28318 0.13614 6.28318 0
  }
   }
 }
}




We observe now, that even if the lights are only at different positions, that 
always the one on closer on the x-axis gets turned off earlier than the other 
one. 

I was looking for an error in our code, but even in the osgviewer the same 
behavior is present. Secondly I tried to find an approach to define the 
directionsector once for both lightpoint. But unfortunately without any success.

We can't include the light behavior into our engine, without larger effort, 
therefore we are looking for a solution base on the osg file format.

I really hoping to find some help!

Thank you!

kind regards,
Renato

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66383#66383





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org