Lights sources and animation
#1
Hello,

I'm using Reader3ds with PowerTools for 3D scene visualization and animation and I have found one issue with lights.

My 3D scene contains 5 light sources with color #FF666666. This scene looks fine, lighting is soft and beautiful, but when I run the animation, all lights change color to #FFFFFFFF that breaks scene lighting.
Same behavior in the Viewer3ds.

Sample image attached.

Are there any workaround for this issue?

Thanks,
Vladimir


Attached Files Thumbnail(s)
   
#2
I have found workaround for this issue. Maybe it is not very good solution from the performance side, but on my dev and test configurations it works fine.
Main idea - collect lights settings after scene loading and restore it on each animation step.

Code:
private Dictionary<Light, Color> _lights;

private void ReadSceneLightsColors()
{
    _lights = new Dictionary<Light, Color>();

    foreach (var light in _mainReader3ds.Lights)
    {
        _lights[light] = light.Color;
    }
}

private void RestoreLights()
{
    _mainReader3ds.BeginInit();

    foreach (var light in _mainReader3ds.Lights)
    {
        light.Color = _lights[light];
    }

    _mainReader3ds.EndInit();
}

private void ViewOnRendering(object sender, EventArgs e)
{
    _mainReader3ds.Animator.DoAnimate();

    RestoreLights();
}
#3
From the original 3ds file that was privately sent to me I have seen that the light color was changed because the 3ds file defines one key frame (used to define animations) for the color of the light with white color.

This color was different from the color that was set when the light was initially defined in 3ds file - there the light was gray.

So when the animation was started, this key frame was used for the light color. Usually (at least for the 3ds file that I had) the color defined by the light and in the key frame are the same. But in your case this was not the case.

I have changed the Reader3ds to not use the key frame color if there is only one key frame defined (so if the color is not being animated).

I have already send a fixed version to ViSor. I am preparing a new version of Reader3ds and Viewer3ds that will be available soon and will also contain that fix.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)