mirror of
https://github.com/leozide/leocad
synced 2024-12-26 21:58:44 +01:00
Added support for area size key frames.
This commit is contained in:
parent
e061eca2e8
commit
59c1930b83
8 changed files with 281 additions and 242 deletions
|
@ -76,6 +76,7 @@ class lcPiece;
|
||||||
class lcCamera;
|
class lcCamera;
|
||||||
class lcLight;
|
class lcLight;
|
||||||
enum class lcLightType;
|
enum class lcLightType;
|
||||||
|
enum class lcLightAreaShape;
|
||||||
class lcGroup;
|
class lcGroup;
|
||||||
class PieceInfo;
|
class PieceInfo;
|
||||||
typedef std::map<const PieceInfo*, std::map<int, int>> lcPartsList;
|
typedef std::map<const PieceInfo*, std::map<int, int>> lcPartsList;
|
||||||
|
|
|
@ -3163,7 +3163,9 @@ void lcModel::SetCameraName(lcCamera* Camera, const QString& Name)
|
||||||
|
|
||||||
void lcModel::SetLightType(lcLight* Light, lcLightType LightType)
|
void lcModel::SetLightType(lcLight* Light, lcLightType LightType)
|
||||||
{
|
{
|
||||||
Light->SetLightType(LightType);
|
if (!Light->SetLightType(LightType))
|
||||||
|
return;
|
||||||
|
|
||||||
Light->UpdatePosition(mCurrentStep);
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
SaveCheckpoint(tr("Changing Light Type"));
|
SaveCheckpoint(tr("Changing Light Type"));
|
||||||
|
@ -3173,9 +3175,6 @@ void lcModel::SetLightType(lcLight* Light, lcLightType LightType)
|
||||||
|
|
||||||
void lcModel::SetLightColor(lcLight* Light, const lcVector3& Color)
|
void lcModel::SetLightColor(lcLight* Light, const lcVector3& Color)
|
||||||
{
|
{
|
||||||
if (Light->GetColor() == Color)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Light->SetColor(Color, mCurrentStep, gMainWindow->GetAddKeys());
|
Light->SetColor(Color, mCurrentStep, gMainWindow->GetAddKeys());
|
||||||
Light->UpdatePosition(mCurrentStep);
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
@ -3186,9 +3185,6 @@ void lcModel::SetLightColor(lcLight* Light, const lcVector3& Color)
|
||||||
|
|
||||||
void lcModel::SetSpotLightConeAngle(lcLight* Light, float Angle)
|
void lcModel::SetSpotLightConeAngle(lcLight* Light, float Angle)
|
||||||
{
|
{
|
||||||
if (Light->GetSpotConeAngle() == Angle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Light->SetSpotConeAngle(Angle, mCurrentStep, gMainWindow->GetAddKeys());
|
Light->SetSpotConeAngle(Angle, mCurrentStep, gMainWindow->GetAddKeys());
|
||||||
Light->UpdatePosition(mCurrentStep);
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
@ -3199,9 +3195,6 @@ void lcModel::SetSpotLightConeAngle(lcLight* Light, float Angle)
|
||||||
|
|
||||||
void lcModel::SetSpotLightPenumbraAngle(lcLight* Light, float Angle)
|
void lcModel::SetSpotLightPenumbraAngle(lcLight* Light, float Angle)
|
||||||
{
|
{
|
||||||
if (Light->GetSpotPenumbraAngle() == Angle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Light->SetSpotPenumbraAngle(Angle, mCurrentStep, gMainWindow->GetAddKeys());
|
Light->SetSpotPenumbraAngle(Angle, mCurrentStep, gMainWindow->GetAddKeys());
|
||||||
Light->UpdatePosition(mCurrentStep);
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
@ -3212,9 +3205,6 @@ void lcModel::SetSpotLightPenumbraAngle(lcLight* Light, float Angle)
|
||||||
|
|
||||||
void lcModel::SetSpotLightTightness(lcLight* Light, float Tightness)
|
void lcModel::SetSpotLightTightness(lcLight* Light, float Tightness)
|
||||||
{
|
{
|
||||||
if (Light->GetSpotTightness() == Tightness)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Light->SetSpotTightness(Tightness, mCurrentStep, gMainWindow->GetAddKeys());
|
Light->SetSpotTightness(Tightness, mCurrentStep, gMainWindow->GetAddKeys());
|
||||||
Light->UpdatePosition(mCurrentStep);
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
@ -3223,12 +3213,33 @@ void lcModel::SetSpotLightTightness(lcLight* Light, float Tightness)
|
||||||
UpdateAllViews();
|
UpdateAllViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::SetLightCastShadow(lcLight* Light, bool CastShadow)
|
void lcModel::SetAreaLightShape(lcLight* Light, lcLightAreaShape LightAreaShape)
|
||||||
{
|
{
|
||||||
if (Light->GetCastShadow() == CastShadow)
|
if (!Light->SetAreaShape(LightAreaShape))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
SaveCheckpoint(tr("Changing Area Light Shape"));
|
||||||
|
gMainWindow->UpdateSelectedObjects(false);
|
||||||
|
UpdateAllViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcModel::SetAreaLightSize(lcLight* Light, lcVector2 LightAreaSize)
|
||||||
|
{
|
||||||
|
Light->SetAreaSize(LightAreaSize, mCurrentStep, gMainWindow->GetAddKeys());
|
||||||
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
SaveCheckpoint(tr("Changing Area Light Size"));
|
||||||
|
gMainWindow->UpdateSelectedObjects(false);
|
||||||
|
UpdateAllViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcModel::SetLightCastShadow(lcLight* Light, bool CastShadow)
|
||||||
|
{
|
||||||
|
if (!Light->SetCastShadow(CastShadow))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Light->SetCastShadow(CastShadow);
|
|
||||||
Light->UpdatePosition(mCurrentStep);
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
SaveCheckpoint(tr("Changing Light Shadow"));
|
SaveCheckpoint(tr("Changing Light Shadow"));
|
||||||
|
|
|
@ -373,6 +373,8 @@ public:
|
||||||
void SetSpotLightConeAngle(lcLight* Light, float Angle);
|
void SetSpotLightConeAngle(lcLight* Light, float Angle);
|
||||||
void SetSpotLightPenumbraAngle(lcLight* Light, float Angle);
|
void SetSpotLightPenumbraAngle(lcLight* Light, float Angle);
|
||||||
void SetSpotLightTightness(lcLight* Light, float Tightness);
|
void SetSpotLightTightness(lcLight* Light, float Tightness);
|
||||||
|
void SetAreaLightShape(lcLight* Light, lcLightAreaShape LightAreaShape);
|
||||||
|
void SetAreaLightSize(lcLight* Light, lcVector2 LightAreaSize);
|
||||||
void SetLightCastShadow(lcLight* Light, bool CastShadow);
|
void SetLightCastShadow(lcLight* Light, bool CastShadow);
|
||||||
void SetLightName(lcLight* Light, const QString& Name);
|
void SetLightName(lcLight* Light, const QString& Name);
|
||||||
void UpdateLight(lcLight* Light, const lcLightProperties Props, int Property);
|
void UpdateLight(lcLight* Light, const lcLightProperties Props, int Property);
|
||||||
|
|
192
common/light.cpp
192
common/light.cpp
|
@ -18,6 +18,7 @@
|
||||||
#define LC_LIGHT_POSITION_EDGE 7.5f
|
#define LC_LIGHT_POSITION_EDGE 7.5f
|
||||||
|
|
||||||
static const std::array<QLatin1String, static_cast<int>(lcLightType::Count)> gLightTypes = { QLatin1String("POINT"), QLatin1String("SPOT"), QLatin1String("DIRECTIONAL"), QLatin1String("AREA") };
|
static const std::array<QLatin1String, static_cast<int>(lcLightType::Count)> gLightTypes = { QLatin1String("POINT"), QLatin1String("SPOT"), QLatin1String("DIRECTIONAL"), QLatin1String("AREA") };
|
||||||
|
static const std::array<QLatin1String, static_cast<int>(lcLightAreaShape::Count)> gLightAreaShapes = { QLatin1String("RECTANGLE"), QLatin1String("SQUARE"), QLatin1String("DISK"), QLatin1String("ELLIPSE") };
|
||||||
|
|
||||||
lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
||||||
: lcObject(lcObjectType::Light), mLightType(LightType)
|
: lcObject(lcObjectType::Light), mLightType(LightType)
|
||||||
|
@ -35,8 +36,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
||||||
mPOVRayExponent = 1.0f;
|
mPOVRayExponent = 1.0f;
|
||||||
mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f;
|
mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f;
|
||||||
mAreaGrid = lcVector2(10.0f, 10.0f);
|
mAreaGrid = lcVector2(10.0f, 10.0f);
|
||||||
mAreaSize = lcVector2(200.0f, 200.0f);
|
|
||||||
mLightShape = LC_LIGHT_SHAPE_SQUARE;
|
|
||||||
|
|
||||||
mPositionKeys.ChangeKey(mWorldMatrix.GetTranslation(), 1, true);
|
mPositionKeys.ChangeKey(mWorldMatrix.GetTranslation(), 1, true);
|
||||||
mRotationKeys.ChangeKey(lcMatrix33(mWorldMatrix), 1, true);
|
mRotationKeys.ChangeKey(lcMatrix33(mWorldMatrix), 1, true);
|
||||||
|
@ -44,6 +43,7 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
||||||
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, true);
|
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, true);
|
||||||
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
|
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
|
||||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||||
|
mAreaSizeKeys.ChangeKey(mAreaSize, 1, true);
|
||||||
|
|
||||||
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
||||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||||
|
@ -56,7 +56,7 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
||||||
UpdatePosition(1);
|
UpdatePosition(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString lcLight::GetLightTypeString(lcLightType LightType)
|
QString lcLight::GetTypeString(lcLightType LightType)
|
||||||
{
|
{
|
||||||
switch (LightType)
|
switch (LightType)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,29 @@ QString lcLight::GetLightTypeString(lcLightType LightType)
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString lcLight::GetAreaShapeString(lcLightAreaShape LightAreaShape)
|
||||||
|
{
|
||||||
|
switch (LightAreaShape)
|
||||||
|
{
|
||||||
|
case lcLightAreaShape::Rectangle:
|
||||||
|
return QT_TRANSLATE_NOOP("Light Shapes", "Rectangle");
|
||||||
|
|
||||||
|
case lcLightAreaShape::Square:
|
||||||
|
return QT_TRANSLATE_NOOP("Light Shapes", "Square");
|
||||||
|
|
||||||
|
case lcLightAreaShape::Disk:
|
||||||
|
return QT_TRANSLATE_NOOP("Light Shapes", "Disk");
|
||||||
|
|
||||||
|
case lcLightAreaShape::Ellipse:
|
||||||
|
return QT_TRANSLATE_NOOP("Light Shapes", "Ellipse");
|
||||||
|
|
||||||
|
case lcLightAreaShape::Count:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
void lcLight::SaveLDraw(QTextStream& Stream) const
|
void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||||
{
|
{
|
||||||
const QLatin1String LineEnding("\r\n");
|
const QLatin1String LineEnding("\r\n");
|
||||||
|
@ -167,10 +190,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||||
else
|
else
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_TIGHTNESS ") << mSpotTightness << LineEnding;
|
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_TIGHTNESS ") << mSpotTightness << LineEnding;
|
||||||
|
|
||||||
if (mPOVRayLight)
|
if (!mPOVRayLight)
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (mLightFactorKeys.GetSize() > 1)
|
if (mLightFactorKeys.GetSize() > 1)
|
||||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_AND_SPOT_BLEND_KEY ");
|
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_AND_SPOT_BLEND_KEY ");
|
||||||
|
@ -202,44 +222,13 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||||
else
|
else
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_ROWS ") << mAreaGrid[0] << QLatin1String(" AREA_COLUMNS ") << mAreaGrid[1] << LineEnding;
|
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_ROWS ") << mAreaGrid[0] << QLatin1String(" AREA_COLUMNS ") << mAreaGrid[1] << LineEnding;
|
||||||
}
|
}
|
||||||
if (mLightFactorKeys.GetSize() > 1)
|
|
||||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT SIZE_KEY ");
|
Stream << QLatin1String("0 !LEOCAD LIGHT SHAPE ") << gLightAreaShapes[static_cast<int>(mAreaShape)] << LineEnding;
|
||||||
|
|
||||||
|
if (mAreaSizeKeys.GetSize() > 1)
|
||||||
|
mAreaSizeKeys.SaveKeysLDraw(Stream, "LIGHT AREA_SIZE_KEY ");
|
||||||
else
|
else
|
||||||
{
|
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_SIZE ") << mAreaSize[0] << mAreaSize[1] << LineEnding;
|
||||||
if (mPOVRayLight)
|
|
||||||
{
|
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT WIDTH ") << mAreaSize[0] << QLatin1String(" HEIGHT ") << mAreaSize[1] << LineEnding;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mLightShape == LC_LIGHT_SHAPE_RECTANGLE || mLightShape == LC_LIGHT_SHAPE_ELLIPSE || mLightFactor[1] > 0)
|
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT WIDTH ") << mLightFactor[0] << QLatin1String(" HEIGHT ") << mLightFactor[1] << LineEnding;
|
|
||||||
else
|
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT SIZE ") << mLightFactor[0] << LineEnding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT SHAPE ");
|
|
||||||
|
|
||||||
QString Shape = QLatin1String("UNDEFINED ");
|
|
||||||
|
|
||||||
switch (mLightShape)
|
|
||||||
{
|
|
||||||
case LC_LIGHT_SHAPE_SQUARE:
|
|
||||||
Shape = QLatin1String("SQUARE ");
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_SHAPE_DISK:
|
|
||||||
Shape = QLatin1String("DISK ");
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_SHAPE_RECTANGLE:
|
|
||||||
Shape = QLatin1String("RECTANGLE ");
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_SHAPE_ELLIPSE:
|
|
||||||
Shape = QLatin1String("ELLIPSE ");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT SHAPE ") << Shape << LineEnding;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -379,6 +368,28 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||||
}
|
}
|
||||||
else if (Token == QLatin1String("SPOT_TIGHTNESS_KEY"))
|
else if (Token == QLatin1String("SPOT_TIGHTNESS_KEY"))
|
||||||
mSpotTightnessKeys.LoadKeysLDraw(Stream);
|
mSpotTightnessKeys.LoadKeysLDraw(Stream);
|
||||||
|
else if (Token == QLatin1String("SHAPE"))
|
||||||
|
{
|
||||||
|
QString AreaShape;
|
||||||
|
Stream >> AreaShape;
|
||||||
|
|
||||||
|
for (size_t ShapeIndex = 0; ShapeIndex < gLightAreaShapes.size(); ShapeIndex++)
|
||||||
|
{
|
||||||
|
if (AreaShape == gLightAreaShapes[ShapeIndex])
|
||||||
|
{
|
||||||
|
mAreaShape = static_cast<lcLightAreaShape>(ShapeIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Token == QLatin1String("AREA_SIZE"))
|
||||||
|
{
|
||||||
|
Stream >> mAreaSize[0] >> mAreaSize[1];
|
||||||
|
mAreaSizeKeys.ChangeKey(mAreaSize, 1, true);
|
||||||
|
}
|
||||||
|
else if (Token == QLatin1String("AREA_SIZE_KEY"))
|
||||||
|
mAreaSizeKeys.LoadKeysLDraw(Stream);
|
||||||
|
|
||||||
else if (Token == QLatin1String("POWER") || Token == QLatin1String("STRENGTH"))
|
else if (Token == QLatin1String("POWER") || Token == QLatin1String("STRENGTH"))
|
||||||
{
|
{
|
||||||
if (mPOVRayLight)
|
if (mPOVRayLight)
|
||||||
|
@ -392,25 +403,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||||
mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true);
|
mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Token == QLatin1String("RADIUS") || Token == QLatin1String("SIZE") || Token == QLatin1String("WIDTH") || (mHeightSet = Token == QLatin1String("HEIGHT")) || (mSpotBlendSet = Token == QLatin1String("SPOT_BLEND")) || (mAngleSet = Token == QLatin1String("ANGLE")))
|
|
||||||
{
|
|
||||||
if (mPOVRayLight)
|
|
||||||
{
|
|
||||||
if (Token == QLatin1String("WIDTH"))
|
|
||||||
Stream >> mAreaSize[0];
|
|
||||||
else if (Token == QLatin1String("HEIGHT"))
|
|
||||||
Stream >> mAreaSize[1];
|
|
||||||
mLightFactorKeys.ChangeKey(mAreaSize, 1, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Token == QLatin1String("HEIGHT") || Token == QLatin1String("SPOT_BLEND"))
|
|
||||||
Stream >> mLightFactor[1];
|
|
||||||
else
|
|
||||||
Stream >> mLightFactor[0];
|
|
||||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Token == QLatin1String("AREA_ROWS"))
|
else if (Token == QLatin1String("AREA_ROWS"))
|
||||||
{
|
{
|
||||||
mPOVRayLight = true;
|
mPOVRayLight = true;
|
||||||
|
@ -423,21 +415,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||||
Stream >> mAreaGrid[1];
|
Stream >> mAreaGrid[1];
|
||||||
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
|
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
|
||||||
}
|
}
|
||||||
else if (Token == QLatin1String("SHAPE"))
|
|
||||||
{
|
|
||||||
QString Shape;
|
|
||||||
Stream >> Shape;
|
|
||||||
Shape.replace("\"", "");
|
|
||||||
|
|
||||||
if (Shape == QLatin1String("SQUARE"))
|
|
||||||
mLightShape = LC_LIGHT_SHAPE_SQUARE;
|
|
||||||
else if (Shape == QLatin1String("DISK") || Shape == QLatin1String("CIRCLE"))
|
|
||||||
mLightShape = LC_LIGHT_SHAPE_DISK;
|
|
||||||
else if (Shape == QLatin1String("RECTANGLE"))
|
|
||||||
mLightShape = LC_LIGHT_SHAPE_RECTANGLE;
|
|
||||||
else if (Shape == QLatin1String("ELLIPSE"))
|
|
||||||
mLightShape = LC_LIGHT_SHAPE_ELLIPSE;
|
|
||||||
}
|
|
||||||
else if (Token == QLatin1String("DIFFUSE"))
|
else if (Token == QLatin1String("DIFFUSE"))
|
||||||
{
|
{
|
||||||
Stream >>mLightDiffuse;
|
Stream >>mLightDiffuse;
|
||||||
|
@ -522,14 +499,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcLightType::Area:
|
case lcLightType::Area:
|
||||||
if (mLightShape == LC_LIGHT_SHAPE_RECTANGLE || mLightShape == LC_LIGHT_SHAPE_ELLIPSE)
|
|
||||||
{
|
|
||||||
if (!mHeightSet)
|
|
||||||
{
|
|
||||||
mLightFactor[1] = 0.25f;
|
|
||||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcLightType::Count:
|
case lcLightType::Count:
|
||||||
|
@ -557,9 +526,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property)
|
||||||
{
|
{
|
||||||
switch(Property)
|
switch(Property)
|
||||||
{
|
{
|
||||||
case LC_LIGHT_SHAPE:
|
|
||||||
mLightShape = Props.mLightShape;
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_FACTOR:
|
case LC_LIGHT_FACTOR:
|
||||||
if (Props.mPOVRayLight && mLightType == lcLightType::Area)
|
if (Props.mPOVRayLight && mLightType == lcLightType::Area)
|
||||||
{
|
{
|
||||||
|
@ -755,12 +721,18 @@ void lcLight::Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix,
|
||||||
SetRotation(NewLocalToWorldMatrix, Step, AddKey);
|
SetRotation(NewLocalToWorldMatrix, Step, AddKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcLight::SetLightType(lcLightType LightType)
|
bool lcLight::SetLightType(lcLightType LightType)
|
||||||
{
|
{
|
||||||
if (static_cast<int>(LightType) < 0 || LightType >= lcLightType::Count)
|
if (static_cast<int>(LightType) < 0 || LightType >= lcLightType::Count)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
if (mLightType != LightType)
|
||||||
|
{
|
||||||
mLightType = LightType;
|
mLightType = LightType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcLight::SetColor(const lcVector3& Color, lcStep Step, bool AddKey)
|
void lcLight::SetColor(const lcVector3& Color, lcStep Step, bool AddKey)
|
||||||
|
@ -783,9 +755,37 @@ void lcLight::SetSpotTightness(float Tightness, lcStep Step, bool AddKey)
|
||||||
mSpotTightnessKeys.ChangeKey(Tightness, Step, AddKey);
|
mSpotTightnessKeys.ChangeKey(Tightness, Step, AddKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcLight::SetCastShadow(bool CastShadow)
|
bool lcLight::SetAreaShape(lcLightAreaShape AreaShape)
|
||||||
{
|
{
|
||||||
|
if (static_cast<int>(AreaShape) < 0 || AreaShape >= lcLightAreaShape::Count)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (mAreaShape != AreaShape)
|
||||||
|
{
|
||||||
|
mAreaShape = AreaShape;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcLight::SetAreaSize(lcVector2 AreaSize, lcStep Step, bool AddKey)
|
||||||
|
{
|
||||||
|
if (mAreaShape == lcLightAreaShape::Square || mAreaShape == lcLightAreaShape::Disk)
|
||||||
|
AreaSize[1] = AreaSize[0];
|
||||||
|
|
||||||
|
mAreaSizeKeys.ChangeKey(AreaSize, Step, AddKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lcLight::SetCastShadow(bool CastShadow)
|
||||||
|
{
|
||||||
|
if (mCastShadow != CastShadow)
|
||||||
|
{
|
||||||
mCastShadow = CastShadow;
|
mCastShadow = CastShadow;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcLight::InsertTime(lcStep Start, lcStep Time)
|
void lcLight::InsertTime(lcStep Start, lcStep Time)
|
||||||
|
@ -796,6 +796,7 @@ void lcLight::InsertTime(lcStep Start, lcStep Time)
|
||||||
mSpotConeAngleKeys.InsertTime(Start, Time);
|
mSpotConeAngleKeys.InsertTime(Start, Time);
|
||||||
mSpotPenumbraAngleKeys.InsertTime(Start, Time);
|
mSpotPenumbraAngleKeys.InsertTime(Start, Time);
|
||||||
mSpotTightnessKeys.InsertTime(Start, Time);
|
mSpotTightnessKeys.InsertTime(Start, Time);
|
||||||
|
mAreaSizeKeys.InsertTime(Start, Time);
|
||||||
|
|
||||||
mAttenuationKeys.InsertTime(Start, Time);
|
mAttenuationKeys.InsertTime(Start, Time);
|
||||||
mLightFactorKeys.InsertTime(Start, Time);
|
mLightFactorKeys.InsertTime(Start, Time);
|
||||||
|
@ -814,6 +815,7 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time)
|
||||||
mSpotConeAngleKeys.RemoveTime(Start, Time);
|
mSpotConeAngleKeys.RemoveTime(Start, Time);
|
||||||
mSpotPenumbraAngleKeys.RemoveTime(Start, Time);
|
mSpotPenumbraAngleKeys.RemoveTime(Start, Time);
|
||||||
mSpotTightnessKeys.RemoveTime(Start, Time);
|
mSpotTightnessKeys.RemoveTime(Start, Time);
|
||||||
|
mAreaSizeKeys.RemoveTime(Start, Time);
|
||||||
|
|
||||||
mAttenuationKeys.RemoveTime(Start, Time);
|
mAttenuationKeys.RemoveTime(Start, Time);
|
||||||
mLightFactorKeys.RemoveTime(Start, Time);
|
mLightFactorKeys.RemoveTime(Start, Time);
|
||||||
|
@ -843,6 +845,7 @@ void lcLight::UpdatePosition(lcStep Step)
|
||||||
mSpotConeAngle = mSpotConeAngleKeys.CalculateKey(Step);
|
mSpotConeAngle = mSpotConeAngleKeys.CalculateKey(Step);
|
||||||
mSpotPenumbraAngle = mSpotPenumbraAngleKeys.CalculateKey(Step);
|
mSpotPenumbraAngle = mSpotPenumbraAngleKeys.CalculateKey(Step);
|
||||||
mSpotTightness = mSpotTightnessKeys.CalculateKey(Step);
|
mSpotTightness = mSpotTightnessKeys.CalculateKey(Step);
|
||||||
|
mAreaSize = mAreaSizeKeys.CalculateKey(Step);
|
||||||
|
|
||||||
mAttenuation = mAttenuationKeys.CalculateKey(Step);
|
mAttenuation = mAttenuationKeys.CalculateKey(Step);
|
||||||
mLightFactor = mLightFactorKeys.CalculateKey(Step);
|
mLightFactor = mLightFactorKeys.CalculateKey(Step);
|
||||||
|
@ -946,7 +949,7 @@ void lcLight::DrawAreaLight(lcContext* Context) const
|
||||||
{
|
{
|
||||||
SetupLightMatrix(Context);
|
SetupLightMatrix(Context);
|
||||||
|
|
||||||
if (mLightShape == LC_LIGHT_SHAPE_SQUARE || mLightShape == LC_LIGHT_SHAPE_RECTANGLE)
|
if (mAreaShape == lcLightAreaShape::Square || mAreaShape == lcLightAreaShape::Rectangle)
|
||||||
{
|
{
|
||||||
float Verts[4 * 3];
|
float Verts[4 * 3];
|
||||||
float* CurVert = Verts;
|
float* CurVert = Verts;
|
||||||
|
@ -1271,6 +1274,9 @@ void lcLight::RemoveKeyFrames()
|
||||||
mSpotTightnessKeys.RemoveAll();
|
mSpotTightnessKeys.RemoveAll();
|
||||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||||
|
|
||||||
|
mAreaSizeKeys.RemoveAll();
|
||||||
|
mAreaSizeKeys.ChangeKey(mAreaSize, 1, true);
|
||||||
|
|
||||||
mAttenuationKeys.RemoveAll();
|
mAttenuationKeys.RemoveAll();
|
||||||
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
||||||
|
|
||||||
|
|
|
@ -25,20 +25,17 @@ enum class lcLightType
|
||||||
Count
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lcLightShape
|
enum class lcLightAreaShape
|
||||||
{
|
{
|
||||||
LC_LIGHT_SHAPE_UNDEFINED = -1,
|
Rectangle,
|
||||||
LC_LIGHT_SHAPE_SQUARE,
|
Square,
|
||||||
LC_LIGHT_SHAPE_DISK,
|
Disk,
|
||||||
LC_LIGHT_SHAPE_RECTANGLE,
|
Ellipse,
|
||||||
LC_LIGHT_SHAPE_ELLIPSE
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lcLightProperty
|
enum lcLightProperty
|
||||||
{
|
{
|
||||||
LC_LIGHT_NONE,
|
|
||||||
LC_LIGHT_SHAPE,
|
|
||||||
LC_LIGHT_TYPE,
|
|
||||||
LC_LIGHT_FACTOR,
|
LC_LIGHT_FACTOR,
|
||||||
LC_LIGHT_DIFFUSE,
|
LC_LIGHT_DIFFUSE,
|
||||||
LC_LIGHT_SPECULAR,
|
LC_LIGHT_SPECULAR,
|
||||||
|
@ -59,7 +56,6 @@ struct lcLightProperties
|
||||||
float mSpotCutoff;
|
float mSpotCutoff;
|
||||||
bool mEnableCutoff;
|
bool mEnableCutoff;
|
||||||
bool mPOVRayLight;
|
bool mPOVRayLight;
|
||||||
int mLightShape;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class lcLight : public lcObject
|
class lcLight : public lcObject
|
||||||
|
@ -73,7 +69,8 @@ public:
|
||||||
lcLight& operator=(const lcLight&) = delete;
|
lcLight& operator=(const lcLight&) = delete;
|
||||||
lcLight& operator=(lcLight&&) = delete;
|
lcLight& operator=(lcLight&&) = delete;
|
||||||
|
|
||||||
static QString GetLightTypeString(lcLightType LightType);
|
static QString GetTypeString(lcLightType LightType);
|
||||||
|
static QString GetAreaShapeString(lcLightAreaShape LightAreaShape);
|
||||||
|
|
||||||
bool IsPointLight() const
|
bool IsPointLight() const
|
||||||
{
|
{
|
||||||
|
@ -100,11 +97,11 @@ public:
|
||||||
return mLightType;
|
return mLightType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLightType(lcLightType LightType);
|
bool SetLightType(lcLightType LightType);
|
||||||
|
|
||||||
int GetLightShape() const
|
lcLightAreaShape GetLightShape() const
|
||||||
{
|
{
|
||||||
return mLightShape;
|
return mAreaShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSelected() const override
|
bool IsSelected() const override
|
||||||
|
@ -282,7 +279,21 @@ public:
|
||||||
return mSpotTightness;
|
return mSpotTightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCastShadow(bool CastShadow);
|
bool SetAreaShape(lcLightAreaShape LightAreaShape);
|
||||||
|
|
||||||
|
lcLightAreaShape GetAreaShape() const
|
||||||
|
{
|
||||||
|
return mAreaShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetAreaSize(lcVector2 AreaSize, lcStep Step, bool AddKey);
|
||||||
|
|
||||||
|
lcVector2 GetAreaSize() const
|
||||||
|
{
|
||||||
|
return mAreaSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetCastShadow(bool CastShadow);
|
||||||
|
|
||||||
bool GetCastShadow() const
|
bool GetCastShadow() const
|
||||||
{
|
{
|
||||||
|
@ -306,6 +317,7 @@ public:
|
||||||
bool Setup(int LightIndex);
|
bool Setup(int LightIndex);
|
||||||
void CreateName(const lcArray<lcLight*>& Lights);
|
void CreateName(const lcArray<lcLight*>& Lights);
|
||||||
void UpdateLight(lcStep Step, lcLightProperties Props, int Property);
|
void UpdateLight(lcStep Step, lcLightProperties Props, int Property);
|
||||||
|
|
||||||
lcLightProperties GetLightProperties() const
|
lcLightProperties GetLightProperties() const
|
||||||
{
|
{
|
||||||
lcLightProperties props;
|
lcLightProperties props;
|
||||||
|
@ -317,7 +329,6 @@ public:
|
||||||
props.mPOVRayLight = mPOVRayLight;
|
props.mPOVRayLight = mPOVRayLight;
|
||||||
props.mEnableCutoff = mEnableCutoff;
|
props.mEnableCutoff = mEnableCutoff;
|
||||||
props.mAreaGrid = mAreaGrid;
|
props.mAreaGrid = mAreaGrid;
|
||||||
props.mLightShape = mLightShape;
|
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,11 +337,9 @@ public:
|
||||||
lcVector3 mAttenuation;
|
lcVector3 mAttenuation;
|
||||||
lcVector2 mLightFactor;
|
lcVector2 mLightFactor;
|
||||||
lcVector2 mAreaGrid;
|
lcVector2 mAreaGrid;
|
||||||
lcVector2 mAreaSize;
|
|
||||||
bool mAngleSet;
|
bool mAngleSet;
|
||||||
bool mSpotBlendSet;
|
bool mSpotBlendSet;
|
||||||
bool mSpotCutoffSet;
|
bool mSpotCutoffSet;
|
||||||
bool mHeightSet;
|
|
||||||
bool mEnableCutoff;
|
bool mEnableCutoff;
|
||||||
bool mPOVRayLight;
|
bool mPOVRayLight;
|
||||||
float mLightDiffuse;
|
float mLightDiffuse;
|
||||||
|
@ -353,20 +362,22 @@ protected:
|
||||||
void DrawCone(lcContext* Context, float TargetDistance) const;
|
void DrawCone(lcContext* Context, float TargetDistance) const;
|
||||||
|
|
||||||
quint32 mState = 0;
|
quint32 mState = 0;
|
||||||
lcLightType mLightType;
|
lcLightType mLightType = lcLightType::Point;
|
||||||
bool mCastShadow = true;
|
bool mCastShadow = true;
|
||||||
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||||
float mSpotConeAngle = 80.0f;
|
float mSpotConeAngle = 80.0f;
|
||||||
float mSpotPenumbraAngle = 0.0f;
|
float mSpotPenumbraAngle = 0.0f;
|
||||||
float mSpotTightness = 0.0f;
|
float mSpotTightness = 0.0f;
|
||||||
|
lcLightAreaShape mAreaShape = lcLightAreaShape::Rectangle;
|
||||||
|
lcVector2 mAreaSize = lcVector2(200.0f, 200.0f);
|
||||||
|
|
||||||
int mLightShape;
|
|
||||||
lcObjectKeyArray<lcVector3> mPositionKeys;
|
lcObjectKeyArray<lcVector3> mPositionKeys;
|
||||||
lcObjectKeyArray<lcMatrix33> mRotationKeys;
|
lcObjectKeyArray<lcMatrix33> mRotationKeys;
|
||||||
lcObjectKeyArray<lcVector3> mColorKeys;
|
lcObjectKeyArray<lcVector3> mColorKeys;
|
||||||
lcObjectKeyArray<float> mSpotConeAngleKeys;
|
lcObjectKeyArray<float> mSpotConeAngleKeys;
|
||||||
lcObjectKeyArray<float> mSpotPenumbraAngleKeys;
|
lcObjectKeyArray<float> mSpotPenumbraAngleKeys;
|
||||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||||
|
lcObjectKeyArray<lcVector2> mAreaSizeKeys;
|
||||||
|
|
||||||
lcObjectKeyArray<lcVector3> mAttenuationKeys;
|
lcObjectKeyArray<lcVector3> mAttenuationKeys;
|
||||||
lcObjectKeyArray<lcVector2> mLightFactorKeys;
|
lcObjectKeyArray<lcVector2> mLightFactorKeys;
|
||||||
|
|
|
@ -2177,23 +2177,31 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
const lcVector3 LightPosition = Light->GetPosition();
|
const lcVector3 LightPosition = Light->GetPosition();
|
||||||
const lcVector3 LightTarget = LightPosition + Light->GetDirection();
|
const lcVector3 LightTarget = LightPosition + Light->GetDirection();
|
||||||
const lcVector3 LightColor = Light->GetColor();
|
const lcVector3 LightColor = Light->GetColor();
|
||||||
const QString LightName = QString(Light->mName).replace(" ","_");
|
const QString LightName = QString(Light->mName).replace(" ", "_");
|
||||||
LightType = Light->GetLightType();
|
LightType = Light->GetLightType();
|
||||||
Shadowless = Light->GetCastShadow() ? 0 : 1;
|
Shadowless = Light->GetCastShadow() ? 0 : 1;
|
||||||
Power = Light->mPOVRayExponent;
|
Power = Light->mPOVRayExponent;
|
||||||
|
|
||||||
switch(LightType)
|
switch (LightType)
|
||||||
{
|
{
|
||||||
|
case lcLightType::Point:
|
||||||
|
break;
|
||||||
|
|
||||||
case lcLightType::Spot:
|
case lcLightType::Spot:
|
||||||
SpotFalloff = Light->GetSpotConeAngle() / 2.0f;
|
SpotFalloff = Light->GetSpotConeAngle() / 2.0f;
|
||||||
SpotRadius = SpotFalloff - Light->GetSpotPenumbraAngle();
|
SpotRadius = SpotFalloff - Light->GetSpotPenumbraAngle();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case lcLightType::Directional:
|
||||||
|
break;
|
||||||
|
|
||||||
case lcLightType::Area:
|
case lcLightType::Area:
|
||||||
AreaCircle = Light->GetLightShape() == LC_LIGHT_SHAPE_DISK ? 1 : 0;
|
AreaCircle = (Light->GetLightShape() == lcLightAreaShape::Disk || Light->GetLightShape() == lcLightAreaShape::Ellipse) ? 1 : 0;
|
||||||
AreaSize = Light->mAreaSize;
|
AreaSize = Light->GetAreaSize();
|
||||||
AreaGrid = Light->mAreaGrid;
|
AreaGrid = Light->mAreaGrid;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
case lcLightType::Count:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -499,7 +499,12 @@ QWidget* lcQPropertiesTree::createEditor(QWidget* Parent, QTreeWidgetItem* Item)
|
||||||
else if (Item == mLightTypeItem)
|
else if (Item == mLightTypeItem)
|
||||||
{
|
{
|
||||||
for (int LightTypeIndex = 0; LightTypeIndex < static_cast<int>(lcLightType::Count); LightTypeIndex++)
|
for (int LightTypeIndex = 0; LightTypeIndex < static_cast<int>(lcLightType::Count); LightTypeIndex++)
|
||||||
editor->addItem(lcLight::GetLightTypeString(static_cast<lcLightType>(LightTypeIndex)));
|
editor->addItem(lcLight::GetTypeString(static_cast<lcLightType>(LightTypeIndex)));
|
||||||
|
}
|
||||||
|
else if (Item == mLightAreaShapeItem)
|
||||||
|
{
|
||||||
|
for (int LightAreaShapeIndex = 0; LightAreaShapeIndex < static_cast<int>(lcLightAreaShape::Count); LightAreaShapeIndex++)
|
||||||
|
editor->addItem(lcLight::GetAreaShapeString(static_cast<lcLightAreaShape>(LightAreaShapeIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int value = Item->data(0, PropertyValueRole).toInt();
|
int value = Item->data(0, PropertyValueRole).toInt();
|
||||||
|
@ -529,25 +534,6 @@ QWidget* lcQPropertiesTree::createEditor(QWidget* Parent, QTreeWidgetItem* Item)
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PropertyLightShape:
|
|
||||||
{
|
|
||||||
QComboBox *editor = new QComboBox(Parent);
|
|
||||||
|
|
||||||
editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
|
||||||
editor->setMinimumContentsLength(1);
|
|
||||||
|
|
||||||
QStringList shapes = { tr("Square"), tr("Disk"), tr("Rectangle"), tr("Ellipse") };
|
|
||||||
for (int i = 0; i < shapes.size(); i++)
|
|
||||||
editor->addItem(shapes.at(i), QVariant::fromValue(i));
|
|
||||||
|
|
||||||
int value = Item->data(0, PropertyValueRole).toInt();
|
|
||||||
editor->setCurrentIndex(value);
|
|
||||||
|
|
||||||
connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
|
|
||||||
|
|
||||||
return editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PropertyColor:
|
case PropertyColor:
|
||||||
{
|
{
|
||||||
QPushButton *Editor = new QPushButton(Parent);
|
QPushButton *Editor = new QPushButton(Parent);
|
||||||
|
@ -893,13 +879,25 @@ void lcQPropertiesTree::slotReturnPressed()
|
||||||
|
|
||||||
Model->SetSpotLightTightness(Light, Value);
|
Model->SetSpotLightTightness(Light, Value);
|
||||||
}
|
}
|
||||||
else if (Item == lightFactorA || Item == lightFactorB)
|
else if (Item == mLightAreaSizeXItem)
|
||||||
|
{
|
||||||
|
lcVector2 Value = Light->GetAreaSize();
|
||||||
|
Value[0] = lcParseValueLocalized(Editor->text());
|
||||||
|
|
||||||
|
Model->SetAreaLightSize(Light, Value);
|
||||||
|
}
|
||||||
|
else if (Item == mLightAreaSizeYItem)
|
||||||
|
{
|
||||||
|
lcVector2 Value = Light->GetAreaSize();
|
||||||
|
Value[1] = lcParseValueLocalized(Editor->text());
|
||||||
|
|
||||||
|
Model->SetAreaLightSize(Light, Value);
|
||||||
|
}
|
||||||
|
else if (Item == lightFactorA)
|
||||||
{
|
{
|
||||||
float Value = lcParseValueLocalized(Editor->text());
|
float Value = lcParseValueLocalized(Editor->text());
|
||||||
if (Item == lightFactorA)
|
if (Item == lightFactorA)
|
||||||
Props.mLightFactor[0] = Value;
|
Props.mLightFactor[0] = Value;
|
||||||
else if (Item == lightFactorB)
|
|
||||||
Props.mLightFactor[1] = Value;
|
|
||||||
|
|
||||||
Model->UpdateLight(Light, Props, LC_LIGHT_FACTOR);
|
Model->UpdateLight(Light, Props, LC_LIGHT_FACTOR);
|
||||||
}
|
}
|
||||||
|
@ -937,7 +935,6 @@ void lcQPropertiesTree::slotReturnPressed()
|
||||||
|
|
||||||
Model->UpdateLight(Light, Props, LC_LIGHT_AREA_GRID);
|
Model->UpdateLight(Light, Props, LC_LIGHT_AREA_GRID);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Item == mLightNameItem)
|
else if (Item == mLightNameItem)
|
||||||
{
|
{
|
||||||
QString Value = Editor->text();
|
QString Value = Editor->text();
|
||||||
|
@ -1004,10 +1001,9 @@ void lcQPropertiesTree::slotSetValue(int Value)
|
||||||
{
|
{
|
||||||
Model->SetLightType(Light, static_cast<lcLightType>(Value));
|
Model->SetLightType(Light, static_cast<lcLightType>(Value));
|
||||||
}
|
}
|
||||||
else if (Item == lightShape)
|
else if (Item == mLightAreaShapeItem)
|
||||||
{
|
{
|
||||||
Props.mLightShape = static_cast<lcLightShape>(Value);
|
Model->SetAreaLightShape(Light, static_cast<lcLightAreaShape>(Value));
|
||||||
Model->UpdateLight(Light, Props, LC_LIGHT_SHAPE);
|
|
||||||
}
|
}
|
||||||
else if (Item == lightFormat)
|
else if (Item == lightFormat)
|
||||||
{
|
{
|
||||||
|
@ -1167,12 +1163,13 @@ void lcQPropertiesTree::SetEmpty()
|
||||||
lightExponent = nullptr;
|
lightExponent = nullptr;
|
||||||
mLightTypeItem = nullptr;
|
mLightTypeItem = nullptr;
|
||||||
lightFactorA = nullptr;
|
lightFactorA = nullptr;
|
||||||
lightFactorB = nullptr;
|
|
||||||
mLightNameItem = nullptr;
|
mLightNameItem = nullptr;
|
||||||
mLightSpotConeAngleItem = nullptr;
|
mLightSpotConeAngleItem = nullptr;
|
||||||
mLightSpotPenumbraAngleItem = nullptr;
|
mLightSpotPenumbraAngleItem = nullptr;
|
||||||
mLightSpotTightnessItem = nullptr;
|
mLightSpotTightnessItem = nullptr;
|
||||||
lightShape = nullptr;
|
mLightAreaShapeItem = nullptr;
|
||||||
|
mLightAreaSizeXItem = nullptr;
|
||||||
|
mLightAreaSizeYItem = nullptr;
|
||||||
lightFormat = nullptr;
|
lightFormat = nullptr;
|
||||||
mLightCastShadowItem = nullptr;
|
mLightCastShadowItem = nullptr;
|
||||||
lightAreaGridRows = nullptr;
|
lightAreaGridRows = nullptr;
|
||||||
|
@ -1411,9 +1408,10 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
QString Name = tr("Light");
|
QString Name = tr("Light");
|
||||||
QString ExponentLabel = tr("Exponent");
|
QString ExponentLabel = tr("Exponent");
|
||||||
QString FactorALabel = QLatin1String("FactorA");
|
QString FactorALabel = QLatin1String("FactorA");
|
||||||
QString Format, Shape, ExponentToolTip, FactorAToolTip, FactorBToolTip;
|
QString Format, ExponentToolTip, FactorAToolTip, FactorBToolTip;
|
||||||
lcLightType LightType = lcLightType::Point;
|
lcLightType LightType = lcLightType::Point;
|
||||||
lcLightShape ShapeIndex = LC_LIGHT_SHAPE_UNDEFINED;
|
lcLightAreaShape LightAreaShape = lcLightAreaShape::Rectangle;
|
||||||
|
lcVector2 LightAreaSize(0.0f, 0.0f);
|
||||||
int FormatIndex = 0;
|
int FormatIndex = 0;
|
||||||
float Diffuse = 0.0f;
|
float Diffuse = 0.0f;
|
||||||
float Specular = 0.0f;
|
float Specular = 0.0f;
|
||||||
|
@ -1447,14 +1445,17 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
|
|
||||||
Factor = Light->mLightFactor;
|
Factor = Light->mLightFactor;
|
||||||
LightType = Light->GetLightType();
|
LightType = Light->GetLightType();
|
||||||
|
LightAreaShape = Light->GetAreaShape();
|
||||||
|
LightAreaSize = Light->GetAreaSize();
|
||||||
|
|
||||||
switch(LightType)
|
switch (LightType)
|
||||||
{
|
{
|
||||||
case lcLightType::Point:
|
case lcLightType::Point:
|
||||||
FactorALabel = tr("Radius (m)");
|
FactorALabel = tr("Radius (m)");
|
||||||
FactorAToolTip = tr("The light size for shadow sampling in metres.");
|
FactorAToolTip = tr("The light size for shadow sampling in metres.");
|
||||||
ExponentLabel = tr("Exponent");
|
ExponentLabel = tr("Exponent");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcLightType::Spot:
|
case lcLightType::Spot:
|
||||||
FactorBToolTip = tr("The softness of the spotlight edge.");
|
FactorBToolTip = tr("The softness of the spotlight edge.");
|
||||||
ExponentLabel = tr("Power");
|
ExponentLabel = tr("Power");
|
||||||
|
@ -1470,51 +1471,20 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
FactorAToolTip = tr("Shadow soft size - Light size in metres for shadow sampling.");
|
FactorAToolTip = tr("Shadow soft size - Light size in metres for shadow sampling.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcLightType::Directional:
|
case lcLightType::Directional:
|
||||||
FactorALabel = tr("Angle (°)");
|
FactorALabel = tr("Angle (°)");
|
||||||
FactorAToolTip = tr("Angular diamater of the sun as seen from the Earth.");
|
FactorAToolTip = tr("Angular diamater of the sun as seen from the Earth.");
|
||||||
ExponentLabel = tr("Strength");
|
ExponentLabel = tr("Strength");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lcLightType::Area:
|
case lcLightType::Area:
|
||||||
ExponentLabel = tr("Power");
|
ExponentLabel = tr("Power");
|
||||||
|
|
||||||
if (POVRayLight)
|
|
||||||
{
|
|
||||||
Factor = Light->mAreaSize;
|
|
||||||
FactorALabel = tr("Width");
|
|
||||||
FactorAToolTip = tr("The width (X direction) of the area light.");
|
|
||||||
FactorBToolTip = tr("The height (Y direction) of the area light.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FactorALabel = tr("Width");
|
|
||||||
FactorAToolTip = tr("The width (X direction) of the area light.");
|
|
||||||
FactorBToolTip = tr("The height (Y direction) of the area light.");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeIndex = static_cast<lcLightShape>(Light->GetLightType());
|
|
||||||
|
|
||||||
switch(ShapeIndex)
|
|
||||||
{
|
|
||||||
case LC_LIGHT_SHAPE_SQUARE:
|
|
||||||
Shape = tr("Square");
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_SHAPE_DISK:
|
|
||||||
Shape = POVRayLight ? tr("Circle") : tr("Disk");
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_SHAPE_RECTANGLE:
|
|
||||||
Shape = tr("Rectangle");
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_SHAPE_ELLIPSE:
|
|
||||||
Shape = tr("Ellipse");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Diffuse = Light->mLightDiffuse;
|
Diffuse = Light->mLightDiffuse;
|
||||||
Specular = Light->mLightSpecular;
|
Specular = Light->mLightSpecular;
|
||||||
|
@ -1538,7 +1508,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
AreaGrid = Light->mAreaGrid;
|
AreaGrid = Light->mAreaGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWidgetMode != LC_PROPERTY_WIDGET_LIGHT || mLightType != LightType || mLightShape != ShapeIndex || mPOVRayLight != POVRayLight)
|
if (mWidgetMode != LC_PROPERTY_WIDGET_LIGHT || mLightType != LightType || mLightAreaShape != LightAreaShape || mPOVRayLight != POVRayLight)
|
||||||
{
|
{
|
||||||
SetEmpty();
|
SetEmpty();
|
||||||
|
|
||||||
|
@ -1549,7 +1519,12 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
mLightColorItem = addProperty(mLightAttributesItem, tr("Color"), PropertyColor);
|
mLightColorItem = addProperty(mLightAttributesItem, tr("Color"), PropertyColor);
|
||||||
mLightCastShadowItem = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
mLightCastShadowItem = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
||||||
|
|
||||||
if (LightType == lcLightType::Spot)
|
switch (LightType)
|
||||||
|
{
|
||||||
|
case lcLightType::Point:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lcLightType::Spot:
|
||||||
{
|
{
|
||||||
mLightSpotConeAngleItem = addProperty(mLightAttributesItem, tr("Spot Cone Angle"), PropertyFloat);
|
mLightSpotConeAngleItem = addProperty(mLightAttributesItem, tr("Spot Cone Angle"), PropertyFloat);
|
||||||
mLightSpotConeAngleItem->setToolTip(1, tr("The angle (in degrees) of the spot light's beam."));
|
mLightSpotConeAngleItem->setToolTip(1, tr("The angle (in degrees) of the spot light's beam."));
|
||||||
|
@ -1558,23 +1533,40 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
mLightSpotPenumbraAngleItem->setToolTip(1, tr("The angle (in degrees) over which the intensity of the spot light falls off to zero."));
|
mLightSpotPenumbraAngleItem->setToolTip(1, tr("The angle (in degrees) over which the intensity of the spot light falls off to zero."));
|
||||||
|
|
||||||
mLightSpotTightnessItem = addProperty(mLightAttributesItem, tr("Spot Tightness"), PropertyFloat);
|
mLightSpotTightnessItem = addProperty(mLightAttributesItem, tr("Spot Tightness"), PropertyFloat);
|
||||||
mLightSpotTightnessItem->setToolTip(1, tr("Additional exponential spotlight edge softening (POV-Ray only)."));
|
mLightSpotTightnessItem->setToolTip(1, tr("Additional exponential spot light edge softening (POV-Ray only)."));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
|
case lcLightType::Directional:
|
||||||
|
break;
|
||||||
|
|
||||||
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
case lcLightType::Area:
|
||||||
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloat);
|
|
||||||
|
|
||||||
if (LightType == lcLightType::Area)
|
|
||||||
{
|
{
|
||||||
lightShape = addProperty(mLightAttributesItem, tr("Shape"), PropertyLightShape);
|
mLightAreaShapeItem = addProperty(mLightAttributesItem, tr("Area Shape"), PropertyStringList);
|
||||||
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloat);
|
mLightAreaShapeItem->setToolTip(1, tr("The shape of the area light."));
|
||||||
|
|
||||||
if (ShapeIndex == LC_LIGHT_SHAPE_RECTANGLE || ShapeIndex == LC_LIGHT_SHAPE_ELLIPSE || POVRayLight)
|
switch (LightAreaShape)
|
||||||
lightFactorB = addProperty(mLightAttributesItem, tr("Height"), PropertyFloat);
|
{
|
||||||
else
|
case lcLightAreaShape::Rectangle:
|
||||||
FactorAToolTip = tr("The size of the area light grid.");
|
case lcLightAreaShape::Ellipse:
|
||||||
|
mLightAreaSizeXItem = addProperty(mLightAttributesItem, tr("Area Width"), PropertyFloat);
|
||||||
|
mLightAreaSizeXItem->setToolTip(1, tr("The width (X direction) of the area light."));
|
||||||
|
|
||||||
|
mLightAreaSizeYItem = addProperty(mLightAttributesItem, tr("Area Height"), PropertyFloat);
|
||||||
|
mLightAreaSizeYItem->setToolTip(1, tr("The height (Y direction) of the area light."));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lcLightAreaShape::Square:
|
||||||
|
case lcLightAreaShape::Disk:
|
||||||
|
mLightAreaSizeXItem = addProperty(mLightAttributesItem, tr("Area Size"), PropertyFloat);
|
||||||
|
mLightAreaSizeXItem->setToolTip(1, tr("The size of the area light."));
|
||||||
|
|
||||||
|
mLightAreaSizeYItem = nullptr;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lcLightAreaShape::Count:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (POVRayLight)
|
if (POVRayLight)
|
||||||
{
|
{
|
||||||
|
@ -1582,6 +1574,16 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
lightAreaGridColumns = addProperty(mLightAttributesItem, tr("Grid Columns"), PropertyFloat);
|
lightAreaGridColumns = addProperty(mLightAttributesItem, tr("Grid Columns"), PropertyFloat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lcLightType::Count:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
|
||||||
|
|
||||||
|
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
||||||
|
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloat);
|
||||||
|
|
||||||
if (!POVRayLight)
|
if (!POVRayLight)
|
||||||
{
|
{
|
||||||
|
@ -1616,7 +1618,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
|
|
||||||
mWidgetMode = LC_PROPERTY_WIDGET_LIGHT;
|
mWidgetMode = LC_PROPERTY_WIDGET_LIGHT;
|
||||||
mLightType = LightType;
|
mLightType = LightType;
|
||||||
mLightShape = ShapeIndex;
|
mLightAreaShape = LightAreaShape;
|
||||||
mPOVRayLight = POVRayLight;
|
mPOVRayLight = POVRayLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1656,7 +1658,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
lightFormat->setText(1, Format);
|
lightFormat->setText(1, Format);
|
||||||
lightFormat->setData(0, PropertyValueRole, FormatIndex);
|
lightFormat->setData(0, PropertyValueRole, FormatIndex);
|
||||||
|
|
||||||
mLightTypeItem->setText(1, lcLight::GetLightTypeString(LightType));
|
mLightTypeItem->setText(1, lcLight::GetTypeString(LightType));
|
||||||
mLightTypeItem->setData(0, PropertyValueRole, static_cast<int>(LightType));
|
mLightTypeItem->setData(0, PropertyValueRole, static_cast<int>(LightType));
|
||||||
|
|
||||||
mLightCastShadowItem->setCheckState(1, CastShadow ? Qt::Checked : Qt::Unchecked);
|
mLightCastShadowItem->setCheckState(1, CastShadow ? Qt::Checked : Qt::Unchecked);
|
||||||
|
@ -1674,19 +1676,16 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
}
|
}
|
||||||
else if (LightType == lcLightType::Area)
|
else if (LightType == lcLightType::Area)
|
||||||
{
|
{
|
||||||
lightShape->setText(1, Shape);
|
mLightAreaShapeItem->setText(1, lcLight::GetAreaShapeString(LightAreaShape));
|
||||||
lightShape->setData(0, PropertyValueRole, ShapeIndex);
|
mLightAreaShapeItem->setData(0, PropertyValueRole, static_cast<int>(LightAreaShape));
|
||||||
lightShape->setToolTip(1, tr("Suggested shape of the arealight."));
|
|
||||||
|
|
||||||
lightFactorA->setText(1, lcFormatValueLocalized(Factor[0]));
|
mLightAreaSizeXItem->setText(1, lcFormatValueLocalized(LightAreaSize[0]));
|
||||||
lightFactorA->setData(0, PropertyValueRole, Factor[0]);
|
mLightAreaSizeXItem->setData(0, PropertyValueRole, LightAreaSize[0]);
|
||||||
lightFactorA->setToolTip(1, FactorAToolTip);
|
|
||||||
|
|
||||||
if (ShapeIndex == LC_LIGHT_SHAPE_RECTANGLE || ShapeIndex == LC_LIGHT_SHAPE_ELLIPSE || POVRayLight)
|
if (mLightAreaSizeYItem)
|
||||||
{
|
{
|
||||||
lightFactorB->setText(1, lcFormatValueLocalized(Factor[1]));
|
mLightAreaSizeYItem->setText(1, lcFormatValueLocalized(LightAreaSize[1]));
|
||||||
lightFactorB->setData(0, PropertyValueRole, Factor[1]);
|
mLightAreaSizeYItem->setData(0, PropertyValueRole, LightAreaSize[1]);
|
||||||
lightFactorB->setToolTip(1, FactorBToolTip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (POVRayLight)
|
if (POVRayLight)
|
||||||
|
|
|
@ -50,7 +50,6 @@ public:
|
||||||
PropertyString,
|
PropertyString,
|
||||||
PropertyStringList,
|
PropertyStringList,
|
||||||
PropertyLightFormat,
|
PropertyLightFormat,
|
||||||
PropertyLightShape,
|
|
||||||
PropertyColor,
|
PropertyColor,
|
||||||
PropertyPieceColor,
|
PropertyPieceColor,
|
||||||
PropertyPart
|
PropertyPart
|
||||||
|
@ -79,7 +78,7 @@ protected:
|
||||||
void SetMultiple();
|
void SetMultiple();
|
||||||
|
|
||||||
lcLightType mLightType;
|
lcLightType mLightType;
|
||||||
int mLightShape;
|
lcLightAreaShape mLightAreaShape;
|
||||||
bool mPOVRayLight;
|
bool mPOVRayLight;
|
||||||
|
|
||||||
lcPropertyWidgetMode mWidgetMode;
|
lcPropertyWidgetMode mWidgetMode;
|
||||||
|
@ -145,7 +144,9 @@ protected:
|
||||||
QTreeWidgetItem* mLightSpotConeAngleItem;
|
QTreeWidgetItem* mLightSpotConeAngleItem;
|
||||||
QTreeWidgetItem* mLightSpotPenumbraAngleItem;
|
QTreeWidgetItem* mLightSpotPenumbraAngleItem;
|
||||||
QTreeWidgetItem* mLightSpotTightnessItem;
|
QTreeWidgetItem* mLightSpotTightnessItem;
|
||||||
QTreeWidgetItem* lightShape;
|
QTreeWidgetItem* mLightAreaShapeItem;
|
||||||
|
QTreeWidgetItem* mLightAreaSizeXItem;
|
||||||
|
QTreeWidgetItem* mLightAreaSizeYItem;
|
||||||
QTreeWidgetItem* lightFactorA;
|
QTreeWidgetItem* lightFactorA;
|
||||||
QTreeWidgetItem* lightFactorB;
|
QTreeWidgetItem* lightFactorB;
|
||||||
QTreeWidgetItem* mLightNameItem;
|
QTreeWidgetItem* mLightNameItem;
|
||||||
|
|
Loading…
Reference in a new issue