ToolBox widget cleanup. (#17)

This commit was merged in pull request #17.
This commit is contained in:
2025-03-23 22:28:41 +00:00
parent d827d02a15
commit f40366cb8d
12 changed files with 296 additions and 149 deletions

View File

@@ -222,6 +222,9 @@
</property>
</action>
<action name="actionLoad_Model">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</iconset>
@@ -234,6 +237,9 @@
</property>
</action>
<action name="actionDelete_Object">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</iconset>

View File

@@ -482,21 +482,9 @@ void QtkScene::update()
myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f);
}
// Helper lambda to set the light position used by GLSL shaders on the model.
// TODO: This could be a helper function on the Model class.
auto setLightPosition = [](const std::string & lightName, Model * model) {
if (auto light = Model::getInstance(lightName.c_str()); light) {
QVector3D position = light->getTransform().getTranslation();
model->setUniform("uLight.position", position);
} else {
qDebug() << "[QtkScene] Failed to set light position: "
<< lightName.c_str();
}
};
QMatrix4x4 posMatrix;
if (auto alien = getModel("alienTest"); alien) {
setLightPosition("alienTestLight", alien);
alien->setLightPosition("alienTestLight");
alien->setUniform("uCameraPosition", cameraPosition);
posMatrix = alien->getTransform().toMatrix();
@@ -508,7 +496,7 @@ void QtkScene::update()
}
if (auto spartan = getModel("spartanTest"); spartan) {
setLightPosition("spartanTestLight", spartan);
spartan->setLightPosition("spartanTestLight");
spartan->setUniform("uCameraPosition", cameraPosition);
posMatrix = spartan->getTransform().toMatrix();
@@ -520,7 +508,7 @@ void QtkScene::update()
}
if (auto phong = getModel("testPhong"); phong) {
setLightPosition("testLight", phong);
phong->setLightPosition("testLight");
phong->getTransform().rotate(0.75f, 1.0f, 0.5f, 0.0f);
phong->bindShaders();