mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Added light power attribute.
This commit is contained in:
parent
96523c39b9
commit
5430dd6170
6 changed files with 52 additions and 9 deletions
|
@ -3237,6 +3237,16 @@ void lcModel::SetLightSize(lcLight* Light, lcVector2 LightAreaSize)
|
|||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetLightPower(lcLight* Light, float Power)
|
||||
{
|
||||
Light->SetPower(Power, mCurrentStep, gMainWindow->GetAddKeys());
|
||||
Light->UpdatePosition(mCurrentStep);
|
||||
|
||||
SaveCheckpoint(tr("Changing Light Power"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetLightCastShadow(lcLight* Light, bool CastShadow)
|
||||
{
|
||||
if (!Light->SetCastShadow(CastShadow))
|
||||
|
|
|
@ -375,6 +375,7 @@ public:
|
|||
void SetSpotLightTightness(lcLight* Light, float Tightness);
|
||||
void SetAreaLightShape(lcLight* Light, lcLightAreaShape LightAreaShape);
|
||||
void SetLightSize(lcLight* Light, lcVector2 LightAreaSize);
|
||||
void SetLightPower(lcLight* Light, float Power);
|
||||
void SetLightCastShadow(lcLight* Light, bool CastShadow);
|
||||
void SetLightName(lcLight* Light, const QString& Name);
|
||||
void UpdateLight(lcLight* Light, const lcLightProperties Props, int Property);
|
||||
|
|
|
@ -40,6 +40,7 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
|||
mPositionKeys.ChangeKey(mWorldMatrix.GetTranslation(), 1, true);
|
||||
mRotationKeys.ChangeKey(lcMatrix33(mWorldMatrix), 1, true);
|
||||
mColorKeys.ChangeKey(mColor, 1, true);
|
||||
mPowerKeys.ChangeKey(mPower, 1, true);
|
||||
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, true);
|
||||
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
|
@ -785,6 +786,11 @@ void lcLight::SetSize(lcVector2 Size, lcStep Step, bool AddKey)
|
|||
mSizeKeys.ChangeKey(Size, Step, AddKey);
|
||||
}
|
||||
|
||||
void lcLight::SetPower(float Power, lcStep Step, bool AddKey)
|
||||
{
|
||||
mPowerKeys.ChangeKey(Power, Step, AddKey);
|
||||
}
|
||||
|
||||
bool lcLight::SetCastShadow(bool CastShadow)
|
||||
{
|
||||
if (mCastShadow != CastShadow)
|
||||
|
@ -805,6 +811,7 @@ void lcLight::InsertTime(lcStep Start, lcStep Time)
|
|||
mSpotPenumbraAngleKeys.InsertTime(Start, Time);
|
||||
mSpotTightnessKeys.InsertTime(Start, Time);
|
||||
mSizeKeys.InsertTime(Start, Time);
|
||||
mPowerKeys.InsertTime(Start, Time);
|
||||
|
||||
mAttenuationKeys.InsertTime(Start, Time);
|
||||
mLightDiffuseKeys.InsertTime(Start, Time);
|
||||
|
@ -823,6 +830,7 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time)
|
|||
mSpotPenumbraAngleKeys.RemoveTime(Start, Time);
|
||||
mSpotTightnessKeys.RemoveTime(Start, Time);
|
||||
mSizeKeys.RemoveTime(Start, Time);
|
||||
mPowerKeys.RemoveTime(Start, Time);
|
||||
|
||||
mAttenuationKeys.RemoveTime(Start, Time);
|
||||
mLightDiffuseKeys.RemoveTime(Start, Time);
|
||||
|
@ -852,6 +860,7 @@ void lcLight::UpdatePosition(lcStep Step)
|
|||
mSpotPenumbraAngle = mSpotPenumbraAngleKeys.CalculateKey(Step);
|
||||
mSpotTightness = mSpotTightnessKeys.CalculateKey(Step);
|
||||
mSize = mSizeKeys.CalculateKey(Step);
|
||||
mPower = mPowerKeys.CalculateKey(Step);
|
||||
|
||||
mAttenuation = mAttenuationKeys.CalculateKey(Step);
|
||||
mLightDiffuse = mLightDiffuseKeys.CalculateKey(Step);
|
||||
|
@ -1292,6 +1301,9 @@ void lcLight::RemoveKeyFrames()
|
|||
mSizeKeys.RemoveAll();
|
||||
mSizeKeys.ChangeKey(mSize, 1, true);
|
||||
|
||||
mPowerKeys.RemoveAll();
|
||||
mPowerKeys.ChangeKey(mPower, 1, true);
|
||||
|
||||
mAttenuationKeys.RemoveAll();
|
||||
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
||||
|
||||
|
|
|
@ -280,6 +280,13 @@ public:
|
|||
return mSize;
|
||||
}
|
||||
|
||||
void SetPower(float Power, lcStep Step, bool AddKey);
|
||||
|
||||
float GetPower() const
|
||||
{
|
||||
return mPower;
|
||||
}
|
||||
|
||||
bool SetCastShadow(bool CastShadow);
|
||||
|
||||
bool GetCastShadow() const
|
||||
|
@ -351,6 +358,7 @@ protected:
|
|||
bool mCastShadow = true;
|
||||
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||
lcVector2 mSize = lcVector2(0.0f, 0.0f);
|
||||
float mPower = 1.0f;
|
||||
float mSpotConeAngle = 80.0f;
|
||||
float mSpotPenumbraAngle = 0.0f;
|
||||
float mSpotTightness = 0.0f;
|
||||
|
@ -365,6 +373,7 @@ protected:
|
|||
lcObjectKeyArray<lcMatrix33> mRotationKeys;
|
||||
lcObjectKeyArray<lcVector3> mColorKeys;
|
||||
lcObjectKeyArray<lcVector2> mSizeKeys;
|
||||
lcObjectKeyArray<float> mPowerKeys;
|
||||
lcObjectKeyArray<float> mSpotConeAngleKeys;
|
||||
lcObjectKeyArray<float> mSpotPenumbraAngleKeys;
|
||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||
|
|
|
@ -447,9 +447,6 @@ QWidget* lcQPropertiesTree::createEditor(QWidget* Parent, QTreeWidgetItem* Item)
|
|||
return Editor;
|
||||
}
|
||||
|
||||
case PropertyFloatReadOnly:
|
||||
return nullptr;
|
||||
|
||||
case PropertyStep:
|
||||
{
|
||||
QLineEdit* Editor = new QLineEdit(Parent);
|
||||
|
@ -859,6 +856,12 @@ void lcQPropertiesTree::slotReturnPressed()
|
|||
|
||||
Model->SetLightSize(Light, Value);
|
||||
}
|
||||
else if (Item == mLightPowerItem)
|
||||
{
|
||||
float Value = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->SetLightPower(Light, Value);
|
||||
}
|
||||
else if (Item == lightDiffuse)
|
||||
{
|
||||
Props.mLightDiffuse = lcParseValueLocalized(Editor->text());
|
||||
|
@ -1049,10 +1052,7 @@ QTreeWidgetItem *lcQPropertiesTree::addProperty(QTreeWidgetItem *parent, const Q
|
|||
newItem = new QTreeWidgetItem(this, QStringList(label));
|
||||
|
||||
newItem->setData(0, PropertyTypeRole, QVariant(propertyType));
|
||||
|
||||
if (propertyType != PropertyFloatReadOnly)
|
||||
newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);
|
||||
|
||||
newItem->setExpanded(true);
|
||||
|
||||
if (propertyType == PropertyGroup)
|
||||
|
@ -1097,6 +1097,7 @@ void lcQPropertiesTree::SetEmpty()
|
|||
|
||||
lightConfiguration = nullptr;
|
||||
mLightColorItem = nullptr;
|
||||
mLightPowerItem = nullptr;
|
||||
mLightAttributesItem = nullptr;
|
||||
lightDiffuse = nullptr;
|
||||
lightSpecular = nullptr;
|
||||
|
@ -1366,6 +1367,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
lcLightType LightType = lcLightType::Point;
|
||||
lcLightAreaShape LightAreaShape = lcLightAreaShape::Rectangle;
|
||||
lcVector2 LightSize(0.0f, 0.0f);
|
||||
float Power = 0.0f;
|
||||
int FormatIndex = 0;
|
||||
float Diffuse = 0.0f;
|
||||
float Specular = 0.0f;
|
||||
|
@ -1390,6 +1392,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
CastShadow = Light->GetCastShadow();
|
||||
Position = Light->GetPosition();
|
||||
Color = lcQColorFromVector3(Light->GetColor());
|
||||
Power = Light->GetPower();
|
||||
SpotConeAngle = Light->GetSpotConeAngle();
|
||||
SpotPenumbraAngle = Light->GetSpotPenumbraAngle();
|
||||
|
||||
|
@ -1419,7 +1422,6 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
Diffuse = Light->mLightDiffuse;
|
||||
Specular = Light->mLightSpecular;
|
||||
|
||||
|
@ -1449,7 +1451,13 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
mLightAttributesItem = addProperty(nullptr, tr("Light Attributes"), PropertyGroup);
|
||||
mLightNameItem = addProperty(mLightAttributesItem, tr("Name"), PropertyString);
|
||||
mLightTypeItem = addProperty(mLightAttributesItem, tr("Type"), PropertyStringList);
|
||||
|
||||
mLightColorItem = addProperty(mLightAttributesItem, tr("Color"), PropertyColor);
|
||||
mLightColorItem->setToolTip(1, tr("Color of the emitted light."));
|
||||
|
||||
mLightPowerItem = addProperty(mLightAttributesItem, tr("Power"), PropertyFloat);
|
||||
mLightPowerItem->setToolTip(1, tr("Power of the light in Watts (Blender only)."));
|
||||
|
||||
mLightCastShadowItem = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
||||
|
||||
switch (LightType)
|
||||
|
@ -1592,6 +1600,9 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
mLightColorItem->setText(1, Color.name().toUpper());
|
||||
mLightColorItem->setData(0, PropertyValueRole, Color);
|
||||
|
||||
mLightPowerItem->setText(1, lcFormatValueLocalized(Power));
|
||||
mLightPowerItem->setData(0, PropertyValueRole, Power);
|
||||
|
||||
lightFormat->setText(1, Format);
|
||||
lightFormat->setData(0, PropertyValueRole, FormatIndex);
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
PropertyGroup,
|
||||
PropertyBool,
|
||||
PropertyFloat,
|
||||
PropertyFloatReadOnly,
|
||||
PropertyStep,
|
||||
PropertyString,
|
||||
PropertyStringList,
|
||||
|
@ -117,6 +116,7 @@ protected:
|
|||
|
||||
QTreeWidgetItem* lightConfiguration;
|
||||
QTreeWidgetItem* mLightColorItem;
|
||||
QTreeWidgetItem* mLightPowerItem;
|
||||
QTreeWidgetItem* mLightAttributesItem;
|
||||
QTreeWidgetItem* lightDiffuse;
|
||||
QTreeWidgetItem* lightSpecular;
|
||||
|
|
Loading…
Reference in a new issue