Made light type/shape immutable.
This commit is contained in:
+72
-72
@@ -333,46 +333,46 @@ const lcCommand gCommands[] =
|
||||
QT_TRANSLATE_NOOP("Status", "Select all pieces of the same type and color"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_RELATIVE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformRelative"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Relative Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Move and rotate objects relative to the one that has focus"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_ABSOLUTE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformAbsolute"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Absolute Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Move and rotate objects in absolute coordinates"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_TOGGLE_RELATIVE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformToggleRelative"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Toggle Relative Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Toggle moving and rotating objects relative to the one that has focus"),
|
||||
// LC_EDIT_TRANSFORM_RELATIVE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformRelative"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Relative Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Move and rotate objects relative to the one that has focus"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_SEPARATELY
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformSeparately"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Rotate Separately"),
|
||||
QT_TRANSLATE_NOOP("Status", "Rotate selected pieces separately"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_TOGETHER
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformTogether"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Rotate Together"),
|
||||
QT_TRANSLATE_NOOP("Status", "Rotate selected pieces together"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_TOGGLE_SEPARATE
|
||||
// LC_EDIT_TRANSFORM_ABSOLUTE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformToggleSeparate"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Toggle Separate Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Toggle rotating selected pieces separately"),
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformAbsolute"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Absolute Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Move and rotate objects in absolute coordinates"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_TOGGLE_RELATIVE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformToggleRelative"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Toggle Relative Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Toggle moving and rotating objects relative to the one that has focus"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_SEPARATELY
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformSeparately"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Rotate Separately"),
|
||||
QT_TRANSLATE_NOOP("Status", "Rotate selected pieces separately"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_TOGETHER
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformTogether"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Rotate Together"),
|
||||
QT_TRANSLATE_NOOP("Status", "Rotate selected pieces together"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_TRANSFORM_TOGGLE_SEPARATE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.TransformToggleSeparate"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Toggle Separate Transforms"),
|
||||
QT_TRANSLATE_NOOP("Status", "Toggle rotating selected pieces separately"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_SNAP_MOVE_TOGGLE
|
||||
@@ -641,27 +641,13 @@ const lcCommand gCommands[] =
|
||||
QT_TRANSLATE_NOOP("Status", "Add new pieces to the model"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_LIGHT
|
||||
// LC_EDIT_ACTION_POINT_LIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.Light"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Light"),
|
||||
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"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_AREALIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.Arealight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Arealight"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new arealight sources to the model - edit in Properties tab"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_SUNLIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.Sunlight"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Sunlight"),
|
||||
QT_TRANSLATE_NOOP("Status", "Add new omnidirectional sunlight sources to the model - edit in Properties tab"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_SPOTLIGHT
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.Spotlight"),
|
||||
@@ -669,6 +655,20 @@ const lcCommand gCommands[] =
|
||||
QT_TRANSLATE_NOOP("Status", "Add new spotlights 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"),
|
||||
""
|
||||
},
|
||||
// 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"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_ACTION_CAMERA
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Tool.Camera"),
|
||||
@@ -1376,7 +1376,7 @@ const lcCommand gCommands[] =
|
||||
QT_TRANSLATE_NOOP("Status", "Make copies of the selected pieces"),
|
||||
""
|
||||
},
|
||||
// LC_PIECE_VIEW_SELECTED_MODEL
|
||||
// LC_PIECE_VIEW_SELECTED_MODEL
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Piece.ViewSelectedModel"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Open Selected Model"),
|
||||
@@ -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::Light
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewAreaLight"), // lcTool::AreaLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewSunLight"), // lcTool::SunLight
|
||||
QT_TRANSLATE_NOOP("Mouse", "NewSpotLight"), // lcTool::SpotLight
|
||||
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", "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
|
||||
};
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(gToolNames, lcTool::Count);
|
||||
|
||||
@@ -98,10 +98,10 @@ enum lcCommandId
|
||||
LC_EDIT_TRANSFORM_RELATIVE_ROTATION,
|
||||
LC_EDIT_ACTION_FIRST,
|
||||
LC_EDIT_ACTION_INSERT = LC_EDIT_ACTION_FIRST,
|
||||
LC_EDIT_ACTION_LIGHT,
|
||||
LC_EDIT_ACTION_AREALIGHT,
|
||||
LC_EDIT_ACTION_SUNLIGHT,
|
||||
LC_EDIT_ACTION_POINT_LIGHT,
|
||||
LC_EDIT_ACTION_SPOTLIGHT,
|
||||
LC_EDIT_ACTION_DIRECTIONAL_LIGHT,
|
||||
LC_EDIT_ACTION_AREA_LIGHT,
|
||||
LC_EDIT_ACTION_CAMERA,
|
||||
LC_EDIT_ACTION_SELECT,
|
||||
LC_EDIT_ACTION_MOVE,
|
||||
@@ -300,10 +300,10 @@ extern const lcCommand gCommands[];
|
||||
enum class lcTool
|
||||
{
|
||||
Insert,
|
||||
Light,
|
||||
PointLight,
|
||||
Spotlight,
|
||||
DirectionalLight,
|
||||
AreaLight,
|
||||
SunLight,
|
||||
SpotLight,
|
||||
Camera,
|
||||
Select,
|
||||
Move,
|
||||
|
||||
@@ -75,6 +75,7 @@ class lcObject;
|
||||
class lcPiece;
|
||||
class lcCamera;
|
||||
class lcLight;
|
||||
enum class lcLightType;
|
||||
class lcGroup;
|
||||
class PieceInfo;
|
||||
typedef std::map<const PieceInfo*, std::map<int, int>> lcPartsList;
|
||||
|
||||
+24
-24
@@ -204,23 +204,23 @@ void lcMainWindow::CreateActions()
|
||||
QIcon EditActionLightIcon;
|
||||
EditActionLightIcon.addFile(":/resources/action_light.png");
|
||||
EditActionLightIcon.addFile(":/resources/action_light_16.png");
|
||||
mActions[LC_EDIT_ACTION_LIGHT]->setIcon(EditActionLightIcon);
|
||||
|
||||
QIcon EditActionArealightIcon;
|
||||
EditActionArealightIcon.addFile(":/resources/action_arealight.png");
|
||||
EditActionArealightIcon.addFile(":/resources/action_arealight_16.png");
|
||||
mActions[LC_EDIT_ACTION_AREALIGHT]->setIcon(EditActionArealightIcon);
|
||||
|
||||
QIcon EditActionSunlightIcon;
|
||||
EditActionSunlightIcon.addFile(":/resources/action_sunlight.png");
|
||||
EditActionSunlightIcon.addFile(":/resources/action_sunlight_16.png");
|
||||
mActions[LC_EDIT_ACTION_SUNLIGHT]->setIcon(EditActionSunlightIcon);
|
||||
mActions[LC_EDIT_ACTION_POINT_LIGHT]->setIcon(EditActionLightIcon);
|
||||
|
||||
QIcon EditActionSpotLightIcon;
|
||||
EditActionSpotLightIcon.addFile(":/resources/action_spotlight.png");
|
||||
EditActionSpotLightIcon.addFile(":/resources/action_spotlight_16.png");
|
||||
mActions[LC_EDIT_ACTION_SPOTLIGHT]->setIcon(EditActionSpotLightIcon);
|
||||
|
||||
QIcon EditActionSunlightIcon;
|
||||
EditActionSunlightIcon.addFile(":/resources/action_sunlight.png");
|
||||
EditActionSunlightIcon.addFile(":/resources/action_sunlight_16.png");
|
||||
mActions[LC_EDIT_ACTION_DIRECTIONAL_LIGHT]->setIcon(EditActionSunlightIcon);
|
||||
|
||||
QIcon EditActionArealightIcon;
|
||||
EditActionArealightIcon.addFile(":/resources/action_arealight.png");
|
||||
EditActionArealightIcon.addFile(":/resources/action_arealight_16.png");
|
||||
mActions[LC_EDIT_ACTION_AREA_LIGHT]->setIcon(EditActionArealightIcon);
|
||||
|
||||
QIcon EditActionSelectIcon;
|
||||
EditActionSelectIcon.addFile(":/resources/action_select.png");
|
||||
EditActionSelectIcon.addFile(":/resources/action_select_16.png");
|
||||
@@ -431,10 +431,10 @@ void lcMainWindow::CreateMenus()
|
||||
|
||||
mToolsMenu = new QMenu(tr("Tools"), this);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_INSERT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_LIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_AREALIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_SUNLIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_POINT_LIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_SPOTLIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_DIRECTIONAL_LIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_AREA_LIGHT]);
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_CAMERA]);
|
||||
mToolsMenu->addSeparator();
|
||||
mToolsMenu->addAction(mActions[LC_EDIT_ACTION_SELECT]);
|
||||
@@ -676,10 +676,10 @@ void lcMainWindow::CreateToolBars()
|
||||
mToolsToolBar->setObjectName("ToolsToolbar");
|
||||
insertToolBarBreak(mToolsToolBar);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_INSERT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_LIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_AREALIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_SUNLIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_POINT_LIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_SPOTLIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_DIRECTIONAL_LIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_AREA_LIGHT]);
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_CAMERA]);
|
||||
mToolsToolBar->addSeparator();
|
||||
mToolsToolBar->addAction(mActions[LC_EDIT_ACTION_SELECT]);
|
||||
@@ -831,7 +831,7 @@ void lcMainWindow::TogglePreviewWidget(bool Visible)
|
||||
else
|
||||
mPreviewToolBar->hide();
|
||||
}
|
||||
else if (Visible)
|
||||
else if (Visible)
|
||||
{
|
||||
CreatePreviewWidget();
|
||||
}
|
||||
@@ -3376,20 +3376,20 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||
SetTool(lcTool::Insert);
|
||||
break;
|
||||
|
||||
case LC_EDIT_ACTION_LIGHT:
|
||||
SetTool(lcTool::Light);
|
||||
case LC_EDIT_ACTION_POINT_LIGHT:
|
||||
SetTool(lcTool::PointLight);
|
||||
break;
|
||||
|
||||
case LC_EDIT_ACTION_AREALIGHT:
|
||||
case LC_EDIT_ACTION_AREA_LIGHT:
|
||||
SetTool(lcTool::AreaLight);
|
||||
break;
|
||||
|
||||
case LC_EDIT_ACTION_SUNLIGHT:
|
||||
SetTool(lcTool::SunLight);
|
||||
case LC_EDIT_ACTION_DIRECTIONAL_LIGHT:
|
||||
SetTool(lcTool::DirectionalLight);
|
||||
break;
|
||||
|
||||
case LC_EDIT_ACTION_SPOTLIGHT:
|
||||
SetTool(lcTool::SpotLight);
|
||||
SetTool(lcTool::Spotlight);
|
||||
break;
|
||||
|
||||
case LC_EDIT_ACTION_CAMERA:
|
||||
|
||||
+31
-15
@@ -620,7 +620,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||
|
||||
if (Token != QLatin1String("!LEOCAD"))
|
||||
{
|
||||
mFileLines.append(OriginalLine);
|
||||
mFileLines.append(OriginalLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||
else if (Token == QLatin1String("LIGHT"))
|
||||
{
|
||||
if (!Light)
|
||||
Light = new lcLight(0.0f, 0.0f, 0.0f);
|
||||
Light = new lcLight(lcVector3(0.0f, 0.0f, 0.0f), lcVector3(0.0f, 0.0f, 0.0f), lcLightType::Point);
|
||||
|
||||
if (Light->ParseLDrawLine(LineStream))
|
||||
{
|
||||
@@ -734,7 +734,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||
|
||||
if (Library->IsPrimitive(CleanId.constData()))
|
||||
{
|
||||
mFileLines.append(OriginalLine);
|
||||
mFileLines.append(OriginalLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1039,7 +1039,7 @@ bool lcModel::LoadLDD(const QString& FileData)
|
||||
{
|
||||
std::vector<lcPiece*> Pieces;
|
||||
std::vector<std::vector<lcPiece*>> Groups;
|
||||
|
||||
|
||||
if (!lcImportLXFMLFile(FileData, Pieces, Groups))
|
||||
return false;
|
||||
|
||||
@@ -4069,13 +4069,13 @@ void lcModel::EndMouseTool(lcTool Tool, bool Accept)
|
||||
switch (Tool)
|
||||
{
|
||||
case lcTool::Insert:
|
||||
case lcTool::Light:
|
||||
case lcTool::PointLight:
|
||||
case lcTool::DirectionalLight:
|
||||
case lcTool::AreaLight:
|
||||
case lcTool::SunLight:
|
||||
break;
|
||||
|
||||
case lcTool::SpotLight:
|
||||
SaveCheckpoint(tr("New SpotLight"));
|
||||
case lcTool::Spotlight:
|
||||
SaveCheckpoint(tr("New Spotlight"));
|
||||
break;
|
||||
|
||||
case lcTool::Camera:
|
||||
@@ -4143,25 +4143,41 @@ void lcModel::InsertPieceToolClicked(const lcMatrix44& WorldMatrix)
|
||||
|
||||
void lcModel::PointLightToolClicked(const lcVector3& Position)
|
||||
{
|
||||
lcLight* Light = new lcLight(Position[0], Position[1], Position[2]);
|
||||
lcLight* Light = new lcLight(Position, lcVector3(0.0f, 0.0f, 0.0f), lcLightType::Point);
|
||||
Light->CreateName(mLights);
|
||||
mLights.Add(Light);
|
||||
|
||||
ClearSelectionAndSetFocus(Light, LC_LIGHT_SECTION_POSITION, false);
|
||||
SaveCheckpoint(tr("New Light"));
|
||||
SaveCheckpoint(tr("New Point Light"));
|
||||
}
|
||||
|
||||
void lcModel::BeginDirectionalLightTool(const lcVector3& Position, const lcVector3& Target, int LightType)
|
||||
void lcModel::BeginDirectionalLightTool(const lcVector3& Position, const lcVector3& Target, lcLightType LightType)
|
||||
{
|
||||
lcLight* Light = new lcLight(Position[0], Position[1], Position[2], Target[0], Target[1], Target[2], LightType);
|
||||
lcLight* Light = new lcLight(Position, Target, LightType);
|
||||
Light->CreateName(mLights);
|
||||
mLights.Add(Light);
|
||||
|
||||
mMouseToolDistance = Target;
|
||||
|
||||
ClearSelectionAndSetFocus(Light, LC_LIGHT_SECTION_TARGET, false);
|
||||
QString light(LightType == LC_AREALIGHT ? "Arealight " : LightType == LC_SUNLIGHT ? "Sunlight " : "Spotlight ");
|
||||
SaveCheckpoint(tr("%1").arg(light));
|
||||
|
||||
switch (LightType)
|
||||
{
|
||||
case lcLightType::Point:
|
||||
break;
|
||||
|
||||
case lcLightType::Spot:
|
||||
SaveCheckpoint(tr("New Spot Light"));
|
||||
break;
|
||||
|
||||
case lcLightType::Directional:
|
||||
SaveCheckpoint(tr("New Directional Light"));
|
||||
break;
|
||||
|
||||
case lcLightType::Area:
|
||||
SaveCheckpoint(tr("New Area Light"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lcModel::UpdateDirectionalLightTool(const lcVector3& Position)
|
||||
@@ -4467,7 +4483,7 @@ void lcModel::ShowArrayDialog()
|
||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("No pieces selected."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
lcArrayDialog Dialog(gMainWindow);
|
||||
|
||||
if (Dialog.exec() != QDialog::Accepted)
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ public:
|
||||
void EndMouseTool(lcTool Tool, bool Accept);
|
||||
void InsertPieceToolClicked(const lcMatrix44& WorldMatrix);
|
||||
void PointLightToolClicked(const lcVector3& Position);
|
||||
void BeginDirectionalLightTool(const lcVector3& Position, const lcVector3& Target, int LightType);
|
||||
void BeginDirectionalLightTool(const lcVector3& Position, const lcVector3& Target, lcLightType LightType);
|
||||
void UpdateDirectionalLightTool(const lcVector3& Position);
|
||||
void BeginSpotLightTool(const lcVector3& Position, const lcVector3& Target);
|
||||
void BeginCameraTool(const lcVector3& Position, const lcVector3& Target);
|
||||
|
||||
+121
-113
@@ -416,7 +416,7 @@ lcMatrix44 lcView::GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info)
|
||||
lcModel* ActiveModel = GetActiveModel();
|
||||
|
||||
lcPieceInfoRayTest PieceInfoRayTest = FindPieceInfoUnderPointer(IgnoreSelected);
|
||||
|
||||
|
||||
if (PieceInfoRayTest.Info)
|
||||
{
|
||||
lcVector3 Position = PieceInfoRayTest.Plane;
|
||||
@@ -1362,7 +1362,7 @@ void lcView::DrawRotateViewOverlay()
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormatPosition(2);
|
||||
|
||||
GLushort Indices[64 + 32] =
|
||||
GLushort Indices[64 + 32] =
|
||||
{
|
||||
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, 16, 16,
|
||||
17, 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, 0,
|
||||
@@ -1595,23 +1595,23 @@ lcTrackTool lcView::GetOverrideTrackTool(Qt::MouseButton Button) const
|
||||
|
||||
constexpr lcTrackTool TrackToolFromTool[] =
|
||||
{
|
||||
lcTrackTool::Insert, // lcTool::Insert
|
||||
lcTrackTool::PointLight, // lcTool::Light
|
||||
lcTrackTool::AreaLight, // lcTool::AreaLight
|
||||
lcTrackTool::SunLight, // lcTool::SunLight
|
||||
lcTrackTool::SpotLight, // lcTool::SpotLight
|
||||
lcTrackTool::Camera, // lcTool::Camera
|
||||
lcTrackTool::Select, // lcTool::Select
|
||||
lcTrackTool::MoveXYZ, // lcTool::Move
|
||||
lcTrackTool::RotateXYZ, // lcTool::Rotate
|
||||
lcTrackTool::Eraser, // lcTool::Eraser
|
||||
lcTrackTool::Paint, // lcTool::Paint
|
||||
lcTrackTool::ColorPicker, // lcTool::ColorPicker
|
||||
lcTrackTool::Zoom, // lcTool::Zoom
|
||||
lcTrackTool::Pan, // lcTool::Pan
|
||||
lcTrackTool::OrbitXY, // lcTool::RotateView
|
||||
lcTrackTool::Roll, // lcTool::Roll
|
||||
lcTrackTool::ZoomRegion // lcTool::ZoomRegion
|
||||
lcTrackTool::Insert, // lcTool::Insert
|
||||
lcTrackTool::PointLight, // lcTool::PointLight
|
||||
lcTrackTool::Spotlight, // lcTool::Spotlight
|
||||
lcTrackTool::DirectionalLight, // lcTool::DirectionalLight
|
||||
lcTrackTool::AreaLight, // lcTool::AreaLight
|
||||
lcTrackTool::Camera, // lcTool::Camera
|
||||
lcTrackTool::Select, // lcTool::Select
|
||||
lcTrackTool::MoveXYZ, // lcTool::Move
|
||||
lcTrackTool::RotateXYZ, // lcTool::Rotate
|
||||
lcTrackTool::Eraser, // lcTool::Eraser
|
||||
lcTrackTool::Paint, // lcTool::Paint
|
||||
lcTrackTool::ColorPicker, // lcTool::ColorPicker
|
||||
lcTrackTool::Zoom, // lcTool::Zoom
|
||||
lcTrackTool::Pan, // lcTool::Pan
|
||||
lcTrackTool::OrbitXY, // lcTool::RotateView
|
||||
lcTrackTool::Roll, // lcTool::Roll
|
||||
lcTrackTool::ZoomRegion // lcTool::ZoomRegion
|
||||
};
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(TrackToolFromTool, lcTool::Count);
|
||||
@@ -1867,38 +1867,38 @@ lcCursor lcView::GetCursor() const
|
||||
|
||||
constexpr lcCursor CursorFromTrackTool[] =
|
||||
{
|
||||
lcCursor::Select, // lcTrackTool::None
|
||||
lcCursor::Brick, // lcTrackTool::Insert
|
||||
lcCursor::Light, // lcTrackTool::PointLight
|
||||
lcCursor::Arealight, // lcTrackTool::AreaLight
|
||||
lcCursor::Sunlight, // lcTrackTool::SunLight
|
||||
lcCursor::Spotlight, // lcTrackTool::SpotLight
|
||||
lcCursor::Camera, // lcTrackTool::Camera
|
||||
lcCursor::Select, // lcTrackTool::Select
|
||||
lcCursor::Move, // lcTrackTool::MoveX
|
||||
lcCursor::Move, // lcTrackTool::MoveY
|
||||
lcCursor::Move, // lcTrackTool::MoveZ
|
||||
lcCursor::Move, // lcTrackTool::MoveXY
|
||||
lcCursor::Move, // lcTrackTool::MoveXZ
|
||||
lcCursor::Move, // lcTrackTool::MoveYZ
|
||||
lcCursor::Move, // lcTrackTool::MoveXYZ
|
||||
lcCursor::Rotate, // lcTrackTool::RotateX
|
||||
lcCursor::Rotate, // lcTrackTool::RotateY
|
||||
lcCursor::Rotate, // lcTrackTool::RotateZ
|
||||
lcCursor::Rotate, // lcTrackTool::RotateXY
|
||||
lcCursor::Rotate, // lcTrackTool::RotateXYZ
|
||||
lcCursor::Move, // lcTrackTool::ScalePlus
|
||||
lcCursor::Move, // lcTrackTool::ScaleMinus
|
||||
lcCursor::Delete, // lcTrackTool::Eraser
|
||||
lcCursor::Paint, // lcTrackTool::Paint
|
||||
lcCursor::ColorPicker, // lcTrackTool::ColorPicker
|
||||
lcCursor::Zoom, // lcTrackTool::Zoom
|
||||
lcCursor::Pan, // lcTrackTool::Pan
|
||||
lcCursor::RotateX, // lcTrackTool::OrbitX
|
||||
lcCursor::RotateY, // lcTrackTool::OrbitY
|
||||
lcCursor::RotateView, // lcTrackTool::OrbitXY
|
||||
lcCursor::Roll, // lcTrackTool::Roll
|
||||
lcCursor::ZoomRegion // lcTrackTool::ZoomRegion
|
||||
lcCursor::Select, // lcTrackTool::None
|
||||
lcCursor::Brick, // lcTrackTool::Insert
|
||||
lcCursor::PointLight, // lcTrackTool::PointLight
|
||||
lcCursor::Spotlight, // lcTrackTool::Spotlight
|
||||
lcCursor::DirectionalLight, // lcTrackTool::DirectionalLight
|
||||
lcCursor::AreaLight, // lcTrackTool::AreaLight
|
||||
lcCursor::Camera, // lcTrackTool::Camera
|
||||
lcCursor::Select, // lcTrackTool::Select
|
||||
lcCursor::Move, // lcTrackTool::MoveX
|
||||
lcCursor::Move, // lcTrackTool::MoveY
|
||||
lcCursor::Move, // lcTrackTool::MoveZ
|
||||
lcCursor::Move, // lcTrackTool::MoveXY
|
||||
lcCursor::Move, // lcTrackTool::MoveXZ
|
||||
lcCursor::Move, // lcTrackTool::MoveYZ
|
||||
lcCursor::Move, // lcTrackTool::MoveXYZ
|
||||
lcCursor::Rotate, // lcTrackTool::RotateX
|
||||
lcCursor::Rotate, // lcTrackTool::RotateY
|
||||
lcCursor::Rotate, // lcTrackTool::RotateZ
|
||||
lcCursor::Rotate, // lcTrackTool::RotateXY
|
||||
lcCursor::Rotate, // lcTrackTool::RotateXYZ
|
||||
lcCursor::Move, // lcTrackTool::ScalePlus
|
||||
lcCursor::Move, // lcTrackTool::ScaleMinus
|
||||
lcCursor::Delete, // lcTrackTool::Eraser
|
||||
lcCursor::Paint, // lcTrackTool::Paint
|
||||
lcCursor::ColorPicker, // lcTrackTool::ColorPicker
|
||||
lcCursor::Zoom, // lcTrackTool::Zoom
|
||||
lcCursor::Pan, // lcTrackTool::Pan
|
||||
lcCursor::RotateX, // lcTrackTool::OrbitX
|
||||
lcCursor::RotateY, // lcTrackTool::OrbitY
|
||||
lcCursor::RotateView, // lcTrackTool::OrbitXY
|
||||
lcCursor::Roll, // lcTrackTool::Roll
|
||||
lcCursor::ZoomRegion // lcTrackTool::ZoomRegion
|
||||
};
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(CursorFromTrackTool, lcTrackTool::Count);
|
||||
@@ -1925,10 +1925,10 @@ void lcView::SetCursor(lcCursor CursorType)
|
||||
{ 0, 0, "" }, // lcCursor::Hidden
|
||||
{ 0, 0, "" }, // lcCursor::Default
|
||||
{ 8, 3, ":/resources/cursor_insert" }, // lcCursor::Brick
|
||||
{ 15, 15, ":/resources/cursor_light" }, // lcCursor::Light
|
||||
{ 15, 15, ":/resources/cursor_arealight" }, // lcCursor::Arealight
|
||||
{ 15, 15, ":/resources/cursor_sunlight" }, // lcCursor::Sunlight
|
||||
{ 15, 15, ":/resources/cursor_light" }, // lcCursor::PointLight
|
||||
{ 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
|
||||
{ 0, 2, ":/resources/cursor_select" }, // lcCursor::Select
|
||||
{ 0, 2, ":/resources/cursor_select_add" }, // lcCursor::SelectAdd
|
||||
@@ -1976,38 +1976,38 @@ lcTool lcView::GetCurrentTool() const
|
||||
{
|
||||
constexpr lcTool ToolFromTrackTool[] =
|
||||
{
|
||||
lcTool::Select, // lcTrackTool::None
|
||||
lcTool::Insert, // lcTrackTool::Insert
|
||||
lcTool::Light, // lcTrackTool::PointLight
|
||||
lcTool::AreaLight, // lcTrackTool::AreaLight
|
||||
lcTool::SunLight, // lcTrackTool::SunLight
|
||||
lcTool::SpotLight, // lcTrackTool::SpotLight
|
||||
lcTool::Camera, // lcTrackTool::Camera
|
||||
lcTool::Select, // lcTrackTool::Select
|
||||
lcTool::Move, // lcTrackTool::MoveX
|
||||
lcTool::Move, // lcTrackTool::MoveY
|
||||
lcTool::Move, // lcTrackTool::MoveZ
|
||||
lcTool::Move, // lcTrackTool::MoveXY
|
||||
lcTool::Move, // lcTrackTool::MoveXZ
|
||||
lcTool::Move, // lcTrackTool::MoveYZ
|
||||
lcTool::Move, // lcTrackTool::MoveXYZ
|
||||
lcTool::Rotate, // lcTrackTool::RotateX
|
||||
lcTool::Rotate, // lcTrackTool::RotateY
|
||||
lcTool::Rotate, // lcTrackTool::RotateZ
|
||||
lcTool::Rotate, // lcTrackTool::RotateXY
|
||||
lcTool::Rotate, // lcTrackTool::RotateXYZ
|
||||
lcTool::Move, // lcTrackTool::ScalePlus
|
||||
lcTool::Move, // lcTrackTool::ScaleMinus
|
||||
lcTool::Eraser, // lcTrackTool::Eraser
|
||||
lcTool::Paint, // lcTrackTool::Paint
|
||||
lcTool::ColorPicker, // lcTrackTool::ColorPicker
|
||||
lcTool::Zoom, // lcTrackTool::Zoom
|
||||
lcTool::Pan, // lcTrackTool::Pan
|
||||
lcTool::RotateView, // lcTrackTool::OrbitX
|
||||
lcTool::RotateView, // lcTrackTool::OrbitY
|
||||
lcTool::RotateView, // lcTrackTool::OrbitXY
|
||||
lcTool::Roll, // lcTrackTool::Roll
|
||||
lcTool::ZoomRegion // lcTrackTool::ZoomRegion
|
||||
lcTool::Select, // lcTrackTool::None
|
||||
lcTool::Insert, // lcTrackTool::Insert
|
||||
lcTool::PointLight, // lcTrackTool::PointLight
|
||||
lcTool::Spotlight, // lcTrackTool::Spotlight
|
||||
lcTool::DirectionalLight, // lcTrackTool::DirectionalLight
|
||||
lcTool::AreaLight, // lcTrackTool::AreaLight
|
||||
lcTool::Camera, // lcTrackTool::Camera
|
||||
lcTool::Select, // lcTrackTool::Select
|
||||
lcTool::Move, // lcTrackTool::MoveX
|
||||
lcTool::Move, // lcTrackTool::MoveY
|
||||
lcTool::Move, // lcTrackTool::MoveZ
|
||||
lcTool::Move, // lcTrackTool::MoveXY
|
||||
lcTool::Move, // lcTrackTool::MoveXZ
|
||||
lcTool::Move, // lcTrackTool::MoveYZ
|
||||
lcTool::Move, // lcTrackTool::MoveXYZ
|
||||
lcTool::Rotate, // lcTrackTool::RotateX
|
||||
lcTool::Rotate, // lcTrackTool::RotateY
|
||||
lcTool::Rotate, // lcTrackTool::RotateZ
|
||||
lcTool::Rotate, // lcTrackTool::RotateXY
|
||||
lcTool::Rotate, // lcTrackTool::RotateXYZ
|
||||
lcTool::Move, // lcTrackTool::ScalePlus
|
||||
lcTool::Move, // lcTrackTool::ScaleMinus
|
||||
lcTool::Eraser, // lcTrackTool::Eraser
|
||||
lcTool::Paint, // lcTrackTool::Paint
|
||||
lcTool::ColorPicker, // lcTrackTool::ColorPicker
|
||||
lcTool::Zoom, // lcTrackTool::Zoom
|
||||
lcTool::Pan, // lcTrackTool::Pan
|
||||
lcTool::RotateView, // lcTrackTool::OrbitX
|
||||
lcTool::RotateView, // lcTrackTool::OrbitY
|
||||
lcTool::RotateView, // lcTrackTool::OrbitXY
|
||||
lcTool::Roll, // lcTrackTool::Roll
|
||||
lcTool::ZoomRegion // lcTrackTool::ZoomRegion
|
||||
};
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(ToolFromTrackTool, lcTrackTool::Count);
|
||||
@@ -2041,22 +2041,22 @@ void lcView::UpdateTrackTool()
|
||||
NewTrackTool = lcTrackTool::Insert;
|
||||
break;
|
||||
|
||||
case lcTool::Light:
|
||||
case lcTool::PointLight:
|
||||
NewTrackTool = lcTrackTool::PointLight;
|
||||
break;
|
||||
|
||||
case lcTool::Spotlight:
|
||||
NewTrackTool = lcTrackTool::Spotlight;
|
||||
break;
|
||||
|
||||
case lcTool::DirectionalLight:
|
||||
NewTrackTool = lcTrackTool::DirectionalLight;
|
||||
break;
|
||||
|
||||
case lcTool::AreaLight:
|
||||
NewTrackTool = lcTrackTool::AreaLight;;
|
||||
break;
|
||||
|
||||
case lcTool::SunLight:
|
||||
NewTrackTool = lcTrackTool::SunLight;
|
||||
break;
|
||||
|
||||
case lcTool::SpotLight:
|
||||
NewTrackTool = lcTrackTool::SpotLight;
|
||||
break;
|
||||
|
||||
case lcTool::Camera:
|
||||
NewTrackTool = lcTrackTool::Camera;
|
||||
break;
|
||||
@@ -2272,22 +2272,30 @@ void lcView::StartTracking(lcTrackButton TrackButton)
|
||||
lcTool Tool = GetCurrentTool();
|
||||
lcModel* ActiveModel = GetActiveModel();
|
||||
|
||||
auto AddLight = [this, ActiveModel](lcLightType LightType)
|
||||
{
|
||||
lcVector3 Position = GetCameraLightInsertPosition();
|
||||
lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f);
|
||||
ActiveModel->BeginDirectionalLightTool(Position, Target, LightType);
|
||||
};
|
||||
|
||||
switch (Tool)
|
||||
{
|
||||
case lcTool::Insert:
|
||||
case lcTool::Light:
|
||||
case lcTool::PointLight:
|
||||
break;
|
||||
|
||||
case lcTool::Spotlight:
|
||||
AddLight(lcLightType::Spot);
|
||||
break;
|
||||
|
||||
case lcTool::DirectionalLight:
|
||||
AddLight(lcLightType::Directional);
|
||||
break;
|
||||
|
||||
case lcTool::AreaLight:
|
||||
case lcTool::SunLight:
|
||||
case lcTool::SpotLight:
|
||||
{
|
||||
lcVector3 Position = GetCameraLightInsertPosition();
|
||||
lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f);
|
||||
int LightType = Tool == lcTool::AreaLight ? LC_AREALIGHT : Tool == lcTool::SunLight ? LC_SUNLIGHT : LC_SPOTLIGHT;
|
||||
ActiveModel->BeginDirectionalLightTool(Position, Target, LightType);
|
||||
}
|
||||
break;
|
||||
AddLight(lcLightType::Area);
|
||||
break;
|
||||
|
||||
case lcTool::Camera:
|
||||
{
|
||||
@@ -2342,12 +2350,12 @@ void lcView::StopTracking(bool Accept)
|
||||
switch (Tool)
|
||||
{
|
||||
case lcTool::Insert:
|
||||
case lcTool::Light:
|
||||
case lcTool::PointLight:
|
||||
break;
|
||||
|
||||
case lcTool::Spotlight:
|
||||
case lcTool::DirectionalLight:
|
||||
case lcTool::AreaLight:
|
||||
case lcTool::SunLight:
|
||||
case lcTool::SpotLight:
|
||||
case lcTool::Camera:
|
||||
ActiveModel->EndMouseTool(Tool, Accept);
|
||||
break;
|
||||
@@ -2474,13 +2482,13 @@ void lcView::OnButtonDown(lcTrackButton TrackButton)
|
||||
}
|
||||
break;
|
||||
|
||||
case lcTrackTool::Spotlight:
|
||||
case lcTrackTool::DirectionalLight:
|
||||
case lcTrackTool::AreaLight:
|
||||
case lcTrackTool::SunLight:
|
||||
case lcTrackTool::SpotLight:
|
||||
case lcTrackTool::Camera:
|
||||
StartTracking(TrackButton);
|
||||
break;
|
||||
|
||||
|
||||
case lcTrackTool::Select:
|
||||
{
|
||||
lcObjectSection ObjectSection = FindObjectUnderPointer(false, false);
|
||||
@@ -2713,9 +2721,9 @@ void lcView::OnMouseMove()
|
||||
case lcTrackTool::PointLight:
|
||||
break;
|
||||
|
||||
case lcTrackTool::Spotlight:
|
||||
case lcTrackTool::DirectionalLight:
|
||||
case lcTrackTool::AreaLight:
|
||||
case lcTrackTool::SunLight:
|
||||
case lcTrackTool::SpotLight:
|
||||
ActiveModel->UpdateDirectionalLightTool(GetCameraLightInsertPosition());
|
||||
break;
|
||||
|
||||
|
||||
+5
-5
@@ -17,10 +17,10 @@ enum class lcCursor
|
||||
Hidden = First,
|
||||
Default,
|
||||
Brick,
|
||||
Light,
|
||||
Arealight,
|
||||
Sunlight,
|
||||
PointLight,
|
||||
Spotlight,
|
||||
DirectionalLight,
|
||||
AreaLight,
|
||||
Camera,
|
||||
Select,
|
||||
SelectAdd,
|
||||
@@ -53,9 +53,9 @@ enum class lcTrackTool
|
||||
None,
|
||||
Insert,
|
||||
PointLight,
|
||||
Spotlight,
|
||||
DirectionalLight,
|
||||
AreaLight,
|
||||
SunLight,
|
||||
SpotLight,
|
||||
Camera,
|
||||
Select,
|
||||
MoveX,
|
||||
|
||||
@@ -674,9 +674,9 @@ bool lcViewManipulator::IsTrackToolAllowed(lcTrackTool TrackTool, quint32 Allowe
|
||||
case lcTrackTool::None:
|
||||
case lcTrackTool::Insert:
|
||||
case lcTrackTool::PointLight:
|
||||
case lcTrackTool::Spotlight:
|
||||
case lcTrackTool::DirectionalLight:
|
||||
case lcTrackTool::AreaLight:
|
||||
case lcTrackTool::SunLight:
|
||||
case lcTrackTool::SpotLight:
|
||||
case lcTrackTool::Camera:
|
||||
case lcTrackTool::Select:
|
||||
return true;
|
||||
|
||||
+175
-231
@@ -14,61 +14,30 @@
|
||||
#define LC_LIGHT_SUN_RADIUS 8.5f
|
||||
#define LC_LIGHT_SPOT_BASE_EDGE 12.5f
|
||||
|
||||
// New omni light.
|
||||
lcLight::lcLight(float px, float py, float pz)
|
||||
: lcObject(lcObjectType::Light)
|
||||
{
|
||||
Initialize(lcVector3(px, py, pz), lcVector3(0.0f, 0.0f, 0.0f), LC_POINTLIGHT);
|
||||
UpdatePosition(1);
|
||||
}
|
||||
static const std::array<QLatin1String, 4> gLightTypes = { QLatin1String("POINT"), QLatin1String("SPOT"), QLatin1String("DIRECTIONAL"), QLatin1String("AREA") };
|
||||
|
||||
// New directional light.
|
||||
lcLight::lcLight(float px, float py, float pz, float tx, float ty, float tz, int LightType)
|
||||
: lcObject(lcObjectType::Light)
|
||||
{
|
||||
Initialize(lcVector3(px, py, pz), lcVector3(tx, ty, tz), LightType);
|
||||
UpdatePosition(1);
|
||||
}
|
||||
|
||||
void lcLight::SetLightState(int LightType)
|
||||
lcLight::lcLight(const lcVector3& Position, const lcVector3& TargetPosition, lcLightType LightType)
|
||||
: lcObject(lcObjectType::Light), mPosition(Position), mTargetPosition(TargetPosition), mLightType(LightType)
|
||||
{
|
||||
mState = 0;
|
||||
|
||||
switch (LightType)
|
||||
{
|
||||
case LC_AREALIGHT:
|
||||
case LC_SUNLIGHT:
|
||||
case LC_SPOTLIGHT:
|
||||
mState |= LC_LIGHT_DIRECTIONAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lcLight::Initialize(const lcVector3& Position, const lcVector3& TargetPosition, int LightType)
|
||||
{
|
||||
SetLightState(LightType);
|
||||
|
||||
mPOVRayLight = false;
|
||||
mShadowless = false;
|
||||
mEnableCutoff = false;
|
||||
mPosition = Position;
|
||||
mTargetPosition = TargetPosition;
|
||||
mAmbientColor = lcVector4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
mDiffuseColor = lcVector4(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
mSpecularColor = lcVector4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mAttenuation = lcVector3(1.0f, 0.0f, 0.0f);
|
||||
mLightColor = lcVector3(1.0f, 1.0f, 1.0f); /*RGB - White*/
|
||||
mLightType = LightType ? LightType : int(LC_POINTLIGHT);
|
||||
mLightFactor[0] = LightType ? LightType == LC_SUNLIGHT ? 11.4f : 0.25f : 0.0f;
|
||||
mLightFactor[1] = LightType == LC_AREALIGHT ? 0.25f : LightType == LC_SPOTLIGHT ? 0.150f : 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;
|
||||
mPOVRayExponent = 1.0f;
|
||||
mSpotSize = 75.0f;
|
||||
mSpotCutoff = LightType ? LightType != LC_SUNLIGHT ? 40.0f : 0.0f : 30.0f;
|
||||
mSpotCutoff = LightType != lcLightType::Directional ? 40.0f : 0.0f;
|
||||
mSpotFalloff = 45.0f;
|
||||
mSpotTightness = 0;
|
||||
mAreaGrid = lcVector2(10.0f, 10.0f);
|
||||
@@ -81,9 +50,7 @@ void lcLight::Initialize(const lcVector3& Position, const lcVector3& TargetPosit
|
||||
mDiffuseColorKeys.ChangeKey(mDiffuseColor, 1, true);
|
||||
mSpecularColorKeys.ChangeKey(mSpecularColor, 1, true);
|
||||
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
||||
mLightShapeKeys.ChangeKey(mLightShape, 1, true);
|
||||
mLightColorKeys.ChangeKey(mLightColor, 1, true);
|
||||
mLightTypeKeys.ChangeKey(mLightType, 1, true);
|
||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||
mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true);
|
||||
mLightSpecularKeys.ChangeKey(mLightSpecular, 1, true);
|
||||
@@ -93,10 +60,8 @@ void lcLight::Initialize(const lcVector3& Position, const lcVector3& TargetPosit
|
||||
mSpotSizeKeys.ChangeKey(mSpotSize, 1, true);
|
||||
mSpotTightnessKeys.ChangeKey(mSpotTightness, 1, true);
|
||||
mAreaGridKeys.ChangeKey(mAreaGrid, 1, true);
|
||||
}
|
||||
|
||||
lcLight::~lcLight()
|
||||
{
|
||||
UpdatePosition(1);
|
||||
}
|
||||
|
||||
void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||
@@ -114,7 +79,7 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT POSITION ") << mPosition[0] << ' ' << mPosition[1] << ' ' << mPosition[2] << LineEnding;
|
||||
|
||||
if (mLightType != LC_POINTLIGHT && !(mLightType == LC_AREALIGHT && mPOVRayLight))
|
||||
if (mLightType != lcLightType::Point && !(mLightType == lcLightType::Area && mPOVRayLight))
|
||||
{
|
||||
if (mTargetPositionKeys.GetSize() > 1)
|
||||
mTargetPositionKeys.SaveKeysLDraw(Stream, "LIGHT TARGET_POSITION_KEY ");
|
||||
@@ -140,158 +105,126 @@ void lcLight::SaveLDraw(QTextStream& Stream) const
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPECULAR ") << mLightSpecular << LineEnding;
|
||||
}
|
||||
|
||||
if (mLightType == LC_SUNLIGHT)
|
||||
{
|
||||
if (mSpotExponentKeys.GetSize() > 1)
|
||||
mSpotExponentKeys.SaveKeysLDraw(Stream, "LIGHT STRENGTH_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT STRENGTH ") << (mPOVRayLight ? mPOVRayExponent : mSpotExponent) << LineEnding;
|
||||
if (mSpotExponentKeys.GetSize() > 1)
|
||||
mSpotExponentKeys.SaveKeysLDraw(Stream, "LIGHT POWER_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT POWER ") << (mPOVRayLight ? mPOVRayExponent : mSpotExponent) << LineEnding;
|
||||
|
||||
if (mEnableCutoff && !mPOVRayLight)
|
||||
{
|
||||
if (mSpotCutoffKeys.GetSize() > 1)
|
||||
mSpotCutoffKeys.SaveKeysLDraw(Stream, "LIGHT CUTOFF_DISTANCE_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT CUTOFF_DISTANCE ") << mSpotCutoff << LineEnding;
|
||||
}
|
||||
|
||||
switch (mLightType)
|
||||
{
|
||||
case lcLightType::Point:
|
||||
if (!mPOVRayLight)
|
||||
{
|
||||
if (mLightFactorKeys.GetSize() > 1)
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT ANGLE_KEY ");
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT ANGLE ") << mLightFactor[0] << LineEnding;
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << mLightFactor[0] << LineEnding;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mSpotExponentKeys.GetSize() > 1)
|
||||
mSpotExponentKeys.SaveKeysLDraw(Stream, "LIGHT POWER_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT POWER ") << (mPOVRayLight ? mPOVRayExponent : mSpotExponent) << LineEnding;
|
||||
break;
|
||||
|
||||
if (mEnableCutoff && !mPOVRayLight)
|
||||
case lcLightType::Spot:
|
||||
if (mPOVRayLight)
|
||||
{
|
||||
if (mSpotCutoffKeys.GetSize() > 1)
|
||||
mSpotCutoffKeys.SaveKeysLDraw(Stream, "LIGHT CUTOFF_DISTANCE_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT CUTOFF_DISTANCE ") << mSpotCutoff << LineEnding;
|
||||
}
|
||||
|
||||
switch (mLightType)
|
||||
{
|
||||
case LC_POINTLIGHT:
|
||||
if (!mPOVRayLight)
|
||||
{
|
||||
if (mLightFactorKeys.GetSize() > 1)
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << mLightFactor[0] << LineEnding;
|
||||
}
|
||||
break;
|
||||
case LC_SPOTLIGHT:
|
||||
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
|
||||
{
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << mLightFactor[0] << LineEnding;
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_BLEND ") << mLightFactor[1] << LineEnding;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LC_AREALIGHT:
|
||||
if (mPOVRayLight)
|
||||
{
|
||||
if (mAreaGridKeys.GetSize() > 1)
|
||||
mAreaGridKeys.SaveKeysLDraw(Stream, "LIGHT AREA_GRID_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_ROWS ") << mAreaGrid[0] << QLatin1String(" AREA_COLUMNS ") << mAreaGrid[1] << LineEnding;
|
||||
}
|
||||
if (mLightFactorKeys.GetSize() > 1)
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT SIZE_KEY ");
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT RADIUS_KEY ");
|
||||
else
|
||||
{
|
||||
if (mPOVRayLight)
|
||||
{
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT WIDTH ") << mAreaSize[0] << QLatin1String(" HEIGHT ") << mAreaSize[1] << LineEnding;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mLightShape == LC_LIGHT_SHAPE_RECTANGLE || mLightShape == LC_LIGHT_SHAPE_ELLIPSE || mLightFactor[1] > 0)
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT WIDTH ") << mLightFactor[0] << QLatin1String(" HEIGHT ") << mLightFactor[1] << LineEnding;
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SIZE ") << mLightFactor[0] << LineEnding;
|
||||
}
|
||||
}
|
||||
if (mLightShapeKeys.GetSize() > 1)
|
||||
mLightShapeKeys.SaveKeysLDraw(Stream, "LIGHT SHAPE_KEY ");
|
||||
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 SHAPE ");
|
||||
|
||||
QString Shape = QLatin1String("Undefined ");
|
||||
switch(mLightShape)
|
||||
{
|
||||
case LC_LIGHT_SHAPE_SQUARE:
|
||||
Shape = QLatin1String("Square ");
|
||||
break;
|
||||
case LC_LIGHT_SHAPE_DISK:
|
||||
Shape = mPOVRayLight ? QLatin1String("Circle ") : QLatin1String("Disk ");
|
||||
break;
|
||||
case LC_LIGHT_SHAPE_RECTANGLE:
|
||||
Shape = QLatin1String("Rectangle ");
|
||||
break;
|
||||
case LC_LIGHT_SHAPE_ELLIPSE:
|
||||
Shape = QLatin1String("Ellipse ");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Stream << QLatin1String(Shape.toLatin1()) << LineEnding;
|
||||
}
|
||||
|
||||
break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (mLightTypeKeys.GetSize() > 1)
|
||||
mLightTypeKeys.SaveKeysLDraw(Stream, "LIGHT TYPE_KEY ");
|
||||
else
|
||||
{
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT TYPE ");
|
||||
|
||||
QString Type = QLatin1String("Undefined ");
|
||||
switch(mLightType)
|
||||
else
|
||||
{
|
||||
case LC_POINTLIGHT:
|
||||
Type = QLatin1String("Point ");
|
||||
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
|
||||
{
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT RADIUS ") << mLightFactor[0] << LineEnding;
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SPOT_BLEND ") << mLightFactor[1] << LineEnding;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case lcLightType::Directional:
|
||||
if (mSpotExponentKeys.GetSize() > 1)
|
||||
mSpotExponentKeys.SaveKeysLDraw(Stream, "LIGHT STRENGTH_KEY ");
|
||||
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:
|
||||
if (mPOVRayLight)
|
||||
{
|
||||
if (mAreaGridKeys.GetSize() > 1)
|
||||
mAreaGridKeys.SaveKeysLDraw(Stream, "LIGHT AREA_GRID_KEY ");
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT AREA_ROWS ") << mAreaGrid[0] << QLatin1String(" AREA_COLUMNS ") << mAreaGrid[1] << LineEnding;
|
||||
}
|
||||
if (mLightFactorKeys.GetSize() > 1)
|
||||
mLightFactorKeys.SaveKeysLDraw(Stream, "LIGHT SIZE_KEY ");
|
||||
else
|
||||
{
|
||||
if (mPOVRayLight)
|
||||
{
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT WIDTH ") << mAreaSize[0] << QLatin1String(" HEIGHT ") << mAreaSize[1] << LineEnding;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mLightShape == LC_LIGHT_SHAPE_RECTANGLE || mLightShape == LC_LIGHT_SHAPE_ELLIPSE || mLightFactor[1] > 0)
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT WIDTH ") << mLightFactor[0] << QLatin1String(" HEIGHT ") << mLightFactor[1] << LineEnding;
|
||||
else
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SIZE ") << mLightFactor[0] << LineEnding;
|
||||
}
|
||||
}
|
||||
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SHAPE ");
|
||||
|
||||
QString Shape = QLatin1String("UNDEFINED ");
|
||||
switch (mLightShape)
|
||||
{
|
||||
case LC_LIGHT_SHAPE_SQUARE:
|
||||
Shape = QLatin1String("SQUARE ");
|
||||
break;
|
||||
case LC_SUNLIGHT:
|
||||
Type = QLatin1String("Sun ");
|
||||
case LC_LIGHT_SHAPE_DISK:
|
||||
Shape = QLatin1String("DISK ");
|
||||
break;
|
||||
case LC_AREALIGHT:
|
||||
Type = QLatin1String("Area ");
|
||||
case LC_LIGHT_SHAPE_RECTANGLE:
|
||||
Shape = QLatin1String("RECTANGLE ");
|
||||
break;
|
||||
case LC_SPOTLIGHT:
|
||||
Type = QLatin1String("Spot ");
|
||||
case LC_LIGHT_SHAPE_ELLIPSE:
|
||||
Shape = QLatin1String("ELLIPSE ");
|
||||
break;
|
||||
}
|
||||
Stream << QLatin1String(Type.toLatin1()) << QLatin1String("NAME ") << mName << LineEnding;
|
||||
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT SHAPE ") << Shape << LineEnding;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Stream << QLatin1String("0 !LEOCAD LIGHT TYPE ") << gLightTypes[static_cast<int>(mLightType)] << QLatin1String(" NAME ") << mName << LineEnding;
|
||||
}
|
||||
|
||||
void lcLight::CreateName(const lcArray<lcLight*>& Lights)
|
||||
@@ -315,7 +248,26 @@ void lcLight::CreateName(const lcArray<lcLight*>& Lights)
|
||||
|
||||
int MaxLightNumber = 0;
|
||||
|
||||
const QLatin1String Prefix(mLightType == LC_POINTLIGHT ? "Pointlight " : mLightType == LC_AREALIGHT ? "Arealight " : mLightType == LC_SUNLIGHT ? "Sunlight " : "Spotlight ");
|
||||
QString Prefix;
|
||||
|
||||
switch (mLightType)
|
||||
{
|
||||
case lcLightType::Point:
|
||||
Prefix = QLatin1String("Pointlight ");
|
||||
break;
|
||||
|
||||
case lcLightType::Spot:
|
||||
Prefix = QLatin1String("Spotlight ");
|
||||
break;
|
||||
|
||||
case lcLightType::Directional:
|
||||
Prefix = QLatin1String("Directionallight ");
|
||||
break;
|
||||
|
||||
case lcLightType::Area:
|
||||
Prefix = QLatin1String("Arealight ");
|
||||
break;
|
||||
}
|
||||
|
||||
for (const lcLight* Light : Lights)
|
||||
{
|
||||
@@ -410,16 +362,16 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||
{
|
||||
QString Shape;
|
||||
Stream >> Shape;
|
||||
Shape = Shape.replace("\"", "").toLower();
|
||||
if (Shape == QLatin1String("square"))
|
||||
Shape.replace("\"", "");
|
||||
|
||||
if (Shape == QLatin1String("SQUARE"))
|
||||
mLightShape = LC_LIGHT_SHAPE_SQUARE;
|
||||
else if (Shape == QLatin1String("disk") || Shape == QLatin1String("circle"))
|
||||
else if (Shape == QLatin1String("DISK") || Shape == QLatin1String("CIRCLE"))
|
||||
mLightShape = LC_LIGHT_SHAPE_DISK;
|
||||
else if (Shape == QLatin1String("rectangle"))
|
||||
else if (Shape == QLatin1String("RECTANGLE"))
|
||||
mLightShape = LC_LIGHT_SHAPE_RECTANGLE;
|
||||
else if (Shape == QLatin1String("ellipse"))
|
||||
else if (Shape == QLatin1String("ELLIPSE"))
|
||||
mLightShape = LC_LIGHT_SHAPE_ELLIPSE;
|
||||
mLightShapeKeys.ChangeKey(mLightShape, 1, true);
|
||||
}
|
||||
else if (Token == QLatin1String("DIFFUSE"))
|
||||
{
|
||||
@@ -441,17 +393,15 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||
{
|
||||
QString Type;
|
||||
Stream >> Type;
|
||||
Type = Type.replace("\"", "").toLower();
|
||||
if (Type == QLatin1String("point"))
|
||||
mLightType = LC_POINTLIGHT;
|
||||
else if (Type == QLatin1String("sun"))
|
||||
mLightType = LC_SUNLIGHT;
|
||||
else if (Type == QLatin1String("spot"))
|
||||
mLightType = LC_SPOTLIGHT;
|
||||
else if (Type == QLatin1String("area"))
|
||||
mLightType = LC_AREALIGHT;
|
||||
SetLightState(mLightType);
|
||||
mLightTypeKeys.ChangeKey(mLightType, 1, true);
|
||||
|
||||
for (size_t TypeIndex = 0; TypeIndex < gLightTypes.size(); TypeIndex++)
|
||||
{
|
||||
if (Type == gLightTypes[TypeIndex])
|
||||
{
|
||||
mLightType = static_cast<lcLightType>(TypeIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Token == QLatin1String("POSITION"))
|
||||
{
|
||||
@@ -485,16 +435,12 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||
mSpotTightnessKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("AREA_GRID_KEY"))
|
||||
mAreaGridKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SHAPE_KEY"))
|
||||
mLightShapeKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("DIFFUSE_KEY"))
|
||||
mLightDiffuseKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("SPECULAR_KEY"))
|
||||
mLightSpecularKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("CUTOFF_DISTANCE_KEY"))
|
||||
mSpotCutoffKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("TYPE_KEY"))
|
||||
mLightTypeKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("POSITION_KEY"))
|
||||
mPositionKeys.LoadKeysLDraw(Stream);
|
||||
else if (Token == QLatin1String("TARGET_POSITION_KEY"))
|
||||
@@ -505,34 +451,45 @@ bool lcLight::ParseLDrawLine(QTextStream& Stream)
|
||||
mName.replace("\"", "");
|
||||
|
||||
// Set default settings per light type
|
||||
if (mLightType == LC_SPOTLIGHT)
|
||||
switch (mLightType)
|
||||
{
|
||||
case lcLightType::Point:
|
||||
break;
|
||||
|
||||
case lcLightType::Spot:
|
||||
if (!mSpotBlendSet)
|
||||
{
|
||||
mLightFactor[1] = 0.15f;
|
||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||
}
|
||||
}
|
||||
if (mLightType == LC_AREALIGHT && (mLightShape == LC_LIGHT_SHAPE_RECTANGLE || mLightShape == LC_LIGHT_SHAPE_ELLIPSE)) {
|
||||
if (!mHeightSet)
|
||||
{
|
||||
mLightFactor[1] = 0.25f;
|
||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||
}
|
||||
}
|
||||
if (mLightType == LC_SUNLIGHT)
|
||||
{
|
||||
break;
|
||||
|
||||
case lcLightType::Directional:
|
||||
if (!mAngleSet)
|
||||
{
|
||||
mLightFactor[0] = 11.4f;
|
||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||
}
|
||||
|
||||
if (!mSpotCutoffSet)
|
||||
{
|
||||
mSpotCutoff = 0.0f;
|
||||
mSpotCutoff = 0.0f;
|
||||
mSpotCutoffKeys.ChangeKey(mSpotCutoff, 1, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case lcLightType::Area:
|
||||
if (mLightShape == LC_LIGHT_SHAPE_RECTANGLE || mLightShape == LC_LIGHT_SHAPE_ELLIPSE)
|
||||
{
|
||||
if (!mHeightSet)
|
||||
{
|
||||
mLightFactor[1] = 0.25f;
|
||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -564,14 +521,13 @@ void lcLight::UpdateLight(lcStep Step, lcLightProperties Props, int Property)
|
||||
{
|
||||
case LC_LIGHT_SHAPE:
|
||||
mLightShape = Props.mLightShape;
|
||||
mLightShapeKeys.ChangeKey(mLightShape, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_COLOR:
|
||||
mLightColor = Props.mLightColor;
|
||||
mLightColorKeys.ChangeKey(mLightColor, Step, false);
|
||||
break;
|
||||
case LC_LIGHT_FACTOR:
|
||||
if (Props.mPOVRayLight && mLightType == LC_AREALIGHT)
|
||||
if (Props.mPOVRayLight && mLightType == lcLightType::Area)
|
||||
{
|
||||
mAreaSize = Props.mLightFactor;
|
||||
mLightFactorKeys.ChangeKey(mAreaSize, 1, true);
|
||||
@@ -757,9 +713,7 @@ void lcLight::InsertTime(lcStep Start, lcStep Time)
|
||||
mDiffuseColorKeys.InsertTime(Start, Time);
|
||||
mSpecularColorKeys.InsertTime(Start, Time);
|
||||
mAttenuationKeys.InsertTime(Start, Time);
|
||||
mLightShapeKeys.InsertTime(Start, Time);
|
||||
mLightColorKeys.InsertTime(Start, Time);
|
||||
mLightTypeKeys.InsertTime(Start, Time);
|
||||
mLightFactorKeys.InsertTime(Start, Time);
|
||||
mLightDiffuseKeys.InsertTime(Start, Time);
|
||||
mLightSpecularKeys.InsertTime(Start, Time);
|
||||
@@ -779,9 +733,7 @@ void lcLight::RemoveTime(lcStep Start, lcStep Time)
|
||||
mDiffuseColorKeys.RemoveTime(Start, Time);
|
||||
mSpecularColorKeys.RemoveTime(Start, Time);
|
||||
mAttenuationKeys.RemoveTime(Start, Time);
|
||||
mLightShapeKeys.RemoveTime(Start, Time);
|
||||
mLightColorKeys.RemoveTime(Start, Time);
|
||||
mLightTypeKeys.RemoveTime(Start, Time);
|
||||
mLightFactorKeys.RemoveTime(Start, Time);
|
||||
mLightDiffuseKeys.RemoveTime(Start, Time);
|
||||
mLightSpecularKeys.RemoveTime(Start, Time);
|
||||
@@ -801,9 +753,7 @@ void lcLight::UpdatePosition(lcStep Step)
|
||||
mDiffuseColor = mDiffuseColorKeys.CalculateKey(Step);
|
||||
mSpecularColor = mSpecularColorKeys.CalculateKey(Step);
|
||||
mAttenuation = mAttenuationKeys.CalculateKey(Step);
|
||||
mLightShape = mLightShapeKeys.CalculateKey(Step);
|
||||
mLightColor = mLightColorKeys.CalculateKey(Step);
|
||||
mLightType = mLightTypeKeys.CalculateKey(Step);
|
||||
mLightFactor = mLightFactorKeys.CalculateKey(Step);
|
||||
mLightDiffuse = mLightDiffuseKeys.CalculateKey(Step);
|
||||
mLightSpecular = mLightSpecularKeys.CalculateKey(Step);
|
||||
@@ -886,9 +836,9 @@ void lcLight::DrawDirectionalLight(lcContext* Context) const
|
||||
float Verts[(20 + 8 + 2 + 16) * 3];
|
||||
float* CurVert = Verts;
|
||||
|
||||
if (mLightType != LC_SUNLIGHT)
|
||||
if (mLightType != lcLightType::Directional)
|
||||
{
|
||||
if (mLightType == LC_SPOTLIGHT)
|
||||
if (mLightType == lcLightType::Spot)
|
||||
{
|
||||
for (int EdgeIdx = 0; EdgeIdx < 8; EdgeIdx++)
|
||||
{
|
||||
@@ -908,7 +858,7 @@ void lcLight::DrawDirectionalLight(lcContext* Context) const
|
||||
*CurVert++ = LC_LIGHT_SPOT_BASE_EDGE; *CurVert++ = LC_LIGHT_SPOT_BASE_EDGE; *CurVert++ = -LC_LIGHT_POSITION_EDGE;
|
||||
*CurVert++ = -LC_LIGHT_SPOT_BASE_EDGE; *CurVert++ = LC_LIGHT_SPOT_BASE_EDGE; *CurVert++ = -LC_LIGHT_POSITION_EDGE;
|
||||
}
|
||||
else if (mLightType == LC_AREALIGHT)
|
||||
else if (mLightType == lcLightType::Area)
|
||||
{
|
||||
const float LC_LIGHT_AREA_EDGE = 5.0f;
|
||||
const float LC_LIGHT_AREA_H_EDGE = 8.5f;
|
||||
@@ -947,7 +897,7 @@ void lcLight::DrawDirectionalLight(lcContext* Context) const
|
||||
|
||||
int BaseIndices = 0;
|
||||
|
||||
if (mLightType == LC_SPOTLIGHT)
|
||||
if (mLightType == lcLightType::Spot)
|
||||
{
|
||||
BaseIndices = 56;
|
||||
const GLushort Indices[56 + 24 + 2 + 40] =
|
||||
@@ -967,7 +917,7 @@ void lcLight::DrawDirectionalLight(lcContext* Context) const
|
||||
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
}
|
||||
else if (mLightType == LC_AREALIGHT)
|
||||
else if (mLightType == lcLightType::Area)
|
||||
{
|
||||
BaseIndices = 32;
|
||||
const GLushort Indices[32 + 24 + 2] =
|
||||
@@ -984,7 +934,7 @@ void lcLight::DrawDirectionalLight(lcContext* Context) const
|
||||
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
}
|
||||
else if (mLightType == LC_SUNLIGHT)
|
||||
else if (mLightType == lcLightType::Directional)
|
||||
{
|
||||
constexpr float Radius = LC_LIGHT_SUN_RADIUS;
|
||||
constexpr int Slices = 9; // longitude
|
||||
@@ -1175,7 +1125,7 @@ void lcLight::DrawDirectionalLight(lcContext* Context) const
|
||||
|
||||
int SpotCone = 0;
|
||||
|
||||
if (mLightType == LC_SPOTLIGHT)
|
||||
if (mLightType == lcLightType::Spot)
|
||||
{
|
||||
SpotCone = 40;
|
||||
|
||||
@@ -1316,18 +1266,12 @@ void lcLight::RemoveKeyFrames()
|
||||
mAttenuationKeys.RemoveAll();
|
||||
mAttenuationKeys.ChangeKey(mAttenuation, 1, true);
|
||||
|
||||
mLightShapeKeys.RemoveAll();
|
||||
mLightShapeKeys.ChangeKey(mLightShape, 1, false);
|
||||
|
||||
mLightColorKeys.RemoveAll();
|
||||
mLightColorKeys.ChangeKey(mLightColor, 1, true);
|
||||
|
||||
mLightFactorKeys.RemoveAll();
|
||||
mLightFactorKeys.ChangeKey(mLightFactor, 1, true);
|
||||
|
||||
mLightTypeKeys.RemoveAll();
|
||||
mLightTypeKeys.ChangeKey(mLightType, 1, true);
|
||||
|
||||
mLightDiffuseKeys.RemoveAll();
|
||||
mLightDiffuseKeys.ChangeKey(mLightDiffuse, 1, true);
|
||||
|
||||
|
||||
+25
-23
@@ -5,11 +5,10 @@
|
||||
|
||||
#define LC_LIGHT_HIDDEN 0x0001
|
||||
#define LC_LIGHT_DISABLED 0x0002
|
||||
#define LC_LIGHT_DIRECTIONAL 0x0004
|
||||
#define LC_LIGHT_POSITION_SELECTED 0x0008
|
||||
#define LC_LIGHT_POSITION_FOCUSED 0x0010
|
||||
#define LC_LIGHT_TARGET_SELECTED 0x0020
|
||||
#define LC_LIGHT_TARGET_FOCUSED 0x0040
|
||||
#define LC_LIGHT_POSITION_SELECTED 0x0010
|
||||
#define LC_LIGHT_POSITION_FOCUSED 0x0020
|
||||
#define LC_LIGHT_TARGET_SELECTED 0x0040
|
||||
#define LC_LIGHT_TARGET_FOCUSED 0x0080
|
||||
|
||||
#define LC_LIGHT_SELECTION_MASK (LC_LIGHT_POSITION_SELECTED | LC_LIGHT_TARGET_SELECTED)
|
||||
#define LC_LIGHT_FOCUS_MASK (LC_LIGHT_POSITION_FOCUSED | LC_LIGHT_TARGET_FOCUSED)
|
||||
@@ -20,13 +19,12 @@ enum lcLightSection
|
||||
LC_LIGHT_SECTION_TARGET
|
||||
};
|
||||
|
||||
enum lcLightType
|
||||
enum class lcLightType
|
||||
{
|
||||
LC_UNDEFINED_LIGHT,
|
||||
LC_POINTLIGHT,
|
||||
LC_AREALIGHT,
|
||||
LC_SUNLIGHT,
|
||||
LC_SPOTLIGHT
|
||||
Point,
|
||||
Spot,
|
||||
Directional,
|
||||
Area
|
||||
};
|
||||
|
||||
enum lcLightShape
|
||||
@@ -79,9 +77,8 @@ struct lcLightProperties
|
||||
class lcLight : public lcObject
|
||||
{
|
||||
public:
|
||||
lcLight(float px, float py, float pz);
|
||||
lcLight(float px, float py, float pz, float tx, float ty, float tz, int LightType);
|
||||
~lcLight();
|
||||
lcLight(const lcVector3& Position, const lcVector3& TargetPosition, lcLightType LightType);
|
||||
virtual ~lcLight() = default;
|
||||
|
||||
lcLight(const lcLight&) = delete;
|
||||
lcLight(lcLight&&) = delete;
|
||||
@@ -90,12 +87,22 @@ public:
|
||||
|
||||
bool IsPointLight() const
|
||||
{
|
||||
return (mState & LC_LIGHT_DIRECTIONAL) == 0;
|
||||
return mLightType == lcLightType::Point;
|
||||
}
|
||||
|
||||
bool IsDirectionalLight() const
|
||||
{
|
||||
return (mState & LC_LIGHT_DIRECTIONAL) != 0;
|
||||
return mLightType == lcLightType::Directional;
|
||||
}
|
||||
|
||||
lcLightType GetLightType() const
|
||||
{
|
||||
return mLightType;
|
||||
}
|
||||
|
||||
int GetLightShape() const
|
||||
{
|
||||
return mLightShape;
|
||||
}
|
||||
|
||||
bool IsSelected() const override
|
||||
@@ -296,8 +303,6 @@ public:
|
||||
bool mEnableCutoff;
|
||||
bool mPOVRayLight;
|
||||
bool mShadowless;
|
||||
int mLightType;
|
||||
int mLightShape;
|
||||
float mLightDiffuse;
|
||||
float mLightSpecular;
|
||||
float mSpotSize;
|
||||
@@ -318,8 +323,6 @@ protected:
|
||||
lcObjectKeyArray<lcVector3> mLightColorKeys;
|
||||
lcObjectKeyArray<lcVector2> mLightFactorKeys;
|
||||
lcObjectKeyArray<lcVector2> mAreaGridKeys;
|
||||
lcObjectKeyArray<int> mLightTypeKeys;
|
||||
lcObjectKeyArray<int> mLightShapeKeys;
|
||||
lcObjectKeyArray<float> mLightSpecularKeys;
|
||||
lcObjectKeyArray<float> mLightDiffuseKeys;
|
||||
lcObjectKeyArray<float> mSpotSizeKeys;
|
||||
@@ -328,11 +331,10 @@ protected:
|
||||
lcObjectKeyArray<float> mSpotExponentKeys;
|
||||
lcObjectKeyArray<float> mSpotTightnessKeys;
|
||||
|
||||
void Initialize(const lcVector3& Position, const lcVector3& TargetPosition, int LightType);
|
||||
|
||||
void DrawDirectionalLight(lcContext* Context) const;
|
||||
void DrawPointLight(lcContext* Context) const;
|
||||
void SetLightState(int LightType);
|
||||
|
||||
quint32 mState;
|
||||
lcLightType mLightType;
|
||||
int mLightShape;
|
||||
};
|
||||
|
||||
+26
-31
@@ -1859,12 +1859,6 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
|
||||
POVFile.WriteLine("global_settings { assumed_gamma 1.0 }\n\n");
|
||||
|
||||
/* POV-Ray uses a left-handed coordinate system
|
||||
* - positive x-axis pointing right
|
||||
* - positive y-axis pointing up
|
||||
* - positive z-axis pointing away from you
|
||||
* POVRay [0]x,[1]y,[2]z = LeoCAD [1]y,[0]x,[2]z */
|
||||
|
||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
std::map<const PieceInfo*, std::pair<char[LC_PIECE_NAME_LEN + 1], int>> PieceTable;
|
||||
size_t NumColors = gColorList.size();
|
||||
@@ -1930,7 +1924,7 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
|
||||
for (const lcLight* Light : Lights)
|
||||
{
|
||||
if (Light->mLightType == LC_AREALIGHT)
|
||||
if (Light->GetLightType() == lcLightType::Area)
|
||||
{
|
||||
if (FloorColor == lcVector3(0.8f,0.8f,0.8f))
|
||||
FloorColor = {1.0f,1.0f,1.0f};
|
||||
@@ -2015,16 +2009,25 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
"#ifndef (SkipWriteLightMacro)\n"
|
||||
"#macro WriteLight(Type, Shadowless, Location, Target, Color, Power, SpotRadius, SpotFalloff, SpotTightness, AreaCircle, AreaWidth, AreaHeight, AreaRows, AreaColumns)\n"
|
||||
" #local PointLight = %i;\n"
|
||||
" #local Spotlight = %i;\n"
|
||||
" #local DirectionalLight = %i;\n"
|
||||
" #local AreaLight = %i;\n"
|
||||
" #local SunLight = %i;\n"
|
||||
" #local SpotLight = %i;\n"
|
||||
" light_source {\n"
|
||||
" Location\n"
|
||||
" color rgb Color*Power\n"
|
||||
" #if (Shadowless > 0)\n"
|
||||
" shadowless\n"
|
||||
" #end\n"
|
||||
" #if (Type = AreaLight)\n"
|
||||
" #if (Type = Spotlight)\n"
|
||||
" spotlight\n"
|
||||
" radius SpotRadius\n"
|
||||
" falloff SpotFalloff\n"
|
||||
" tightness SpotTightness\n"
|
||||
" point_at Target\n"
|
||||
" #elseif (Type = DirectionalLight)\n"
|
||||
" parallel\n"
|
||||
" point_at Target\n"
|
||||
" #elseif (Type = AreaLight)\n"
|
||||
" area_light AreaWidth, AreaHeight, AreaRows, AreaColumns\n"
|
||||
" jitter\n"
|
||||
" #if (AreaCircle > 0 & AreaWidth > 2 & AreaHeight > 2 & AreaRows > 1 & AreaColumns > 1 )\n"
|
||||
@@ -2033,20 +2036,11 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
" orient\n"
|
||||
" #end\n"
|
||||
" #end\n"
|
||||
" #elseif (Type = SunLight)\n"
|
||||
" parallel\n"
|
||||
" point_at Target\n"
|
||||
" #elseif (Type = SpotLight)\n"
|
||||
" spotlight\n"
|
||||
" radius SpotRadius\n"
|
||||
" falloff SpotFalloff\n"
|
||||
" tightness SpotTightness\n"
|
||||
" point_at Target\n"
|
||||
" #end\n"
|
||||
" }\n"
|
||||
"#end\n"
|
||||
"#end\n\n",
|
||||
LC_POINTLIGHT, LC_AREALIGHT, LC_SUNLIGHT, LC_SPOTLIGHT);
|
||||
lcLightType::Point, lcLightType::Spot, lcLightType::Directional, lcLightType::Area);
|
||||
POVFile.WriteLine(Line);
|
||||
|
||||
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||
@@ -2147,7 +2141,8 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
|
||||
lcVector3 LightTarget(0.0f, 0.0f, 0.0f), LightColor(1.0f, 1.0f, 1.0f);
|
||||
lcVector2 AreaSize(200.0f, 200.0f), AreaGrid(10.0f, 10.0f);
|
||||
int AreaCircle = 0, Shadowless = 0, LightType = LC_AREALIGHT;
|
||||
int AreaCircle = 0, Shadowless = 0;
|
||||
lcLightType LightType = lcLightType::Area;
|
||||
float Power = 0, SpotRadius = 0, SpotFalloff = 0, SpotTightness = 0;
|
||||
if (Lights.IsEmpty())
|
||||
{
|
||||
@@ -2178,25 +2173,25 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
{
|
||||
const lcVector3& Location = Light->mPosition;
|
||||
const QString LightName = QString(Light->mName).replace(" ","_");
|
||||
LightType = Light->mLightType;
|
||||
LightType = Light->GetLightType();
|
||||
Shadowless = static_cast<int>(Light->mShadowless);
|
||||
LightColor = Light->mLightColor;
|
||||
Power = Light->mPOVRayExponent;
|
||||
switch(LightType)
|
||||
{
|
||||
case LC_AREALIGHT:
|
||||
AreaCircle = Light->mLightShape == LC_LIGHT_SHAPE_DISK ? 1 : 0;
|
||||
AreaSize = Light->mAreaSize;
|
||||
AreaGrid = Light->mAreaGrid;
|
||||
break;
|
||||
case LC_SUNLIGHT:
|
||||
LightTarget = Light->mTargetPosition;
|
||||
break;
|
||||
case LC_SPOTLIGHT:
|
||||
case lcLightType::Spot:
|
||||
LightTarget = Light->mTargetPosition;
|
||||
SpotFalloff = Light->mSpotFalloff;
|
||||
SpotRadius = Light->mSpotSize - SpotFalloff;
|
||||
break;
|
||||
case lcLightType::Directional:
|
||||
LightTarget = Light->mTargetPosition;
|
||||
break;
|
||||
case lcLightType::Area:
|
||||
AreaCircle = Light->GetLightShape() == LC_LIGHT_SHAPE_DISK ? 1 : 0;
|
||||
AreaSize = Light->mAreaSize;
|
||||
AreaGrid = Light->mAreaGrid;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+89
-82
@@ -300,7 +300,7 @@ void lcQPropertiesTree::mousePressEvent(QMouseEvent *event)
|
||||
if (item)
|
||||
{
|
||||
if ((item != m_delegate->editedItem()) && (event->button() == Qt::LeftButton) && (header()->logicalIndexAt(event->pos().x()) == 1) &&
|
||||
((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled)))
|
||||
((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled)))
|
||||
editItem(item, 1);
|
||||
}
|
||||
}
|
||||
@@ -484,16 +484,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
||||
}
|
||||
|
||||
case PropertyFloatReadOnly:
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
float value = item->data(0, PropertyValueRole).toFloat();
|
||||
|
||||
editor->setText(lcFormatValueLocalized(value));
|
||||
editor->setReadOnly(true);
|
||||
editor->setToolTip(tr("Property is read only"));
|
||||
|
||||
return editor;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
case PropertyStep:
|
||||
{
|
||||
@@ -534,16 +525,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
||||
}
|
||||
|
||||
case PropertyStringLightReadOnly:
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
const char *value = (const char*)item->data(0, PropertyValueRole).value<void*>();
|
||||
|
||||
editor->setText(value);
|
||||
editor->setReadOnly(true);
|
||||
editor->setToolTip(tr("Property is read only"));
|
||||
|
||||
return editor;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
case PropertyLightFormat:
|
||||
{
|
||||
@@ -552,7 +534,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
||||
editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
editor->setMinimumContentsLength(1);
|
||||
|
||||
QStringList formats = { "Blender", "POVRay" };
|
||||
QStringList formats = { QLatin1String("Blender"), QLatin1String("POVRay") };
|
||||
for (int i = 0; i < formats.size(); i++)
|
||||
editor->addItem(formats.at(i), QVariant::fromValue(i));
|
||||
|
||||
@@ -571,7 +553,7 @@ QWidget *lcQPropertiesTree::createEditor(QWidget *parent, QTreeWidgetItem *item)
|
||||
editor->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
editor->setMinimumContentsLength(1);
|
||||
|
||||
QStringList shapes = { "Square", "Disk", "Rectangle", "Ellipse" };
|
||||
QStringList shapes = { tr("Square"), tr("Disk"), tr("Rectangle"), tr("Ellipse") };
|
||||
for (int i = 0; i < shapes.size(); i++)
|
||||
editor->addItem(shapes.at(i), QVariant::fromValue(i));
|
||||
|
||||
@@ -1141,6 +1123,9 @@ QTreeWidgetItem *lcQPropertiesTree::addProperty(QTreeWidgetItem *parent, const Q
|
||||
newItem->setIcon(0, m_expandIcon);
|
||||
}
|
||||
|
||||
if (propertyType == PropertyStringLightReadOnly || propertyType == PropertyFloatReadOnly)
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -1450,7 +1435,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
QString FactorALabel = QLatin1String("FactorA");
|
||||
QString Type = QLatin1String("Undefined");
|
||||
QString Format, Shape, SpotSizeToolTip, ExponentToolTip, FactorAToolTip, FactorBToolTip;
|
||||
lcLightType LightIndex = LC_UNDEFINED_LIGHT;
|
||||
lcLightType LightType = lcLightType::Point;
|
||||
lcLightShape ShapeIndex = LC_LIGHT_SHAPE_UNDEFINED;
|
||||
int FormatIndex = 0;
|
||||
float SpotSize = 0.0f;
|
||||
@@ -1484,17 +1469,46 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
Target = Light->mTargetPosition;
|
||||
Color = Light->mLightColor;
|
||||
Factor = Light->mLightFactor;
|
||||
LightIndex = static_cast<lcLightType>(Light->mLightType);
|
||||
LightType = Light->GetLightType();
|
||||
|
||||
switch(LightIndex)
|
||||
switch(LightType)
|
||||
{
|
||||
case LC_POINTLIGHT:
|
||||
Type = QLatin1String("Point");
|
||||
case lcLightType::Point:
|
||||
Type = tr("Point");
|
||||
FactorALabel = tr("Radius (m)");
|
||||
FactorAToolTip = tr("The light size for shadow sampling in metres.");
|
||||
ExponentLabel = tr("Exponent");
|
||||
break;
|
||||
case LC_AREALIGHT:
|
||||
Type = QLatin1String("Area");
|
||||
case lcLightType::Spot:
|
||||
Type = tr("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.");
|
||||
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:
|
||||
Type = tr("Sun");
|
||||
FactorALabel = tr("Angle (°)");
|
||||
FactorAToolTip = tr("Angular diamater of the sun as seen from the Earth.");
|
||||
ExponentLabel = tr("Strength");
|
||||
break;
|
||||
case lcLightType::Area:
|
||||
Type = tr("Area");
|
||||
ExponentLabel = tr("Power");
|
||||
|
||||
if (POVRayLight)
|
||||
{
|
||||
Factor = Light->mAreaSize;
|
||||
@@ -1509,34 +1523,12 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
FactorBToolTip = tr("The height (Y direction) of the area light in units.");
|
||||
}
|
||||
break;
|
||||
case LC_SUNLIGHT:
|
||||
Type = QLatin1String("Sun");
|
||||
FactorALabel = tr("Angle (°)");
|
||||
FactorAToolTip = tr("Angular diamater of the sun as seen from the Earth.");
|
||||
break;
|
||||
case LC_SPOTLIGHT:
|
||||
Type = QLatin1String("Spot");
|
||||
FactorBToolTip = tr("The softness of the spotlight edge.");
|
||||
if (POVRayLight)
|
||||
{
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShapeIndex = static_cast<lcLightShape>(Light->mLightShape);
|
||||
ShapeIndex = static_cast<lcLightShape>(Light->GetLightType());
|
||||
|
||||
switch(ShapeIndex)
|
||||
{
|
||||
case LC_LIGHT_SHAPE_SQUARE:
|
||||
@@ -1557,6 +1549,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
|
||||
Diffuse = Light->mLightDiffuse;
|
||||
Specular = Light->mLightSpecular;
|
||||
|
||||
if (POVRayLight)
|
||||
{
|
||||
Exponent = Light->mPOVRayExponent;
|
||||
@@ -1567,66 +1560,61 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
Exponent = Light->mSpotExponent;
|
||||
ExponentToolTip = tr("Intensity of the light in watts.");
|
||||
}
|
||||
ExponentLabel = LightIndex == LC_SUNLIGHT ? tr("Strength") : tr("Power");
|
||||
|
||||
ExponentLabel = LightType == lcLightType::Directional ? tr("Strength") : tr("Power");
|
||||
Cutoff = Light->mSpotCutoff;
|
||||
EnableCutoff = Light->mEnableCutoff;
|
||||
TargetProperty = Light->mLightType > LC_POINTLIGHT ? PropertyFloat : PropertyFloatReadOnly;
|
||||
TargetProperty = LightType != lcLightType::Point ? PropertyFloat : PropertyFloatReadOnly;
|
||||
SpotSize = Light->mSpotSize;
|
||||
SpotFalloff = Light->mSpotFalloff;
|
||||
SpotTightness = Light->mSpotTightness;
|
||||
AreaGrid = Light->mAreaGrid;
|
||||
}
|
||||
|
||||
if (mWidgetMode != LC_PROPERTY_WIDGET_LIGHT || mLightType != LightIndex || mLightShape != ShapeIndex || mPOVRayLight != POVRayLight)
|
||||
if (mWidgetMode != LC_PROPERTY_WIDGET_LIGHT || mLightType != LightType || mLightShape != ShapeIndex || mPOVRayLight != POVRayLight)
|
||||
{
|
||||
SetEmpty();
|
||||
|
||||
// Configuration
|
||||
lightConfiguration = addProperty(nullptr, tr("Configuration"), PropertyGroup);
|
||||
lightFormat = addProperty(lightConfiguration, tr("Format"), PropertyLightFormat);
|
||||
|
||||
// Position
|
||||
lightPosition = addProperty(nullptr, tr("Position"), PropertyGroup);
|
||||
lightPositionX = addProperty(lightPosition, tr("X"), PropertyFloat);
|
||||
lightPositionY = addProperty(lightPosition, tr("Y"), PropertyFloat);
|
||||
lightPositionZ = addProperty(lightPosition, tr("Z"), PropertyFloat);
|
||||
|
||||
// Target Position
|
||||
if (LightIndex != LC_POINTLIGHT && !(LightIndex == LC_AREALIGHT && POVRayLight))
|
||||
if (LightType != lcLightType::Point && !(LightType == lcLightType::Area && POVRayLight))
|
||||
{
|
||||
lightTarget = addProperty(nullptr, tr("Target"), PropertyGroup);
|
||||
lightTargetX = addProperty(lightTarget, tr("X"), TargetProperty);
|
||||
lightTargetY = addProperty(lightTarget, tr("Y"), TargetProperty);
|
||||
lightTargetZ = addProperty(lightTarget, tr("Z"), TargetProperty);
|
||||
}
|
||||
|
||||
// Light Colour
|
||||
lightColor = addProperty(nullptr, tr("Color"), PropertyGroup);
|
||||
lightColorIcon = addProperty(lightColor, tr("Name"), PropertyLightColor);
|
||||
lightColorR = addProperty(lightColor, tr("Red"), PropertyFloat);
|
||||
lightColorG = addProperty(lightColor, tr("Green"), PropertyFloat);
|
||||
lightColorB = addProperty(lightColor, tr("Blue"), PropertyFloat);
|
||||
|
||||
// Properties
|
||||
lightProperties = addProperty(nullptr, tr("Properties"), PropertyGroup);
|
||||
lightType = addProperty(lightProperties, tr("Type"), PropertyStringLightReadOnly);
|
||||
lightShadowless = addProperty(lightProperties, tr("Shadowless"), PropertyBool);
|
||||
lightExponent = addProperty(lightProperties, ExponentLabel, PropertyFloat);
|
||||
if ((LightIndex == LC_POINTLIGHT || LightIndex == LC_SUNLIGHT) && !POVRayLight)
|
||||
|
||||
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
||||
lightFactorA = addProperty(lightProperties, FactorALabel, PropertyFloat);
|
||||
if (LightIndex == LC_AREALIGHT)
|
||||
{
|
||||
lightShape = addProperty(lightProperties, tr("Shape"), PropertyLightShape);
|
||||
lightFactorA = addProperty(lightProperties, FactorALabel, PropertyFloat);
|
||||
if (ShapeIndex == LC_LIGHT_SHAPE_RECTANGLE || ShapeIndex == LC_LIGHT_SHAPE_ELLIPSE || POVRayLight)
|
||||
lightFactorB = addProperty(lightProperties, tr("Height (Y)"), PropertyFloat);
|
||||
else
|
||||
FactorAToolTip = tr("The size of the area light grid in metres.");
|
||||
if (POVRayLight)
|
||||
{
|
||||
lightAreaGridRows = addProperty(lightProperties, tr("Grid Rows"), PropertyFloat);
|
||||
lightAreaGridColumns = addProperty(lightProperties, tr("Grid Columns"), PropertyFloat);
|
||||
}
|
||||
}
|
||||
else if (LightIndex == LC_SPOTLIGHT)
|
||||
|
||||
if (LightType == lcLightType::Spot)
|
||||
{
|
||||
lightSpotSize = addProperty(lightProperties, tr("Spot Size (°)"), SpotSizeProperty);
|
||||
lightFactorA = addProperty(lightProperties, FactorALabel, PropertyFloat);
|
||||
lightFactorA = addProperty(lightProperties, FactorALabel, PropertyFloatLightSpotSize);
|
||||
|
||||
if (!POVRayLight)
|
||||
lightFactorB = addProperty(lightProperties, tr("Spot Blend"), PropertyFloat);
|
||||
else
|
||||
@@ -1635,20 +1623,39 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
lightSpotTightness = addProperty(lightProperties, tr("Spot Tightness"), PropertyFloat);
|
||||
}
|
||||
}
|
||||
else if (LightType == lcLightType::Area)
|
||||
{
|
||||
lightShape = addProperty(lightProperties, tr("Shape"), PropertyLightShape);
|
||||
lightFactorA = addProperty(lightProperties, FactorALabel, PropertyFloat);
|
||||
|
||||
if (ShapeIndex == LC_LIGHT_SHAPE_RECTANGLE || ShapeIndex == LC_LIGHT_SHAPE_ELLIPSE || POVRayLight)
|
||||
lightFactorB = addProperty(lightProperties, tr("Height"), PropertyFloat);
|
||||
else
|
||||
FactorAToolTip = tr("The size of the area light grid in metres.");
|
||||
|
||||
if (POVRayLight)
|
||||
{
|
||||
lightAreaGridRows = addProperty(lightProperties, tr("Grid Rows"), PropertyFloat);
|
||||
lightAreaGridColumns = addProperty(lightProperties, tr("Grid Columns"), PropertyFloat);
|
||||
}
|
||||
}
|
||||
|
||||
if (!POVRayLight)
|
||||
{
|
||||
if (LightIndex != LC_SUNLIGHT)
|
||||
if (LightType != lcLightType::Directional)
|
||||
{
|
||||
lightEnableCutoff = addProperty(lightProperties, tr("Cutoff"), PropertyBool);
|
||||
lightCutoff = addProperty(lightProperties, tr("Cutoff Distance"), PropertyFloat);
|
||||
}
|
||||
|
||||
lightDiffuse = addProperty(lightProperties, tr("Diffuse"), PropertyFloat);
|
||||
lightSpecular = addProperty(lightProperties, tr("Specular"), PropertyFloat);
|
||||
}
|
||||
|
||||
lightName = addProperty(lightProperties, tr("Name"), PropertyString);
|
||||
|
||||
mWidgetMode = LC_PROPERTY_WIDGET_LIGHT;
|
||||
mLightType = LightIndex;
|
||||
mLightType = LightType;
|
||||
mLightShape = ShapeIndex;
|
||||
mPOVRayLight = POVRayLight;
|
||||
}
|
||||
@@ -1662,7 +1669,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
lightPositionZ->setText(1, lcFormatValueLocalized(Position[2]));
|
||||
lightPositionZ->setData(0, PropertyValueRole, Position[2]);
|
||||
|
||||
if (LightIndex != LC_POINTLIGHT && !(LightIndex == LC_AREALIGHT && POVRayLight))
|
||||
if (LightType != lcLightType::Point && !(LightType == lcLightType::Area && POVRayLight))
|
||||
{
|
||||
lightTargetX->setText(1, lcFormatValueLocalized(Target[0]));
|
||||
lightTargetX->setData(0, PropertyValueRole, Target[0]);
|
||||
@@ -1711,13 +1718,13 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
lightExponent->setData(0, PropertyValueRole, Exponent);
|
||||
lightExponent->setToolTip(1, ExponentToolTip);
|
||||
|
||||
if ((LightIndex == LC_POINTLIGHT || LightIndex == LC_SUNLIGHT) && !POVRayLight)
|
||||
if ((LightType == lcLightType::Point || LightType == lcLightType::Directional) && !POVRayLight)
|
||||
{
|
||||
lightFactorA->setText(1, lcFormatValueLocalized(Factor[0]));
|
||||
lightFactorA->setData(0, PropertyValueRole, Factor[0]);
|
||||
lightFactorA->setToolTip(1, FactorAToolTip);
|
||||
}
|
||||
else if (LightIndex == LC_AREALIGHT)
|
||||
else if (LightType == lcLightType::Area)
|
||||
{
|
||||
lightShape->setText(1, Shape);
|
||||
lightShape->setData(0, PropertyValueRole, ShapeIndex);
|
||||
@@ -1745,7 +1752,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
lightAreaGridColumns->setToolTip(1, tr("The number of sample columns in the area light."));
|
||||
}
|
||||
}
|
||||
else if (LightIndex == LC_SPOTLIGHT)
|
||||
else if (LightType == lcLightType::Spot)
|
||||
{
|
||||
lightSpotSize->setText(1, lcFormatValueLocalized(SpotSize));
|
||||
lightSpotSize->setData(0, PropertyValueRole, SpotSize);
|
||||
@@ -1775,7 +1782,7 @@ void lcQPropertiesTree::SetLight(lcObject* Focus)
|
||||
|
||||
if (!POVRayLight)
|
||||
{
|
||||
if (LightIndex != LC_SUNLIGHT)
|
||||
if (LightType != lcLightType::Directional)
|
||||
{
|
||||
lightEnableCutoff->setText(1, EnableCutoff ? "True" : "False");
|
||||
lightEnableCutoff->setData(0, PropertyValueRole, EnableCutoff);
|
||||
|
||||
@@ -81,7 +81,7 @@ protected:
|
||||
|
||||
void getPartProperties(lcPartProperties *properties);
|
||||
|
||||
int mLightType;
|
||||
lcLightType mLightType;
|
||||
int mLightShape;
|
||||
bool mPOVRayLight;
|
||||
|
||||
|
||||
@@ -5602,7 +5602,7 @@ Informace o tom, jak stáhnout a nainstalovat knihovnu, naleznete na adrese http
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../common/lc_model.cpp" line="3957"/>
|
||||
<source>New SpotLight</source>
|
||||
<source>New Spotlight</source>
|
||||
<translation>Nový zdroj osvětlení</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -5501,7 +5501,7 @@ Bitte lesen sie unter https://www.leocad.org nach wie man eine Bibliothek herunt
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../common/lc_model.cpp" line="3957"/>
|
||||
<source>New SpotLight</source>
|
||||
<source>New Spotlight</source>
|
||||
<translation>Neues Scheinwerferlicht</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -5577,7 +5577,7 @@ Por favor, visita https://www.leocad.org para saber cómo descargar e instalar u
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../common/lc_model.cpp" line="3957"/>
|
||||
<source>New SpotLight</source>
|
||||
<source>New Spotlight</source>
|
||||
<translation>nuevo foco</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -5485,7 +5485,7 @@ SVP visitez https://www.leocad.org pour apprendre comment télécharger et insta
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../common/lc_model.cpp" line="3957"/>
|
||||
<source>New SpotLight</source>
|
||||
<source>New Spotlight</source>
|
||||
<translation>Nouvelle lumière projecteur</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -5412,7 +5412,7 @@ Veja https://www.leocad.org para saber como descarragar e instalar uma bibliotec
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../common/lc_model.cpp" line="3957"/>
|
||||
<source>New SpotLight</source>
|
||||
<source>New Spotlight</source>
|
||||
<translation>Novo Projector</translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
@@ -5477,7 +5477,7 @@ Please visit https://www.leocad.org for information on how to download and insta
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../common/lc_model.cpp" line="3957"/>
|
||||
<source>New SpotLight</source>
|
||||
<source>New Spotlight</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
||||
Reference in New Issue
Block a user