mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0024310: TKOpenGl - GLSL compatibility issues
Lights defintion clean up: - remove duplicated enumeration TLightType (equals to Visual3d_TypeOfLightSource) - remove unused fields from Graphic3d_CLight - OpenGl_Light, reuse Graphic3d_CLight definition Phong GLSL program: - move out cumulative ambient light intencity from limited list of lights - compatibility issues, replace array of structures (light sources, materials, clipping planes) with arrays of primitive types New Draw Harness command vlight to alter light sources definition. OpenGl_ShaderProgram::Initialize() - add missing Linker log
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
class Light from Visual3d inherits TShared
|
||||
|
||||
---Version:
|
||||
@@ -43,17 +42,15 @@ class Light from Visual3d inherits TShared
|
||||
|
||||
uses
|
||||
|
||||
Color from Quantity,
|
||||
|
||||
CLight from Graphic3d,
|
||||
Vector from Graphic3d,
|
||||
Vertex from Graphic3d,
|
||||
|
||||
TypeOfLightSource from Visual3d
|
||||
Color from Quantity,
|
||||
CLight from Graphic3d,
|
||||
Vector from Graphic3d,
|
||||
Vertex from Graphic3d,
|
||||
TypeOfLightSource from Visual3d
|
||||
|
||||
raises
|
||||
|
||||
LightDefinitionError from Visual3d
|
||||
LightDefinitionError from Visual3d
|
||||
|
||||
is
|
||||
|
||||
@@ -207,12 +204,16 @@ is
|
||||
-- Category: Inquire methods
|
||||
----------------------------
|
||||
|
||||
Headlight ( me )
|
||||
returns Boolean from Standard is static;
|
||||
---Level: Public
|
||||
---Purpose: Returns the headlight state of the light <me>
|
||||
---Category: Inquire methods
|
||||
|
||||
Headlight ( me )
|
||||
returns Boolean from Standard is static;
|
||||
---Level: Public
|
||||
---Purpose: Returns the headlight state of the light <me>
|
||||
---Category: Inquire methods
|
||||
|
||||
SetHeadlight( me : mutable; theValue : Boolean from Standard ) is static;
|
||||
---Level: Public
|
||||
---Purpose: Setup headlight flag.
|
||||
|
||||
Color ( me )
|
||||
returns Color from Quantity is static;
|
||||
---Level: Public
|
||||
@@ -279,6 +280,14 @@ is
|
||||
-- if the type of the light is not TOLS_SPOT.
|
||||
raises LightDefinitionError is static;
|
||||
|
||||
CLight ( me )
|
||||
returns CLight from Graphic3d
|
||||
is static;
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
---Purpose: Returns the light defintion.
|
||||
---Category: Inquire methods
|
||||
|
||||
--------------------------
|
||||
-- Category: Class methods
|
||||
--------------------------
|
||||
@@ -309,32 +318,12 @@ is
|
||||
-- spot light spread angle.
|
||||
---Category: Private methods
|
||||
|
||||
--
|
||||
--
|
||||
|
||||
fields
|
||||
|
||||
--
|
||||
-- Class : Visual3d_Light
|
||||
--
|
||||
-- Purpose : Declaration of variables specific to light sources
|
||||
--
|
||||
-- Reminder : A light source is defined by:
|
||||
-- - its type
|
||||
-- - its colour
|
||||
-- - the attenuation factor ( positional and spot only)
|
||||
-- - its angle ( spot only )
|
||||
-- - its concentration ( spot only )
|
||||
-- - its direction ( directional and spot only )
|
||||
-- - its position ( positional and spot only )
|
||||
--
|
||||
-- It is actived in a context of view.
|
||||
--
|
||||
|
||||
-- the type
|
||||
MyType : TypeOfLightSource from Visual3d;
|
||||
|
||||
-- the associated C structure
|
||||
MyCLight : CLight from Graphic3d;
|
||||
-- the associated C structure
|
||||
myCLight : CLight from Graphic3d;
|
||||
|
||||
friends
|
||||
|
||||
|
@@ -16,509 +16,378 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/***********************************************************************
|
||||
|
||||
FUNCTION :
|
||||
----------
|
||||
File Visual3d_Light :
|
||||
|
||||
Declaration of variables specific to light sources
|
||||
|
||||
NOTES:
|
||||
----------
|
||||
|
||||
A light source is defined by :
|
||||
- type
|
||||
- color
|
||||
- reduction factors ( for positional and spot only )
|
||||
- its angle ( for spot only )
|
||||
- its concentration ( for spot only )
|
||||
- its direction ( directional and spot only )
|
||||
- its position ( positional and spot only )
|
||||
|
||||
It is active in a view, in the associated context.
|
||||
|
||||
ATTENTION:
|
||||
----------
|
||||
|
||||
- AngleCone is given in radian [Pex] while OpenGl works in
|
||||
degreees. The limits for Pex are [0,PI] while for OpenGl this is [0,90].
|
||||
- Two reduction factors are used with Pex while OpenGl uses three.
|
||||
- The ereduction factors have range [0.0,1.0] for Pex and
|
||||
for OpenGl the range is [0.0,n]
|
||||
- The concentration varies from [0.,1.0] for Pex to [0,128] for OpenGl.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Includes
|
||||
*/
|
||||
|
||||
#include <Visual3d_Light.ixx>
|
||||
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Visual3d_Light::Visual3d_Light ():
|
||||
MyType (Visual3d_TOLS_AMBIENT) {
|
||||
|
||||
MyCLight.WsId = -1;
|
||||
MyCLight.ViewId = 0; /* not used */
|
||||
MyCLight.LightType = int (MyType);
|
||||
MyCLight.Headlight = 0;
|
||||
|
||||
Quantity_Color White (Quantity_NOC_WHITE);
|
||||
|
||||
MyCLight.Color.r = float (White.Red ());
|
||||
MyCLight.Color.g = float (White.Green ());
|
||||
MyCLight.Color.b = float (White.Blue ());
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_False);
|
||||
|
||||
// =======================================================================
|
||||
// function : Visual3d_Light
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Visual3d_Light::Visual3d_Light()
|
||||
{
|
||||
myCLight.Type = Visual3d_TOLS_AMBIENT;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& Color):
|
||||
MyType (Visual3d_TOLS_AMBIENT) {
|
||||
|
||||
MyCLight.WsId = -1;
|
||||
MyCLight.ViewId = 0; /* not used */
|
||||
MyCLight.LightType = int (MyType);
|
||||
MyCLight.Headlight = 0;
|
||||
|
||||
MyCLight.Color.r = float (Color.Red ());
|
||||
MyCLight.Color.g = float (Color.Green ());
|
||||
MyCLight.Color.b = float (Color.Blue ());
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_False);
|
||||
|
||||
// =======================================================================
|
||||
// function : Visual3d_Light
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& theColor)
|
||||
{
|
||||
myCLight.Type = Visual3d_TOLS_AMBIENT;
|
||||
myCLight.Color.r() = Standard_ShortReal (theColor.Red());
|
||||
myCLight.Color.g() = Standard_ShortReal (theColor.Green());
|
||||
myCLight.Color.b() = Standard_ShortReal (theColor.Blue());
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Visual3d_Light::Visual3d_Light(const Quantity_Color& Color,const Graphic3d_Vector& Direction,const Standard_Boolean Headlight): MyType (Visual3d_TOLS_DIRECTIONAL) {
|
||||
|
||||
if (Direction.LengthZero ())
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightDirection");
|
||||
|
||||
MyCLight.WsId = -1;
|
||||
MyCLight.ViewId = 0; /* not used */
|
||||
MyCLight.LightType = int (MyType);
|
||||
MyCLight.Headlight = Headlight? 1:0;
|
||||
|
||||
Standard_Real Norme, X, Y, Z;
|
||||
|
||||
Color.Values (X, Y, Z, Quantity_TOC_RGB);
|
||||
MyCLight.Color.r = float (X);
|
||||
MyCLight.Color.g = float (Y);
|
||||
MyCLight.Color.b = float (Z);
|
||||
|
||||
Direction.Coord (X, Y, Z);
|
||||
Norme = Sqrt (X*X+Y*Y+Z*Z);
|
||||
// Direction.LengthZero () == Standard_False
|
||||
MyCLight.Direction.x = float (X/Norme);
|
||||
MyCLight.Direction.y = float (Y/Norme);
|
||||
MyCLight.Direction.z = float (Z/Norme);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_False);
|
||||
// =======================================================================
|
||||
// function : Visual3d_Light
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& theColor,
|
||||
const Graphic3d_Vector& theDir,
|
||||
const Standard_Boolean theIsHeadlight)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (theDir.LengthZero(),
|
||||
"Bad value for LightDirection");
|
||||
myCLight.Type = Visual3d_TOLS_DIRECTIONAL;
|
||||
myCLight.IsHeadlight = theIsHeadlight;
|
||||
myCLight.Color.r() = Standard_ShortReal (theColor.Red());
|
||||
myCLight.Color.g() = Standard_ShortReal (theColor.Green());
|
||||
myCLight.Color.b() = Standard_ShortReal (theColor.Blue());
|
||||
|
||||
Standard_Real X, Y, Z;
|
||||
theDir.Coord (X, Y, Z);
|
||||
const Standard_Real aNorm = Sqrt (X * X + Y * Y + Z * Z);
|
||||
myCLight.Direction.x() = Standard_ShortReal (X / aNorm);
|
||||
myCLight.Direction.y() = Standard_ShortReal (Y / aNorm);
|
||||
myCLight.Direction.z() = Standard_ShortReal (Z / aNorm);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& Color, const Graphic3d_Vertex& Position, const Standard_Real Fact1, const Standard_Real Fact2):
|
||||
MyType (Visual3d_TOLS_POSITIONAL) {
|
||||
|
||||
if ( (Fact1 == 0.0) && (Fact2 == 0.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if ( (Fact1 < 0.0) || (Fact1 > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if ( (Fact2 < 0.0) || (Fact2 > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
MyCLight.WsId = -1;
|
||||
MyCLight.ViewId = 0; /* not used */
|
||||
MyCLight.LightType = int (MyType);
|
||||
MyCLight.Headlight = 0;
|
||||
|
||||
MyCLight.Color.r = float (Color.Red ());
|
||||
MyCLight.Color.g = float (Color.Green ());
|
||||
MyCLight.Color.b = float (Color.Blue ());
|
||||
|
||||
MyCLight.Position.x = float (Position.X ());
|
||||
MyCLight.Position.y = float (Position.Y ());
|
||||
MyCLight.Position.z = float (Position.Z ());
|
||||
|
||||
MyCLight.Attenuation[0] = float (Fact1);
|
||||
MyCLight.Attenuation[1] = float (Fact2);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_False);
|
||||
|
||||
// =======================================================================
|
||||
// function : Visual3d_Light
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& theColor,
|
||||
const Graphic3d_Vertex& thePos,
|
||||
const Standard_Real theFact1,
|
||||
const Standard_Real theFact2)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if ((theFact1 == 0.0 && theFact2 == 0.0)
|
||||
|| (theFact1 < 0.0 || theFact1 > 1.0)
|
||||
|| (theFact2 < 0.0 || theFact2 > 1.0),
|
||||
"Bad value for LightAttenuation");
|
||||
myCLight.Type = Visual3d_TOLS_POSITIONAL;
|
||||
myCLight.IsHeadlight = Standard_False;
|
||||
myCLight.Color.r() = Standard_ShortReal (theColor.Red());
|
||||
myCLight.Color.g() = Standard_ShortReal (theColor.Green());
|
||||
myCLight.Color.b() = Standard_ShortReal (theColor.Blue());
|
||||
myCLight.Position.x() = Standard_ShortReal (thePos.X());
|
||||
myCLight.Position.y() = Standard_ShortReal (thePos.Y());
|
||||
myCLight.Position.z() = Standard_ShortReal (thePos.Z());
|
||||
myCLight.ChangeConstAttenuation() = Standard_ShortReal (theFact1);
|
||||
myCLight.ChangeLinearAttenuation() = Standard_ShortReal (theFact2);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
// =======================================================================
|
||||
// function : Visual3d_Light
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& theColor,
|
||||
const Graphic3d_Vertex& thePos,
|
||||
const Graphic3d_Vector& theDir,
|
||||
const Standard_Real theConcentration,
|
||||
const Standard_Real theFact1,
|
||||
const Standard_Real theFact2,
|
||||
const Standard_Real theAngleCone)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (theDir.LengthZero(),
|
||||
"Bad value for LightDirection");
|
||||
Visual3d_LightDefinitionError_Raise_if (theConcentration < 0.0 || theConcentration > 1.0,
|
||||
"Bad value for LightConcentration");
|
||||
Visual3d_LightDefinitionError_Raise_if ((theFact1 == 0.0 && theFact2 == 0.0)
|
||||
|| (theFact1 < 0.0 || theFact1 > 1.0)
|
||||
|| (theFact2 < 0.0 || theFact2 > 1.0),
|
||||
"Bad value for LightAttenuation");
|
||||
Visual3d_LightDefinitionError_Raise_if (!Visual3d_Light::IsValid (theAngleCone),
|
||||
"Bad value for LightAngle");
|
||||
myCLight.Type = Visual3d_TOLS_SPOT;
|
||||
myCLight.IsHeadlight = Standard_False;
|
||||
myCLight.Color.r() = Standard_ShortReal (theColor.Red());
|
||||
myCLight.Color.g() = Standard_ShortReal (theColor.Green());
|
||||
myCLight.Color.b() = Standard_ShortReal (theColor.Blue());
|
||||
myCLight.Position.x() = Standard_ShortReal (thePos.X());
|
||||
myCLight.Position.y() = Standard_ShortReal (thePos.Y());
|
||||
myCLight.Position.z() = Standard_ShortReal (thePos.Z());
|
||||
|
||||
Visual3d_Light::Visual3d_Light (const Quantity_Color& Color, const Graphic3d_Vertex& Position, const Graphic3d_Vector& Direction, const Standard_Real Concentration, const Standard_Real Fact1, const Standard_Real Fact2, const Standard_Real AngleCone):
|
||||
MyType (Visual3d_TOLS_SPOT) {
|
||||
|
||||
if (Direction.LengthZero ())
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightDirection");
|
||||
|
||||
if ( (Concentration < 0.0) || (Concentration > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightConcentration");
|
||||
|
||||
if ( (Fact1 == 0.0) && (Fact2 == 0.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if ( (Fact1 < 0.0) || (Fact1 > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if ( (Fact2 < 0.0) || (Fact2 > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if (Visual3d_Light::IsValid (AngleCone)) {
|
||||
|
||||
MyCLight.WsId = -1;
|
||||
MyCLight.ViewId = 0; /* not used */
|
||||
MyCLight.LightType = int (MyType);
|
||||
MyCLight.Headlight = 0;
|
||||
|
||||
Standard_Real X, Y, Z;
|
||||
|
||||
Color.Values (X, Y, Z, Quantity_TOC_RGB);
|
||||
MyCLight.Color.r = float (X);
|
||||
MyCLight.Color.g = float (Y);
|
||||
MyCLight.Color.b = float (Z);
|
||||
|
||||
Position.Coord (X, Y, Z);
|
||||
MyCLight.Position.x = float (X);
|
||||
MyCLight.Position.y = float (Y);
|
||||
MyCLight.Position.z = float (Z);
|
||||
|
||||
Direction.Coord (X, Y, Z);
|
||||
MyCLight.Direction.x = float (X);
|
||||
MyCLight.Direction.y = float (Y);
|
||||
MyCLight.Direction.z = float (Z);
|
||||
|
||||
MyCLight.Concentration = float (Concentration);
|
||||
|
||||
MyCLight.Attenuation[0] = float (Fact1);
|
||||
MyCLight.Attenuation[1] = float (Fact2);
|
||||
|
||||
MyCLight.Angle = float (AngleCone);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_False);
|
||||
|
||||
}
|
||||
else
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAngle");
|
||||
Standard_Real X, Y, Z;
|
||||
theDir.Coord (X, Y, Z);
|
||||
myCLight.Direction.x() = Standard_ShortReal (X);
|
||||
myCLight.Direction.y() = Standard_ShortReal (Y);
|
||||
myCLight.Direction.z() = Standard_ShortReal (Z);
|
||||
|
||||
myCLight.ChangeConcentration() = Standard_ShortReal (theConcentration);
|
||||
myCLight.ChangeConstAttenuation() = Standard_ShortReal (theFact1);
|
||||
myCLight.ChangeLinearAttenuation() = Standard_ShortReal (theFact2);
|
||||
myCLight.ChangeAngle() = Standard_ShortReal (theAngleCone);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Quantity_Color Visual3d_Light::Color () const {
|
||||
|
||||
Quantity_Color AColor (Standard_Real (MyCLight.Color.r),
|
||||
Standard_Real (MyCLight.Color.g),
|
||||
Standard_Real (MyCLight.Color.b),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
return (AColor);
|
||||
|
||||
// =======================================================================
|
||||
// function : Color
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Quantity_Color Visual3d_Light::Color() const
|
||||
{
|
||||
return Quantity_Color (Standard_Real (myCLight.Color.r()),
|
||||
Standard_Real (myCLight.Color.g()),
|
||||
Standard_Real (myCLight.Color.b()),
|
||||
Quantity_TOC_RGB);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Visual3d_TypeOfLightSource Visual3d_Light::LightType () const {
|
||||
|
||||
return (MyType);
|
||||
|
||||
// =======================================================================
|
||||
// function : LightType
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Visual3d_TypeOfLightSource Visual3d_Light::LightType() const
|
||||
{
|
||||
return (Visual3d_TypeOfLightSource )myCLight.Type;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
Standard_Boolean Visual3d_Light::Headlight () const {
|
||||
return MyCLight.Headlight==0? Standard_False:Standard_True;
|
||||
// =======================================================================
|
||||
// function : Headlight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Visual3d_Light::Headlight() const
|
||||
{
|
||||
return myCLight.IsHeadlight;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::Values (Quantity_Color& Color) const {
|
||||
|
||||
Quantity_Color AColor (Standard_Real (MyCLight.Color.r),
|
||||
Standard_Real (MyCLight.Color.g),
|
||||
Standard_Real (MyCLight.Color.b),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
if (MyType == Visual3d_TOLS_AMBIENT)
|
||||
Color = AColor;
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_AMBIENT");
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHeadlight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetHeadlight (const Standard_Boolean theValue)
|
||||
{
|
||||
myCLight.IsHeadlight = theValue;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::Values (Quantity_Color& Color, Graphic3d_Vector& Direction) const {
|
||||
|
||||
Quantity_Color AColor (Standard_Real (MyCLight.Color.r),
|
||||
Standard_Real (MyCLight.Color.g),
|
||||
Standard_Real (MyCLight.Color.b),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
Graphic3d_Vector ADirection (Standard_Real (MyCLight.Direction.x),
|
||||
Standard_Real (MyCLight.Direction.y),
|
||||
Standard_Real (MyCLight.Direction.z));
|
||||
|
||||
if (MyType == Visual3d_TOLS_DIRECTIONAL) {
|
||||
Color = AColor;
|
||||
Direction = ADirection;
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_DIRECTIONAL");
|
||||
|
||||
// =======================================================================
|
||||
// function : Values
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::Values (Quantity_Color& theColor) const
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_AMBIENT,
|
||||
"Light Type != Visual3d_TOLS_AMBIENT");
|
||||
theColor.SetValues (Standard_Real (myCLight.Color.r()),
|
||||
Standard_Real (myCLight.Color.g()),
|
||||
Standard_Real (myCLight.Color.b()),
|
||||
Quantity_TOC_RGB);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::Values (Quantity_Color& Color, Graphic3d_Vertex& Position, Standard_Real& Fact1, Standard_Real& Fact2) const {
|
||||
|
||||
Quantity_Color AColor (Standard_Real (MyCLight.Color.r),
|
||||
Standard_Real (MyCLight.Color.g),
|
||||
Standard_Real (MyCLight.Color.b),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
Graphic3d_Vertex APosition (Standard_Real (MyCLight.Position.x),
|
||||
Standard_Real (MyCLight.Position.y),
|
||||
Standard_Real (MyCLight.Position.z));
|
||||
|
||||
if (MyType == Visual3d_TOLS_POSITIONAL) {
|
||||
Color = AColor;
|
||||
Position = APosition;
|
||||
Fact1 = Standard_Real (MyCLight.Attenuation[0]);
|
||||
Fact2 = Standard_Real (MyCLight.Attenuation[1]);
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_POSITIONAL");
|
||||
|
||||
// =======================================================================
|
||||
// function : Values
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::Values (Quantity_Color& theColor,
|
||||
Graphic3d_Vector& theDir) const
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_DIRECTIONAL,
|
||||
"Light Type != Visual3d_TOLS_DIRECTIONAL");
|
||||
theColor.SetValues (Standard_Real (myCLight.Color.r()),
|
||||
Standard_Real (myCLight.Color.g()),
|
||||
Standard_Real (myCLight.Color.b()),
|
||||
Quantity_TOC_RGB);
|
||||
theDir.SetCoord (Standard_Real (myCLight.Direction.x()),
|
||||
Standard_Real (myCLight.Direction.y()),
|
||||
Standard_Real (myCLight.Direction.z()));
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::Values (Quantity_Color& Color, Graphic3d_Vertex& Position, Graphic3d_Vector& Direction, Standard_Real& Concentration, Standard_Real& Fact1, Standard_Real& Fact2, Standard_Real& AngleCone) const {
|
||||
|
||||
Quantity_Color AColor (Standard_Real (MyCLight.Color.r),
|
||||
Standard_Real (MyCLight.Color.g),
|
||||
Standard_Real (MyCLight.Color.b),
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
Graphic3d_Vertex APosition (Standard_Real (MyCLight.Position.x),
|
||||
Standard_Real (MyCLight.Position.y),
|
||||
Standard_Real (MyCLight.Position.z));
|
||||
|
||||
Graphic3d_Vector ADirection (Standard_Real (MyCLight.Direction.x),
|
||||
Standard_Real (MyCLight.Direction.y),
|
||||
Standard_Real (MyCLight.Direction.z));
|
||||
|
||||
if (MyType == Visual3d_TOLS_SPOT) {
|
||||
Color = AColor;
|
||||
Position = APosition;
|
||||
Direction = ADirection;
|
||||
Concentration = Standard_Real (MyCLight.Concentration);
|
||||
Fact1 = Standard_Real (MyCLight.Attenuation[0]);
|
||||
Fact2 = Standard_Real (MyCLight.Attenuation[1]);
|
||||
AngleCone = Standard_Real (MyCLight.Angle);
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : Values
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::Values (Quantity_Color& theColor,
|
||||
Graphic3d_Vertex& thePos,
|
||||
Standard_Real& theFact1,
|
||||
Standard_Real& theFact2) const
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_POSITIONAL,
|
||||
"Light Type != Visual3d_TOLS_POSITIONAL");
|
||||
theColor.SetValues (Standard_Real (myCLight.Color.r()),
|
||||
Standard_Real (myCLight.Color.g()),
|
||||
Standard_Real (myCLight.Color.b()),
|
||||
Quantity_TOC_RGB);
|
||||
thePos.SetCoord (Standard_Real (myCLight.Position.x()),
|
||||
Standard_Real (myCLight.Position.y()),
|
||||
Standard_Real (myCLight.Position.z()));
|
||||
theFact1 = Standard_Real (myCLight.ConstAttenuation());
|
||||
theFact2 = Standard_Real (myCLight.LinearAttenuation());
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetAngle (const Standard_Real AngleCone) {
|
||||
|
||||
if (! Visual3d_Light::IsValid (AngleCone))
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAngle");
|
||||
|
||||
if (MyType == Visual3d_TOLS_SPOT) {
|
||||
MyCLight.Angle = float (AngleCone);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : Values
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::Values (Quantity_Color& theColor,
|
||||
Graphic3d_Vertex& thePos,
|
||||
Graphic3d_Vector& theDir,
|
||||
Standard_Real& theConcentration,
|
||||
Standard_Real& theFact1,
|
||||
Standard_Real& theFact2,
|
||||
Standard_Real& theAngleCone) const
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_SPOT,
|
||||
"Light Type != Visual3d_TOLS_SPOT");
|
||||
theColor.SetValues (Standard_Real (myCLight.Color.r()),
|
||||
Standard_Real (myCLight.Color.g()),
|
||||
Standard_Real (myCLight.Color.b()),
|
||||
Quantity_TOC_RGB);
|
||||
thePos.SetCoord (Standard_Real (myCLight.Position.x()),
|
||||
Standard_Real (myCLight.Position.y()),
|
||||
Standard_Real (myCLight.Position.z()));
|
||||
theDir.SetCoord (Standard_Real (myCLight.Direction.x()),
|
||||
Standard_Real (myCLight.Direction.y()),
|
||||
Standard_Real (myCLight.Direction.z()));
|
||||
theConcentration = Standard_Real (myCLight.Concentration());
|
||||
theFact1 = Standard_Real (myCLight.ConstAttenuation());
|
||||
theFact2 = Standard_Real (myCLight.LinearAttenuation());
|
||||
theAngleCone = Standard_Real (myCLight.Angle());
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetAttenuation1 (const Standard_Real Fact1) {
|
||||
|
||||
if ( (Fact1 < 0.0) || (Fact1 > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if ( (MyType == Visual3d_TOLS_POSITIONAL) ||
|
||||
(MyType == Visual3d_TOLS_SPOT) ) {
|
||||
MyCLight.Attenuation[0] = float (Fact1);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_POSITIONAL and != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAngle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetAngle (const Standard_Real theAngleCone)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (!Visual3d_Light::IsValid (theAngleCone),
|
||||
"Bad value for LightAngle");
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_SPOT,
|
||||
"Light Type != Visual3d_TOLS_SPOT");
|
||||
myCLight.ChangeAngle() = Standard_ShortReal (theAngleCone);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetAttenuation2 (const Standard_Real Fact2) {
|
||||
|
||||
if ( (Fact2 < 0.0) || (Fact2 > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightAttenuation");
|
||||
|
||||
if ( (MyType == Visual3d_TOLS_POSITIONAL) ||
|
||||
(MyType == Visual3d_TOLS_SPOT) ) {
|
||||
MyCLight.Attenuation[1] = float (Fact2);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_POSITIONAL and != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAttenuation1
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetAttenuation1 (const Standard_Real theFact1)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (theFact1 < 0.0 || theFact1 > 1.0,
|
||||
"Bad value for LightAttenuation");
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_POSITIONAL
|
||||
&& myCLight.Type != Visual3d_TOLS_SPOT,
|
||||
"Light Type != Visual3d_TOLS_SPOT and != Visual3d_TOLS_POSITIONAL");
|
||||
myCLight.ChangeConstAttenuation() = Standard_ShortReal (theFact1);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetColor (const Quantity_Color& Color) {
|
||||
|
||||
MyCLight.Color.r = float (Color.Red ());
|
||||
MyCLight.Color.g = float (Color.Green ());
|
||||
MyCLight.Color.b = float (Color.Blue ());
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAttenuation2
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetAttenuation2 (const Standard_Real theFact2)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (theFact2 < 0.0 || theFact2 > 1.0,
|
||||
"Bad value for LightAttenuation");
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_POSITIONAL
|
||||
&& myCLight.Type != Visual3d_TOLS_SPOT,
|
||||
"Light Type != Visual3d_TOLS_SPOT and != Visual3d_TOLS_POSITIONAL");
|
||||
myCLight.ChangeLinearAttenuation() = Standard_ShortReal (theFact2);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetConcentration (const Standard_Real Concentration) {
|
||||
|
||||
if ( (Concentration < 0.0) || (Concentration > 1.0) )
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightConcentration");
|
||||
|
||||
if (MyType == Visual3d_TOLS_SPOT) {
|
||||
MyCLight.Concentration = float (Concentration);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : SetColor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetColor (const Quantity_Color& theColor)
|
||||
{
|
||||
myCLight.Color.r() = float (theColor.Red());
|
||||
myCLight.Color.g() = float (theColor.Green());
|
||||
myCLight.Color.b() = float (theColor.Blue());
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetDirection (const Graphic3d_Vector& Direction) {
|
||||
|
||||
if (Direction.LengthZero ())
|
||||
Visual3d_LightDefinitionError::Raise
|
||||
("Bad value for LightDirection");
|
||||
|
||||
if ( (MyType == Visual3d_TOLS_DIRECTIONAL) ||
|
||||
(MyType == Visual3d_TOLS_SPOT) ) {
|
||||
|
||||
Standard_Real Norme, X, Y, Z;
|
||||
Direction.Coord (X, Y, Z);
|
||||
Norme = Sqrt (X*X+Y*Y+Z*Z);
|
||||
// Direction.LengthZero () == Standard_False
|
||||
MyCLight.Direction.x = float (X/Norme);
|
||||
MyCLight.Direction.y = float (Y/Norme);
|
||||
MyCLight.Direction.z = float (Z/Norme);
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_DIRECTIONAL and != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : SetConcentration
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetConcentration (const Standard_Real theConcentration)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (theConcentration < 0.0 || theConcentration > 1.0,
|
||||
"Bad value for LightConcentration");
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_SPOT,
|
||||
"Light Type != Visual3d_TOLS_SPOT");
|
||||
myCLight.ChangeConcentration() = Standard_ShortReal (theConcentration);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void Visual3d_Light::SetPosition (const Graphic3d_Vertex& Position) {
|
||||
|
||||
if ( (MyType == Visual3d_TOLS_POSITIONAL) ||
|
||||
(MyType == Visual3d_TOLS_SPOT) ) {
|
||||
|
||||
MyCLight.Position.x = float (Position.X ());
|
||||
MyCLight.Position.y = float (Position.Y ());
|
||||
MyCLight.Position.z = float (Position.Z ());
|
||||
|
||||
MyCLight.LightId =
|
||||
Graphic3d_GraphicDriver::Light (MyCLight, Standard_True);
|
||||
|
||||
}
|
||||
else Visual3d_LightDefinitionError::Raise
|
||||
("Light Type != Visual3d_TOLS_POSITIONAL and != Visual3d_TOLS_SPOT");
|
||||
|
||||
// =======================================================================
|
||||
// function : SetDirection
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetDirection (const Graphic3d_Vector& theDir)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (theDir.LengthZero(),
|
||||
"Bad value for LightDirection");
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_SPOT
|
||||
&& myCLight.Type != Visual3d_TOLS_DIRECTIONAL,
|
||||
"Light Type != Visual3d_TOLS_DIRECTIONAL and != Visual3d_TOLS_SPOT");
|
||||
Standard_Real X, Y, Z;
|
||||
theDir.Coord (X, Y, Z);
|
||||
const Standard_Real aNorm = Sqrt (X * X + Y * Y + Z * Z);
|
||||
myCLight.Direction.x() = float (X / aNorm);
|
||||
myCLight.Direction.y() = float (Y / aNorm);
|
||||
myCLight.Direction.z() = float (Z / aNorm);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Standard_Integer Visual3d_Light::Limit () {
|
||||
|
||||
// Old method, replaced by GraphicDriver::InquireLightLimit ()
|
||||
return 0;
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Visual3d_Light::SetPosition (const Graphic3d_Vertex& thePos)
|
||||
{
|
||||
Visual3d_LightDefinitionError_Raise_if (myCLight.Type != Visual3d_TOLS_SPOT
|
||||
&& myCLight.Type != Visual3d_TOLS_POSITIONAL,
|
||||
"Light Type != Visual3d_TOLS_POSITIONAL and != Visual3d_TOLS_SPOT");
|
||||
myCLight.Position.x() = float (thePos.X());
|
||||
myCLight.Position.y() = float (thePos.Y());
|
||||
myCLight.Position.z() = float (thePos.Z());
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Standard_Integer Visual3d_Light::Identification () const {
|
||||
|
||||
return (Standard_Integer (MyCLight.LightId));
|
||||
|
||||
// =======================================================================
|
||||
// function : Limit
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Visual3d_Light::Limit()
|
||||
{
|
||||
// Old method, replaced by GraphicDriver::InquireLightLimit()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Standard_Boolean Visual3d_Light::IsValid (const Standard_Real AAngle) {
|
||||
|
||||
return ( (AAngle < M_PI) && (AAngle >= 0.0) );
|
||||
|
||||
// =======================================================================
|
||||
// function : Identification
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Visual3d_Light::Identification() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
// =======================================================================
|
||||
// function : IsValid
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Visual3d_Light::IsValid (const Standard_Real theAngle)
|
||||
{
|
||||
return (theAngle < M_PI)
|
||||
&& (theAngle >= 0.0);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : CLight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_CLight& Visual3d_Light::CLight() const
|
||||
{
|
||||
return myCLight;
|
||||
}
|
||||
|
@@ -79,9 +79,6 @@
|
||||
#define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
|
||||
// positions.
|
||||
|
||||
#define BUC60570 //GG 14-09-99 Don't activates lighting
|
||||
// when the view shading model is NONE.
|
||||
|
||||
#define GER61454 //GG 14-09-99 Activates model clipping planes
|
||||
|
||||
#define RIC120302 //GG Add a NEW SetWindow method which enable
|
||||
@@ -706,148 +703,45 @@ Standard_Real Rap;
|
||||
|
||||
}
|
||||
|
||||
void Visual3d_View::UpdateLights () {
|
||||
|
||||
Standard_Integer i, j;
|
||||
CALL_DEF_LIGHT *lights=NULL;
|
||||
|
||||
#ifdef BUC60570
|
||||
if( MyContext.Model() == Visual3d_TOM_NONE ) {
|
||||
// Activates only a white ambient light
|
||||
MyCView.Context.NbActiveLight = 1;
|
||||
lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
|
||||
MyCView.Context.ActiveLight = lights;
|
||||
|
||||
lights[0].WsId = MyCView.ViewId;
|
||||
lights[0].ViewId = MyCView.ViewId;
|
||||
lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
|
||||
lights[0].Active = 1;
|
||||
lights[0].LightId = 0;
|
||||
lights[0].Headlight = 0;
|
||||
lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
|
||||
} else {
|
||||
#endif
|
||||
i = MyContext.NumberOfActivatedLights ();
|
||||
j = MyGraphicDriver->InquireLightLimit ();
|
||||
MyCView.Context.NbActiveLight = (i > j ? j : i);
|
||||
|
||||
if (MyCView.Context.NbActiveLight > 0) {
|
||||
|
||||
// Dynamic Allocation
|
||||
lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
|
||||
|
||||
MyCView.Context.ActiveLight = lights;
|
||||
|
||||
Standard_Real X, Y, Z;
|
||||
|
||||
Standard_Real LightConcentration = 0.;
|
||||
Standard_Real LightAttenuation1 = 0.;
|
||||
Standard_Real LightAttenuation2 = 0.;
|
||||
Standard_Real LightAngle = 0.;
|
||||
Quantity_Color LightColor;
|
||||
Graphic3d_Vertex LightPosition;
|
||||
Graphic3d_Vector LightDirection;
|
||||
Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
|
||||
|
||||
// Parcing of light sources
|
||||
for (j=0; j<MyCView.Context.NbActiveLight; j++) {
|
||||
LightType = (MyContext.ActivatedLight (j+1))->LightType ();
|
||||
|
||||
lights[j].WsId = MyCView.ViewId;
|
||||
lights[j].ViewId = MyCView.ViewId;
|
||||
|
||||
lights[j].LightType = int (LightType);
|
||||
lights[j].Active = 1;
|
||||
lights[j].LightId =
|
||||
int ((MyContext.ActivatedLight (j+1))->Identification ());
|
||||
lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
|
||||
|
||||
switch (LightType) {
|
||||
|
||||
case Visual3d_TOLS_AMBIENT :
|
||||
(MyContext.ActivatedLight (j+1))->Values (
|
||||
LightColor
|
||||
);
|
||||
break;
|
||||
|
||||
case Visual3d_TOLS_POSITIONAL :
|
||||
(MyContext.ActivatedLight (j+1))->Values (
|
||||
LightColor,
|
||||
LightPosition,
|
||||
LightAttenuation1,
|
||||
LightAttenuation2
|
||||
);
|
||||
break;
|
||||
|
||||
case Visual3d_TOLS_DIRECTIONAL :
|
||||
(MyContext.ActivatedLight (j+1))->Values (
|
||||
LightColor,
|
||||
LightDirection
|
||||
);
|
||||
break;
|
||||
|
||||
case Visual3d_TOLS_SPOT :
|
||||
(MyContext.ActivatedLight (j+1))->Values (
|
||||
LightColor,
|
||||
LightPosition,
|
||||
LightDirection,
|
||||
LightConcentration,
|
||||
LightAttenuation1,
|
||||
LightAttenuation2,
|
||||
LightAngle
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
lights[j].Color.r = float (LightColor.Red ());
|
||||
lights[j].Color.g = float (LightColor.Green ());
|
||||
lights[j].Color.b = float (LightColor.Blue ());
|
||||
|
||||
if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
|
||||
(LightType == Visual3d_TOLS_SPOT) ) {
|
||||
LightPosition.Coord (X, Y, Z);
|
||||
lights[j].Position.x = float (X);
|
||||
lights[j].Position.y = float (Y);
|
||||
lights[j].Position.z = float (Z);
|
||||
}
|
||||
|
||||
if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
|
||||
(LightType == Visual3d_TOLS_SPOT) ) {
|
||||
LightDirection.Coord (X, Y, Z);
|
||||
lights[j].Direction.x = float (X);
|
||||
lights[j].Direction.y = float (Y);
|
||||
lights[j].Direction.z = float (Z);
|
||||
}
|
||||
|
||||
if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
|
||||
(LightType == Visual3d_TOLS_SPOT) ) {
|
||||
lights[j].Attenuation[0] =
|
||||
float (LightAttenuation1);
|
||||
lights[j].Attenuation[1] =
|
||||
float (LightAttenuation2);
|
||||
}
|
||||
|
||||
if (LightType == Visual3d_TOLS_SPOT) {
|
||||
lights[j].Concentration =
|
||||
float (LightConcentration);
|
||||
lights[j].Angle =
|
||||
float (LightAngle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef BUC60570
|
||||
void Visual3d_View::UpdateLights()
|
||||
{
|
||||
if (IsDeleted()
|
||||
|| !IsDefined())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// management of light sources
|
||||
if (! IsDeleted ())
|
||||
if (IsDefined ())
|
||||
MyGraphicDriver->SetLight (MyCView);
|
||||
|
||||
// Dynamic allocation
|
||||
if (MyCView.Context.NbActiveLight > 0) delete [] lights;
|
||||
if (MyContext.Model() == Visual3d_TOM_NONE)
|
||||
{
|
||||
// activate only a white ambient light
|
||||
Graphic3d_CLight aCLight;
|
||||
aCLight.Type = Visual3d_TOLS_AMBIENT;
|
||||
aCLight.IsHeadlight = Standard_False;
|
||||
aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f;
|
||||
|
||||
MyCView.Context.NbActiveLight = 1;
|
||||
MyCView.Context.ActiveLight = &aCLight;
|
||||
MyGraphicDriver->SetLight (MyCView);
|
||||
MyCView.Context.ActiveLight = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
|
||||
MyGraphicDriver->InquireLightLimit());
|
||||
if (MyCView.Context.NbActiveLight < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// parcing of light sources
|
||||
MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight];
|
||||
for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter)
|
||||
{
|
||||
MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
|
||||
}
|
||||
MyGraphicDriver->SetLight (MyCView);
|
||||
delete[] MyCView.Context.ActiveLight;
|
||||
MyCView.Context.ActiveLight = NULL;
|
||||
}
|
||||
|
||||
void Visual3d_View::UpdatePlanes()
|
||||
|
Reference in New Issue
Block a user