Support Blender light sizes for all types of lights.

This commit is contained in:
Leonardo Zide 2023-09-17 11:45:14 -07:00
parent 59c1930b83
commit 177c1b82d7
7 changed files with 174 additions and 236 deletions

View file

@ -3225,12 +3225,12 @@ void lcModel::SetAreaLightShape(lcLight* Light, lcLightAreaShape LightAreaShape)
UpdateAllViews();
}
void lcModel::SetAreaLightSize(lcLight* Light, lcVector2 LightAreaSize)
void lcModel::SetLightSize(lcLight* Light, lcVector2 LightAreaSize)
{
Light->SetAreaSize(LightAreaSize, mCurrentStep, gMainWindow->GetAddKeys());
Light->SetSize(LightAreaSize, mCurrentStep, gMainWindow->GetAddKeys());
Light->UpdatePosition(mCurrentStep);
SaveCheckpoint(tr("Changing Area Light Size"));
SaveCheckpoint(tr("Changing Light Size"));
gMainWindow->UpdateSelectedObjects(false);
UpdateAllViews();
}

View file

@ -374,7 +374,7 @@ public:
void SetSpotLightPenumbraAngle(lcLight* Light, float Angle);
void SetSpotLightTightness(lcLight* Light, float Tightness);
void SetAreaLightShape(lcLight* Light, lcLightAreaShape LightAreaShape);
void SetAreaLightSize(lcLight* Light, lcVector2 LightAreaSize);
void SetLightSize(lcLight* Light, lcVector2 LightAreaSize);
void SetLightCastShadow(lcLight* Light, bool CastShadow);
void SetLightName(lcLight* Light, const QString& Name);
void UpdateLight(lcLight* Light, const lcLightProperties Props, int Property);

View file

@ -28,8 +28,6 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
mPOVRayLight = false;
mEnableCutoff = false;
mAttenuation = lcVector3(1.0f, 0.0f, 0.0f);
mLightFactor[0] = LightType == lcLightType::Directional ? 11.4f : 0.25f;
mLightFactor[1] = LightType == lcLightType::Area ? 0.25f : LightType == lcLightType::Spot ? 0.150f : 0.0f;
mLightDiffuse = 1.0f;
mLightSpecular = 1.0f;
mSpotExponent = 10.0f;
@ -37,16 +35,16 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f;
mAreaGrid = lcVector2(10.0f, 10.0f);
UpdateLightType();
mPositionKeys.ChangeKey(mWorldMatrix.GetTranslation(), 1, true);
mRotationKeys.ChangeKey(lcMatrix33(mWorldMatrix), 1, true);
mColorKeys.ChangeKey(mColor, 1, true);
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, true);
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
mAreaSizeKeys.ChangeKey(mAreaSize, 1, true);
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true);
mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true);
mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true);
@ -56,7 +54,36 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
UpdatePosition(1);
}
QString lcLight::GetTypeString(lcLightType LightType)
void lcLight::UpdateLightType()
{
mSizeKeys.RemoveAll();
switch (mLightType)
{
case lcLightType::Point:
mSize = lcVector2(0.0f, 0.0f);
break;
case lcLightType::Spot:
mSize = lcVector2(0.0f, 0.0f);
break;
case lcLightType::Directional:
mSize = lcVector2(0.00918f * LC_DTOR, 0.0f);
break;
case lcLightType::Area:
mSize = lcVector2(200.0f, 200.0f);
break;
case lcLightType::Count:
break;
}
mSizeKeys.ChangeKey(mSize, 1, true);
}
QString lcLight::GetLightTypeString(lcLightType LightType)
{
switch (LightType)
{
@ -133,6 +160,11 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
else
Stream << QLatin1String("0 !LEOCAD LIGHT COLOR ") << mColor[0] << ' ' << mColor[1] << ' ' << mColor[2] << LineEnding;
if (mSizeKeys.GetSize() > 1)
mSizeKeys.SaveKeysLDraw(Stream, "LIGHT SIZE_KEY ");
else
Stream << QLatin1String("0 !LEOCAD LIGHT SIZE ") << mSize[0] << mSize[1] << LineEnding;
if (!mPOVRayLight)
{
if (mLightDiffuseKeys.GetSize() > 1)
@ -162,16 +194,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
switch (mLightType)
{
case lcLightType::Count:
break;
case lcLightType::Point:
if (!mPOVRayLight)
{
if (mLightFactorKeys.GetSize() > 1)
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_KEY ");
else
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << mLightFactor[0] << LineEnding;
}
break;
case lcLightType::Spot:
@ -190,16 +213,6 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
else
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_TIGHTNESS ") << mSpotTightness << LineEnding;
if (!mPOVRayLight)
{
if (mLightFactorKeys.GetSize() > 1)
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_AND_SPOT_BLEND_KEY ");
else
{
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << mLightFactor[0] << LineEnding;
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_BLEND ") << mLightFactor[1] << LineEnding;
}
}
break;
case lcLightType::Directional:
@ -208,10 +221,6 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
else
Stream << QLatin1String("0 !LEOCAD LIGHT STRENGTH ") << mSpotExponent << LineEnding;
if (mLightFactorKeys.GetSize() > 1)
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT ANGLE_KEY ");
else
Stream << QLatin1String("0 !LEOCAD LIGHT ANGLE ") << mLightFactor[0] << LineEnding;
break;
case lcLightType::Area:
@ -223,12 +232,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_ROWS ") << mAreaGrid[0] << QLatin1String(" AREA_COLUMNS ") << mAreaGrid[1] << LineEnding;
}
Stream << QLatin1String("0 !LEOCAD LIGHT SHAPE ") << gLightAreaShapes[static_cast<int>(mAreaShape)] << LineEnding;
if (mAreaSizeKeys.GetSize() > 1)
mAreaSizeKeys.SaveKeysLDraw(Stream, "LIGHT AREA_SIZE_KEY ");
else
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_SIZE ") << mAreaSize[0] << mAreaSize[1] << LineEnding;
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_SHAPE ") << gLightAreaShapes[static_cast<int>(mAreaShape)] << LineEnding;
break;
}
@ -368,7 +372,7 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
}
else if (Token == QLatin1String("SPOT_TIGHTNESS_KEY"))
mSpotTightnessKeys.LoadKeysLDraw(Stream);
else if (Token == QLatin1String("SHAPE"))
else if (Token == QLatin1String("AREA_SHAPE"))
{
QString AreaShape;
Stream >> AreaShape;
@ -382,13 +386,13 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
}
}
}
else if (Token == QLatin1String("AREA_SIZE"))
else if (Token == QLatin1String("SIZE"))
{
Stream >> mAreaSize[0] >> mAreaSize[1];
mAreaSizeKeys.ChangeKey(mAreaSize, 1, true);
Stream >> mSize[0] >> mSize[1];
mSizeKeys.ChangeKey(mSize, 1, true);
}
else if (Token == QLatin1String("AREA_SIZE_KEY"))
mAreaSizeKeys.LoadKeysLDraw(Stream);
else if (Token == QLatin1String("SIZE_KEY"))
mSizeKeys.LoadKeysLDraw(Stream);
else if (Token == QLatin1String("POWER") || Token == QLatin1String("STRENGTH"))
{
@ -455,8 +459,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
}
else if ((Token == QLatin1String("POWER_KEY")) || (Token == QLatin1String("STRENGTH_KEY")))
mSpotExponentKeys.LoadKeysLDraw(Stream);
else if ((Token == QLatin1String("ANGLE_KEY")) || (Token == QLatin1String("RADIUS_KEY")) || (Token == QLatin1String("SIZE_KEY")) || (Token == QLatin1String("RADIUS_AND_SPOT_BLEND_KEY")))
mLightFactorKeys.LoadKeysLDraw(Stream);
else if (Token == QLatin1String("AREA_GRID_KEY"))
mAreaGridKeys.LoadKeysLDraw(Stream);
else if (Token == QLatin1String("DIFFUSE_KEY"))
@ -474,23 +476,10 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
switch (mLightType)
{
case lcLightType::Point:
break;
case lcLightType::Spot:
if (!mSpotBlendSet)
{
mLightFactor[1] = 0.15f;
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
}
break;
case lcLightType::Directional:
if (!mAngleSet)
{
mLightFactor[0] = 11.4f;
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
}
if (!mSpotCutoffSet)
{
mSpotCutoff = 0.0f;
@ -499,8 +488,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
break;
case lcLightType::Area:
break;
case lcLightType::Count:
break;
}
@ -526,18 +513,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property)
{
switch(Property)
{
case LC_LIGHT_FACTOR:
if (Props.mPOVRayLight && mLightType == lcLightType::Area)
{
mAreaSize = Props.mLightFactor;
mLightFactorKeys.ChangeKey(mAreaSize, 1, true);
}
else
{
mLightFactor = Props.mLightFactor;
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
}
break;
case LC_LIGHT_DIFFUSE:
mLightDiffuse = Props.mLightDiffuse;
mLightDiffuseKeys.ChangeKey(mLightDiffuse, Step, false);
@ -621,7 +596,7 @@ void lcLight::RayTest(lcObjectRayTest& ObjectRayTest) const
float x = lcDot(IntersectionDirection, XAxis);
float y = lcDot(IntersectionDirection, YAxis);
if (fabsf(x) < mAreaSize.x / 2.0f && fabsf(y) < mAreaSize.y / 2.0f)
if (fabsf(x) < mSize.x / 2.0f && fabsf(y) < mSize.y / 2.0f)
{
float Distance = lcLength(Intersection - ObjectRayTest.Start);
@ -726,13 +701,14 @@ bool lcLight::SetLightType(lcLightType LightType)
if (static_cast<int>(LightType) < 0 || LightType >= lcLightType::Count)
return false;
if (mLightType != LightType)
{
mLightType = LightType;
return true;
}
if (mLightType == LightType)
return false;
return false;
mLightType = LightType;
UpdateLightType();
return true;
}
void lcLight::SetColor(const lcVector3& Color, lcStep Step, bool AddKey)
@ -769,12 +745,12 @@ bool lcLight::SetAreaShape(lcLightAreaShape AreaShape)
return false;
}
void lcLight::SetAreaSize(lcVector2 AreaSize, lcStep Step, bool AddKey)
void lcLight::SetSize(lcVector2 Size, lcStep Step, bool AddKey)
{
if (mAreaShape == lcLightAreaShape::Square || mAreaShape == lcLightAreaShape::Disk)
AreaSize[1] = AreaSize[0];
if (mLightType == lcLightType::Area && (mAreaShape == lcLightAreaShape::Square || mAreaShape == lcLightAreaShape::Disk))
Size[1] = Size[0];
mAreaSizeKeys.ChangeKey(AreaSize, Step, AddKey);
mSizeKeys.ChangeKey(Size, Step, AddKey);
}
bool lcLight::SetCastShadow(bool CastShadow)
@ -796,10 +772,9 @@ void lcLight::InsertTime(lcStep Start, lcStep Time)
mSpotConeAngleKeys.InsertTime(Start, Time);
mSpotPenumbraAngleKeys.InsertTime(Start, Time);
mSpotTightnessKeys.InsertTime(Start, Time);
mAreaSizeKeys.InsertTime(Start, Time);
mSizeKeys.InsertTime(Start, Time);
mAttenuationKeys.InsertTime(Start, Time);
mLightFactorKeys.InsertTime(Start, Time);
mLightDiffuseKeys.InsertTime(Start, Time);
mLightSpecularKeys.InsertTime(Start, Time);
mSpotCutoffKeys.InsertTime(Start, Time);
@ -815,10 +790,9 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time)
mSpotConeAngleKeys.RemoveTime(Start, Time);
mSpotPenumbraAngleKeys.RemoveTime(Start, Time);
mSpotTightnessKeys.RemoveTime(Start, Time);
mAreaSizeKeys.RemoveTime(Start, Time);
mSizeKeys.RemoveTime(Start, Time);
mAttenuationKeys.RemoveTime(Start, Time);
mLightFactorKeys.RemoveTime(Start, Time);
mLightDiffuseKeys.RemoveTime(Start, Time);
mLightSpecularKeys.RemoveTime(Start, Time);
mSpotCutoffKeys.RemoveTime(Start, Time);
@ -845,10 +819,9 @@ void lcLight::UpdatePosition(lcStep Step)
mSpotConeAngle = mSpotConeAngleKeys.CalculateKey(Step);
mSpotPenumbraAngle = mSpotPenumbraAngleKeys.CalculateKey(Step);
mSpotTightness = mSpotTightnessKeys.CalculateKey(Step);
mAreaSize = mAreaSizeKeys.CalculateKey(Step);
mSize = mSizeKeys.CalculateKey(Step);
mAttenuation = mAttenuationKeys.CalculateKey(Step);
mLightFactor = mLightFactorKeys.CalculateKey(Step);
mLightDiffuse = mLightDiffuseKeys.CalculateKey(Step);
mLightSpecular = mLightSpecularKeys.CalculateKey(Step);
mSpotCutoff = mSpotCutoffKeys.CalculateKey(Step);
@ -954,20 +927,20 @@ void lcLight::DrawAreaLight(lcContext* Context) const
float Verts[4 * 3];
float* CurVert = Verts;
*CurVert++ = -mAreaSize.x / 2.0f;
*CurVert++ = -mAreaSize.y / 2.0f;
*CurVert++ = -mSize.x / 2.0f;
*CurVert++ = -mSize.y / 2.0f;
*CurVert++ = 0.0f;
*CurVert++ = mAreaSize.x / 2.0f;
*CurVert++ = -mAreaSize.y / 2.0f;
*CurVert++ = mSize.x / 2.0f;
*CurVert++ = -mSize.y / 2.0f;
*CurVert++ = 0.0f;
*CurVert++ = mAreaSize.x / 2.0f;
*CurVert++ = mAreaSize.y / 2.0f;
*CurVert++ = mSize.x / 2.0f;
*CurVert++ = mSize.y / 2.0f;
*CurVert++ = 0.0f;
*CurVert++ = -mAreaSize.x / 2.0f;
*CurVert++ = mAreaSize.y / 2.0f;
*CurVert++ = -mSize.x / 2.0f;
*CurVert++ = mSize.y / 2.0f;
*CurVert++ = 0.0f;
Context->SetVertexBufferPointer(Verts);
@ -992,8 +965,8 @@ void lcLight::DrawAreaLight(lcContext* Context) const
for (int EdgeIndex = 0; EdgeIndex < CircleEdges; EdgeIndex++)
{
float c = cosf((float)EdgeIndex / CircleEdges * LC_2PI) * mAreaSize.x / 2.0f;
float s = sinf((float)EdgeIndex / CircleEdges * LC_2PI) * mAreaSize.y / 2.0f;
float c = cosf((float)EdgeIndex / CircleEdges * LC_2PI) * mSize.x / 2.0f;
float s = sinf((float)EdgeIndex / CircleEdges * LC_2PI) * mSize.y / 2.0f;
*CurVert++ = c;
*CurVert++ = s;
@ -1274,15 +1247,12 @@ void lcLight::RemoveKeyFrames()
mSpotTightnessKeys.RemoveAll();
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
mAreaSizeKeys.RemoveAll();
mAreaSizeKeys.ChangeKey(mAreaSize, 1, true);
mSizeKeys.RemoveAll();
mSizeKeys.ChangeKey(mSize, 1, true);
mAttenuationKeys.RemoveAll();
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
mLightFactorKeys.RemoveAll();
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
mLightDiffuseKeys.RemoveAll();
mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true);

View file

@ -36,7 +36,6 @@ enum class lcLightAreaShape
enum lcLightProperty
{
LC_LIGHT_FACTOR,
LC_LIGHT_DIFFUSE,
LC_LIGHT_SPECULAR,
LC_LIGHT_EXPONENT,
@ -48,7 +47,6 @@ enum lcLightProperty
struct lcLightProperties
{
lcVector2 mLightFactor;
lcVector2 mAreaGrid;
float mLightDiffuse;
float mLightSpecular;
@ -69,7 +67,7 @@ public:
lcLight& operator=(const lcLight&) = delete;
lcLight& operator=(lcLight&&) = delete;
static QString GetTypeString(lcLightType LightType);
static QString GetLightTypeString(lcLightType LightType);
static QString GetAreaShapeString(lcLightAreaShape LightAreaShape);
bool IsPointLight() const
@ -99,11 +97,6 @@ public:
bool SetLightType(lcLightType LightType);
lcLightAreaShape GetLightShape() const
{
return mAreaShape;
}
bool IsSelected() const override
{
return (mState & LC_LIGHT_SELECTION_MASK) != 0;
@ -286,11 +279,11 @@ public:
return mAreaShape;
}
void SetAreaSize(lcVector2 AreaSize, lcStep Step, bool AddKey);
void SetSize(lcVector2 Size, lcStep Step, bool AddKey);
lcVector2 GetAreaSize() const
lcVector2 GetSize() const
{
return mAreaSize;
return mSize;
}
bool SetCastShadow(bool CastShadow);
@ -321,7 +314,6 @@ public:
lcLightProperties GetLightProperties() const
{
lcLightProperties props;
props.mLightFactor = mLightFactor;
props.mLightDiffuse = mLightDiffuse;
props.mLightSpecular = mLightSpecular;
props.mSpotExponent = mSpotExponent;
@ -335,9 +327,7 @@ public:
lcMatrix44 mWorldMatrix;
lcVector3 mAttenuation;
lcVector2 mLightFactor;
lcVector2 mAreaGrid;
bool mAngleSet;
bool mSpotBlendSet;
bool mSpotCutoffSet;
bool mEnableCutoff;
@ -347,9 +337,10 @@ public:
float mSpotCutoff;
float mSpotExponent;
float mPOVRayExponent;
QString mName;
protected:
void UpdateLightType();
void DrawPointLight(lcContext* Context) const;
void DrawSpotLight(lcContext* Context) const;
void DrawDirectionalLight(lcContext* Context) const;
@ -361,26 +352,26 @@ protected:
void DrawTarget(lcContext* Context, float TargetDistance) const;
void DrawCone(lcContext* Context, float TargetDistance) const;
QString mName;
quint32 mState = 0;
lcLightType mLightType = lcLightType::Point;
bool mCastShadow = true;
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
lcVector2 mSize = lcVector2(0.0f, 0.0f);
float mSpotConeAngle = 80.0f;
float mSpotPenumbraAngle = 0.0f;
float mSpotTightness = 0.0f;
lcLightAreaShape mAreaShape = lcLightAreaShape::Rectangle;
lcVector2 mAreaSize = lcVector2(200.0f, 200.0f);
lcObjectKeyArray<lcVector3> mPositionKeys;
lcObjectKeyArray<lcMatrix33> mRotationKeys;
lcObjectKeyArray<lcVector3> mColorKeys;
lcObjectKeyArray<lcVector2> mSizeKeys;
lcObjectKeyArray<float> mSpotConeAngleKeys;
lcObjectKeyArray<float> mSpotPenumbraAngleKeys;
lcObjectKeyArray<float> mSpotTightnessKeys;
lcObjectKeyArray<lcVector2> mAreaSizeKeys;
lcObjectKeyArray<lcVector3> mAttenuationKeys;
lcObjectKeyArray<lcVector2> mLightFactorKeys;
lcObjectKeyArray<lcVector2> mAreaGridKeys;
lcObjectKeyArray<float> mLightSpecularKeys;
lcObjectKeyArray<float> mLightDiffuseKeys;

View file

@ -2177,7 +2177,7 @@ bool Project::ExportPOVRay(const QString& FileName)
const lcVector3 LightPosition = Light->GetPosition();
const lcVector3 LightTarget = LightPosition + Light->GetDirection();
const lcVector3 LightColor = Light->GetColor();
const QString LightName = QString(Light->mName).replace(" ", "_");
const QString LightName = QString(Light->GetName()).replace(" ", "_");
LightType = Light->GetLightType();
Shadowless = Light->GetCastShadow() ? 0 : 1;
Power = Light->mPOVRayExponent;
@ -2196,8 +2196,8 @@ bool Project::ExportPOVRay(const QString& FileName)
break;
case lcLightType::Area:
AreaCircle = (Light->GetLightShape() == lcLightAreaShape::Disk || Light->GetLightShape() == lcLightAreaShape::Ellipse) ? 1 : 0;
AreaSize = Light->GetAreaSize();
AreaCircle = (Light->GetAreaShape() == lcLightAreaShape::Disk || Light->GetAreaShape() == lcLightAreaShape::Ellipse) ? 1 : 0;
AreaSize = Light->GetSize();
AreaGrid = Light->mAreaGrid;
break;

View file

@ -499,7 +499,7 @@ QWidget* lcQPropertiesTree::createEditor(QWidget* Parent, QTreeWidgetItem* Item)
else if (Item == mLightTypeItem)
{
for (int LightTypeIndex = 0; LightTypeIndex < static_cast<int>(lcLightType::Count); LightTypeIndex++)
editor->addItem(lcLight::GetTypeString(static_cast<lcLightType>(LightTypeIndex)));
editor->addItem(lcLight::GetLightTypeString(static_cast<lcLightType>(LightTypeIndex)));
}
else if (Item == mLightAreaShapeItem)
{
@ -879,27 +879,19 @@ void lcQPropertiesTree::slotReturnPressed()
Model->SetSpotLightTightness(Light, Value);
}
else if (Item == mLightAreaSizeXItem)
else if (Item == mLightSizeXItem)
{
lcVector2 Value = Light->GetAreaSize();
lcVector2 Value = Light->GetSize();
Value[0] = lcParseValueLocalized(Editor->text());
Model->SetAreaLightSize(Light, Value);
Model->SetLightSize(Light, Value);
}
else if (Item == mLightAreaSizeYItem)
else if (Item == mLightSizeYItem)
{
lcVector2 Value = Light->GetAreaSize();
lcVector2 Value = Light->GetSize();
Value[1] = lcParseValueLocalized(Editor->text());
Model->SetAreaLightSize(Light, Value);
}
else if (Item == lightFactorA)
{
float Value = lcParseValueLocalized(Editor->text());
if (Item == lightFactorA)
Props.mLightFactor[0] = Value;
Model->UpdateLight(Light, Props, LC_LIGHT_FACTOR);
Model->SetLightSize(Light, Value);
}
else if (Item == lightDiffuse)
{
@ -1162,14 +1154,13 @@ void lcQPropertiesTree::SetEmpty()
lightEnableCutoff = nullptr;
lightExponent = nullptr;
mLightTypeItem = nullptr;
lightFactorA = nullptr;
mLightNameItem = nullptr;
mLightSpotConeAngleItem = nullptr;
mLightSpotPenumbraAngleItem = nullptr;
mLightSpotTightnessItem = nullptr;
mLightAreaShapeItem = nullptr;
mLightAreaSizeXItem = nullptr;
mLightAreaSizeYItem = nullptr;
mLightSizeXItem = nullptr;
mLightSizeYItem = nullptr;
lightFormat = nullptr;
mLightCastShadowItem = nullptr;
lightAreaGridRows = nullptr;
@ -1411,7 +1402,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
QString Format, ExponentToolTip, FactorAToolTip, FactorBToolTip;
lcLightType LightType = lcLightType::Point;
lcLightAreaShape LightAreaShape = lcLightAreaShape::Rectangle;
lcVector2 LightAreaSize(0.0f, 0.0f);
lcVector2 LightSize(0.0f, 0.0f);
int FormatIndex = 0;
float Diffuse = 0.0f;
float Specular = 0.0f;
@ -1425,7 +1416,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
lcVector3 Target(0.0f, 0.0f, 0.0f);
QColor Color(Qt::white);
float SpotConeAngle = 0.0f, SpotPenumbraAngle = 0.0f, SpotTightness = 0.0f;
lcVector2 Factor(0.0f, 0.0f);
lcVector2 AreaGrid(0.0f, 0.0f);
if (Light)
@ -1443,38 +1433,22 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
SpotConeAngle = Light->GetSpotConeAngle();
SpotPenumbraAngle = Light->GetSpotPenumbraAngle();
Factor = Light->mLightFactor;
LightType = Light->GetLightType();
LightAreaShape = Light->GetAreaShape();
LightAreaSize = Light->GetAreaSize();
LightSize = Light->GetSize();
switch (LightType)
{
case lcLightType::Point:
FactorALabel = tr("Radius (m)");
FactorAToolTip = tr("The light size for shadow sampling in metres.");
ExponentLabel = tr("Exponent");
break;
case lcLightType::Spot:
FactorBToolTip = tr("The softness of the spotlight edge.");
ExponentLabel = tr("Power");
if (POVRayLight)
{
FactorALabel = tr("Radius (°)");
FactorAToolTip = tr("The angle between the \"hot-spot\" edge at the beam center and the center line.");
}
else
{
FactorALabel = tr("Radius (m)");
FactorAToolTip = tr("Shadow soft size - Light size in metres for shadow sampling.");
}
break;
case lcLightType::Directional:
FactorALabel = tr("Angle (°)");
FactorAToolTip = tr("Angular diamater of the sun as seen from the Earth.");
ExponentLabel = tr("Strength");
break;
@ -1522,57 +1496,60 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
switch (LightType)
{
case lcLightType::Point:
mLightSizeXItem = addProperty(mLightAttributesItem, tr("Radius"), PropertyFloat);
mLightSizeXItem->setToolTip(1, tr("Shadow soft size (Blender only)."));
break;
case lcLightType::Spot:
{
mLightSpotConeAngleItem = addProperty(mLightAttributesItem, tr("Spot Cone Angle"), PropertyFloat);
mLightSpotConeAngleItem->setToolTip(1, tr("The angle (in degrees) of the spot light's beam."));
mLightSpotConeAngleItem = addProperty(mLightAttributesItem, tr("Spot Cone Angle"), PropertyFloat);
mLightSpotConeAngleItem->setToolTip(1, tr("The angle (in degrees) of the spot light's beam."));
mLightSpotPenumbraAngleItem = addProperty(mLightAttributesItem, tr("Spot Penumbra Angle"), PropertyFloat);
mLightSpotPenumbraAngleItem->setToolTip(1, tr("The angle (in degrees) over which the intensity of the spot light falls off to zero."));
mLightSpotPenumbraAngleItem = addProperty(mLightAttributesItem, tr("Spot Penumbra Angle"), PropertyFloat);
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->setToolTip(1, tr("Additional exponential spot light edge softening (POV-Ray only)."));
}
mLightSpotTightnessItem = addProperty(mLightAttributesItem, tr("Spot Tightness"), PropertyFloat);
mLightSpotTightnessItem->setToolTip(1, tr("Additional exponential spot light edge softening (POV-Ray only)."));
mLightSizeXItem = addProperty(mLightAttributesItem, tr("Radius"), PropertyFloat);
mLightSizeXItem->setToolTip(1, tr("Shadow soft size (Blender only)."));
break;
case lcLightType::Directional:
mLightSizeXItem = addProperty(mLightAttributesItem, tr("Angle"), PropertyFloat);
mLightSizeXItem->setToolTip(1, tr("Angular diameter of the light (Blender only)."));
break;
case lcLightType::Area:
mLightAreaShapeItem = addProperty(mLightAttributesItem, tr("Area Shape"), PropertyStringList);
mLightAreaShapeItem->setToolTip(1, tr("The shape of the area light."));
switch (LightAreaShape)
{
mLightAreaShapeItem = addProperty(mLightAttributesItem, tr("Area Shape"), PropertyStringList);
mLightAreaShapeItem->setToolTip(1, tr("The shape of the area light."));
case lcLightAreaShape::Rectangle:
case lcLightAreaShape::Ellipse:
mLightSizeXItem = addProperty(mLightAttributesItem, tr("Area Width"), PropertyFloat);
mLightSizeXItem->setToolTip(1, tr("The width (X direction) of the area light."));
switch (LightAreaShape)
{
case lcLightAreaShape::Rectangle:
case lcLightAreaShape::Ellipse:
mLightAreaSizeXItem = addProperty(mLightAttributesItem, tr("Area Width"), PropertyFloat);
mLightAreaSizeXItem->setToolTip(1, tr("The width (X direction) of the area light."));
mLightSizeYItem = addProperty(mLightAttributesItem, tr("Area Height"), PropertyFloat);
mLightSizeYItem->setToolTip(1, tr("The height (Y direction) of the area light."));
break;
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:
mLightSizeXItem = addProperty(mLightAttributesItem, tr("Area Size"), PropertyFloat);
mLightSizeXItem->setToolTip(1, tr("The size of the area light."));
case lcLightAreaShape::Square:
case lcLightAreaShape::Disk:
mLightAreaSizeXItem = addProperty(mLightAttributesItem, tr("Area Size"), PropertyFloat);
mLightAreaSizeXItem->setToolTip(1, tr("The size of the area light."));
mLightSizeYItem = nullptr;
break;
mLightAreaSizeYItem = nullptr;
break;
case lcLightAreaShape::Count:
break;
}
case lcLightAreaShape::Count:
break;
}
if (POVRayLight)
{
lightAreaGridRows = addProperty(mLightAttributesItem, tr("Grid Rows"), PropertyFloat);
lightAreaGridColumns = addProperty(mLightAttributesItem, tr("Grid Columns"), PropertyFloat);
}
if (POVRayLight)
{
lightAreaGridRows = addProperty(mLightAttributesItem, tr("Grid Rows"), PropertyFloat);
lightAreaGridColumns = addProperty(mLightAttributesItem, tr("Grid Columns"), PropertyFloat);
}
break;
@ -1582,9 +1559,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloat);
if (!POVRayLight)
{
if (LightType != lcLightType::Directional)
@ -1658,49 +1632,31 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
lightFormat->setText(1, Format);
lightFormat->setData(0, PropertyValueRole, FormatIndex);
mLightTypeItem->setText(1, lcLight::GetTypeString(LightType));
mLightTypeItem->setText(1, lcLight::GetLightTypeString(LightType));
mLightTypeItem->setData(0, PropertyValueRole, static_cast<int>(LightType));
mLightCastShadowItem->setCheckState(1, CastShadow ? Qt::Checked : Qt::Unchecked);
mLightCastShadowItem->setData(0, PropertyValueRole, CastShadow);
mLightSizeXItem->setText(1, lcFormatValueLocalized(LightSize[0]));
mLightSizeXItem->setData(0, PropertyValueRole, LightSize[0]);
if (mLightSizeYItem)
{
mLightSizeYItem->setText(1, lcFormatValueLocalized(LightSize[1]));
mLightSizeYItem->setData(0, PropertyValueRole, LightSize[1]);
}
lightExponent->setText(1, lcFormatValueLocalized(Exponent));
lightExponent->setData(0, PropertyValueRole, Exponent);
lightExponent->setToolTip(1, ExponentToolTip);
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
switch (LightType)
{
lightFactorA->setText(1, lcFormatValueLocalized(Factor[0]));
lightFactorA->setData(0, PropertyValueRole, Factor[0]);
lightFactorA->setToolTip(1, FactorAToolTip);
}
else if (LightType == lcLightType::Area)
{
mLightAreaShapeItem->setText(1, lcLight::GetAreaShapeString(LightAreaShape));
mLightAreaShapeItem->setData(0, PropertyValueRole, static_cast<int>(LightAreaShape));
case lcLightType::Point:
break;
mLightAreaSizeXItem->setText(1, lcFormatValueLocalized(LightAreaSize[0]));
mLightAreaSizeXItem->setData(0, PropertyValueRole, LightAreaSize[0]);
if (mLightAreaSizeYItem)
{
mLightAreaSizeYItem->setText(1, lcFormatValueLocalized(LightAreaSize[1]));
mLightAreaSizeYItem->setData(0, PropertyValueRole, LightAreaSize[1]);
}
if (POVRayLight)
{
lightAreaGridRows->setText(1, lcFormatValueLocalized(AreaGrid[0]));
lightAreaGridRows->setData(0, PropertyValueRole, AreaGrid[0]);
lightAreaGridRows->setToolTip(1, tr("The number of sample rows in the area light."));
lightAreaGridColumns->setText(1, lcFormatValueLocalized(AreaGrid[1]));
lightAreaGridColumns->setData(0, PropertyValueRole, AreaGrid[1]);
lightAreaGridColumns->setToolTip(1, tr("The number of sample columns in the area light."));
}
}
else if (LightType == lcLightType::Spot)
{
case lcLightType::Spot:
mLightSpotConeAngleItem->setText(1, lcFormatValueLocalized(SpotConeAngle));
mLightSpotConeAngleItem->setData(0, PropertyValueRole, SpotConeAngle);
mLightSpotConeAngleItem->setData(0, PropertyRangeRole, QPointF(1.0, 180.0));
@ -1712,6 +1668,29 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
mLightSpotTightnessItem->setText(1, lcFormatValueLocalized(SpotTightness));
mLightSpotTightnessItem->setData(0, PropertyValueRole, SpotTightness);
mLightSpotTightnessItem->setData(0, PropertyRangeRole, QPointF(0.0, 100.0));
break;
case lcLightType::Directional:
break;
case lcLightType::Area:
mLightAreaShapeItem->setText(1, lcLight::GetAreaShapeString(LightAreaShape));
mLightAreaShapeItem->setData(0, PropertyValueRole, static_cast<int>(LightAreaShape));
if (POVRayLight)
{
lightAreaGridRows->setText(1, lcFormatValueLocalized(AreaGrid[0]));
lightAreaGridRows->setData(0, PropertyValueRole, AreaGrid[0]);
lightAreaGridRows->setToolTip(1, tr("The number of sample rows in the area light."));
lightAreaGridColumns->setText(1, lcFormatValueLocalized(AreaGrid[1]));
lightAreaGridColumns->setData(0, PropertyValueRole, AreaGrid[1]);
lightAreaGridColumns->setToolTip(1, tr("The number of sample columns in the area light."));
}
break;
case lcLightType::Count:
break;
}
if (!POVRayLight)

View file

@ -145,10 +145,8 @@ protected:
QTreeWidgetItem* mLightSpotPenumbraAngleItem;
QTreeWidgetItem* mLightSpotTightnessItem;
QTreeWidgetItem* mLightAreaShapeItem;
QTreeWidgetItem* mLightAreaSizeXItem;
QTreeWidgetItem* mLightAreaSizeYItem;
QTreeWidgetItem* lightFactorA;
QTreeWidgetItem* lightFactorB;
QTreeWidgetItem* mLightSizeXItem;
QTreeWidgetItem* mLightSizeYItem;
QTreeWidgetItem* mLightNameItem;
QTreeWidgetItem* lightFormat;
QTreeWidgetItem* mLightCastShadowItem;