mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Reorganized spot light parameters.
This commit is contained in:
parent
846ddaab0d
commit
e061eca2e8
13 changed files with 304 additions and 281 deletions
|
@ -645,28 +645,28 @@ const lcCommand gCommands[] =
|
|||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.PointLight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Point Light"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new omni light sources to the model"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new point light sources to the model"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_SPOTLIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.Spotlight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Spotlight"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new spotlights to the model"),
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.SpotLight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Spot Light"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new spot lights to the model"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_DIRECTIONAL_LIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.DirectionalLight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Directional Light"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new omnidirectional sunlight sources to the model - edit in Properties tab"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new omnidirectional light sources to the model"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_AREA_LIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.AreaLight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Area Light"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new arealight sources to the model - edit in Properties tab"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new area light sources to the model"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_CAMERA
|
||||
|
@ -1872,23 +1872,23 @@ LC_ARRAY_SIZE_CHECK(gCommands, LC_NUM_COMMANDS);
|
|||
|
||||
const char* gToolNames[] =
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewPiece"), // lcTool::Insert
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewPointLight"), // lcTool::PointLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewSpotlight"), // lcTool::Spotlight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewPiece"), // lcTool::Insert
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewPointLight"), // lcTool::PointLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewSpotLight"), // lcTool::SpotLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewDirectionalLight"), // lcTool::DirectionalLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewAreaLight"), // lcTool::AreaLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewCamera"), // lcTool::Camera
|
||||
QT_TRANSLATE_NOOP("Mouse", "Select"), // lcTool::Select
|
||||
QT_TRANSLATE_NOOP("Mouse", "Move"), // lcTool::Move
|
||||
QT_TRANSLATE_NOOP("Mouse", "Rotate"), // lcTool::Rotate
|
||||
QT_TRANSLATE_NOOP("Mouse", "Delete"), // lcTool::Eraser
|
||||
QT_TRANSLATE_NOOP("Mouse", "Paint"), // lcTool::Paint
|
||||
QT_TRANSLATE_NOOP("Mouse", "ColorPicker"), // lcTool::ColorPicker
|
||||
QT_TRANSLATE_NOOP("Mouse", "Zoom"), // lcTool::Zoom
|
||||
QT_TRANSLATE_NOOP("Mouse", "Pan"), // lcTool::Pan
|
||||
QT_TRANSLATE_NOOP("Mouse", "Orbit"), // lcTool::RotateView
|
||||
QT_TRANSLATE_NOOP("Mouse", "Roll"), // lcTool::Roll
|
||||
QT_TRANSLATE_NOOP("Mouse", "ZoomRegion") // lcTool::ZoomRegion
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewAreaLight"), // lcTool::AreaLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewCamera"), // lcTool::Camera
|
||||
QT_TRANSLATE_NOOP("Mouse", "Select"), // lcTool::Select
|
||||
QT_TRANSLATE_NOOP("Mouse", "Move"), // lcTool::Move
|
||||
QT_TRANSLATE_NOOP("Mouse", "Rotate"), // lcTool::Rotate
|
||||
QT_TRANSLATE_NOOP("Mouse", "Delete"), // lcTool::Eraser
|
||||
QT_TRANSLATE_NOOP("Mouse", "Paint"), // lcTool::Paint
|
||||
QT_TRANSLATE_NOOP("Mouse", "ColorPicker"), // lcTool::ColorPicker
|
||||
QT_TRANSLATE_NOOP("Mouse", "Zoom"), // lcTool::Zoom
|
||||
QT_TRANSLATE_NOOP("Mouse", "Pan"), // lcTool::Pan
|
||||
QT_TRANSLATE_NOOP("Mouse", "Orbit"), // lcTool::RotateView
|
||||
QT_TRANSLATE_NOOP("Mouse", "Roll"), // lcTool::Roll
|
||||
QT_TRANSLATE_NOOP("Mouse", "ZoomRegion") // lcTool::ZoomRegion
|
||||
};
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(gToolNames, lcTool::Count);
|
||||
|
|
|
@ -301,7 +301,7 @@ enum class lcTool
|
|||
{
|
||||
Insert,
|
||||
PointLight,
|
||||
Spotlight,
|
||||
SpotLight,
|
||||
DirectionalLight,
|
||||
AreaLight,
|
||||
Camera,
|
||||
|
|
|
@ -3389,7 +3389,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
|||
break;
|
||||
|
||||
case LC_EDIT_ACTION_SPOTLIGHT:
|
||||
SetTool(lcTool::Spotlight);
|
||||
SetTool(lcTool::SpotLight);
|
||||
break;
|
||||
|
||||
case LC_EDIT_ACTION_CAMERA:
|
||||
|
|
|
@ -3184,6 +3184,45 @@ void lcModel::SetLightColor(lcLight* Light, const lcVector3& Color)
|
|||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetSpotLightConeAngle(lcLight* Light, float Angle)
|
||||
{
|
||||
if (Light->GetSpotConeAngle() == Angle)
|
||||
return;
|
||||
|
||||
Light->SetSpotConeAngle(Angle, mCurrentStep, gMainWindow->GetAddKeys());
|
||||
Light->UpdatePosition(mCurrentStep);
|
||||
|
||||
SaveCheckpoint(tr("Changing Spot Light Cone Angle"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetSpotLightPenumbraAngle(lcLight* Light, float Angle)
|
||||
{
|
||||
if (Light->GetSpotPenumbraAngle() == Angle)
|
||||
return;
|
||||
|
||||
Light->SetSpotPenumbraAngle(Angle, mCurrentStep, gMainWindow->GetAddKeys());
|
||||
Light->UpdatePosition(mCurrentStep);
|
||||
|
||||
SaveCheckpoint(tr("Changing Spot Light Penumbra Angle"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetSpotLightTightness(lcLight* Light, float Tightness)
|
||||
{
|
||||
if (Light->GetSpotTightness() == Tightness)
|
||||
return;
|
||||
|
||||
Light->SetSpotTightness(Tightness, mCurrentStep, gMainWindow->GetAddKeys());
|
||||
Light->UpdatePosition(mCurrentStep);
|
||||
|
||||
SaveCheckpoint(tr("Changing Spot Light Tightness"));
|
||||
gMainWindow->UpdateSelectedObjects(false);
|
||||
UpdateAllViews();
|
||||
}
|
||||
|
||||
void lcModel::SetLightCastShadow(lcLight* Light, bool CastShadow)
|
||||
{
|
||||
if (Light->GetCastShadow() == CastShadow)
|
||||
|
@ -4179,14 +4218,11 @@ void lcModel::EndMouseTool(lcTool Tool, bool Accept)
|
|||
{
|
||||
case lcTool::Insert:
|
||||
case lcTool::PointLight:
|
||||
case lcTool::SpotLight:
|
||||
case lcTool::DirectionalLight:
|
||||
case lcTool::AreaLight:
|
||||
break;
|
||||
|
||||
case lcTool::Spotlight:
|
||||
SaveCheckpoint(tr("New Spotlight"));
|
||||
break;
|
||||
|
||||
case lcTool::Camera:
|
||||
gMainWindow->UpdateCameraMenu();
|
||||
SaveCheckpoint(tr("New Camera"));
|
||||
|
|
|
@ -370,6 +370,9 @@ public:
|
|||
|
||||
void SetLightType(lcLight* Light, lcLightType LightType);
|
||||
void SetLightColor(lcLight* Light, const lcVector3& Color);
|
||||
void SetSpotLightConeAngle(lcLight* Light, float Angle);
|
||||
void SetSpotLightPenumbraAngle(lcLight* Light, float Angle);
|
||||
void SetSpotLightTightness(lcLight* Light, float Tightness);
|
||||
void SetLightCastShadow(lcLight* Light, bool CastShadow);
|
||||
void SetLightName(lcLight* Light, const QString& Name);
|
||||
void UpdateLight(lcLight* Light, const lcLightProperties Props, int Property);
|
||||
|
|
|
@ -1597,7 +1597,7 @@ lcTrackTool lcView::GetOverrideTrackTool(Qt::MouseButton Button) const
|
|||
{
|
||||
lcTrackTool::Insert, // lcTool::Insert
|
||||
lcTrackTool::PointLight, // lcTool::PointLight
|
||||
lcTrackTool::Spotlight, // lcTool::Spotlight
|
||||
lcTrackTool::SpotLight, // lcTool::SpotLight
|
||||
lcTrackTool::DirectionalLight, // lcTool::DirectionalLight
|
||||
lcTrackTool::AreaLight, // lcTool::AreaLight
|
||||
lcTrackTool::Camera, // lcTool::Camera
|
||||
|
@ -1870,7 +1870,7 @@ lcCursor lcView::GetCursor() const
|
|||
lcCursor::Select, // lcTrackTool::None
|
||||
lcCursor::Brick, // lcTrackTool::Insert
|
||||
lcCursor::PointLight, // lcTrackTool::PointLight
|
||||
lcCursor::Spotlight, // lcTrackTool::Spotlight
|
||||
lcCursor::SpotLight, // lcTrackTool::SpotLight
|
||||
lcCursor::DirectionalLight, // lcTrackTool::DirectionalLight
|
||||
lcCursor::AreaLight, // lcTrackTool::AreaLight
|
||||
lcCursor::Camera, // lcTrackTool::Camera
|
||||
|
@ -1926,7 +1926,7 @@ void lcView::SetCursor(lcCursor CursorType)
|
|||
{ 0, 0, "" }, // lcCursor::Default
|
||||
{ 8, 3, ":/resources/cursor_insert" }, // lcCursor::Brick
|
||||
{ 15, 15, ":/resources/cursor_light" }, // lcCursor::PointLight
|
||||
{ 7, 10, ":/resources/cursor_spotlight" }, // lcCursor::Spotlight
|
||||
{ 7, 10, ":/resources/cursor_spotlight" }, // lcCursor::SpotLight
|
||||
{ 15, 15, ":/resources/cursor_sunlight" }, // lcCursor::DirectionalLight
|
||||
{ 15, 15, ":/resources/cursor_arealight" }, // lcCursor::AreaLight
|
||||
{ 15, 9, ":/resources/cursor_camera" }, // lcCursor::Camera
|
||||
|
@ -1979,7 +1979,7 @@ lcTool lcView::GetCurrentTool() const
|
|||
lcTool::Select, // lcTrackTool::None
|
||||
lcTool::Insert, // lcTrackTool::Insert
|
||||
lcTool::PointLight, // lcTrackTool::PointLight
|
||||
lcTool::Spotlight, // lcTrackTool::Spotlight
|
||||
lcTool::SpotLight, // lcTrackTool::SpotLight
|
||||
lcTool::DirectionalLight, // lcTrackTool::DirectionalLight
|
||||
lcTool::AreaLight, // lcTrackTool::AreaLight
|
||||
lcTool::Camera, // lcTrackTool::Camera
|
||||
|
@ -2045,8 +2045,8 @@ void lcView::UpdateTrackTool()
|
|||
NewTrackTool = lcTrackTool::PointLight;
|
||||
break;
|
||||
|
||||
case lcTool::Spotlight:
|
||||
NewTrackTool = lcTrackTool::Spotlight;
|
||||
case lcTool::SpotLight:
|
||||
NewTrackTool = lcTrackTool::SpotLight;
|
||||
break;
|
||||
|
||||
case lcTool::DirectionalLight:
|
||||
|
@ -2276,7 +2276,7 @@ void lcView::StartTracking(lcTrackButton TrackButton)
|
|||
{
|
||||
case lcTool::Insert:
|
||||
case lcTool::PointLight:
|
||||
case lcTool::Spotlight:
|
||||
case lcTool::SpotLight:
|
||||
case lcTool::DirectionalLight:
|
||||
case lcTool::AreaLight:
|
||||
break;
|
||||
|
@ -2337,7 +2337,7 @@ void lcView::StopTracking(bool Accept)
|
|||
case lcTool::PointLight:
|
||||
break;
|
||||
|
||||
case lcTool::Spotlight:
|
||||
case lcTool::SpotLight:
|
||||
case lcTool::DirectionalLight:
|
||||
case lcTool::AreaLight:
|
||||
case lcTool::Camera:
|
||||
|
@ -2469,7 +2469,7 @@ void lcView::OnButtonDown(lcTrackButton TrackButton)
|
|||
AddLight(lcLightType::Point);
|
||||
break;
|
||||
|
||||
case lcTrackTool::Spotlight:
|
||||
case lcTrackTool::SpotLight:
|
||||
AddLight(lcLightType::Spot);
|
||||
break;
|
||||
|
||||
|
@ -2715,7 +2715,7 @@ void lcView::OnMouseMove()
|
|||
case lcTrackTool::None:
|
||||
case lcTrackTool::Insert:
|
||||
case lcTrackTool::PointLight:
|
||||
case lcTrackTool::Spotlight:
|
||||
case lcTrackTool::SpotLight:
|
||||
case lcTrackTool::DirectionalLight:
|
||||
case lcTrackTool::AreaLight:
|
||||
break;
|
||||
|
|
|
@ -18,7 +18,7 @@ enum class lcCursor
|
|||
Default,
|
||||
Brick,
|
||||
PointLight,
|
||||
Spotlight,
|
||||
SpotLight,
|
||||
DirectionalLight,
|
||||
AreaLight,
|
||||
Camera,
|
||||
|
@ -53,7 +53,7 @@ enum class lcTrackTool
|
|||
None,
|
||||
Insert,
|
||||
PointLight,
|
||||
Spotlight,
|
||||
SpotLight,
|
||||
DirectionalLight,
|
||||
AreaLight,
|
||||
Camera,
|
||||
|
|
|
@ -674,7 +674,7 @@ bool lcViewManipulator::IsTrackToolAllowed(lcTrackTool TrackTool, quint32 Allowe
|
|||
case lcTrackTool::None:
|
||||
case lcTrackTool::Insert:
|
||||
case lcTrackTool::PointLight:
|
||||
case lcTrackTool::Spotlight:
|
||||
case lcTrackTool::SpotLight:
|
||||
case lcTrackTool::DirectionalLight:
|
||||
case lcTrackTool::AreaLight:
|
||||
case lcTrackTool::Camera:
|
||||
|
|
195
common/light.cpp
195
common/light.cpp
|
@ -33,10 +33,7 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
|||
mLightSpecular = 1.0f;
|
||||
mSpotExponent = 10.0f;
|
||||
mPOVRayExponent = 1.0f;
|
||||
mSpotSize = 75.0f;
|
||||
mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f;
|
||||
mSpotFalloff = 45.0f;
|
||||
mSpotTightness = 0;
|
||||
mAreaGrid = lcVector2(10.0f, 10.0f);
|
||||
mAreaSize = lcVector2(200.0f, 200.0f);
|
||||
mLightShape = LC_LIGHT_SHAPE_SQUARE;
|
||||
|
@ -44,16 +41,16 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
|
|||
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);
|
||||
|
||||
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);
|
||||
mSpotFalloffKeys.ChangeKey(mSpotFalloff, 1, true);
|
||||
mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true);
|
||||
mSpotSizeKeys.ChangeKey(mSpotSize, 1, true);
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
|
||||
|
||||
UpdatePosition(1);
|
||||
|
@ -67,7 +64,7 @@ QString lcLight::GetLightTypeString(lcLightType LightType)
|
|||
return QT_TRANSLATE_NOOP("Light Names", "Point Light");
|
||||
|
||||
case lcLightType::Spot:
|
||||
return QT_TRANSLATE_NOOP("Light Names", "Spotlight");
|
||||
return QT_TRANSLATE_NOOP("Light Names", "Spot Light");
|
||||
|
||||
case lcLightType::Directional:
|
||||
return QT_TRANSLATE_NOOP("Light Names", "Directional Light");
|
||||
|
@ -155,28 +152,26 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
|||
break;
|
||||
|
||||
case lcLightType::Spot:
|
||||
if (mSpotConeAngleKeys.GetSize() > 1)
|
||||
mSpotConeAngleKeys.SaveKeysLDraw(Stream, "LIGHT SPOT_CONE_ANGLE_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_CONE_ANGLE ") << mSpotConeAngle << LineEnding;
|
||||
|
||||
if (mSpotPenumbraAngleKeys.GetSize() > 1)
|
||||
mSpotPenumbraAngleKeys.SaveKeysLDraw(Stream, "LIGHT SPOT_PENUMBRA_ANGLE_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_PENUMBRA_ANGLE ") << mSpotPenumbraAngle << LineEnding;
|
||||
|
||||
if (mSpotTightnessKeys.GetSize() > 1)
|
||||
mSpotTightnessKeys.SaveKeysLDraw(Stream, "SPOT_TIGHTNESS_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_TIGHTNESS ") << mSpotTightness << LineEnding;
|
||||
|
||||
if (mPOVRayLight)
|
||||
{
|
||||
if (mLightFactorKeys.GetSize() > 1)
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << (mSpotSize - mSpotFalloff) << LineEnding;
|
||||
if (mSpotFalloffKeys.GetSize() > 1)
|
||||
mSpotFalloffKeys.SaveKeysLDraw(Stream, "LIGHT SPOT_FALLOFF_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_FALLOFF ") << mSpotFalloff << LineEnding;
|
||||
if (mSpotTightnessKeys.GetSize() > 1)
|
||||
mSpotTightnessKeys.SaveKeysLDraw(Stream, "SPOT_TIGHTNESS_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_TIGHTNESS ") << mSpotTightness << LineEnding;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mSpotSizeKeys.GetSize() > 1)
|
||||
mSpotSizeKeys.SaveKeysLDraw(Stream, "LIGHT SPOT_SIZE_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_SIZE ") << mSpotSize << LineEnding;
|
||||
|
||||
if (mLightFactorKeys.GetSize() > 1)
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_AND_SPOT_BLEND_KEY ");
|
||||
else
|
||||
|
@ -282,7 +277,7 @@ void lcLight::CreateName(const lcArray<lcLight*>& Lights)
|
|||
break;
|
||||
|
||||
case lcLightType::Spot:
|
||||
Prefix = QLatin1String("Spotlight ");
|
||||
Prefix = QLatin1String("Spot Light ");
|
||||
break;
|
||||
|
||||
case lcLightType::Directional:
|
||||
|
@ -362,6 +357,28 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
|||
}
|
||||
else if (Token == QLatin1String("COLOR_KEY"))
|
||||
mColorKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SPOT_CONE_ANGLE"))
|
||||
{
|
||||
Stream >> mSpotConeAngle;
|
||||
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SPOT_CONE_ANGLE_KEY"))
|
||||
mSpotConeAngleKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SPOT_PENUMBRA_ANGLE"))
|
||||
{
|
||||
Stream >> mSpotPenumbraAngle;
|
||||
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SPOT_PENUMBRA_ANGLE_KEY"))
|
||||
mSpotPenumbraAngleKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SPOT_TIGHTNESS"))
|
||||
{
|
||||
mPOVRayLight = true;
|
||||
Stream >> mSpotTightness;
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SPOT_TIGHTNESS_KEY"))
|
||||
mSpotTightnessKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("POWER") || Token == QLatin1String("STRENGTH"))
|
||||
{
|
||||
if (mPOVRayLight)
|
||||
|
@ -406,23 +423,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
|||
Stream >> mAreaGrid[1];
|
||||
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SPOT_FALLOFF"))
|
||||
{
|
||||
mPOVRayLight = true;
|
||||
Stream >> mSpotFalloff;
|
||||
mSpotFalloffKeys.ChangeKey(mSpotFalloff, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SPOT_TIGHTNESS"))
|
||||
{
|
||||
mPOVRayLight = true;
|
||||
Stream >> mSpotTightness;
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SPOT_SIZE"))
|
||||
{
|
||||
Stream >> mSpotSize;
|
||||
mSpotSizeKeys.ChangeKey(mSpotSize, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("SHAPE"))
|
||||
{
|
||||
QString Shape;
|
||||
|
@ -480,12 +480,6 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
|||
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("SPOT_SIZE_KEY"))
|
||||
mSpotSizeKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SPOT_FALLOFF_KEY"))
|
||||
mSpotFalloffKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SPOT_TIGHTNESS_KEY"))
|
||||
mSpotTightnessKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("AREA_GRID_KEY"))
|
||||
mAreaGridKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("DIFFUSE_KEY"))
|
||||
|
@ -602,18 +596,6 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property)
|
|||
mAreaGrid = Props.mAreaGrid;
|
||||
mAreaGridKeys.ChangeKey(mAreaGrid, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_SPOT_SIZE:
|
||||
mSpotSize = Props.mSpotSize;
|
||||
mSpotSizeKeys.ChangeKey(mSpotSize, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_SPOT_FALLOFF:
|
||||
mSpotFalloff = Props.mSpotFalloff;
|
||||
mSpotFalloffKeys.ChangeKey(mSpotFalloff, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_SPOT_TIGHTNESS:
|
||||
mSpotTightness = Props.mSpotTightness;
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_CUTOFF:
|
||||
mSpotCutoff = Props.mSpotCutoff;
|
||||
mSpotCutoffKeys.ChangeKey(mSpotCutoff, Step, false);
|
||||
|
@ -786,6 +768,21 @@ void lcLight::SetColor(const lcVector3& Color, lcStep Step, bool AddKey)
|
|||
mColorKeys.ChangeKey(Color, Step, AddKey);
|
||||
}
|
||||
|
||||
void lcLight::SetSpotConeAngle(float Angle, lcStep Step, bool AddKey)
|
||||
{
|
||||
mSpotConeAngleKeys.ChangeKey(Angle, Step, AddKey);
|
||||
}
|
||||
|
||||
void lcLight::SetSpotPenumbraAngle(float Angle, lcStep Step, bool AddKey)
|
||||
{
|
||||
mSpotPenumbraAngleKeys.ChangeKey(Angle, Step, AddKey);
|
||||
}
|
||||
|
||||
void lcLight::SetSpotTightness(float Tightness, lcStep Step, bool AddKey)
|
||||
{
|
||||
mSpotTightnessKeys.ChangeKey(Tightness, Step, AddKey);
|
||||
}
|
||||
|
||||
void lcLight::SetCastShadow(bool CastShadow)
|
||||
{
|
||||
mCastShadow = CastShadow;
|
||||
|
@ -796,15 +793,16 @@ void lcLight::InsertTime(lcStep Start, lcStep Time)
|
|||
mPositionKeys.InsertTime(Start, Time);
|
||||
mRotationKeys.InsertTime(Start, Time);
|
||||
mColorKeys.InsertTime(Start, Time);
|
||||
mSpotConeAngleKeys.InsertTime(Start, Time);
|
||||
mSpotPenumbraAngleKeys.InsertTime(Start, Time);
|
||||
mSpotTightnessKeys.InsertTime(Start, Time);
|
||||
|
||||
mAttenuationKeys.InsertTime(Start, Time);
|
||||
mLightFactorKeys.InsertTime(Start, Time);
|
||||
mLightDiffuseKeys.InsertTime(Start, Time);
|
||||
mLightSpecularKeys.InsertTime(Start, Time);
|
||||
mSpotSizeKeys.InsertTime(Start, Time);
|
||||
mSpotCutoffKeys.InsertTime(Start, Time);
|
||||
mSpotExponentKeys.InsertTime(Start, Time);
|
||||
mSpotFalloffKeys.InsertTime(Start, Time);
|
||||
mSpotTightnessKeys.InsertTime(Start, Time);
|
||||
mAreaGridKeys.InsertTime(Start, Time);
|
||||
}
|
||||
|
||||
|
@ -813,15 +811,16 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time)
|
|||
mPositionKeys.RemoveTime(Start, Time);
|
||||
mRotationKeys.RemoveTime(Start, Time);
|
||||
mColorKeys.RemoveTime(Start, Time);
|
||||
mSpotConeAngleKeys.RemoveTime(Start, Time);
|
||||
mSpotPenumbraAngleKeys.RemoveTime(Start, Time);
|
||||
mSpotTightnessKeys.RemoveTime(Start, Time);
|
||||
|
||||
mAttenuationKeys.RemoveTime(Start, Time);
|
||||
mLightFactorKeys.RemoveTime(Start, Time);
|
||||
mLightDiffuseKeys.RemoveTime(Start, Time);
|
||||
mLightSpecularKeys.RemoveTime(Start, Time);
|
||||
mSpotSizeKeys.RemoveTime(Start, Time);
|
||||
mSpotCutoffKeys.RemoveTime(Start, Time);
|
||||
mSpotExponentKeys.RemoveTime(Start, Time);
|
||||
mSpotFalloffKeys.RemoveTime(Start, Time);
|
||||
mSpotTightnessKeys.RemoveTime(Start, Time);
|
||||
mAreaGridKeys.RemoveTime(Start, Time);
|
||||
}
|
||||
|
||||
|
@ -841,15 +840,16 @@ void lcLight::UpdatePosition(lcStep Step)
|
|||
}
|
||||
|
||||
mColor = mColorKeys.CalculateKey(Step);
|
||||
mSpotConeAngle = mSpotConeAngleKeys.CalculateKey(Step);
|
||||
mSpotPenumbraAngle = mSpotPenumbraAngleKeys.CalculateKey(Step);
|
||||
mSpotTightness = mSpotTightnessKeys.CalculateKey(Step);
|
||||
|
||||
mAttenuation = mAttenuationKeys.CalculateKey(Step);
|
||||
mLightFactor = mLightFactorKeys.CalculateKey(Step);
|
||||
mLightDiffuse = mLightDiffuseKeys.CalculateKey(Step);
|
||||
mLightSpecular = mLightSpecularKeys.CalculateKey(Step);
|
||||
mSpotSize = mSpotSizeKeys.CalculateKey(Step);
|
||||
mSpotCutoff = mSpotCutoffKeys.CalculateKey(Step);
|
||||
mSpotExponent = mSpotExponentKeys.CalculateKey(Step);
|
||||
mSpotFalloff = mSpotFalloffKeys.CalculateKey(Step);
|
||||
mSpotTightness = mSpotTightnessKeys.CalculateKey(Step);
|
||||
mAreaGrid = mAreaGridKeys.CalculateKey(Step);
|
||||
}
|
||||
|
||||
|
@ -923,7 +923,7 @@ void lcLight::DrawSpotLight(lcContext* Context) const
|
|||
|
||||
Context->DrawIndexedPrimitives(GL_LINES, (ConeEdges + 4) * 2, GL_UNSIGNED_SHORT, 0);
|
||||
|
||||
const float TargetDistance = 25.0f;
|
||||
const float TargetDistance = 250.0f;
|
||||
|
||||
DrawTarget(Context, TargetDistance);
|
||||
|
||||
|
@ -1198,18 +1198,18 @@ void lcLight::DrawTarget(lcContext* Context, float TargetDistance) const
|
|||
void lcLight::DrawCone(lcContext* Context, float TargetDistance) const
|
||||
{
|
||||
constexpr int ConeEdges = 16;
|
||||
const float Radius = tanf(LC_DTOR * mSpotCutoff) * TargetDistance;
|
||||
const float OuterRadius = tanf(LC_DTOR * mSpotConeAngle / 2.0f) * TargetDistance;
|
||||
|
||||
float Verts[(ConeEdges + 1) * 3];
|
||||
float Verts[(ConeEdges * 2 + 1) * 3];
|
||||
float* CurVert = Verts;
|
||||
|
||||
for (int EdgeIndex = 0; EdgeIndex < ConeEdges; EdgeIndex++)
|
||||
{
|
||||
float c = cosf((float)EdgeIndex / ConeEdges * LC_2PI) * Radius;
|
||||
float s = sinf((float)EdgeIndex / ConeEdges * LC_2PI) * Radius;
|
||||
const float c = cosf((float)EdgeIndex / ConeEdges * LC_2PI);
|
||||
const float s = sinf((float)EdgeIndex / ConeEdges * LC_2PI);
|
||||
|
||||
*CurVert++ = c;
|
||||
*CurVert++ = s;
|
||||
*CurVert++ = c * OuterRadius;
|
||||
*CurVert++ = s * OuterRadius;
|
||||
*CurVert++ = -TargetDistance;
|
||||
}
|
||||
|
||||
|
@ -1217,19 +1217,38 @@ void lcLight::DrawCone(lcContext* Context, float TargetDistance) const
|
|||
*CurVert++ = 0.0f;
|
||||
*CurVert++ = 0.0f;
|
||||
|
||||
const bool DrawPenumbra = mSpotPenumbraAngle > 1.0f;
|
||||
|
||||
if (DrawPenumbra)
|
||||
{
|
||||
const float InnerRadius = tanf(LC_DTOR * (mSpotConeAngle / 2.0f - mSpotPenumbraAngle)) * TargetDistance;
|
||||
|
||||
for (int EdgeIndex = 0; EdgeIndex < ConeEdges; EdgeIndex++)
|
||||
{
|
||||
const float c = cosf((float)EdgeIndex / ConeEdges * LC_2PI);
|
||||
const float s = sinf((float)EdgeIndex / ConeEdges * LC_2PI);
|
||||
|
||||
*CurVert++ = c * InnerRadius;
|
||||
*CurVert++ = s * InnerRadius;
|
||||
*CurVert++ = -TargetDistance;
|
||||
}
|
||||
}
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormatPosition(3);
|
||||
|
||||
const GLushort Indices[(ConeEdges + 4) * 2] =
|
||||
constexpr GLushort Indices[(ConeEdges * 2 + 4) * 2] =
|
||||
{
|
||||
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
|
||||
8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 0,
|
||||
16, 0, 16, 4, 16, 8, 16, 12
|
||||
16, 0, 16, 4, 16, 8, 16, 12,
|
||||
17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25,
|
||||
25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 17
|
||||
};
|
||||
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
|
||||
Context->DrawIndexedPrimitives(GL_LINES, (ConeEdges + 4) * 2, GL_UNSIGNED_SHORT, 0);
|
||||
Context->DrawIndexedPrimitives(GL_LINES, DrawPenumbra ? (ConeEdges * 2 + 4) * 2 : (ConeEdges + 4) * 2, GL_UNSIGNED_SHORT, 0);
|
||||
}
|
||||
|
||||
void lcLight::RemoveKeyFrames()
|
||||
|
@ -1243,6 +1262,15 @@ void lcLight::RemoveKeyFrames()
|
|||
mColorKeys.RemoveAll();
|
||||
mColorKeys.ChangeKey(mColor, 1, true);
|
||||
|
||||
mSpotConeAngleKeys.RemoveAll();
|
||||
mSpotConeAngleKeys.ChangeKey(mSpotConeAngle, 1, false);
|
||||
|
||||
mSpotPenumbraAngleKeys.RemoveAll();
|
||||
mSpotPenumbraAngleKeys.ChangeKey(mSpotPenumbraAngle, 1, true);
|
||||
|
||||
mSpotTightnessKeys.RemoveAll();
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
|
||||
mAttenuationKeys.RemoveAll();
|
||||
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
||||
|
||||
|
@ -1255,21 +1283,12 @@ void lcLight::RemoveKeyFrames()
|
|||
mLightSpecularKeys.RemoveAll();
|
||||
mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true);
|
||||
|
||||
mSpotSizeKeys.RemoveAll();
|
||||
mSpotSizeKeys.ChangeKey(mSpotSize, 1, false);
|
||||
|
||||
mSpotCutoffKeys.RemoveAll();
|
||||
mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true);
|
||||
|
||||
mSpotExponentKeys.RemoveAll();
|
||||
mSpotExponentKeys.ChangeKey(mSpotExponent, 1, true);
|
||||
|
||||
mSpotFalloffKeys.RemoveAll();
|
||||
mSpotFalloffKeys.ChangeKey(mSpotFalloff, 1, true);
|
||||
|
||||
mSpotTightnessKeys.RemoveAll();
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
|
||||
mAreaGridKeys.RemoveAll();
|
||||
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
|
||||
}
|
||||
|
|
|
@ -44,9 +44,6 @@ enum lcLightProperty
|
|||
LC_LIGHT_SPECULAR,
|
||||
LC_LIGHT_EXPONENT,
|
||||
LC_LIGHT_AREA_GRID,
|
||||
LC_LIGHT_SPOT_SIZE,
|
||||
LC_LIGHT_SPOT_FALLOFF,
|
||||
LC_LIGHT_SPOT_TIGHTNESS,
|
||||
LC_LIGHT_CUTOFF,
|
||||
LC_LIGHT_USE_CUTOFF,
|
||||
LC_LIGHT_POVRAY
|
||||
|
@ -60,9 +57,6 @@ struct lcLightProperties
|
|||
float mLightSpecular;
|
||||
float mSpotExponent;
|
||||
float mSpotCutoff;
|
||||
float mSpotFalloff;
|
||||
float mSpotTightness;
|
||||
float mSpotSize;
|
||||
bool mEnableCutoff;
|
||||
bool mPOVRayLight;
|
||||
int mLightShape;
|
||||
|
@ -86,7 +80,7 @@ public:
|
|||
return mLightType == lcLightType::Point;
|
||||
}
|
||||
|
||||
bool IsSpotlight() const
|
||||
bool IsSpotLight() const
|
||||
{
|
||||
return mLightType == lcLightType::Spot;
|
||||
}
|
||||
|
@ -267,6 +261,27 @@ public:
|
|||
return mColor;
|
||||
}
|
||||
|
||||
void SetSpotConeAngle(float Angle, lcStep Step, bool AddKey);
|
||||
|
||||
float GetSpotConeAngle() const
|
||||
{
|
||||
return mSpotConeAngle;
|
||||
}
|
||||
|
||||
void SetSpotPenumbraAngle(float Angle, lcStep Step, bool AddKey);
|
||||
|
||||
float GetSpotPenumbraAngle() const
|
||||
{
|
||||
return mSpotPenumbraAngle;
|
||||
}
|
||||
|
||||
void SetSpotTightness(float Angle, lcStep Step, bool AddKey);
|
||||
|
||||
float GetSpotTightness() const
|
||||
{
|
||||
return mSpotTightness;
|
||||
}
|
||||
|
||||
void SetCastShadow(bool CastShadow);
|
||||
|
||||
bool GetCastShadow() const
|
||||
|
@ -299,9 +314,6 @@ public:
|
|||
props.mLightSpecular = mLightSpecular;
|
||||
props.mSpotExponent = mSpotExponent;
|
||||
props.mSpotCutoff = mSpotCutoff;
|
||||
props.mSpotFalloff = mSpotFalloff;
|
||||
props.mSpotTightness = mSpotTightness;
|
||||
props.mSpotSize = mSpotSize;
|
||||
props.mPOVRayLight = mPOVRayLight;
|
||||
props.mEnableCutoff = mEnableCutoff;
|
||||
props.mAreaGrid = mAreaGrid;
|
||||
|
@ -323,10 +335,7 @@ public:
|
|||
bool mPOVRayLight;
|
||||
float mLightDiffuse;
|
||||
float mLightSpecular;
|
||||
float mSpotSize;
|
||||
float mSpotCutoff;
|
||||
float mSpotFalloff;
|
||||
float mSpotTightness;
|
||||
float mSpotExponent;
|
||||
float mPOVRayExponent;
|
||||
QString mName;
|
||||
|
@ -345,22 +354,25 @@ protected:
|
|||
|
||||
quint32 mState = 0;
|
||||
lcLightType mLightType;
|
||||
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||
bool mCastShadow = true;
|
||||
lcVector3 mColor = lcVector3(1.0f, 1.0f, 1.0f);
|
||||
float mSpotConeAngle = 80.0f;
|
||||
float mSpotPenumbraAngle = 0.0f;
|
||||
float mSpotTightness = 0.0f;
|
||||
|
||||
int mLightShape;
|
||||
lcObjectKeyArray<lcVector3> mPositionKeys;
|
||||
lcObjectKeyArray<lcMatrix33> mRotationKeys;
|
||||
lcObjectKeyArray<lcVector3> mColorKeys;
|
||||
lcObjectKeyArray<float> mSpotConeAngleKeys;
|
||||
lcObjectKeyArray<float> mSpotPenumbraAngleKeys;
|
||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||
|
||||
lcObjectKeyArray<lcVector3> mAttenuationKeys;
|
||||
lcObjectKeyArray<lcVector2> mLightFactorKeys;
|
||||
lcObjectKeyArray<lcVector2> mAreaGridKeys;
|
||||
lcObjectKeyArray<float> mLightSpecularKeys;
|
||||
lcObjectKeyArray<float> mLightDiffuseKeys;
|
||||
lcObjectKeyArray<float> mSpotSizeKeys;
|
||||
lcObjectKeyArray<float> mSpotCutoffKeys;
|
||||
lcObjectKeyArray<float> mSpotFalloffKeys;
|
||||
lcObjectKeyArray<float> mSpotExponentKeys;
|
||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||
};
|
||||
|
|
|
@ -2185,8 +2185,8 @@ bool Project::ExportPOVRay(const QString& FileName)
|
|||
switch(LightType)
|
||||
{
|
||||
case lcLightType::Spot:
|
||||
SpotFalloff = Light->mSpotFalloff;
|
||||
SpotRadius = Light->mSpotSize - SpotFalloff;
|
||||
SpotFalloff = Light->GetSpotConeAngle() / 2.0f;
|
||||
SpotRadius = SpotFalloff - Light->GetSpotPenumbraAngle();
|
||||
break;
|
||||
case lcLightType::Area:
|
||||
AreaCircle = Light->GetLightShape() == LC_LIGHT_SHAPE_DISK ? 1 : 0;
|
||||
|
|
|
@ -423,11 +423,11 @@ protected:
|
|||
bool mAllowEmpty;
|
||||
};
|
||||
|
||||
QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item) const
|
||||
QWidget* lcQPropertiesTree::createEditor(QWidget* Parent, QTreeWidgetItem* Item) const
|
||||
{
|
||||
PropertyType propertyType = (PropertyType)item->data(0, lcQPropertiesTree::PropertyTypeRole).toInt();
|
||||
lcQPropertiesTree::PropertyType PropertyType = (lcQPropertiesTree::PropertyType)Item->data(0, lcQPropertiesTree::PropertyTypeRole).toInt();
|
||||
|
||||
switch (propertyType)
|
||||
switch (PropertyType)
|
||||
{
|
||||
case PropertyGroup:
|
||||
case PropertyBool:
|
||||
|
@ -435,65 +435,40 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyFloat:
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
float value = item->data(0, PropertyValueRole).toFloat();
|
||||
QLineEdit* Editor = new QLineEdit(Parent);
|
||||
float Value = Item->data(0, PropertyValueRole).toFloat();
|
||||
QPointF Range = Item->data(0, PropertyRangeRole).toPointF();
|
||||
|
||||
editor->setValidator(new QDoubleValidator(editor));
|
||||
editor->setText(lcFormatValueLocalized(value));
|
||||
Editor->setValidator(Range.isNull() ? new QDoubleValidator(Editor) : new QDoubleValidator(Range.x(), Range.y(), 1, Editor));
|
||||
Editor->setText(lcFormatValueLocalized(Value));
|
||||
|
||||
connect(editor, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
|
||||
connect(Editor, &QLineEdit::returnPressed, this, &lcQPropertiesTree::slotReturnPressed);
|
||||
|
||||
return editor;
|
||||
return Editor;
|
||||
}
|
||||
|
||||
case PropertyFloatLightSpotSize:
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
float value = item->data(0, PropertyValueRole).toFloat();
|
||||
|
||||
editor->setValidator(new QDoubleValidator(1.0, 180.0,1, editor));
|
||||
editor->setText(lcFormatValueLocalized(value));
|
||||
editor->setToolTip(tr("Angle of the spotlight beam."));
|
||||
|
||||
connect(editor, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
|
||||
return editor;
|
||||
}
|
||||
|
||||
case PropertyFloatLightSpotFalloff:
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
float value = item->data(0, PropertyValueRole).toFloat();
|
||||
|
||||
editor->setValidator(new QDoubleValidator(1.0, 90.0,1, editor));
|
||||
editor->setText(lcFormatValueLocalized(value));
|
||||
editor->setToolTip(tr("Angle of the spotlight beam beteeen the cone edge and center line."));
|
||||
|
||||
connect(editor, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
|
||||
return editor;
|
||||
}
|
||||
|
||||
case PropertyFloatReadOnly:
|
||||
return nullptr;
|
||||
|
||||
case PropertyStep:
|
||||
{
|
||||
QLineEdit* Editor = new QLineEdit(parent);
|
||||
QLineEdit* Editor = new QLineEdit(Parent);
|
||||
|
||||
lcStep Value = item->data(0, PropertyValueRole).toUInt();
|
||||
lcStep Value = Item->data(0, PropertyValueRole).toUInt();
|
||||
lcStep Show = partShow->data(0, PropertyValueRole).toUInt();
|
||||
lcStep Hide = partHide->data(0, PropertyValueRole).toUInt();
|
||||
|
||||
if (Show && Hide)
|
||||
{
|
||||
if (item == partShow)
|
||||
if (Item == partShow)
|
||||
Editor->setValidator(new lcStepValidator(1, Hide - 1, false));
|
||||
else
|
||||
Editor->setValidator(new lcStepValidator(Show + 1, LC_STEP_MAX, true));
|
||||
}
|
||||
else
|
||||
Editor->setValidator(new lcStepValidator(1, LC_STEP_MAX, item == partHide));
|
||||
Editor->setValidator(new lcStepValidator(1, LC_STEP_MAX, Item == partHide));
|
||||
|
||||
if (item != partHide || Value != LC_STEP_MAX)
|
||||
if (Item != partHide || Value != LC_STEP_MAX)
|
||||
Editor->setText(QString::number(Value));
|
||||
|
||||
connect(Editor, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
|
||||
|
@ -503,8 +478,8 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyString:
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
QString value = item->data(0, PropertyValueRole).toString();
|
||||
QLineEdit *editor = new QLineEdit(Parent);
|
||||
QString value = Item->data(0, PropertyValueRole).toString();
|
||||
|
||||
editor->setText(value);
|
||||
|
||||
|
@ -515,19 +490,19 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyStringList:
|
||||
{
|
||||
QComboBox* editor = new QComboBox(parent);
|
||||
QComboBox* editor = new QComboBox(Parent);
|
||||
|
||||
if (item == mCameraProjectionItem)
|
||||
if (Item == mCameraProjectionItem)
|
||||
{
|
||||
editor->addItems( { tr("Perspective"), tr("Orthographic") } );
|
||||
}
|
||||
else if (item == mLightTypeItem)
|
||||
else if (Item == mLightTypeItem)
|
||||
{
|
||||
for (int LightTypeIndex = 0; LightTypeIndex < static_cast<int>(lcLightType::Count); LightTypeIndex++)
|
||||
editor->addItem(lcLight::GetLightTypeString(static_cast<lcLightType>(LightTypeIndex)));
|
||||
}
|
||||
|
||||
int value = item->data(0, PropertyValueRole).toInt();
|
||||
int value = Item->data(0, PropertyValueRole).toInt();
|
||||
editor->setCurrentIndex(value);
|
||||
|
||||
connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
|
||||
|
@ -537,7 +512,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyLightFormat:
|
||||
{
|
||||
QComboBox *editor = new QComboBox(parent);
|
||||
QComboBox *editor = new QComboBox(Parent);
|
||||
|
||||
editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
editor->setMinimumContentsLength(1);
|
||||
|
@ -546,7 +521,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
for (int i = 0; i < formats.size(); i++)
|
||||
editor->addItem(formats.at(i), QVariant::fromValue(i));
|
||||
|
||||
int value = item->data(0, PropertyValueRole).toInt();
|
||||
int value = Item->data(0, PropertyValueRole).toInt();
|
||||
editor->setCurrentIndex(value);
|
||||
|
||||
connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
|
||||
|
@ -556,7 +531,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyLightShape:
|
||||
{
|
||||
QComboBox *editor = new QComboBox(parent);
|
||||
QComboBox *editor = new QComboBox(Parent);
|
||||
|
||||
editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
editor->setMinimumContentsLength(1);
|
||||
|
@ -565,7 +540,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
for (int i = 0; i < shapes.size(); i++)
|
||||
editor->addItem(shapes.at(i), QVariant::fromValue(i));
|
||||
|
||||
int value = item->data(0, PropertyValueRole).toInt();
|
||||
int value = Item->data(0, PropertyValueRole).toInt();
|
||||
editor->setCurrentIndex(value);
|
||||
|
||||
connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
|
||||
|
@ -575,8 +550,8 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyColor:
|
||||
{
|
||||
QPushButton *Editor = new QPushButton(parent);
|
||||
QColor Value = item->data(0, PropertyValueRole).value<QColor>();
|
||||
QPushButton *Editor = new QPushButton(Parent);
|
||||
QColor Value = Item->data(0, PropertyValueRole).value<QColor>();
|
||||
|
||||
UpdateLightColorEditor(Editor, Value);
|
||||
|
||||
|
@ -587,8 +562,8 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyPieceColor:
|
||||
{
|
||||
QPushButton *editor = new QPushButton(parent);
|
||||
int value = item->data(0, PropertyValueRole).toInt();
|
||||
QPushButton *editor = new QPushButton(Parent);
|
||||
int value = Item->data(0, PropertyValueRole).toInt();
|
||||
|
||||
updateColorEditor(editor, value);
|
||||
|
||||
|
@ -599,7 +574,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
|
||||
case PropertyPart:
|
||||
{
|
||||
QComboBox *editor = new QComboBox(parent);
|
||||
QComboBox *editor = new QComboBox(Parent);
|
||||
|
||||
editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
editor->setMinimumContentsLength(1);
|
||||
|
@ -627,7 +602,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
|||
for (PieceInfo* Info : SortedPieces)
|
||||
editor->addItem(Info->m_strDescription, QVariant::fromValue((void*)Info));
|
||||
|
||||
PieceInfo *info = (PieceInfo*)item->data(0, PropertyValueRole).value<void*>();
|
||||
PieceInfo *info = (PieceInfo*)Item->data(0, PropertyValueRole).value<void*>();
|
||||
editor->setCurrentIndex(editor->findData(QVariant::fromValue((void*)info)));
|
||||
|
||||
connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int)));
|
||||
|
@ -900,6 +875,24 @@ void lcQPropertiesTree::slotReturnPressed()
|
|||
//
|
||||
// Model->MoveSelectedObjects(Distance, Distance, false, false, true, true);
|
||||
}
|
||||
else if (Item == mLightSpotConeAngleItem)
|
||||
{
|
||||
float Value = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->SetSpotLightConeAngle(Light, Value);
|
||||
}
|
||||
else if (Item == mLightSpotPenumbraAngleItem)
|
||||
{
|
||||
float Value = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->SetSpotLightPenumbraAngle(Light, Value);
|
||||
}
|
||||
else if (Item == mLightSpotTightnessItem)
|
||||
{
|
||||
float Value = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->SetSpotLightTightness(Light, Value);
|
||||
}
|
||||
else if (Item == lightFactorA || Item == lightFactorB)
|
||||
{
|
||||
float Value = lcParseValueLocalized(Editor->text());
|
||||
|
@ -934,25 +927,6 @@ void lcQPropertiesTree::slotReturnPressed()
|
|||
|
||||
Model->UpdateLight(Light, Props, LC_LIGHT_CUTOFF);
|
||||
}
|
||||
else if (Item == lightSpotSize)
|
||||
{
|
||||
Props.mSpotSize = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->UpdateLight(Light, Props, LC_LIGHT_SPOT_SIZE);
|
||||
}
|
||||
|
||||
else if (Item == lightSpotFalloff)
|
||||
{
|
||||
Props.mSpotFalloff = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->UpdateLight(Light, Props, LC_LIGHT_SPOT_FALLOFF);
|
||||
}
|
||||
else if (Item == lightSpotTightness)
|
||||
{
|
||||
Props.mSpotTightness = lcParseValueLocalized(Editor->text());
|
||||
|
||||
Model->UpdateLight(Light, Props, LC_LIGHT_SPOT_TIGHTNESS);
|
||||
}
|
||||
else if (Item == lightAreaGridRows || Item == lightAreaGridColumns)
|
||||
{
|
||||
float Value = lcParseValueLocalized(Editor->text());
|
||||
|
@ -1195,15 +1169,15 @@ void lcQPropertiesTree::SetEmpty()
|
|||
lightFactorA = nullptr;
|
||||
lightFactorB = nullptr;
|
||||
mLightNameItem = nullptr;
|
||||
lightSpotSize = nullptr;
|
||||
mLightSpotConeAngleItem = nullptr;
|
||||
mLightSpotPenumbraAngleItem = nullptr;
|
||||
mLightSpotTightnessItem = nullptr;
|
||||
lightShape = nullptr;
|
||||
lightFormat = nullptr;
|
||||
mLightCastShadowItem = nullptr;
|
||||
lightAreaGridRows = nullptr;
|
||||
lightAreaGridColumns = nullptr;
|
||||
lightSpotFalloff = nullptr;
|
||||
lightSpotTightness = nullptr;
|
||||
|
||||
|
||||
mWidgetMode = LC_PROPERTY_WIDGET_EMPTY;
|
||||
mFocus = nullptr;
|
||||
}
|
||||
|
@ -1437,13 +1411,10 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
QString Name = tr("Light");
|
||||
QString ExponentLabel = tr("Exponent");
|
||||
QString FactorALabel = QLatin1String("FactorA");
|
||||
QString Format, Shape, SpotSizeToolTip, ExponentToolTip, FactorAToolTip, FactorBToolTip;
|
||||
QString Format, Shape, ExponentToolTip, FactorAToolTip, FactorBToolTip;
|
||||
lcLightType LightType = lcLightType::Point;
|
||||
lcLightShape ShapeIndex = LC_LIGHT_SHAPE_UNDEFINED;
|
||||
int FormatIndex = 0;
|
||||
float SpotSize = 0.0f;
|
||||
float SpotFalloff = 0.0f;
|
||||
float SpotTightness = 0.0f;
|
||||
float Diffuse = 0.0f;
|
||||
float Specular = 0.0f;
|
||||
float Cutoff = 0.0f;
|
||||
|
@ -1452,10 +1423,10 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
bool POVRayLight = false;
|
||||
bool CastShadow = true;
|
||||
PropertyType TargetProperty = PropertyFloat;
|
||||
PropertyType SpotSizeProperty = PropertyFloatLightSpotSize;
|
||||
lcVector3 Position(0.0f, 0.0f, 0.0f);
|
||||
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);
|
||||
|
||||
|
@ -1471,6 +1442,9 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
Position = Light->GetPosition();
|
||||
// Target = Light->mTargetPosition;
|
||||
Color = lcQColorFromVector3(Light->GetColor());
|
||||
SpotConeAngle = Light->GetSpotConeAngle();
|
||||
SpotPenumbraAngle = Light->GetSpotPenumbraAngle();
|
||||
|
||||
Factor = Light->mLightFactor;
|
||||
LightType = Light->GetLightType();
|
||||
|
||||
|
@ -1489,15 +1463,11 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
{
|
||||
FactorALabel = tr("Radius (°)");
|
||||
FactorAToolTip = tr("The angle between the \"hot-spot\" edge at the beam center and the center line.");
|
||||
SpotSizeToolTip = tr("Angle of the spotlight beam - Read only.");
|
||||
Factor[0] = Light->mSpotSize - Light->mSpotFalloff;
|
||||
SpotSizeProperty = PropertyFloatReadOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
FactorALabel = tr("Radius (m)");
|
||||
FactorAToolTip = tr("Shadow soft size - Light size in metres for shadow sampling.");
|
||||
SpotSizeToolTip = tr("Angle of the spotlight beam.");
|
||||
}
|
||||
break;
|
||||
case lcLightType::Directional:
|
||||
|
@ -1564,9 +1534,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
Cutoff = Light->mSpotCutoff;
|
||||
EnableCutoff = Light->mEnableCutoff;
|
||||
TargetProperty = LightType != lcLightType::Point ? PropertyFloat : PropertyFloatReadOnly;
|
||||
SpotSize = Light->mSpotSize;
|
||||
SpotFalloff = Light->mSpotFalloff;
|
||||
SpotTightness = Light->mSpotTightness;
|
||||
SpotTightness = Light->GetSpotTightness();
|
||||
AreaGrid = Light->mAreaGrid;
|
||||
}
|
||||
|
||||
|
@ -1581,25 +1549,24 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
mLightColorItem = addProperty(mLightAttributesItem, tr("Color"), PropertyColor);
|
||||
mLightCastShadowItem = addProperty(mLightAttributesItem, tr("Cast Shadows"), PropertyBool);
|
||||
|
||||
if (LightType == lcLightType::Spot)
|
||||
{
|
||||
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."));
|
||||
|
||||
mLightSpotTightnessItem = addProperty(mLightAttributesItem, tr("Spot Tightness"), PropertyFloat);
|
||||
mLightSpotTightnessItem->setToolTip(1, tr("Additional exponential spotlight edge softening (POV-Ray only)."));
|
||||
}
|
||||
|
||||
lightExponent = addProperty(mLightAttributesItem, ExponentLabel, PropertyFloat);
|
||||
|
||||
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
||||
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloat);
|
||||
|
||||
if (LightType == lcLightType::Spot)
|
||||
{
|
||||
lightSpotSize = addProperty(mLightAttributesItem, tr("Spot Size (°)"), SpotSizeProperty);
|
||||
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloatLightSpotSize);
|
||||
|
||||
if (!POVRayLight)
|
||||
lightFactorB = addProperty(mLightAttributesItem, tr("Spot Blend"), PropertyFloat);
|
||||
else
|
||||
{
|
||||
lightSpotFalloff = addProperty(mLightAttributesItem, tr("Spot Falloff (°)"), PropertyFloatLightSpotFalloff);
|
||||
lightSpotTightness = addProperty(mLightAttributesItem, tr("Spot Tightness"), PropertyFloat);
|
||||
}
|
||||
}
|
||||
else if (LightType == lcLightType::Area)
|
||||
if (LightType == lcLightType::Area)
|
||||
{
|
||||
lightShape = addProperty(mLightAttributesItem, tr("Shape"), PropertyLightShape);
|
||||
lightFactorA = addProperty(mLightAttributesItem, FactorALabel, PropertyFloat);
|
||||
|
@ -1735,30 +1702,17 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
|||
}
|
||||
else if (LightType == lcLightType::Spot)
|
||||
{
|
||||
lightSpotSize->setText(1, lcFormatValueLocalized(SpotSize));
|
||||
lightSpotSize->setData(0, PropertyValueRole, SpotSize);
|
||||
lightSpotSize->setToolTip(1, SpotSizeToolTip);
|
||||
mLightSpotConeAngleItem->setText(1, lcFormatValueLocalized(SpotConeAngle));
|
||||
mLightSpotConeAngleItem->setData(0, PropertyValueRole, SpotConeAngle);
|
||||
mLightSpotConeAngleItem->setData(0, PropertyRangeRole, QPointF(1.0, 180.0));
|
||||
|
||||
lightFactorA->setText(1, lcFormatValueLocalized(Factor[0]));
|
||||
lightFactorA->setData(0, PropertyValueRole, Factor[0]);
|
||||
lightFactorA->setToolTip(1, FactorAToolTip);
|
||||
mLightSpotPenumbraAngleItem->setText(1, lcFormatValueLocalized(SpotPenumbraAngle));
|
||||
mLightSpotPenumbraAngleItem->setData(0, PropertyValueRole, SpotPenumbraAngle);
|
||||
mLightSpotPenumbraAngleItem->setData(0, PropertyRangeRole, QPointF(0.0, 180.0));
|
||||
|
||||
if (!POVRayLight)
|
||||
{
|
||||
lightFactorB->setText(1, lcFormatValueLocalized(Factor[1]));
|
||||
lightFactorB->setData(0, PropertyValueRole, Factor[1]);
|
||||
lightFactorB->setToolTip(1, FactorBToolTip);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightSpotFalloff->setText(1, lcFormatValueLocalized(SpotFalloff));
|
||||
lightSpotFalloff->setData(0, PropertyValueRole, SpotFalloff);
|
||||
lightSpotFalloff->setToolTip(1, tr("The angle between the spot beam edge and center line."));
|
||||
|
||||
lightSpotTightness->setText(1, lcFormatValueLocalized(SpotTightness));
|
||||
lightSpotTightness->setData(0, PropertyValueRole, SpotTightness);
|
||||
lightSpotTightness->setToolTip(1, tr("Additional exponential spotlight edge softening."));
|
||||
}
|
||||
mLightSpotTightnessItem->setText(1, lcFormatValueLocalized(SpotTightness));
|
||||
mLightSpotTightnessItem->setData(0, PropertyValueRole, SpotTightness);
|
||||
mLightSpotTightnessItem->setData(0, PropertyRangeRole, QPointF(0.0, 100.0));
|
||||
}
|
||||
|
||||
if (!POVRayLight)
|
||||
|
|
|
@ -36,7 +36,8 @@ public:
|
|||
enum
|
||||
{
|
||||
PropertyTypeRole = Qt::UserRole,
|
||||
PropertyValueRole
|
||||
PropertyValueRole,
|
||||
PropertyRangeRole
|
||||
};
|
||||
|
||||
enum PropertyType
|
||||
|
@ -45,8 +46,6 @@ public:
|
|||
PropertyBool,
|
||||
PropertyFloat,
|
||||
PropertyFloatReadOnly,
|
||||
PropertyFloatLightSpotSize,
|
||||
PropertyFloatLightSpotFalloff,
|
||||
PropertyStep,
|
||||
PropertyString,
|
||||
PropertyStringList,
|
||||
|
@ -143,7 +142,9 @@ protected:
|
|||
QTreeWidgetItem* lightEnableCutoff;
|
||||
QTreeWidgetItem* lightExponent;
|
||||
QTreeWidgetItem* mLightTypeItem;
|
||||
QTreeWidgetItem* lightSpotSize;
|
||||
QTreeWidgetItem* mLightSpotConeAngleItem;
|
||||
QTreeWidgetItem* mLightSpotPenumbraAngleItem;
|
||||
QTreeWidgetItem* mLightSpotTightnessItem;
|
||||
QTreeWidgetItem* lightShape;
|
||||
QTreeWidgetItem* lightFactorA;
|
||||
QTreeWidgetItem* lightFactorB;
|
||||
|
@ -152,8 +153,6 @@ protected:
|
|||
QTreeWidgetItem* mLightCastShadowItem;
|
||||
QTreeWidgetItem* lightAreaGridRows;
|
||||
QTreeWidgetItem* lightAreaGridColumns;
|
||||
QTreeWidgetItem* lightSpotFalloff;
|
||||
QTreeWidgetItem* lightSpotTightness;
|
||||
};
|
||||
|
||||
class lcQPropertiesTreeDelegate : public QItemDelegate
|
||||
|
|
Loading…
Reference in a new issue