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