mirror of
https://github.com/leozide/leocad
synced 2024-12-26 21:58:44 +01:00
Renamed shadowless to cast shadow.
This commit is contained in:
parent
9648dbb977
commit
080a418e1b
7 changed files with 61 additions and 45 deletions
|
@ -3136,6 +3136,19 @@ void lcModel::SetLightColor(lcLight* Light, const lcVector3& Color)
|
||||||
UpdateAllViews();
|
UpdateAllViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcModel::SetLightCastShadow(lcLight* Light, bool CastShadow)
|
||||||
|
{
|
||||||
|
if (Light->GetCastShadow() == CastShadow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Light->SetCastShadow(CastShadow);
|
||||||
|
Light->UpdatePosition(mCurrentStep);
|
||||||
|
|
||||||
|
SaveCheckpoint(tr("Changing Light Shadow"));
|
||||||
|
gMainWindow->UpdateSelectedObjects(false);
|
||||||
|
UpdateAllViews();
|
||||||
|
}
|
||||||
|
|
||||||
void lcModel::SetLightName(lcLight* Light, const QString &Name)
|
void lcModel::SetLightName(lcLight* Light, const QString &Name)
|
||||||
{
|
{
|
||||||
if (Light->GetName() == Name)
|
if (Light->GetName() == Name)
|
||||||
|
|
|
@ -370,6 +370,7 @@ public:
|
||||||
|
|
||||||
void SetLightType(lcLight* Light, lcLightType LightType);
|
void SetLightType(lcLight* Light, lcLightType LightType);
|
||||||
void SetLightColor(lcLight* Light, const lcVector3& Color);
|
void SetLightColor(lcLight* Light, const lcVector3& Color);
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,7 @@ lcLight::lcLight(const lcVector3& Position, const lcVector3& TargetPosition, lcL
|
||||||
}
|
}
|
||||||
|
|
||||||
mPOVRayLight = false;
|
mPOVRayLight = false;
|
||||||
mShadowless = false;
|
|
||||||
mEnableCutoff = false;
|
mEnableCutoff = false;
|
||||||
mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
|
||||||
mAttenuation = lcVector3(1.0f, 0.0f, 0.0f);
|
mAttenuation = lcVector3(1.0f, 0.0f, 0.0f);
|
||||||
mLightFactor[0] = LightType == lcLightType::Directional ? 11.4f : 0.25f;
|
mLightFactor[0] = LightType == lcLightType::Directional ? 11.4f : 0.25f;
|
||||||
mLightFactor[1] = LightType == lcLightType::Area ? 0.25f : LightType == lcLightType::Spot ? 0.150f : 0.0f;
|
mLightFactor[1] = LightType == lcLightType::Area ? 0.25f : LightType == lcLightType::Spot ? 0.150f : 0.0f;
|
||||||
|
@ -108,7 +106,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||||
if (mPOVRayLight)
|
if (mPOVRayLight)
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT POV_RAY") << LineEnding;
|
Stream << QLatin1String("0 !LEOCAD LIGHT POV_RAY") << LineEnding;
|
||||||
|
|
||||||
if (mShadowless)
|
if (!mCastShadow)
|
||||||
Stream << QLatin1String("0 !LEOCAD LIGHT SHADOWLESS") << LineEnding;
|
Stream << QLatin1String("0 !LEOCAD LIGHT SHADOWLESS") << LineEnding;
|
||||||
|
|
||||||
if (mPositionKeys.GetSize() > 1)
|
if (mPositionKeys.GetSize() > 1)
|
||||||
|
@ -485,7 +483,7 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||||
}
|
}
|
||||||
else if (Token == QLatin1String("SHADOWLESS"))
|
else if (Token == QLatin1String("SHADOWLESS"))
|
||||||
{
|
{
|
||||||
mShadowless = true;
|
mCastShadow = false;
|
||||||
}
|
}
|
||||||
else if ((Token == QLatin1String("POWER_KEY")) || (Token == QLatin1String("STRENGTH_KEY")))
|
else if ((Token == QLatin1String("POWER_KEY")) || (Token == QLatin1String("STRENGTH_KEY")))
|
||||||
mSpotExponentKeys.LoadKeysLDraw(Stream);
|
mSpotExponentKeys.LoadKeysLDraw(Stream);
|
||||||
|
@ -609,9 +607,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property)
|
||||||
mLightSpecular = Props.mLightSpecular;
|
mLightSpecular = Props.mLightSpecular;
|
||||||
mLightSpecularKeys.ChangeKey(mLightSpecular, Step, false);
|
mLightSpecularKeys.ChangeKey(mLightSpecular, Step, false);
|
||||||
break;
|
break;
|
||||||
case LC_LIGHT_SHADOWLESS:
|
|
||||||
mShadowless = Props.mShadowless;
|
|
||||||
break;
|
|
||||||
case LC_LIGHT_EXPONENT:
|
case LC_LIGHT_EXPONENT:
|
||||||
if (Props.mPOVRayLight)
|
if (Props.mPOVRayLight)
|
||||||
{
|
{
|
||||||
|
@ -877,6 +872,11 @@ void lcLight::SetColor(const lcVector3& Color, lcStep Step, bool AddKey)
|
||||||
mColorKeys.ChangeKey(Color, Step, AddKey);
|
mColorKeys.ChangeKey(Color, Step, AddKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcLight::SetCastShadow(bool CastShadow)
|
||||||
|
{
|
||||||
|
mCastShadow = CastShadow;
|
||||||
|
}
|
||||||
|
|
||||||
void lcLight::InsertTime(lcStep Start, lcStep Time)
|
void lcLight::InsertTime(lcStep Start, lcStep Time)
|
||||||
{
|
{
|
||||||
mPositionKeys.InsertTime(Start, Time);
|
mPositionKeys.InsertTime(Start, Time);
|
||||||
|
|
|
@ -48,7 +48,6 @@ enum lcLightProperty
|
||||||
LC_LIGHT_FACTOR,
|
LC_LIGHT_FACTOR,
|
||||||
LC_LIGHT_DIFFUSE,
|
LC_LIGHT_DIFFUSE,
|
||||||
LC_LIGHT_SPECULAR,
|
LC_LIGHT_SPECULAR,
|
||||||
LC_LIGHT_SHADOWLESS,
|
|
||||||
LC_LIGHT_EXPONENT,
|
LC_LIGHT_EXPONENT,
|
||||||
LC_LIGHT_AREA_GRID,
|
LC_LIGHT_AREA_GRID,
|
||||||
LC_LIGHT_SPOT_SIZE,
|
LC_LIGHT_SPOT_SIZE,
|
||||||
|
@ -71,7 +70,6 @@ struct lcLightProperties
|
||||||
float mSpotTightness;
|
float mSpotTightness;
|
||||||
float mSpotSize;
|
float mSpotSize;
|
||||||
bool mEnableCutoff;
|
bool mEnableCutoff;
|
||||||
bool mShadowless;
|
|
||||||
bool mPOVRayLight;
|
bool mPOVRayLight;
|
||||||
int mLightShape;
|
int mLightShape;
|
||||||
};
|
};
|
||||||
|
@ -323,6 +321,13 @@ public:
|
||||||
return mColor;
|
return mColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetCastShadow(bool CastShadow);
|
||||||
|
|
||||||
|
bool GetCastShadow() const
|
||||||
|
{
|
||||||
|
return mCastShadow;
|
||||||
|
}
|
||||||
|
|
||||||
void SetName(const QString& Name)
|
void SetName(const QString& Name)
|
||||||
{
|
{
|
||||||
mName = Name;
|
mName = Name;
|
||||||
|
@ -352,7 +357,6 @@ public:
|
||||||
props.mSpotSize = mSpotSize;
|
props.mSpotSize = mSpotSize;
|
||||||
props.mPOVRayLight = mPOVRayLight;
|
props.mPOVRayLight = mPOVRayLight;
|
||||||
props.mEnableCutoff = mEnableCutoff;
|
props.mEnableCutoff = mEnableCutoff;
|
||||||
props.mShadowless = mShadowless;
|
|
||||||
props.mAreaGrid = mAreaGrid;
|
props.mAreaGrid = mAreaGrid;
|
||||||
props.mLightShape = mLightShape;
|
props.mLightShape = mLightShape;
|
||||||
return props;
|
return props;
|
||||||
|
@ -373,7 +377,6 @@ public:
|
||||||
bool mHeightSet;
|
bool mHeightSet;
|
||||||
bool mEnableCutoff;
|
bool mEnableCutoff;
|
||||||
bool mPOVRayLight;
|
bool mPOVRayLight;
|
||||||
bool mShadowless;
|
|
||||||
float mLightDiffuse;
|
float mLightDiffuse;
|
||||||
float mLightSpecular;
|
float mLightSpecular;
|
||||||
float mSpotSize;
|
float mSpotSize;
|
||||||
|
@ -385,8 +388,23 @@ public:
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
lcVector3 mColor;
|
void DrawPointLight(lcContext* Context) const;
|
||||||
|
void DrawSpotLight(lcContext* Context) const;
|
||||||
|
void DrawDirectionalLight(lcContext* Context) const;
|
||||||
|
void DrawAreaLight(lcContext* Context) const;
|
||||||
|
|
||||||
|
float SetupLightMatrix(lcContext* Context) const;
|
||||||
|
void DrawSphere(lcContext* Context, float Radius) const;
|
||||||
|
void DrawCylinder(lcContext* Context, float Radius, float Height) const;
|
||||||
|
void DrawTarget(lcContext* Context, float TargetDistance) const;
|
||||||
|
void DrawCone(lcContext* Context, float TargetDistance) const;
|
||||||
|
|
||||||
|
quint32 mState;
|
||||||
|
lcLightType mLightType;
|
||||||
|
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||||
|
bool mCastShadow = true;
|
||||||
|
|
||||||
|
int mLightShape;
|
||||||
lcObjectKeyArray<lcVector3> mPositionKeys;
|
lcObjectKeyArray<lcVector3> mPositionKeys;
|
||||||
lcObjectKeyArray<lcVector3> mTargetPositionKeys;
|
lcObjectKeyArray<lcVector3> mTargetPositionKeys;
|
||||||
lcObjectKeyArray<lcVector3> mUpVectorKeys;
|
lcObjectKeyArray<lcVector3> mUpVectorKeys;
|
||||||
|
@ -402,19 +420,4 @@ protected:
|
||||||
lcObjectKeyArray<float> mSpotFalloffKeys;
|
lcObjectKeyArray<float> mSpotFalloffKeys;
|
||||||
lcObjectKeyArray<float> mSpotExponentKeys;
|
lcObjectKeyArray<float> mSpotExponentKeys;
|
||||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||||
|
|
||||||
void DrawPointLight(lcContext* Context) const;
|
|
||||||
void DrawSpotLight(lcContext* Context) const;
|
|
||||||
void DrawDirectionalLight(lcContext* Context) const;
|
|
||||||
void DrawAreaLight(lcContext* Context) const;
|
|
||||||
|
|
||||||
float SetupLightMatrix(lcContext* Context) const;
|
|
||||||
void DrawSphere(lcContext* Context, float Radius) const;
|
|
||||||
void DrawCylinder(lcContext* Context, float Radius, float Height) const;
|
|
||||||
void DrawTarget(lcContext* Context, float TargetDistance) const;
|
|
||||||
void DrawCone(lcContext* Context, float TargetDistance) const;
|
|
||||||
|
|
||||||
quint32 mState;
|
|
||||||
lcLightType mLightType;
|
|
||||||
int mLightShape;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2174,7 +2174,7 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
const lcVector3& Location = Light->mPosition;
|
const lcVector3& Location = Light->mPosition;
|
||||||
const QString LightName = QString(Light->mName).replace(" ","_");
|
const QString LightName = QString(Light->mName).replace(" ","_");
|
||||||
LightType = Light->GetLightType();
|
LightType = Light->GetLightType();
|
||||||
Shadowless = static_cast<int>(Light->mShadowless);
|
Shadowless = Light->GetCastShadow() ? 0 : 1;
|
||||||
LightColor = Light->GetColor();
|
LightColor = Light->GetColor();
|
||||||
Power = Light->mPOVRayExponent;
|
Power = Light->mPOVRayExponent;
|
||||||
switch(LightType)
|
switch(LightType)
|
||||||
|
|
|
@ -686,16 +686,15 @@ void lcQPropertiesTree::slotToggled(bool Value)
|
||||||
|
|
||||||
if (Light)
|
if (Light)
|
||||||
{
|
{
|
||||||
lcLightProperties Props = Light->GetLightProperties();
|
|
||||||
if (Item == lightEnableCutoff)
|
if (Item == lightEnableCutoff)
|
||||||
{
|
{
|
||||||
|
lcLightProperties Props = Light->GetLightProperties();
|
||||||
Props.mEnableCutoff = Value;
|
Props.mEnableCutoff = Value;
|
||||||
Model->UpdateLight(Light, Props, LC_LIGHT_USE_CUTOFF);
|
Model->UpdateLight(Light, Props, LC_LIGHT_USE_CUTOFF);
|
||||||
}
|
}
|
||||||
else if (Item == lightShadowless)
|
else if (Item == mLightCastShadowItem)
|
||||||
{
|
{
|
||||||
Props.mShadowless = Value;
|
Model->SetLightCastShadow(Light, Value);
|
||||||
Model->UpdateLight(Light, Props, LC_LIGHT_SHADOWLESS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1196,7 @@ void lcQPropertiesTree::SetEmpty()
|
||||||
lightSpotSize = nullptr;
|
lightSpotSize = nullptr;
|
||||||
lightShape = nullptr;
|
lightShape = nullptr;
|
||||||
lightFormat = nullptr;
|
lightFormat = nullptr;
|
||||||
lightShadowless = nullptr;
|
mLightCastShadowItem = nullptr;
|
||||||
lightAreaGridRows = nullptr;
|
lightAreaGridRows = nullptr;
|
||||||
lightAreaGridColumns = nullptr;
|
lightAreaGridColumns = nullptr;
|
||||||
lightSpotFalloff = nullptr;
|
lightSpotFalloff = nullptr;
|
||||||
|
@ -1449,7 +1448,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
float Exponent = 0.0f;
|
float Exponent = 0.0f;
|
||||||
bool EnableCutoff = false;
|
bool EnableCutoff = false;
|
||||||
bool POVRayLight = false;
|
bool POVRayLight = false;
|
||||||
bool Shadowless = false;
|
bool CastShadow = true;
|
||||||
PropertyType TargetProperty = PropertyFloat;
|
PropertyType TargetProperty = PropertyFloat;
|
||||||
PropertyType SpotSizeProperty = PropertyFloatLightSpotSize;
|
PropertyType SpotSizeProperty = PropertyFloatLightSpotSize;
|
||||||
lcVector3 Position(0.0f, 0.0f, 0.0f);
|
lcVector3 Position(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -1466,7 +1465,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
FormatIndex = static_cast<int>(POVRayLight);
|
FormatIndex = static_cast<int>(POVRayLight);
|
||||||
Format = POVRayLight ? QLatin1String("POVRay") : QLatin1String("Blender");
|
Format = POVRayLight ? QLatin1String("POVRay") : QLatin1String("Blender");
|
||||||
|
|
||||||
Shadowless = Light->mShadowless;
|
CastShadow = Light->GetCastShadow();
|
||||||
Position = Light->mPosition;
|
Position = Light->mPosition;
|
||||||
Target = Light->mTargetPosition;
|
Target = Light->mTargetPosition;
|
||||||
Color = lcQColorFromVector3(Light->GetColor());
|
Color = lcQColorFromVector3(Light->GetColor());
|
||||||
|
@ -1578,8 +1577,8 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
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);
|
||||||
|
mLightCastShadowItem = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
||||||
|
|
||||||
lightShadowless = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
|
||||||
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
|
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
|
||||||
|
|
||||||
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
||||||
|
@ -1691,8 +1690,8 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||||
mLightTypeItem->setText(1, lcLight::GetLightTypeString(LightType));
|
mLightTypeItem->setText(1, lcLight::GetLightTypeString(LightType));
|
||||||
mLightTypeItem->setData(0, PropertyValueRole, static_cast<int>(LightType));
|
mLightTypeItem->setData(0, PropertyValueRole, static_cast<int>(LightType));
|
||||||
|
|
||||||
lightShadowless->setCheckState(1, Shadowless ? Qt::Checked : Qt::Unchecked);
|
mLightCastShadowItem->setCheckState(1, CastShadow ? Qt::Checked : Qt::Unchecked);
|
||||||
lightShadowless->setData(0, PropertyValueRole, Shadowless);
|
mLightCastShadowItem->setData(0, PropertyValueRole, CastShadow);
|
||||||
|
|
||||||
lightExponent->setText(1, lcFormatValueLocalized(Exponent));
|
lightExponent->setText(1, lcFormatValueLocalized(Exponent));
|
||||||
lightExponent->setData(0, PropertyValueRole, Exponent);
|
lightExponent->setData(0, PropertyValueRole, Exponent);
|
||||||
|
|
|
@ -149,7 +149,7 @@ protected:
|
||||||
QTreeWidgetItem* lightFactorB;
|
QTreeWidgetItem* lightFactorB;
|
||||||
QTreeWidgetItem* mLightNameItem;
|
QTreeWidgetItem* mLightNameItem;
|
||||||
QTreeWidgetItem* lightFormat;
|
QTreeWidgetItem* lightFormat;
|
||||||
QTreeWidgetItem* lightShadowless;
|
QTreeWidgetItem* mLightCastShadowItem;
|
||||||
QTreeWidgetItem* lightAreaGridRows;
|
QTreeWidgetItem* lightAreaGridRows;
|
||||||
QTreeWidgetItem* lightAreaGridColumns;
|
QTreeWidgetItem* lightAreaGridColumns;
|
||||||
QTreeWidgetItem* lightSpotFalloff;
|
QTreeWidgetItem* lightSpotFalloff;
|
||||||
|
|
Loading…
Reference in a new issue