mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0032121: Draw Harness, ViewerTest - implement -reset option for vlight command
vlight command has been revised to provide more friendly syntax. Command now accepts light index or name as first argument. Added arguments -enable/-disable for managing enabled state. Added argument -reset to reset light parameters to default values. V3d_Viewer::SetDefaultLights() now sets names "headlight" and "ambient" to created lights. Graphic3d_TypeOfLightSource enumeration values have been renamed to avoid shortcuts. Draw::Atof(), applied corrections to avoid explicit new/delete calls.
This commit is contained in:
@@ -54,8 +54,11 @@ namespace
|
||||
const Graphic3d_Vec4& aLightColor = theLight.PackedColor();
|
||||
switch (theLight.Type())
|
||||
{
|
||||
case Graphic3d_TOLS_AMBIENT : break; // handled by separate if-clause at beginning of method
|
||||
case Graphic3d_TOLS_DIRECTIONAL:
|
||||
case Graphic3d_TypeOfLightSource_Ambient:
|
||||
{
|
||||
break; // handled by separate if-clause at beginning of method
|
||||
}
|
||||
case Graphic3d_TypeOfLightSource_Directional:
|
||||
{
|
||||
// if the last parameter of GL_POSITION, is zero, the corresponding light source is a Directional one
|
||||
const OpenGl_Vec4 anInfDir = -theLight.PackedDirectionRange();
|
||||
@@ -70,7 +73,7 @@ namespace
|
||||
theCtx->core11ffp->glLightf (theLightGlId, GL_SPOT_CUTOFF, THE_DEFAULT_SPOT_CUTOFF);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOLS_POSITIONAL:
|
||||
case Graphic3d_TypeOfLightSource_Positional:
|
||||
{
|
||||
// to create a realistic effect, set the GL_SPECULAR parameter to the same value as the GL_DIFFUSE
|
||||
const OpenGl_Vec4 aPosition (static_cast<float>(theLight.Position().X()), static_cast<float>(theLight.Position().Y()), static_cast<float>(theLight.Position().Z()), 1.0f);
|
||||
@@ -86,7 +89,7 @@ namespace
|
||||
theCtx->core11ffp->glLightf (theLightGlId, GL_QUADRATIC_ATTENUATION, 0.0f);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOLS_SPOT:
|
||||
case Graphic3d_TypeOfLightSource_Spot:
|
||||
{
|
||||
const OpenGl_Vec4 aPosition (static_cast<float>(theLight.Position().X()), static_cast<float>(theLight.Position().Y()), static_cast<float>(theLight.Position().Z()), 1.0f);
|
||||
theCtx->core11ffp->glLightfv (theLightGlId, GL_AMBIENT, THE_DEFAULT_AMBIENT);
|
||||
@@ -464,7 +467,7 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
|
||||
if (!aLight.IsEnabled()) // has no affect with Graphic3d_LightSet::IterationFilter_ExcludeDisabled - here just for consistency
|
||||
{
|
||||
// if it is desired to keep disabled light in the same order - we can replace it with a black light so that it will have no influence on result
|
||||
aLightType = -1; // Graphic3d_TOLS_AMBIENT can be used instead
|
||||
aLightType = -1; // Graphic3d_TypeOfLightSource_Ambient can be used instead
|
||||
aLightParams.Color = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 0.0f);
|
||||
++aLightsNb;
|
||||
continue;
|
||||
@@ -478,11 +481,11 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
|
||||
aLightParams.Parameters = aLight.PackedParams();
|
||||
switch (aLight.Type())
|
||||
{
|
||||
case Graphic3d_TOLS_AMBIENT:
|
||||
case Graphic3d_TypeOfLightSource_Ambient:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOLS_DIRECTIONAL:
|
||||
case Graphic3d_TypeOfLightSource_Directional:
|
||||
{
|
||||
if (aLight.IsHeadlight())
|
||||
{
|
||||
@@ -496,7 +499,7 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOLS_SPOT:
|
||||
case Graphic3d_TypeOfLightSource_Spot:
|
||||
{
|
||||
if (aLight.IsHeadlight())
|
||||
{
|
||||
@@ -510,7 +513,7 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
|
||||
}
|
||||
}
|
||||
Standard_FALLTHROUGH
|
||||
case Graphic3d_TOLS_POSITIONAL:
|
||||
case Graphic3d_TypeOfLightSource_Positional:
|
||||
{
|
||||
if (aLight.IsHeadlight())
|
||||
{
|
||||
|
@@ -93,11 +93,11 @@ bool OpenGl_ShadowMap::UpdateCamera (const Graphic3d_CView& theView,
|
||||
|
||||
switch (myShadowLight->Type())
|
||||
{
|
||||
case Graphic3d_TOLS_AMBIENT:
|
||||
case Graphic3d_TypeOfLightSource_Ambient:
|
||||
{
|
||||
return false; // not applicable
|
||||
}
|
||||
case Graphic3d_TOLS_DIRECTIONAL:
|
||||
case Graphic3d_TypeOfLightSource_Directional:
|
||||
{
|
||||
if (theOrigin != NULL)
|
||||
{
|
||||
@@ -134,12 +134,12 @@ bool OpenGl_ShadowMap::UpdateCamera (const Graphic3d_CView& theView,
|
||||
myLightMatrix = myShadowCamera->ProjectionMatrixF() * myShadowCamera->OrientationMatrixF();
|
||||
return true;
|
||||
}
|
||||
case Graphic3d_TOLS_POSITIONAL:
|
||||
case Graphic3d_TypeOfLightSource_Positional:
|
||||
{
|
||||
// render into cubemap shadowmap texture
|
||||
return false; // not implemented
|
||||
}
|
||||
case Graphic3d_TOLS_SPOT:
|
||||
case Graphic3d_TypeOfLightSource_Spot:
|
||||
{
|
||||
//myShadowCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
|
||||
//myShadowCamera->SetEye (theCastShadowLight->Position());
|
||||
|
@@ -154,7 +154,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
|
||||
myWorkspace = new OpenGl_Workspace (this, NULL);
|
||||
|
||||
Handle(Graphic3d_CLight) aLight = new Graphic3d_CLight (Graphic3d_TOLS_AMBIENT);
|
||||
Handle(Graphic3d_CLight) aLight = new Graphic3d_CLight (Graphic3d_TypeOfLightSource_Ambient);
|
||||
aLight->SetColor (Quantity_NOC_WHITE);
|
||||
myLights = new Graphic3d_LightSet();
|
||||
myNoShadingLight = new Graphic3d_LightSet();
|
||||
|
@@ -2440,7 +2440,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
|
||||
aLightIter.More(); aLightIter.Next())
|
||||
{
|
||||
const Graphic3d_CLight& aLight = *aLightIter.Value();
|
||||
if (aLight.Type() != Graphic3d_TOLS_DIRECTIONAL)
|
||||
if (aLight.Type() != Graphic3d_TypeOfLightSource_Directional)
|
||||
{
|
||||
aLightSources.push_back (aLightIter.Value());
|
||||
}
|
||||
@@ -2449,7 +2449,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
|
||||
for (Graphic3d_LightSet::Iterator aLightIter (myLights, Graphic3d_LightSet::IterationFilter_ExcludeDisabledAndAmbient);
|
||||
aLightIter.More(); aLightIter.Next())
|
||||
{
|
||||
if (aLightIter.Value()->Type() == Graphic3d_TOLS_DIRECTIONAL)
|
||||
if (aLightIter.Value()->Type() == Graphic3d_TypeOfLightSource_Directional)
|
||||
{
|
||||
aLightSources.push_back (aLightIter.Value());
|
||||
}
|
||||
@@ -2484,7 +2484,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
|
||||
-aLight.PackedDirectionRange().z(),
|
||||
0.0f);
|
||||
|
||||
if (aLight.Type() != Graphic3d_TOLS_DIRECTIONAL)
|
||||
if (aLight.Type() != Graphic3d_TypeOfLightSource_Directional)
|
||||
{
|
||||
aPosition = BVH_Vec4f (static_cast<float>(aLight.Position().X()),
|
||||
static_cast<float>(aLight.Position().Y()),
|
||||
|
Reference in New Issue
Block a user