1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-16 10:54:53 +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:
kgv 2021-07-09 23:22:29 +03:00
parent cb7f92396f
commit 06d40093b7
44 changed files with 916 additions and 925 deletions

View File

@ -62,9 +62,9 @@ vrenderparams -rayTrace -fsaa on -reflections off -shadows off
vcamera -persp -fovy 25 vcamera -persp -fovy 25
vviewparams -eye 14 -14 6.8 -up 0 0 1 -at 4 -4 0 -scale 70 vviewparams -eye 14 -14 6.8 -up 0 0 1 -at 4 -4 0 -scale 70
vsetdispmode 1 vsetdispmode 1
vlight def vlight -defaults
vlight add directional direction 1 -2 -10 head 1 color white vlight dirlight1 -type DIRECTIONAL -direction 1 -2 -10 -head 1 -color WHITE
vlight add directional direction 0 -10 0 head 1 color white vlight dirlight2 -type DIRECTIONAL -direction 0 -10 0 -head 1 -color WHITE
# display boxes # display boxes
vdisplay b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 vdisplay b1 b2 b3 b4 b5 b6 b7 b8 b9 b10

View File

@ -243,17 +243,15 @@ ttranslate crpk_47 18.0 27.6 0
eval compound $lrpk brpk eval compound $lrpk brpk
# show result in plain 3d viewer # show result in 3d viewer
if [info exists i7_show_3dview] { vinit View1
vinit Driver1/Viewer1/View1
vclear vclear
vsetdispmode 1 vsetdispmode 1
vrenderparams -msaa 8 vrenderparams -msaa 8
vlight -clear
vlight clear vlight amblight -type AMBIENT
vlight add amb vlight dirlight -type DIRECTIONAL -direction 1 -1 -2 -head 1
vlight add directional direction 1 -1 -2 head 1 if [info exists i7_show_3dview] {
vdisplay case vdisplay case
vsetcolor case GRAY70 vsetcolor case GRAY70
@ -318,12 +316,8 @@ XSetColor D rpk1 GRAY70
XSetColor D rpk2 80664D XSetColor D rpk2 80664D
XSetColor D rpk3 GRAY70 XSetColor D rpk3 GRAY70
XShow D # display in 3D Viewer
vlight clear XDisplay -dispMode 1 D -explore
vlight add amb
vlight add directional direction 1 -1 -2 head 1
vsetdispmode 1
vrenderparams -msaa 8
vfit vfit
# save to STEP if variable i7_save_xde is defined (specifies file name) # save to STEP if variable i7_save_xde is defined (specifies file name)

View File

@ -59,10 +59,10 @@ for {set i 0} {$i < 12} {incr i} {
} }
# Configure light sources # Configure light sources
vlight -change 0 -head 0 vlight -change 0 -headLight 0
vlight -change 0 -direction -0.25 -1 -1 vlight -change 0 -direction -0.25 -1 -1
vlight -change 0 -sm 0.3 vlight -change 0 -smoothAngle 17
vlight -change 0 -int 10.0 vlight -change 0 -intensity 10.0
# Load environment map # Load environment map
vtextureenv on 1 vtextureenv on 1

View File

@ -15,7 +15,7 @@ vglinfo
# setup light sources # setup light sources
vlight -clear vlight -clear
vlight -add positional -head 0 -pos 0.5 0.5 0.85 -sm 0.06 -int 30.0 vlight -add POSITIONAL -headLight 0 -pos 0.5 0.5 0.85 -smoothRadius 0.06 -intensity 30.0 -name pntlight
vvbo 0 vvbo 0
vsetdispmode 1 vsetdispmode 1

View File

@ -211,8 +211,8 @@ vviewparams -size 170.508
# Restore light source parameters # Restore light source parameters
vlight -clear vlight -clear
vlight -add ambient vlight -add AMBIENT -name amblight
vlight -add directional -direction -0.303949 -0.434084 -0.848048 -smoothness 0.3 -intensity 12 vlight -add DIRECTIONAL -direction -0.303949 -0.434084 -0.848048 -smoothAngle 17 -intensity 12 -name dirlight
# Load environment map # Load environment map
vtextureenv on 1 vtextureenv on 1

View File

@ -31,7 +31,7 @@ vsetcolor glass brown
vsettransparency glass 0.6 vsettransparency glass 0.6
# add light source for shadows # add light source for shadows
vlight new spot pos -100 -100 300 vlight spot -type SPOT -pos -100 -100 300
# set white background and fit view # set white background and fit view
vbackground -color WHITE vbackground -color WHITE

View File

@ -313,7 +313,7 @@ bool WasmOcctView::initViewer()
for (V3d_ListOfLight::Iterator aLightIter (aViewer->ActiveLights()); aLightIter.More(); aLightIter.Next()) for (V3d_ListOfLight::Iterator aLightIter (aViewer->ActiveLights()); aLightIter.More(); aLightIter.Next())
{ {
const Handle(V3d_Light)& aLight = aLightIter.Value(); const Handle(V3d_Light)& aLight = aLightIter.Value();
if (aLight->Type() == Graphic3d_TOLS_DIRECTIONAL) if (aLight->Type() == Graphic3d_TypeOfLightSource_Directional)
{ {
aLight->SetCastShadows (true); aLight->SetCastShadows (true);
} }

View File

@ -75,10 +75,10 @@ AIS_LightSource::AIS_LightSource (const Handle(Graphic3d_CLight)& theLight)
myOpposMarkerType (Aspect_TOM_O_POINT), myOpposMarkerType (Aspect_TOM_O_POINT),
mySize (50), mySize (50),
myNbArrows (5), myNbArrows (5),
myNbSplitsQuadric (theLight->Type() == Graphic3d_TOLS_AMBIENT ? 10 : 30), myNbSplitsQuadric (theLight->Type() == Graphic3d_TypeOfLightSource_Ambient ? 10 : 30),
myNbSplitsArrow (20), myNbSplitsArrow (20),
myIsZoomable (theLight->Type() == Graphic3d_TOLS_POSITIONAL myIsZoomable (theLight->Type() == Graphic3d_TypeOfLightSource_Positional
|| theLight->Type() == Graphic3d_TOLS_SPOT), || theLight->Type() == Graphic3d_TypeOfLightSource_Spot),
myToDisplayName (true), myToDisplayName (true),
myToDisplayRange (true), myToDisplayRange (true),
myToSwitchOnClick (true) myToSwitchOnClick (true)
@ -101,7 +101,7 @@ AIS_LightSource::AIS_LightSource (const Handle(Graphic3d_CLight)& theLight)
myDrawer->ArrowAspect()->Aspect()->SetMarkerType (Aspect_TOM_EMPTY); myDrawer->ArrowAspect()->Aspect()->SetMarkerType (Aspect_TOM_EMPTY);
myDrawer->ArrowAspect()->Aspect()->SetMarkerScale (2.0f); myDrawer->ArrowAspect()->Aspect()->SetMarkerScale (2.0f);
myArrowLineAspectShadow = new Graphic3d_AspectLine3d (Quantity_NOC_BLACK, Aspect_TOL_SOLID, myArrowLineAspectShadow = new Graphic3d_AspectLine3d (Quantity_NOC_BLACK, Aspect_TOL_SOLID,
theLight->Type() != Graphic3d_TOLS_AMBIENT ? 3.0f : 1.0f); theLight->Type() != Graphic3d_TypeOfLightSource_Ambient ? 3.0f : 1.0f);
myDrawer->SetupOwnShadingAspect(); myDrawer->SetupOwnShadingAspect();
myDrawer->ShadingAspect()->SetColor (aColor); myDrawer->ShadingAspect()->SetColor (aColor);
@ -155,7 +155,7 @@ void AIS_LightSource::updateLightAspects()
myDrawer->ArrowAspect() ->SetColor (aColor); myDrawer->ArrowAspect() ->SetColor (aColor);
myDrawer->ArrowAspect()->Aspect()->ChangeFrontMaterial().SetColor (aColor); myDrawer->ArrowAspect()->Aspect()->ChangeFrontMaterial().SetColor (aColor);
if (myLightSource->Type() == Graphic3d_TOLS_DIRECTIONAL) if (myLightSource->Type() == Graphic3d_TypeOfLightSource_Directional)
{ {
const Standard_Real anAngleTol = 2.0 * M_PI / 180.0; const Standard_Real anAngleTol = 2.0 * M_PI / 180.0;
Aspect_TypeOfMarker aDirMark = Aspect_TOM_EMPTY; Aspect_TypeOfMarker aDirMark = Aspect_TOM_EMPTY;
@ -179,7 +179,7 @@ void AIS_LightSource::updateLightTransformPersistence()
Handle(Graphic3d_TransformPers) aTrsfPers = myTransformPersistence; Handle(Graphic3d_TransformPers) aTrsfPers = myTransformPersistence;
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
if (!myIsZoomable) if (!myIsZoomable)
{ {
@ -194,7 +194,7 @@ void AIS_LightSource::updateLightTransformPersistence()
} }
break; break;
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers; Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers;
if (myIsZoomable) if (myIsZoomable)
@ -221,8 +221,8 @@ void AIS_LightSource::updateLightTransformPersistence()
} }
break; break;
} }
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight() Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight()
? Graphic3d_TMF_CameraPers ? Graphic3d_TMF_CameraPers
@ -265,7 +265,7 @@ void AIS_LightSource::updateLightLocalTransformation()
myLocalTransformation.Nullify(); myLocalTransformation.Nullify();
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
if (myIsZoomable) if (myIsZoomable)
{ {
@ -275,7 +275,7 @@ void AIS_LightSource::updateLightLocalTransformation()
} }
break; break;
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
const gp_Pnt aLightPos = (myIsZoomable && !myLightSource->IsHeadlight()) const gp_Pnt aLightPos = (myIsZoomable && !myLightSource->IsHeadlight())
? myLightSource->DisplayPosition() ? myLightSource->DisplayPosition()
@ -286,7 +286,7 @@ void AIS_LightSource::updateLightLocalTransformation()
myLocalTransformation = new TopLoc_Datum3D (aTrsf); myLocalTransformation = new TopLoc_Datum3D (aTrsf);
break; break;
} }
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
{ {
if (myIsZoomable) if (myIsZoomable)
{ {
@ -296,7 +296,7 @@ void AIS_LightSource::updateLightLocalTransformation()
} }
break; break;
} }
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
gp_Trsf aTrsf; gp_Trsf aTrsf;
const gp_Ax2 anAx2 (myIsZoomable ? myLightSource->Position() : gp::Origin(), -myLightSource->Direction()); const gp_Ax2 anAx2 (myIsZoomable ? myLightSource->Position() : gp::Origin(), -myLightSource->Direction());
@ -317,11 +317,11 @@ void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theT
const gp_Trsf aTrsf = theTrsf->Transformation(); const gp_Trsf aTrsf = theTrsf->Transformation();
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
break; break;
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
gp_Dir aNewDir = (-gp::DZ()).Transformed (aTrsf); gp_Dir aNewDir = (-gp::DZ()).Transformed (aTrsf);
myLightSource->SetDirection (aNewDir); myLightSource->SetDirection (aNewDir);
@ -332,13 +332,13 @@ void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theT
} }
break; break;
} }
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
{ {
gp_Pnt aNewPos = gp::Origin().Transformed (aTrsf); gp_Pnt aNewPos = gp::Origin().Transformed (aTrsf);
myLightSource->SetPosition (aNewPos); myLightSource->SetPosition (aNewPos);
break; break;
} }
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
gp_Pnt aNewPos = gp::Origin().Transformed (aTrsf); gp_Pnt aNewPos = gp::Origin().Transformed (aTrsf);
myLightSource->SetPosition (aNewPos); myLightSource->SetPosition (aNewPos);
@ -379,10 +379,10 @@ void AIS_LightSource::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TOLS_AMBIENT: computeAmbient (thePrs, theMode); break; case Graphic3d_TypeOfLightSource_Ambient: computeAmbient (thePrs, theMode); break;
case Graphic3d_TOLS_DIRECTIONAL: computeDirectional(thePrs, theMode); break; case Graphic3d_TypeOfLightSource_Directional: computeDirectional(thePrs, theMode); break;
case Graphic3d_TOLS_POSITIONAL: computePositional (thePrs, theMode); break; case Graphic3d_TypeOfLightSource_Positional: computePositional (thePrs, theMode); break;
case Graphic3d_TOLS_SPOT: computeSpot (thePrs, theMode); break; case Graphic3d_TypeOfLightSource_Spot: computeSpot (thePrs, theMode); break;
} }
if (myToDisplayName) if (myToDisplayName)

View File

@ -25,6 +25,7 @@
#include <Draw_ProgressIndicator.hxx> #include <Draw_ProgressIndicator.hxx>
#include <Draw_SequenceOfDrawable3D.hxx> #include <Draw_SequenceOfDrawable3D.hxx>
#include <Message.hxx> #include <Message.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Map.hxx> #include <NCollection_Map.hxx>
#include <Standard_SStream.hxx> #include <Standard_SStream.hxx>
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -873,91 +874,110 @@ static Standard_Boolean Alphabetic(char c)
static Standard_Real Parse(char*&); static Standard_Real Parse(char*&);
static Standard_Real ParseValue(char*& name) static Standard_Real ParseValue (char*& theName)
{ {
while (*name == ' ' || *name == '\t') name++; while (*theName == ' ' || *theName == '\t') { ++theName; }
Standard_Real x = 0; Standard_Real x = 0;
switch (*name) { switch (*theName)
{
case '\0': case '\0':
{
break; break;
}
case '(': case '(':
name++; {
x = Parse(name); ++theName;
if (*name != ')') x = Parse (theName);
if (*theName != ')')
{
std::cout << "Mismatched parenthesis" << std::endl; std::cout << "Mismatched parenthesis" << std::endl;
name++; }
++theName;
break; break;
}
case '+': case '+':
name++; {
x = ParseValue(name); ++theName;
x = ParseValue (theName);
break; break;
}
case '-': case '-':
name++; {
x = - ParseValue(name); ++theName;
x = - ParseValue (theName);
break; break;
}
default: default:
{ {
// process a string // process a string
char* p = theName;
char* p = name; while (Numeric (*p)) { ++p; }
while (Numeric(*p)) p++;
// process scientific notation // process scientific notation
if ((*p == 'e') || (*p == 'E')) { if ((*p == 'e') || (*p == 'E'))
{
if (Numeric (*(p+1)) || *(p+1) == '+' || *(p+1) == '-') if (Numeric (*(p+1)) || *(p+1) == '+' || *(p+1) == '-')
{
p+= 2; p+= 2;
} }
while (Numeric(*p) || Alphabetic(*p)) p++; }
while (Numeric (*p) || Alphabetic (*p)) { p++; }
char c = *p; char c = *p;
*p = '\0'; *p = '\0';
if (Numeric(*name)) // numeric literal if (Numeric (*theName)) // numeric literal
x = Atof(name); {
else if (!Draw::Get((Standard_CString) name,x)) { // variable x = Atof (theName);
}
else if (!Draw::Get ((Standard_CString )theName, x)) // variable
{
// search for a function ... // search for a function ...
*p = c; *p = c;
// count arguments // count arguments
Standard_Integer argc = 1; Standard_Integer argc = 1;
char* q = p; char* q = p;
while ((*q == ' ') || (*q == '\t')) q++; while ((*q == ' ') || (*q == '\t')) { ++q; }
if (*q == '(') { if (*q == '(')
{
Standard_Integer pc = 1; Standard_Integer pc = 1;
argc = 2; argc = 2;
q++; q++;
while ((pc > 0) && *q) { while ((pc > 0) && *q)
if (*q == '(') pc++; {
if (*q == ')') pc--; if (*q == '(') { ++pc; }
if ((pc == 1) && (*q == ',')) argc++; if (*q == ')') { --pc; }
q++; if ((pc == 1) && (*q == ',')) { ++argc; }
++q;
} }
if (pc > 0) { if (pc > 0)
{
std::cout << "Unclosed parenthesis"<< std::endl; std::cout << "Unclosed parenthesis"<< std::endl;
x = 0; x = 0;
} }
else { else
{
// build function call // build function call
// replace , and first and last () by space // replace , and first and last () by space
if (argc > 1) { if (argc > 1)
{
Standard_Integer i = 2; Standard_Integer i = 2;
while (*p != '(') p++; while (*p != '(') { ++p; }
*p = ' '; *p = ' ';
p++; ++p;
pc = 1; pc = 1;
while (pc > 0) { while (pc > 0)
if (*p == '(') pc++; {
if (*p == ')') pc--; if (*p == '(') { ++pc; }
if ((pc == 1) && (*p == ',')) { if (*p == ')') { --pc; }
if ((pc == 1) && (*p == ','))
{
*p = ' '; *p = ' ';
p++; ++p;
i++; ++i;
} }
else else
p++; {
++p;
}
} }
*(p-1) = '\0'; *(p-1) = '\0';
c = *p; c = *p;
@ -965,36 +985,43 @@ static Standard_Real ParseValue(char*& name)
Draw_Interpretor& aCommands = Draw::GetInterpretor(); Draw_Interpretor& aCommands = Draw::GetInterpretor();
// call the function, save the current result // call the function, save the current result
char* sv = 0; TCollection_AsciiString sv (aCommands.Result());
if (*aCommands.Result()) { if (*aCommands.Result())
sv = new char [strlen(aCommands.Result())]; {
strcpy(sv,aCommands.Result());
aCommands.Reset(); aCommands.Reset();
} }
if (aCommands.Eval(name) != 0) { if (aCommands.Eval (theName) != 0)
std::cout << "Call of function " << name << " failed" << std::endl; {
std::cout << "Call of function " << theName << " failed" << std::endl;
x = 0; x = 0;
} }
else else
{
x = Atof (aCommands.Result()); x = Atof (aCommands.Result());
}
aCommands.Reset(); aCommands.Reset();
if (sv) { if (!sv.IsEmpty())
{
aCommands << sv; aCommands << sv;
delete [] sv;
} }
} }
} }
} }
else else
{
Draw_ParseFailed = Standard_True; Draw_ParseFailed = Standard_True;
} }
}
*p = c; *p = c;
name = p; theName = p;
} }
break; break;
} }
while (*name == ' ' || *name == '\t') name++;
while (*theName == ' ' || *theName == '\t')
{
++theName;
}
return x; return x;
} }
@ -1055,17 +1082,16 @@ static Standard_Real Parse(char*& name)
// function : Atof // function : Atof
// purpose : // purpose :
//======================================================================= //=======================================================================
Standard_Real Draw::Atof(const Standard_CString name) Standard_Real Draw::Atof(const Standard_CString theName)
{ {
// copy the string // copy the string
char* n = new char[1+strlen(name)]; NCollection_Array1<char> aBuff (0, (Standard_Integer )strlen (theName));
char* b = n; char* n = &aBuff.ChangeFirst();
strcpy(n,name); strcpy (n, theName);
Draw_ParseFailed = Standard_False; Draw_ParseFailed = Standard_False;
Standard_Real x = Parse(n); Standard_Real x = Parse(n);
while ((*n == ' ') || (*n == '\t')) n++; while ((*n == ' ') || (*n == '\t')) n++;
if (*n) Draw_ParseFailed = Standard_True; if (*n) Draw_ParseFailed = Standard_True;
delete [] b;
return x; return x;
} }

View File

@ -33,10 +33,10 @@ void Graphic3d_CLight::makeId()
TCollection_AsciiString aTypeSuffix; TCollection_AsciiString aTypeSuffix;
switch (myType) switch (myType)
{ {
case Graphic3d_TOLS_AMBIENT: aTypeSuffix = "amb"; break; case Graphic3d_TypeOfLightSource_Ambient: aTypeSuffix = "amb"; break;
case Graphic3d_TOLS_DIRECTIONAL: aTypeSuffix = "dir"; break; case Graphic3d_TypeOfLightSource_Directional: aTypeSuffix = "dir"; break;
case Graphic3d_TOLS_POSITIONAL: aTypeSuffix = "pos"; break; case Graphic3d_TypeOfLightSource_Positional: aTypeSuffix = "pos"; break;
case Graphic3d_TOLS_SPOT: aTypeSuffix = "spot"; break; case Graphic3d_TypeOfLightSource_Spot: aTypeSuffix = "spot"; break;
} }
myId = TCollection_AsciiString ("Graphic3d_CLight_") + aTypeSuffix myId = TCollection_AsciiString ("Graphic3d_CLight_") + aTypeSuffix
@ -62,23 +62,23 @@ Graphic3d_CLight::Graphic3d_CLight (Graphic3d_TypeOfLightSource theType)
{ {
switch (theType) switch (theType)
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
break; break;
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
mySmoothness = 0.2f; mySmoothness = 0.2f;
myIntensity = 20.0f; myIntensity = 20.0f;
break; break;
} }
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
{ {
changeConstAttenuation() = 1.0f; changeConstAttenuation() = 1.0f;
changeLinearAttenuation() = 0.0f; changeLinearAttenuation() = 0.0f;
break; break;
} }
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
changeConstAttenuation() = 1.0f; changeConstAttenuation() = 1.0f;
changeLinearAttenuation() = 0.0f; changeLinearAttenuation() = 0.0f;
@ -90,6 +90,39 @@ Graphic3d_CLight::Graphic3d_CLight (Graphic3d_TypeOfLightSource theType)
makeId(); makeId();
} }
// =======================================================================
// function : CopyFrom
// purpose :
// =======================================================================
void Graphic3d_CLight::CopyFrom (const Handle(Graphic3d_CLight)& theLight)
{
myName = theLight->myName;
myIsEnabled = theLight->myIsEnabled;
myIntensity = theLight->myIntensity;
myColor = theLight->myColor;
if (myType != Graphic3d_TypeOfLightSource_Ambient)
{
myPosition = theLight->myPosition;
myIsHeadlight = theLight->myIsHeadlight;
}
if ((myType == Graphic3d_TypeOfLightSource_Spot
|| myType == Graphic3d_TypeOfLightSource_Directional)
&& (theLight->myType == Graphic3d_TypeOfLightSource_Spot
|| theLight->myType == Graphic3d_TypeOfLightSource_Directional))
{
myDirection = theLight->myDirection;
}
if (myType == Graphic3d_TypeOfLightSource_Directional)
{
myToCastShadows = theLight->myToCastShadows;
}
if (myType == theLight->myType)
{
myParams = theLight->myParams;
mySmoothness = theLight->mySmoothness;
}
}
// ======================================================================= // =======================================================================
// function : SetColor // function : SetColor
// purpose : // purpose :
@ -116,7 +149,7 @@ void Graphic3d_CLight::SetEnabled (Standard_Boolean theIsOn)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetCastShadows (Standard_Boolean theToCast) void Graphic3d_CLight::SetCastShadows (Standard_Boolean theToCast)
{ {
if (myType != Graphic3d_TOLS_DIRECTIONAL) if (myType != Graphic3d_TypeOfLightSource_Directional)
{ {
throw Standard_NotImplemented ("Graphic3d_CLight::SetCastShadows() is not implemented for this light type"); throw Standard_NotImplemented ("Graphic3d_CLight::SetCastShadows() is not implemented for this light type");
} }
@ -130,7 +163,7 @@ void Graphic3d_CLight::SetCastShadows (Standard_Boolean theToCast)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetHeadlight (Standard_Boolean theValue) void Graphic3d_CLight::SetHeadlight (Standard_Boolean theValue)
{ {
if (myType == Graphic3d_TOLS_AMBIENT) if (myType == Graphic3d_TypeOfLightSource_Ambient)
{ {
throw Standard_ProgramError ("Graphic3d_CLight::SetHeadlight() is not applicable to ambient light"); throw Standard_ProgramError ("Graphic3d_CLight::SetHeadlight() is not applicable to ambient light");
} }
@ -144,8 +177,8 @@ void Graphic3d_CLight::SetHeadlight (Standard_Boolean theValue)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetDirection (const gp_Dir& theDir) void Graphic3d_CLight::SetDirection (const gp_Dir& theDir)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_SPOT Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Spot
&& myType != Graphic3d_TOLS_DIRECTIONAL, && myType != Graphic3d_TypeOfLightSource_Directional,
"Graphic3d_CLight::SetDirection(), incorrect light type"); "Graphic3d_CLight::SetDirection(), incorrect light type");
updateRevisionIf (Abs (myDirection.x() - static_cast<Standard_ShortReal> (theDir.X())) > ShortRealEpsilon() updateRevisionIf (Abs (myDirection.x() - static_cast<Standard_ShortReal> (theDir.X())) > ShortRealEpsilon()
|| Abs (myDirection.y() - static_cast<Standard_ShortReal> (theDir.Y())) > ShortRealEpsilon() || Abs (myDirection.y() - static_cast<Standard_ShortReal> (theDir.Y())) > ShortRealEpsilon()
@ -162,8 +195,8 @@ void Graphic3d_CLight::SetDirection (const gp_Dir& theDir)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetPosition (const gp_Pnt& thePosition) void Graphic3d_CLight::SetPosition (const gp_Pnt& thePosition)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_SPOT Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Spot
&& myType != Graphic3d_TOLS_POSITIONAL, && myType != Graphic3d_TypeOfLightSource_Positional,
"Graphic3d_CLight::SetPosition(), incorrect light type"); "Graphic3d_CLight::SetPosition(), incorrect light type");
updateRevisionIf (!myPosition.IsEqual (thePosition, gp::Resolution())); updateRevisionIf (!myPosition.IsEqual (thePosition, gp::Resolution()));
myPosition = thePosition; myPosition = thePosition;
@ -175,7 +208,7 @@ void Graphic3d_CLight::SetPosition (const gp_Pnt& thePosition)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetDisplayPosition (const gp_Pnt& thePosition) void Graphic3d_CLight::SetDisplayPosition (const gp_Pnt& thePosition)
{ {
Standard_ProgramError_Raise_if (myType == Graphic3d_TOLS_AMBIENT, Standard_ProgramError_Raise_if (myType == Graphic3d_TypeOfLightSource_Ambient,
"Graphic3d_CLight::SetDisplayPosition(), incorrect light type"); "Graphic3d_CLight::SetDisplayPosition(), incorrect light type");
updateRevisionIf (!myPosition.IsEqual (thePosition, gp::Resolution())); updateRevisionIf (!myPosition.IsEqual (thePosition, gp::Resolution()));
myPosition = thePosition; myPosition = thePosition;
@ -198,7 +231,7 @@ void Graphic3d_CLight::SetIntensity (Standard_ShortReal theValue)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetAngle (Standard_ShortReal theAngle) void Graphic3d_CLight::SetAngle (Standard_ShortReal theAngle)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_SPOT, Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Spot,
"Graphic3d_CLight::SetAngle(), incorrect light type"); "Graphic3d_CLight::SetAngle(), incorrect light type");
Standard_OutOfRange_Raise_if (theAngle <= 0.0 || theAngle >= M_PI, Standard_OutOfRange_Raise_if (theAngle <= 0.0 || theAngle >= M_PI,
"Graphic3d_CLight::SetAngle(), bad angle"); "Graphic3d_CLight::SetAngle(), bad angle");
@ -213,8 +246,8 @@ void Graphic3d_CLight::SetAngle (Standard_ShortReal theAngle)
void Graphic3d_CLight::SetAttenuation (Standard_ShortReal theConstAttenuation, void Graphic3d_CLight::SetAttenuation (Standard_ShortReal theConstAttenuation,
Standard_ShortReal theLinearAttenuation) Standard_ShortReal theLinearAttenuation)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_POSITIONAL Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Positional
&& myType != Graphic3d_TOLS_SPOT, && myType != Graphic3d_TypeOfLightSource_Spot,
"Graphic3d_CLight::SetAttenuation(), incorrect light type"); "Graphic3d_CLight::SetAttenuation(), incorrect light type");
Standard_OutOfRange_Raise_if (theConstAttenuation < 0.0f Standard_OutOfRange_Raise_if (theConstAttenuation < 0.0f
|| theLinearAttenuation < 0.0f || theLinearAttenuation < 0.0f
@ -231,7 +264,7 @@ void Graphic3d_CLight::SetAttenuation (Standard_ShortReal theConstAttenuation,
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetConcentration (Standard_ShortReal theConcentration) void Graphic3d_CLight::SetConcentration (Standard_ShortReal theConcentration)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_SPOT, "Graphic3d_CLight::SetConcentration(), incorrect light type"); Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Spot, "Graphic3d_CLight::SetConcentration(), incorrect light type");
Standard_OutOfRange_Raise_if (theConcentration < 0.0f || theConcentration > 1.0f, Standard_OutOfRange_Raise_if (theConcentration < 0.0f || theConcentration > 1.0f,
"Graphic3d_CLight::SetConcentration(), bad coefficient"); "Graphic3d_CLight::SetConcentration(), bad coefficient");
updateRevisionIf (Abs (changeConcentration() - theConcentration) > ShortRealEpsilon()); updateRevisionIf (Abs (changeConcentration() - theConcentration) > ShortRealEpsilon());
@ -244,8 +277,8 @@ void Graphic3d_CLight::SetConcentration (Standard_ShortReal theConcentration)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetSmoothRadius (Standard_ShortReal theValue) void Graphic3d_CLight::SetSmoothRadius (Standard_ShortReal theValue)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_POSITIONAL Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Positional
&& myType != Graphic3d_TOLS_SPOT, && myType != Graphic3d_TypeOfLightSource_Spot,
"Graphic3d_CLight::SetSmoothRadius(), incorrect light type"); "Graphic3d_CLight::SetSmoothRadius(), incorrect light type");
Standard_OutOfRange_Raise_if (theValue < 0.0f, "Graphic3d_CLight::SetSmoothRadius(), Bad value for smoothing radius"); Standard_OutOfRange_Raise_if (theValue < 0.0f, "Graphic3d_CLight::SetSmoothRadius(), Bad value for smoothing radius");
updateRevisionIf (Abs (mySmoothness - theValue) > ShortRealEpsilon()); updateRevisionIf (Abs (mySmoothness - theValue) > ShortRealEpsilon());
@ -258,7 +291,7 @@ void Graphic3d_CLight::SetSmoothRadius (Standard_ShortReal theValue)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetSmoothAngle (Standard_ShortReal theValue) void Graphic3d_CLight::SetSmoothAngle (Standard_ShortReal theValue)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_DIRECTIONAL, Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Directional,
"Graphic3d_CLight::SetSmoothAngle(), incorrect light type"); "Graphic3d_CLight::SetSmoothAngle(), incorrect light type");
Standard_OutOfRange_Raise_if (theValue < 0.0f || theValue > Standard_ShortReal(M_PI / 2.0), Standard_OutOfRange_Raise_if (theValue < 0.0f || theValue > Standard_ShortReal(M_PI / 2.0),
"Graphic3d_CLight::SetSmoothAngle(), Bad value for smoothing angle"); "Graphic3d_CLight::SetSmoothAngle(), Bad value for smoothing angle");
@ -272,7 +305,8 @@ void Graphic3d_CLight::SetSmoothAngle (Standard_ShortReal theValue)
// ======================================================================= // =======================================================================
void Graphic3d_CLight::SetRange (Standard_ShortReal theValue) void Graphic3d_CLight::SetRange (Standard_ShortReal theValue)
{ {
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_POSITIONAL && myType != Graphic3d_TOLS_SPOT, Standard_ProgramError_Raise_if (myType != Graphic3d_TypeOfLightSource_Positional
&& myType != Graphic3d_TypeOfLightSource_Spot,
"Graphic3d_CLight::SetRange(), incorrect light type"); "Graphic3d_CLight::SetRange(), incorrect light type");
Standard_OutOfRange_Raise_if (theValue < 0.0, "Graphic3d_CLight::SetRange(), Bad value for falloff range"); Standard_OutOfRange_Raise_if (theValue < 0.0, "Graphic3d_CLight::SetRange(), Bad value for falloff range");
updateRevisionIf (Abs (Range() - theValue) > ShortRealEpsilon()); updateRevisionIf (Abs (Range() - theValue) > ShortRealEpsilon());
@ -291,29 +325,29 @@ void Graphic3d_CLight::DumpJson (Standard_OStream& theOStream, Standard_Integer
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myId) OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myId)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName) OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName)
if (myType == Graphic3d_TOLS_SPOT || myType == Graphic3d_TOLS_POSITIONAL) if (myType == Graphic3d_TypeOfLightSource_Spot || myType == Graphic3d_TypeOfLightSource_Positional)
{ {
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPosition) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPosition)
} }
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColor) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColor)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIntensity) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIntensity)
if (myType == Graphic3d_TOLS_SPOT || myType == Graphic3d_TOLS_DIRECTIONAL) if (myType == Graphic3d_TypeOfLightSource_Spot || myType == Graphic3d_TypeOfLightSource_Directional)
{ {
gp_Dir aDirection = Direction(); gp_Dir aDirection = Direction();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aDirection) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aDirection)
} }
if (myType == Graphic3d_TOLS_POSITIONAL || myType == Graphic3d_TOLS_SPOT) if (myType == Graphic3d_TypeOfLightSource_Positional || myType == Graphic3d_TypeOfLightSource_Spot)
{ {
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ConstAttenuation()) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ConstAttenuation())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, LinearAttenuation()) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, LinearAttenuation())
} }
if (myType == Graphic3d_TOLS_SPOT) if (myType == Graphic3d_TypeOfLightSource_Spot)
{ {
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Angle()) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Angle())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Concentration()) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Concentration())
} }
if (myType == Graphic3d_TOLS_POSITIONAL || myType == Graphic3d_TOLS_SPOT) if (myType == Graphic3d_TypeOfLightSource_Positional || myType == Graphic3d_TypeOfLightSource_Spot)
{ {
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Range()) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Range())
} }

View File

@ -33,6 +33,9 @@ public:
//! Empty constructor, which should be followed by light source properties configuration. //! Empty constructor, which should be followed by light source properties configuration.
Standard_EXPORT Graphic3d_CLight (Graphic3d_TypeOfLightSource theType); Standard_EXPORT Graphic3d_CLight (Graphic3d_TypeOfLightSource theType);
//! Copy parameters from another light source excluding source type.
Standard_EXPORT void CopyFrom (const Handle(Graphic3d_CLight)& theLight);
//! Returns the Type of the Light, cannot be changed after object construction. //! Returns the Type of the Light, cannot be changed after object construction.
Graphic3d_TypeOfLightSource Type() const { return myType; } Graphic3d_TypeOfLightSource Type() const { return myType; }

View File

@ -22,10 +22,10 @@ namespace
//! Suffixes identifying light source type. //! Suffixes identifying light source type.
static const char THE_LIGHT_KEY_LETTERS[Graphic3d_TypeOfLightSource_NB] = static const char THE_LIGHT_KEY_LETTERS[Graphic3d_TypeOfLightSource_NB] =
{ {
'a', // Graphic3d_TOLS_AMBIENT 'a', // Graphic3d_TypeOfLightSource_Ambient
'd', // Graphic3d_TOLS_DIRECTIONAL 'd', // Graphic3d_TypeOfLightSource_Directional
'p', // Graphic3d_TOLS_POSITIONAL 'p', // Graphic3d_TypeOfLightSource_Positional
's' // Graphic3d_TOLS_SPOT 's' // Graphic3d_TypeOfLightSource_Spot
}; };
} }
@ -126,7 +126,7 @@ Standard_Size Graphic3d_LightSet::UpdateRevision()
} }
myLightTypesEnabled[aLight->Type()] += 1; myLightTypesEnabled[aLight->Type()] += 1;
if (aLight->Type() == Graphic3d_TOLS_AMBIENT) if (aLight->Type() == Graphic3d_TypeOfLightSource_Ambient)
{ {
myAmbient += aLight->PackedColor() * aLight->Intensity(); myAmbient += aLight->PackedColor() * aLight->Intensity();
} }
@ -145,12 +145,12 @@ Standard_Size Graphic3d_LightSet::UpdateRevision()
} }
aKeyLong[aLightLast] = '\0'; aKeyLong[aLightLast] = '\0';
myAmbient.a() = 1.0f; myAmbient.a() = 1.0f;
myNbEnabled = myLightTypesEnabled[Graphic3d_TOLS_DIRECTIONAL] myNbEnabled = myLightTypesEnabled[Graphic3d_TypeOfLightSource_Directional]
+ myLightTypesEnabled[Graphic3d_TOLS_POSITIONAL] + myLightTypesEnabled[Graphic3d_TypeOfLightSource_Positional]
+ myLightTypesEnabled[Graphic3d_TOLS_SPOT]; + myLightTypesEnabled[Graphic3d_TypeOfLightSource_Spot];
myKeyEnabledLong = aKeyLong; myKeyEnabledLong = aKeyLong;
myKeyEnabledShort = TCollection_AsciiString (myLightTypesEnabled[Graphic3d_TOLS_DIRECTIONAL] > 0 ? THE_LIGHT_KEY_LETTERS[Graphic3d_TOLS_DIRECTIONAL] : '\0') myKeyEnabledShort = TCollection_AsciiString (myLightTypesEnabled[Graphic3d_TypeOfLightSource_Directional] > 0 ? THE_LIGHT_KEY_LETTERS[Graphic3d_TypeOfLightSource_Directional] : '\0')
+ TCollection_AsciiString (myLightTypesEnabled[Graphic3d_TOLS_POSITIONAL] > 0 ? THE_LIGHT_KEY_LETTERS[Graphic3d_TOLS_POSITIONAL] : '\0') + TCollection_AsciiString (myLightTypesEnabled[Graphic3d_TypeOfLightSource_Positional] > 0 ? THE_LIGHT_KEY_LETTERS[Graphic3d_TypeOfLightSource_Positional] : '\0')
+ TCollection_AsciiString (myLightTypesEnabled[Graphic3d_TOLS_SPOT] > 0 ? THE_LIGHT_KEY_LETTERS[Graphic3d_TOLS_SPOT] : '\0'); + TCollection_AsciiString (myLightTypesEnabled[Graphic3d_TypeOfLightSource_Spot] > 0 ? THE_LIGHT_KEY_LETTERS[Graphic3d_TypeOfLightSource_Spot] : '\0');
return myRevision; return myRevision;
} }

View File

@ -88,7 +88,7 @@ public:
for (; myIter.More(); myIter.Next()) for (; myIter.More(); myIter.Next())
{ {
if ((myFilter & IterationFilter_ExcludeAmbient) != 0 if ((myFilter & IterationFilter_ExcludeAmbient) != 0
&& myIter.Key()->Type() == Graphic3d_TOLS_AMBIENT) && myIter.Key()->Type() == Graphic3d_TypeOfLightSource_Ambient)
{ {
continue; continue;
} }

View File

@ -1168,7 +1168,7 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
for (Graphic3d_LightSet::Iterator aLightIter (theLights, Graphic3d_LightSet::IterationFilter_ExcludeDisabledAndAmbient); for (Graphic3d_LightSet::Iterator aLightIter (theLights, Graphic3d_LightSet::IterationFilter_ExcludeDisabledAndAmbient);
aLightIter.More(); aLightIter.Next()) aLightIter.More(); aLightIter.Next())
{ {
if (aLightIter.Value()->Type() == Graphic3d_TOLS_DIRECTIONAL if (aLightIter.Value()->Type() == Graphic3d_TypeOfLightSource_Directional
&& aLightIter.Value()->ToCastShadows()) && aLightIter.Value()->ToCastShadows())
{ {
aLightsLoop = aLightsLoop + EOL" occDirectionalLight (" + anIndex + ", theNormal, theView, theIsFront," aLightsLoop = aLightsLoop + EOL" occDirectionalLight (" + anIndex + ", theNormal, theView, theIsFront,"
@ -1182,11 +1182,11 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
{ {
switch (aLightIter.Value()->Type()) switch (aLightIter.Value()->Type())
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
break; // skip ambient break; // skip ambient
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
if (theNbShadowMaps > 0 if (theNbShadowMaps > 0
&& aLightIter.Value()->ToCastShadows()) && aLightIter.Value()->ToCastShadows())
@ -1197,13 +1197,13 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
++anIndex; ++anIndex;
break; break;
} }
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
{ {
aLightsLoop = aLightsLoop + EOL" occPointLight (" + anIndex + ", theNormal, theView, aPoint, theIsFront);"; aLightsLoop = aLightsLoop + EOL" occPointLight (" + anIndex + ", theNormal, theView, aPoint, theIsFront);";
++anIndex; ++anIndex;
break; break;
} }
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
aLightsLoop = aLightsLoop + EOL" occSpotLight (" + anIndex + ", theNormal, theView, aPoint, theIsFront);"; aLightsLoop = aLightsLoop + EOL" occSpotLight (" + anIndex + ", theNormal, theView, aPoint, theIsFront);";
++anIndex; ++anIndex;
@ -1220,7 +1220,7 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
EOL" for (int anIndex = 0; anIndex < occLightSourcesCount; ++anIndex)" EOL" for (int anIndex = 0; anIndex < occLightSourcesCount; ++anIndex)"
EOL" {" EOL" {"
EOL" int aType = occLight_Type (anIndex);"; EOL" int aType = occLight_Type (anIndex);";
if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_DIRECTIONAL) > 0) if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Directional) > 0)
{ {
isFirstInLoop = false; isFirstInLoop = false;
aLightsLoop += aLightsLoop +=
@ -1229,7 +1229,7 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
EOL" occDirectionalLight (anIndex, theNormal, theView, theIsFront, 1.0);" EOL" occDirectionalLight (anIndex, theNormal, theView, theIsFront, 1.0);"
EOL" }"; EOL" }";
} }
if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_POSITIONAL) > 0) if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Positional) > 0)
{ {
if (!isFirstInLoop) if (!isFirstInLoop)
{ {
@ -1242,7 +1242,7 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
EOL" occPointLight (anIndex, theNormal, theView, aPoint, theIsFront);" EOL" occPointLight (anIndex, theNormal, theView, aPoint, theIsFront);"
EOL" }"; EOL" }";
} }
if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_SPOT) > 0) if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Spot) > 0)
{ {
if (!isFirstInLoop) if (!isFirstInLoop)
{ {
@ -1267,7 +1267,7 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
aLightsFunc += Shaders_PBRIllumination_glsl; aLightsFunc += Shaders_PBRIllumination_glsl;
} }
if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_DIRECTIONAL) == 1 if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Directional) == 1
&& theNbLights == 1 && theNbLights == 1
&& !theIsPBR && !theIsPBR
&& theNbShadowMaps == 0) && theNbShadowMaps == 0)
@ -1276,7 +1276,7 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
aLightsLoop = EOL" directionalLightFirst(theNormal, theView, theIsFront, 1.0);"; aLightsLoop = EOL" directionalLightFirst(theNormal, theView, theIsFront, 1.0);";
aLightsFunc += THE_FUNC_directionalLightFirst; aLightsFunc += THE_FUNC_directionalLightFirst;
} }
else if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_DIRECTIONAL) > 0) else if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Directional) > 0)
{ {
if (theNbShadowMaps > 0) if (theNbShadowMaps > 0)
{ {
@ -1284,11 +1284,11 @@ TCollection_AsciiString Graphic3d_ShaderManager::stdComputeLighting (Standard_In
} }
aLightsFunc += theIsPBR ? Shaders_PBRDirectionalLight_glsl : Shaders_PhongDirectionalLight_glsl; aLightsFunc += theIsPBR ? Shaders_PBRDirectionalLight_glsl : Shaders_PhongDirectionalLight_glsl;
} }
if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_POSITIONAL) > 0) if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Positional) > 0)
{ {
aLightsFunc += theIsPBR ? Shaders_PBRPointLight_glsl : Shaders_PhongPointLight_glsl; aLightsFunc += theIsPBR ? Shaders_PBRPointLight_glsl : Shaders_PhongPointLight_glsl;
} }
if (theLights->NbEnabledLightsOfType (Graphic3d_TOLS_SPOT) > 0) if (theLights->NbEnabledLightsOfType (Graphic3d_TypeOfLightSource_Spot) > 0)
{ {
aLightsFunc += theIsPBR ? Shaders_PBRSpotLight_glsl : Shaders_PhongSpotLight_glsl; aLightsFunc += theIsPBR ? Shaders_PBRSpotLight_glsl : Shaders_PhongSpotLight_glsl;
} }

View File

@ -20,21 +20,27 @@
//! Definition of all the type of light source. //! Definition of all the type of light source.
enum Graphic3d_TypeOfLightSource enum Graphic3d_TypeOfLightSource
{ {
Graphic3d_TOLS_AMBIENT, //!< ambient light Graphic3d_TypeOfLightSource_Ambient, //!< ambient light
Graphic3d_TOLS_DIRECTIONAL, //!< directional light Graphic3d_TypeOfLightSource_Directional, //!< directional light
Graphic3d_TOLS_POSITIONAL, //!< positional light Graphic3d_TypeOfLightSource_Positional, //!< positional light
Graphic3d_TOLS_SPOT, //!< spot light Graphic3d_TypeOfLightSource_Spot, //!< spot light
// obsolete aliases // obsolete aliases
V3d_AMBIENT = Graphic3d_TOLS_AMBIENT, Graphic3d_TOLS_AMBIENT = Graphic3d_TypeOfLightSource_Ambient,
V3d_DIRECTIONAL = Graphic3d_TOLS_DIRECTIONAL, Graphic3d_TOLS_DIRECTIONAL = Graphic3d_TypeOfLightSource_Directional,
V3d_POSITIONAL = Graphic3d_TOLS_POSITIONAL, Graphic3d_TOLS_POSITIONAL = Graphic3d_TypeOfLightSource_Positional,
V3d_SPOT = Graphic3d_TOLS_SPOT Graphic3d_TOLS_SPOT = Graphic3d_TypeOfLightSource_Spot,
//
V3d_AMBIENT = Graphic3d_TypeOfLightSource_Ambient,
V3d_DIRECTIONAL = Graphic3d_TypeOfLightSource_Directional,
V3d_POSITIONAL = Graphic3d_TypeOfLightSource_Positional,
V3d_SPOT = Graphic3d_TypeOfLightSource_Spot
}; };
enum enum
{ {
//! Auxiliary value defining the overall number of values in enumeration Graphic3d_TypeOfLightSource //! Auxiliary value defining the overall number of values in enumeration Graphic3d_TypeOfLightSource
Graphic3d_TypeOfLightSource_NB = Graphic3d_TOLS_SPOT + 1 Graphic3d_TypeOfLightSource_NB = Graphic3d_TypeOfLightSource_Spot + 1
}; };
#endif // _Graphic3d_TypeOfLightSource_HeaderFile #endif // _Graphic3d_TypeOfLightSource_HeaderFile

View File

@ -54,8 +54,11 @@ namespace
const Graphic3d_Vec4& aLightColor = theLight.PackedColor(); const Graphic3d_Vec4& aLightColor = theLight.PackedColor();
switch (theLight.Type()) switch (theLight.Type())
{ {
case Graphic3d_TOLS_AMBIENT : break; // handled by separate if-clause at beginning of method case Graphic3d_TypeOfLightSource_Ambient:
case Graphic3d_TOLS_DIRECTIONAL: {
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 // if the last parameter of GL_POSITION, is zero, the corresponding light source is a Directional one
const OpenGl_Vec4 anInfDir = -theLight.PackedDirectionRange(); const OpenGl_Vec4 anInfDir = -theLight.PackedDirectionRange();
@ -70,7 +73,7 @@ namespace
theCtx->core11ffp->glLightf (theLightGlId, GL_SPOT_CUTOFF, THE_DEFAULT_SPOT_CUTOFF); theCtx->core11ffp->glLightf (theLightGlId, GL_SPOT_CUTOFF, THE_DEFAULT_SPOT_CUTOFF);
break; 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 // 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); 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); theCtx->core11ffp->glLightf (theLightGlId, GL_QUADRATIC_ATTENUATION, 0.0f);
break; 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); 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); 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 (!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 // 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); aLightParams.Color = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 0.0f);
++aLightsNb; ++aLightsNb;
continue; continue;
@ -478,11 +481,11 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
aLightParams.Parameters = aLight.PackedParams(); aLightParams.Parameters = aLight.PackedParams();
switch (aLight.Type()) switch (aLight.Type())
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
break; break;
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
if (aLight.IsHeadlight()) if (aLight.IsHeadlight())
{ {
@ -496,7 +499,7 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
} }
break; break;
} }
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
if (aLight.IsHeadlight()) if (aLight.IsHeadlight())
{ {
@ -510,7 +513,7 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
} }
} }
Standard_FALLTHROUGH Standard_FALLTHROUGH
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
{ {
if (aLight.IsHeadlight()) if (aLight.IsHeadlight())
{ {

View File

@ -93,11 +93,11 @@ bool OpenGl_ShadowMap::UpdateCamera (const Graphic3d_CView& theView,
switch (myShadowLight->Type()) switch (myShadowLight->Type())
{ {
case Graphic3d_TOLS_AMBIENT: case Graphic3d_TypeOfLightSource_Ambient:
{ {
return false; // not applicable return false; // not applicable
} }
case Graphic3d_TOLS_DIRECTIONAL: case Graphic3d_TypeOfLightSource_Directional:
{ {
if (theOrigin != NULL) if (theOrigin != NULL)
{ {
@ -134,12 +134,12 @@ bool OpenGl_ShadowMap::UpdateCamera (const Graphic3d_CView& theView,
myLightMatrix = myShadowCamera->ProjectionMatrixF() * myShadowCamera->OrientationMatrixF(); myLightMatrix = myShadowCamera->ProjectionMatrixF() * myShadowCamera->OrientationMatrixF();
return true; return true;
} }
case Graphic3d_TOLS_POSITIONAL: case Graphic3d_TypeOfLightSource_Positional:
{ {
// render into cubemap shadowmap texture // render into cubemap shadowmap texture
return false; // not implemented return false; // not implemented
} }
case Graphic3d_TOLS_SPOT: case Graphic3d_TypeOfLightSource_Spot:
{ {
//myShadowCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective); //myShadowCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
//myShadowCamera->SetEye (theCastShadowLight->Position()); //myShadowCamera->SetEye (theCastShadowLight->Position());

View File

@ -154,7 +154,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
myWorkspace = new OpenGl_Workspace (this, NULL); 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); aLight->SetColor (Quantity_NOC_WHITE);
myLights = new Graphic3d_LightSet(); myLights = new Graphic3d_LightSet();
myNoShadingLight = new Graphic3d_LightSet(); myNoShadingLight = new Graphic3d_LightSet();

View File

@ -2440,7 +2440,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
aLightIter.More(); aLightIter.Next()) aLightIter.More(); aLightIter.Next())
{ {
const Graphic3d_CLight& aLight = *aLightIter.Value(); const Graphic3d_CLight& aLight = *aLightIter.Value();
if (aLight.Type() != Graphic3d_TOLS_DIRECTIONAL) if (aLight.Type() != Graphic3d_TypeOfLightSource_Directional)
{ {
aLightSources.push_back (aLightIter.Value()); 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); for (Graphic3d_LightSet::Iterator aLightIter (myLights, Graphic3d_LightSet::IterationFilter_ExcludeDisabledAndAmbient);
aLightIter.More(); aLightIter.Next()) aLightIter.More(); aLightIter.Next())
{ {
if (aLightIter.Value()->Type() == Graphic3d_TOLS_DIRECTIONAL) if (aLightIter.Value()->Type() == Graphic3d_TypeOfLightSource_Directional)
{ {
aLightSources.push_back (aLightIter.Value()); aLightSources.push_back (aLightIter.Value());
} }
@ -2484,7 +2484,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
-aLight.PackedDirectionRange().z(), -aLight.PackedDirectionRange().z(),
0.0f); 0.0f);
if (aLight.Type() != Graphic3d_TOLS_DIRECTIONAL) if (aLight.Type() != Graphic3d_TypeOfLightSource_Directional)
{ {
aPosition = BVH_Vec4f (static_cast<float>(aLight.Position().X()), aPosition = BVH_Vec4f (static_cast<float>(aLight.Position().X()),
static_cast<float>(aLight.Position().Y()), static_cast<float>(aLight.Position().Y()),

View File

@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_AmbientLight, Graphic3d_CLight)
// purpose : // purpose :
// ======================================================================= // =======================================================================
V3d_AmbientLight::V3d_AmbientLight (const Quantity_Color& theColor) V3d_AmbientLight::V3d_AmbientLight (const Quantity_Color& theColor)
: Graphic3d_CLight (Graphic3d_TOLS_AMBIENT) : Graphic3d_CLight (Graphic3d_TypeOfLightSource_Ambient)
{ {
SetColor (theColor); SetColor (theColor);
} }

View File

@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_DirectionalLight,V3d_PositionLight)
V3d_DirectionalLight::V3d_DirectionalLight (const V3d_TypeOfOrientation theDirection, V3d_DirectionalLight::V3d_DirectionalLight (const V3d_TypeOfOrientation theDirection,
const Quantity_Color& theColor, const Quantity_Color& theColor,
const Standard_Boolean theIsHeadlight) const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL) : V3d_PositionLight (Graphic3d_TypeOfLightSource_Directional)
{ {
SetColor (theColor); SetColor (theColor);
SetHeadlight (theIsHeadlight); SetHeadlight (theIsHeadlight);
@ -38,7 +38,7 @@ V3d_DirectionalLight::V3d_DirectionalLight (const V3d_TypeOfOrientation theDirec
V3d_DirectionalLight::V3d_DirectionalLight (const gp_Dir& theDirection, V3d_DirectionalLight::V3d_DirectionalLight (const gp_Dir& theDirection,
const Quantity_Color& theColor, const Quantity_Color& theColor,
const Standard_Boolean theIsHeadlight) const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL) : V3d_PositionLight (Graphic3d_TypeOfLightSource_Directional)
{ {
SetColor (theColor); SetColor (theColor);
SetHeadlight (theIsHeadlight); SetHeadlight (theIsHeadlight);

View File

@ -21,7 +21,7 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_PositionalLight,V3d_PositionLight)
// ======================================================================= // =======================================================================
V3d_PositionalLight::V3d_PositionalLight (const gp_Pnt& thePos, V3d_PositionalLight::V3d_PositionalLight (const gp_Pnt& thePos,
const Quantity_Color& theColor) const Quantity_Color& theColor)
: V3d_PositionLight (Graphic3d_TOLS_POSITIONAL) : V3d_PositionLight (Graphic3d_TypeOfLightSource_Positional)
{ {
SetColor (theColor); SetColor (theColor);
SetPosition (thePos); SetPosition (thePos);

View File

@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_SpotLight,V3d_PositionLight)
V3d_SpotLight::V3d_SpotLight (const gp_Pnt& thePos, V3d_SpotLight::V3d_SpotLight (const gp_Pnt& thePos,
const V3d_TypeOfOrientation theDirection, const V3d_TypeOfOrientation theDirection,
const Quantity_Color& theColor) const Quantity_Color& theColor)
: V3d_PositionLight (Graphic3d_TOLS_SPOT) : V3d_PositionLight (Graphic3d_TypeOfLightSource_Spot)
{ {
SetColor (theColor); SetColor (theColor);
SetPosition (thePos); SetPosition (thePos);
@ -38,7 +38,7 @@ V3d_SpotLight::V3d_SpotLight (const gp_Pnt& thePos,
V3d_SpotLight::V3d_SpotLight (const gp_Pnt& thePos, V3d_SpotLight::V3d_SpotLight (const gp_Pnt& thePos,
const gp_Dir& theDirection, const gp_Dir& theDirection,
const Quantity_Color& theColor) const Quantity_Color& theColor)
: V3d_PositionLight (Graphic3d_TOLS_SPOT) : V3d_PositionLight (Graphic3d_TypeOfLightSource_Spot)
{ {
SetColor (theColor); SetColor (theColor);
SetPosition (thePos); SetPosition (thePos);

View File

@ -439,8 +439,11 @@ void V3d_Viewer::SetDefaultLights()
DelLight (aLight); DelLight (aLight);
} }
Handle(V3d_DirectionalLight) aDirLight = new V3d_DirectionalLight (V3d_Zneg, Quantity_NOC_WHITE, Standard_True); Handle(V3d_DirectionalLight) aDirLight = new V3d_DirectionalLight (V3d_Zneg, Quantity_NOC_WHITE);
aDirLight->SetName ("headlight");
aDirLight->SetHeadlight (true);
Handle(V3d_AmbientLight) anAmbLight = new V3d_AmbientLight (Quantity_NOC_WHITE); Handle(V3d_AmbientLight) anAmbLight = new V3d_AmbientLight (Quantity_NOC_WHITE);
anAmbLight->SetName ("amblight");
AddLight (aDirLight); AddLight (aDirLight);
AddLight (anAmbLight); AddLight (anAmbLight);
SetLightOn (aDirLight); SetLightOn (aDirLight);

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ vdisplay -top -dispMode 1 -trsfPers zoom -trsfPersPos 1000 0 0 zp
vclipplane pln -equation -1 0 0 1000 -set vclipplane pln -equation -1 0 0 1000 -set
# check positional lights # check positional lights
vlight add positional pos 1000 0 0.001 color RED1 headlight 0 vlight pntlight -type POSITIONAL -pos 1000 0 0.001 -color RED1 -headlight 0
vremove f1000 vremove f1000
vmoveto 220 220 vmoveto 220 220

View File

@ -1,5 +1,5 @@
puts "========" puts "========"
puts "Test to verify the lights are turned off after 'vlight clear' (and scene is black)" puts "Test to verify the lights are turned off after 'vlight -clear' (and scene is black)"
puts "========" puts "========"
pload MODELING VISUALIZATION pload MODELING VISUALIZATION
@ -15,7 +15,7 @@ vsetdispmode 1
vdisplay b vdisplay b
vfit vfit
vlight clear vlight -clear
set color [vreadpixel 100 100 rgb] set color [vreadpixel 100 100 rgb]
set black "0 0 0" set black "0 0 0"

View File

@ -22,7 +22,7 @@ vdisplay s1 s2
vsetmaterial s1 Gold vsetmaterial s1 Gold
vsetmaterial s2 Silver vsetmaterial s2 Silver
vsetlocation s1 0.0 0.1 0.0 vsetlocation s1 0.0 0.1 0.0
vlight -change 0 -dir 0.667 -0.667 -0.333 vlight -change 0 -dir 0.667 -0.667 -0.333 -smoothAngle 6 -intensity 100
vturnview 3.0 -1.2 -0.1 vturnview 3.0 -1.2 -0.1
vfit vfit
@ -33,8 +33,6 @@ vrenderparams -rayDepth 12
set aModeNum 0 set aModeNum 0
vlight change 0 sm 0.1
vlight change 0 int 100
vbsdf s1 roughness 6400 vbsdf s1 roughness 6400
vfps 200 vfps 200

View File

@ -72,6 +72,6 @@ vfront
vturnview 0 -0.3 0 vturnview 0 -0.3 0
vfit vfit
vlight -change 0 -dir -0.577 -0.577 -0.577 vlight -change 0 -dir -0.577 -0.577 -0.577
vlight add directional vlight dirlight -type directional
vrenderparams -raytrace -raydepth 5 -shadows off -reflections -fsaa vrenderparams -raytrace -raydepth 5 -shadows off -reflections -fsaa
vdump ${imagedir}/${casename}.png vdump ${imagedir}/${casename}.png

View File

@ -10,7 +10,6 @@ tclean f
# draw box # draw box
vclear vclear
vclose ALL
vinit View1 vinit View1
vdefaults -absDefl 0.5 vdefaults -absDefl 0.5
vsetdispmode 1 vsetdispmode 1

View File

@ -10,7 +10,6 @@ tclean f
# draw box # draw box
vclear vclear
vclose ALL
vinit View1 vinit View1
vdefaults -absDefl 0.5 vdefaults -absDefl 0.5
vsetdispmode 1 vsetdispmode 1
@ -21,14 +20,10 @@ vrotate -0.5 0.0 0.0
vfit vfit
# setup lights # setup lights
vlight delete 0 vlight -clear
vlight delete 0 vlight amblight -type AMBIENT -color WHITE
vlight delete 0 vlight dirlight1 -type DIRECTIONAL -dir 1 0 0 -color GREEN -headlight 1
vlight delete 0 vlight dirlight2 -type DIRECTIONAL -dir -1 0 0 -color RED1 -headlight 1
vlight delete 0
vlight add ambient color WHITE
vlight add directional dir 1 0 0 color GREEN headlight 1
vlight add directional dir -1 0 0 color RED1 headlight 1
# take snapshot with fixed pipeline # take snapshot with fixed pipeline
vdump $::imagedir/${::casename}_OFF.png vdump $::imagedir/${::casename}_OFF.png

View File

@ -13,10 +13,10 @@ vdefaults -absDefl 0.5
vdisplay -dispMode 1 f vdisplay -dispMode 1 f
# setup lights # setup lights
vlight clear vlight -clear
vlight add ambient color WHITE vlight amblight -type AMBIENT -color WHITE
vlight add directional dir 1 0 0 color GREEN headlight 1 vlight dirlight1 -type DIRECTIONAL -dir 1 0 0 -color GREEN -headlight 1
vlight add directional dir -1 0 0 color RED1 headlight 1 vlight dirlight2 -type DIRECTIONAL -dir -1 0 0 -color RED1 -headlight 1
vrenderparams -shadingModel flat vrenderparams -shadingModel flat
vdump $::imagedir/${::casename}.png vdump $::imagedir/${::casename}.png

View File

@ -9,14 +9,10 @@ vclose ALL
vinit View1 vinit View1
vcaps -ffp 0 vcaps -ffp 0
vrenderparams -shadingModel vert vrenderparams -shadingModel vert
vlight delete 0 vlight -clear
vlight delete 0 vlight amblight -type AMBIENT -color WHITE
vlight delete 0 vlight dirlight1 -type DIRECTIONAL -dir 1 0 0 -color GREEN -headlight 1
vlight delete 0 vlight dirlight2 -type DIRECTIONAL -dir -1 0 0 -color RED1 -headlight 1
vlight delete 0
vlight add ambient color WHITE
vlight add directional dir 1 0 0 color GREEN headlight 1
vlight add directional dir -1 0 0 color RED1 headlight 1
# display shape # display shape
restore [locate_data_file occ/fuse.brep] f restore [locate_data_file occ/fuse.brep] f

View File

@ -28,8 +28,8 @@ vfit
# setup light # setup light
vcaps -ffp 0 vcaps -ffp 0
vrenderparams -shadingModel vert vrenderparams -shadingModel vert
vlight clear vlight -clear
vlight add positional pos $anX 0 0.001 color RED1 headLight 0 vlight pntlight -type POSITIONAL -pos $anX 0 0.001 -color RED1 -headLight 0
set aColor1 [vreadpixel 205 180 rgb name] set aColor1 [vreadpixel 205 180 rgb name]
set aColor2 [vreadpixel 205 210 rgb name] set aColor2 [vreadpixel 205 210 rgb name]

View File

@ -28,8 +28,8 @@ vfit
# setup light # setup light
vcaps -ffp 0 vcaps -ffp 0
vrenderparams -shadingModel vert vrenderparams -shadingModel vert
vlight clear vlight -clear
vlight add spotLight pos $anX 0 0.001 dir 0 0 -1 angle 60 constAtten 0.1 exponent 0.1 color RED1 headLight 0 vlight spot -type SPOTLIGHT -pos $anX 0 0.001 -dir 0 0 -1 -spotAngle 60 -constAtten 0.1 -exponent 0.1 -color RED1 -headLight 0
set aColor1 [vreadpixel 205 180 rgb name] set aColor1 [vreadpixel 205 180 rgb name]
set aColor2 [vreadpixel 205 220 rgb name] set aColor2 [vreadpixel 205 220 rgb name]

View File

@ -11,14 +11,10 @@ vclose ALL
vinit View1 vinit View1
vcaps -ffp 0 vcaps -ffp 0
vrenderparams -shadingModel phong vrenderparams -shadingModel phong
vlight delete 0 vlight -clear
vlight delete 0 vlight amblight -type AMBIENT -color WHITE
vlight delete 0 vlight dirlight1 -type DIRECTIONAL -dir 1 0 0 -color GREEN -headlight 1
vlight delete 0 vlight dirlight2 -type DIRECTIONAL -dir -1 0 0 -color RED1 -headlight 1
vlight delete 0
vlight add ambient color WHITE
vlight add directional dir 1 0 0 color GREEN headlight 1
vlight add directional dir -1 0 0 color RED1 headlight 1
# display shape # display shape
restore [locate_data_file occ/fuse.brep] f restore [locate_data_file occ/fuse.brep] f

View File

@ -32,12 +32,12 @@ set THE_LIGHTS {
{ -4 -1 0 MAGENTA } { -4 -1 0 MAGENTA }
{ 4 -1 0 MAGENTA3 } { 4 -1 0 MAGENTA3 }
} }
vlight clear vlight -clear
for { set aLightIter 1 } { $aLightIter <= 10 } { incr aLightIter } { for { set aLightIter 1 } { $aLightIter <= 10 } { incr aLightIter } {
set aLight [lindex $THE_LIGHTS [expr $aLightIter - 1]] set aLight [lindex $THE_LIGHTS [expr $aLightIter - 1]]
set aColor [lindex $aLight 3] set aColor [lindex $aLight 3]
set aPos [list [lindex $aLight 0] [lindex $aLight 1] [lindex $aLight 2]] set aPos [list [lindex $aLight 0] [lindex $aLight 1] [lindex $aLight 2]]
vlight add positional pos {*}$aPos color $aColor headLight 0 vlight pntlight${aLightIter} -type POSITIONAL -pos {*}$aPos -color $aColor -headLight 0
vpoint v${aLightIter} {*}$aPos vpoint v${aLightIter} {*}$aPos
vdrawtext t${aLightIter} "light${aLightIter} $aColor" -pos {*}$aPos -color $aColor vdrawtext t${aLightIter} "light${aLightIter} $aColor" -pos {*}$aPos -color $aColor
vdump $::imagedir/${::casename}_${aLightIter}.png vdump $::imagedir/${::casename}_${aLightIter}.png

View File

@ -11,7 +11,7 @@ vinit View1 -width 1024 -height 768
vaxo vaxo
vcaps -ffp 0 vcaps -ffp 0
vrenderparams -shadingModel phong vrenderparams -shadingModel phong
vlight clear vlight -clear
set THE_LIGHTS { set THE_LIGHTS {
{ -1 -1 -1 RED1 } { -1 -1 -1 RED1 }

View File

@ -17,7 +17,7 @@ vfit
# define lights # define lights
set THE_COLORS { RED1 YELLOW BLUE CYAN PURPLE WHITE HOTPINK GREEN MAGENTA MAGENTA3 } set THE_COLORS { RED1 YELLOW BLUE CYAN PURPLE WHITE HOTPINK GREEN MAGENTA MAGENTA3 }
vlight clear vlight -clear
set aNbColors 10 set aNbColors 10
set aLightIndex 0 set aLightIndex 0
set aConstAtten 0.1 set aConstAtten 0.1

View File

@ -28,8 +28,8 @@ vfit
# setup light # setup light
vcaps -ffp 0 vcaps -ffp 0
vrenderparams -shadingModel phong vrenderparams -shadingModel phong
vlight clear vlight -clear
vlight add spotLight pos $anX 0 0.001 dir 0 0 -1 angle 60 constAtten 0.1 exponent 0.1 color RED1 headLight 0 vlight spot -type SPOTLIGHT -pos $anX 0 0.001 -dir 0 0 -1 -spotAngle 60 -constAtten 0.1 -exponent 0.1 -color RED1 -headLight 0
set aColor1 [vreadpixel 205 180 rgb name] set aColor1 [vreadpixel 205 180 rgb name]
set aColor2 [vreadpixel 205 220 rgb name] set aColor2 [vreadpixel 205 220 rgb name]

View File

@ -13,8 +13,8 @@ box b 1 2 3
vdisplay b vdisplay b
vsetdispmode 1 vsetdispmode 1
vtexture b 0 vtexture b 0
vlight clear vlight -clear
vlight add ambient color white vlight amblight -type AMBIENT -color WHITE
vfit vfit
vtexture b -modulate off vtexture b -modulate off

View File

@ -14,10 +14,10 @@ vaspects b -material Brass
vfit vfit
puts "=== Add light sources and display their presentations ===" puts "=== Add light sources and display their presentations ==="
vlight -add ambient -color WHITE -name AMBIENT -display vlight AMBIENT -type AMBIENT -color WHITE -display
vlight -add directional -dir 0 1 0 -name DIR -color GREEN -display vlight DIR -type DIRECTIONAL -dir 0 1 0 -color GREEN -display
vlight -add spotlight -pos 50 25 25 -dir -1 0 0 -intensity 1000000000 -name SPOT -color RED -display vlight SPOT -type SPOTLIGHT -pos 50 25 25 -dir -1 0 0 -intensity 1000000000 -color RED -display
vlight -add positional -pos 25 25 50 -intensity 10000000000 -range 20 -name POSITIONAL -color BLUE -display vlight POSITIONAL -type POSITIONAL -pos 25 25 50 -intensity 10000000000 -range 20 -color BLUE -display
vdump $imagedir/${casename}_def.png vdump $imagedir/${casename}_def.png

View File

@ -8,21 +8,21 @@ vinit View1
vlight -clear vlight -clear
vbackground -color GRAY vbackground -color GRAY
vrenderparams -shadingModel PHONG vrenderparams -shadingModel PHONG
vlight -add ambient -COLOR WHITE -intensity 0.1 vlight amblight -type AMBIENT -color WHITE -intensity 0.1
box b 10 10 10 30 30 30 box b 10 10 10 30 30 30
vdisplay b -dispMode 1 vdisplay b -dispMode 1
vaspects b -material Brass vaspects b -material Brass
vfit vfit
puts "=== Check headlight option with spotlight ===" puts "=== Check headlight option with spotlight ==="
vlight -add spotlight -dir 0 0 -1 -head 1 -intensity 1000000000 -color GREEN -display aSpotlight vlight aSpotlight -type SPOTLIGHT -dir 0 0 -1 -head 1 -intensity 1000000000 -color GREEN -display
set aColor1 [vreadpixel 200 200 rgb name] set aColor1 [vreadpixel 200 200 rgb name]
if { "$aColor1" != "GREEN" } { puts "Error: expected color near the light is GREEN" } if { "$aColor1" != "GREEN" } { puts "Error: expected color near the light is GREEN" }
vdump $imagedir/${casename}_spot.png vdump $imagedir/${casename}_spot.png
puts "=== Check headlight option with positional light ===" puts "=== Check headlight option with positional light ==="
vlight -remove 1 vlight aSpotlight -remove
vlight -add positional -head 1 -color RED -display aPosLight vlight aPosLight -type POSITIONAL -head 1 -color RED -display
set aColor2 [vreadpixel 200 200 rgb name] set aColor2 [vreadpixel 200 200 rgb name]
if { "$aColor2" != "RED" } { puts "Error: expected color near the light is RED" } if { "$aColor2" != "RED" } { puts "Error: expected color near the light is RED" }
vdump $imagedir/${casename}_pos.png vdump $imagedir/${casename}_pos.png

View File

@ -8,12 +8,12 @@ vinit View1
vlight -clear vlight -clear
vbackground -color GRAY vbackground -color GRAY
vrenderparams -shadingModel PHONG vrenderparams -shadingModel PHONG
vlight -add ambient -COLOR WHITE -intensity 0.1 vlight amblight -type AMBIENT -color WHITE -intensity 0.1
box b 0 0 0 30 30 30 box b 0 0 0 30 30 30
vdisplay b -dispMode 1 vdisplay b -dispMode 1
vsetmaterial b Brass vsetmaterial b Brass
vfit vfit
vlight -add spotlight -pos 15 -10 15 -dir 0 1 0 -name aSpotLight -color RED -display vlight aSpotLight -type SPOTLIGHT -pos 15 -10 15 -dir 0 1 0 -color RED -display
puts "=== Attach manipulator ===" puts "=== Attach manipulator ==="
vmanipulator m -attach aSpotLight -adjustPosition location vmanipulator m -attach aSpotLight -adjustPosition location