summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--.qmake.conf2
-rw-r--r--doc/qt3dstudio-project.qdocconf10
-rw-r--r--doc/src/00-concepts.qdoc2
-rw-r--r--doc/src/03-studio/0-menu.qdoc22
-rw-r--r--doc/src/03-studio/1-toolbar.qdoc7
-rw-r--r--doc/src/03-studio/4-basic-objects-palette.qdoc19
-rw-r--r--doc/src/03-studio/5-timeline-palette.qdoc20
-rw-r--r--doc/src/03-studio/7-inspector-palette.qdoc68
-rw-r--r--doc/src/03-studio/8-action-palette.qdoc31
-rw-r--r--doc/src/03-studio/9-keyboard-shortcuts.qdoc20
-rw-r--r--doc/src/04-viewer/0-menu.qdoc62
-rw-r--r--doc/src/04-viewer/1-keyboard.qdoc49
-rw-r--r--doc/src/04-viewer/2-commandline.qdoc90
-rw-r--r--doc/src/04-viewer/3-remote-deployment.qdoc20
-rw-r--r--doc/src/07-file-formats/0-uia.qdoc2
-rw-r--r--doc/src/07-file-formats/5-custom-material-reference.qdoc30
-rw-r--r--doc/src/07-file-formats/6-effect-reference.qdoc21
-rw-r--r--doc/src/07-file-formats/custom-materials-effects.qdoc116
-rw-r--r--doc/src/10-best-practices/100-elementvisibilities.qdoc124
-rw-r--r--doc/src/10-best-practices/30-using-sub-presentations.qdoc4
-rw-r--r--doc/src/10-best-practices/60-importing-3d-content.qdoc4
-rw-r--r--doc/src/10-best-practices/80-effects.qdoc107
-rw-r--r--doc/src/10-best-practices/95-data-input.qdoc11
-rw-r--r--doc/src/10-best-practices/additive-gradient.qdoc63
-rw-r--r--doc/src/10-best-practices/brush-strokes.qdoc65
-rw-r--r--doc/src/10-best-practices/chromatic-aberration.qdoc77
-rw-r--r--doc/src/10-best-practices/corona.qdoc106
-rw-r--r--doc/src/10-best-practices/depth-of-field-effect.qdoc84
-rw-r--r--doc/src/10-best-practices/desaturate.qdoc52
-rw-r--r--doc/src/10-best-practices/distortion-ripple.qdoc72
-rw-r--r--doc/src/10-best-practices/distortion-sphere.qdoc62
-rw-r--r--doc/src/10-best-practices/distortion-spiral.qdoc61
-rw-r--r--doc/src/10-best-practices/edge-detect.qdoc53
-rw-r--r--doc/src/10-best-practices/emboss-effect.qdoc51
-rw-r--r--doc/src/10-best-practices/exporting-from-3dsmax.qdoc (renamed from doc/Src/10-best-practices/exporting-from-3dsmax.qdoc)0
-rw-r--r--doc/src/10-best-practices/exporting-from-blender.qdoc (renamed from doc/Src/10-best-practices/exporting-from-blender.qdoc)41
-rw-r--r--doc/src/10-best-practices/exporting-from-maya.qdoc (renamed from doc/Src/10-best-practices/exporting-from-maya.qdoc)0
-rw-r--r--doc/src/10-best-practices/exporting-from-modo.qdoc (renamed from doc/Src/10-best-practices/exporting-from-modo.qdoc)0
-rw-r--r--doc/src/10-best-practices/frame-flipper.qdoc60
-rw-r--r--doc/src/10-best-practices/fullscreen-texture-overlay.qdoc57
-rw-r--r--doc/src/10-best-practices/fxaa-effect.qdoc43
-rw-r--r--doc/src/10-best-practices/gaussian-blur-effect.qdoc28
-rw-r--r--doc/src/10-best-practices/hdr-bloom-tonemap-effect.qdoc83
-rw-r--r--doc/src/10-best-practices/motion-blur-effect.qdoc38
-rw-r--r--doc/src/10-best-practices/practices-index.qdoc2
-rw-r--r--doc/src/10-best-practices/screen-space-ao.qdoc96
-rw-r--r--doc/src/10-best-practices/sepia.qdoc51
-rw-r--r--doc/src/10-best-practices/smaa1x.qdoc41
-rw-r--r--doc/src/10-best-practices/stylize-scatter.qdoc66
-rw-r--r--doc/src/10-best-practices/tilt-shift-effect.qdoc69
-rw-r--r--doc/src/10-best-practices/vignette.qdoc56
-rw-r--r--doc/src/11-quick-start-guides/quick-start-guide.qdoc9
-rw-r--r--doc/src/animations.qdoc58
-rw-r--r--doc/src/bloom.qdoc56
-rw-r--r--doc/src/blur.qdoc55
-rw-r--r--doc/src/color-master.qdoc68
-rw-r--r--doc/src/comparison.qdoc5
-rw-r--r--doc/src/glossary.qdoc153
-rw-r--r--doc/src/images/ApplicationPreferences.pngbin36068 -> 24617 bytes
-rw-r--r--doc/src/images/Effects-DOF-Debug.pngbin1864 -> 7578 bytes
-rw-r--r--doc/src/images/Effects-TiltShift-Debug.pngbin881 -> 6867 bytes
-rw-r--r--doc/src/images/Studio-Basic-Signal.pngbin0 -> 9918 bytes
-rw-r--r--doc/src/images/Studio-SceneView.pngbin207201 -> 209545 bytes
-rw-r--r--doc/src/images/Studio-Timeline-Animation.pngbin3473 -> 3829 bytes
-rw-r--r--doc/src/images/Studio-Timeline-SceneGraph.pngbin22222 -> 9931 bytes
-rw-r--r--doc/src/images/Studio-Timeline-SignalAction.pngbin0 -> 8576 bytes
-rw-r--r--doc/src/images/Studio-Toolbar-EditCameras.pngbin2339 -> 2196 bytes
-rw-r--r--doc/src/images/addAssets.pngbin227735 -> 229395 bytes
-rw-r--r--doc/src/images/additive-gradient-icon.pngbin0 -> 20954 bytes
-rw-r--r--doc/src/images/bezier-curves.pngbin0 -> 25973 bytes
-rw-r--r--doc/src/images/blender-fbx-export-axis.pngbin0 -> 11484 bytes
-rw-r--r--doc/src/images/bloom-icon.pngbin0 -> 28441 bytes
-rw-r--r--doc/src/images/blur-icon.pngbin0 -> 6418 bytes
-rw-r--r--doc/src/images/brush-strokes-icon.pngbin0 -> 8695 bytes
-rw-r--r--doc/src/images/chromatic-aberration-icon.pngbin0 -> 22883 bytes
-rw-r--r--doc/src/images/color-master-icon.pngbin0 -> 12118 bytes
-rw-r--r--doc/src/images/corona-icon.pngbin0 -> 11732 bytes
-rw-r--r--doc/src/images/datainput-meta.pngbin10035 -> 9515 bytes
-rw-r--r--doc/src/images/desaturate-icon.pngbin0 -> 7649 bytes
-rw-r--r--doc/src/images/distortion-ripple-icon.pngbin0 -> 24266 bytes
-rw-r--r--doc/src/images/distortion-sphere-icon.pngbin0 -> 20246 bytes
-rw-r--r--doc/src/images/distortion-spiral-icon.pngbin0 -> 22972 bytes
-rw-r--r--doc/src/images/edge-detect-icon.pngbin0 -> 21559 bytes
-rw-r--r--doc/src/images/editListGroupObjects.pngbin0 -> 4209 bytes
-rw-r--r--doc/src/images/effects-additive-gradient.pngbin0 -> 86634 bytes
-rw-r--r--doc/src/images/effects-bloom.pngbin0 -> 148440 bytes
-rw-r--r--doc/src/images/effects-blur.pngbin0 -> 21347 bytes
-rw-r--r--doc/src/images/effects-brush-strokes.pngbin0 -> 54544 bytes
-rw-r--r--doc/src/images/effects-chromatic-aberration.pngbin0 -> 121248 bytes
-rw-r--r--doc/src/images/effects-color-master.pngbin0 -> 42781 bytes
-rw-r--r--doc/src/images/effects-corona.pngbin0 -> 51977 bytes
-rw-r--r--doc/src/images/effects-desaturate.pngbin0 -> 23840 bytes
-rw-r--r--doc/src/images/effects-distortion-ripple.pngbin0 -> 109250 bytes
-rw-r--r--doc/src/images/effects-distortion-sphere.pngbin0 -> 115758 bytes
-rw-r--r--doc/src/images/effects-distortion-spiral.pngbin0 -> 98758 bytes
-rw-r--r--doc/src/images/effects-edge-detect.pngbin0 -> 93597 bytes
-rw-r--r--doc/src/images/effects-emboss.pngbin0 -> 61625 bytes
-rw-r--r--doc/src/images/effects-frame-flipper.pngbin0 -> 107745 bytes
-rw-r--r--doc/src/images/effects-fullscreen-texture-overlay.pngbin0 -> 57512 bytes
-rw-r--r--doc/src/images/effects-screen-space-ao.pngbin0 -> 80226 bytes
-rw-r--r--doc/src/images/effects-sepia.pngbin0 -> 46435 bytes
-rw-r--r--doc/src/images/effects-smaa1x.pngbin0 -> 39146 bytes
-rw-r--r--doc/src/images/effects-stylize-scatter.pngbin0 -> 52224 bytes
-rw-r--r--doc/src/images/effects-vignette.pngbin0 -> 59815 bytes
-rw-r--r--doc/src/images/emboss-icon.pngbin0 -> 8506 bytes
-rw-r--r--doc/src/images/frame-flipper-icon.pngbin0 -> 6009 bytes
-rw-r--r--doc/src/images/fullscreen-texture-overlay-icon.pngbin0 -> 12349 bytes
-rw-r--r--doc/src/images/materials-category-dummy.pngbin0 -> 16852 bytes
-rw-r--r--doc/src/images/materials-category-several.pngbin0 -> 20414 bytes
-rw-r--r--doc/src/images/new-data-input.pngbin8381 -> 7749 bytes
-rw-r--r--doc/src/images/object-amination-channels.pngbin0 -> 10930 bytes
-rw-r--r--doc/src/images/object-animated-properties.pngbin0 -> 7221 bytes
-rw-r--r--doc/src/images/object-animation-channels.pngbin0 -> 10930 bytes
-rw-r--r--doc/src/images/screen-space-ao-icon.pngbin0 -> 11068 bytes
-rw-r--r--doc/src/images/select-animation-type.pngbin0 -> 17759 bytes
-rw-r--r--doc/src/images/sepia-icon.pngbin0 -> 7583 bytes
-rw-r--r--doc/src/images/smaa1x-icon.pngbin0 -> 10458 bytes
-rw-r--r--doc/src/images/stylize-scatter-icon.pngbin0 -> 10801 bytes
-rw-r--r--doc/src/images/timeline-datainput.pngbin22729 -> 10463 bytes
-rw-r--r--doc/src/images/variant-tags-panel.pngbin8736 -> 9733 bytes
-rw-r--r--doc/src/images/vignette-icon.pngbin0 -> 11702 bytes
-rw-r--r--doc/src/layers.qdoc11
-rw-r--r--doc/src/materials-shaders.qdoc4
-rw-r--r--doc/src/whatsnew.qdoc64
-rw-r--r--doc/style/qt5-sidebar.html19
-rw-r--r--product_dependencies.yaml3
-rw-r--r--qt3dstudio.pro38
m---------src/3rdparty/ColladaDOM0
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp2
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdDataModelChangeKeyframe.h31
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h48
-rw-r--r--src/Authoring/Client/Code/Core/Core/Core.cpp13
-rw-r--r--src/Authoring/Client/Code/Core/Core/Dispatch.cpp11
-rw-r--r--src/Authoring/Client/Code/Core/Core/Dispatch.h9
-rw-r--r--src/Authoring/Client/Code/Core/Core/DispatchListeners.h5
-rw-r--r--src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp299
-rw-r--r--src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h53
-rw-r--r--src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp44
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp188
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.h17
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp22
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp709
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp450
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h14
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDocSceneGraph.h2
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDocumentBufferCache.h4
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h13
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IDocumentReader.h15
-rw-r--r--src/Authoring/Client/Code/Core/Doc/IKeyframesManager.h9
-rw-r--r--src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp13
-rw-r--r--src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h4
-rw-r--r--src/Authoring/Client/Code/Core/Types/Rotation3.h2
-rw-r--r--src/Authoring/Client/Code/Core/Utility/HotKeys.cpp10
-rw-r--r--src/Authoring/Client/Code/Core/Utility/HotKeys.h2
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp13
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h1
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp869
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioPreferences.h240
-rw-r--r--src/Authoring/Client/Code/Core/Utility/cpuid.cpp2
-rw-r--r--src/Authoring/Client/Code/Shared/CommonConstants.h156
-rw-r--r--src/Authoring/Common/Code/Preferences.h69
-rw-r--r--src/Authoring/Common/Code/Qt3DSCommonPrecompile.h1
-rw-r--r--src/Authoring/Common/Code/Qt3DSMessageBox.cpp32
-rw-r--r--src/Authoring/Common/Code/Qt3DSMessageBox.h7
-rw-r--r--src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h7
-rw-r--r--src/Authoring/Common/Code/_Win32/Preferences.cpp203
-rw-r--r--src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp2
-rw-r--r--src/Authoring/Common/Common.pro12
-rw-r--r--src/Authoring/CoreLib/CoreLib.pro16
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp136
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h7
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp4
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h6
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp12
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp111
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportFbxSGTranslation.cpp567
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp25
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.h1
-rw-r--r--src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h37
-rw-r--r--src/Authoring/Qt3DStudio/Application/AboutDlg.cpp10
-rw-r--r--src/Authoring/Qt3DStudio/Application/DataInputDlg.cpp29
-rw-r--r--src/Authoring/Qt3DStudio/Application/DataInputDlg.h6
-rw-r--r--src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp51
-rw-r--r--src/Authoring/Qt3DStudio/Application/DataInputListDlg.h4
-rw-r--r--src/Authoring/Qt3DStudio/Application/DataInputSelectView.cpp10
-rw-r--r--src/Authoring/Qt3DStudio/Application/DurationEditDlg.cpp26
-rw-r--r--src/Authoring/Qt3DStudio/Application/PresentationFile.cpp150
-rw-r--r--src/Authoring/Qt3DStudio/Application/PresentationFile.h14
-rw-r--r--src/Authoring/Qt3DStudio/Application/ProjectFile.cpp31
-rw-r--r--src/Authoring/Qt3DStudio/Application/ProjectFile.h9
-rw-r--r--src/Authoring/Qt3DStudio/Application/StudioApp.cpp384
-rw-r--r--src/Authoring/Qt3DStudio/Application/StudioApp.h44
-rw-r--r--src/Authoring/Qt3DStudio/Application/StudioTutorialWidget.cpp7
-rw-r--r--src/Authoring/Qt3DStudio/Controls/AppFonts.cpp2
-rw-r--r--src/Authoring/Qt3DStudio/DragAndDrop/BasicObjectDropSource.cpp19
-rw-r--r--src/Authoring/Qt3DStudio/Info.plist146
-rw-r--r--src/Authoring/Qt3DStudio/MainFrm.cpp272
-rw-r--r--src/Authoring/Qt3DStudio/MainFrm.h14
-rw-r--r--src/Authoring/Qt3DStudio/MainFrm.ui77
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/ActionView.cpp46
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/ActionView.h9
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml5
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericFloat.qml4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml39
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXY.qml6
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZ.qml9
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml137
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZ.qml4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml (renamed from src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.h)67
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/BasicObjects/BasicObjectsModel.cpp1
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/DataInputChooser.qml2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml16
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.cpp1
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.h7
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp481
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h61
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp90
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h14
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml108
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.cpp39
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp46
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.h3
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp8
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.h3
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/TextureChooserView.cpp16
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/VariantsGroupModel.cpp2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/PaletteManager.cpp25
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/PaletteManager.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.cpp6
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp185
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h15
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.cpp112
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.h8
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.qml37
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.cpp4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.qml3
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItem.h10
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItemProperty.h16
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp33
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h8
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp66
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h58
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp1
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp35
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp123
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h23
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.cpp82
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.h31
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp8
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/Keyframe.h4
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp135
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.h15
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.cpp29
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowTypes.h21
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineConstants.h10
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp240
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h20
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.cpp58
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/NavigationBarItem.cpp6
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp17
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.h3
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp275
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h10
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.cpp115
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp537
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h49
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp497
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h25
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp58
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp (renamed from src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp)55
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h (renamed from src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h)12
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.cpp197
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.h8
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.cpp2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h20
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp59
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeader.cpp10
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp15
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/controls/FloatTextField.qml9
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml4
-rw-r--r--src/Authoring/Qt3DStudio/PreviewHelper.cpp23
-rw-r--r--src/Authoring/Qt3DStudio/Qt3DStudio.pro44
-rw-r--r--src/Authoring/Qt3DStudio/Render/IStudioRenderer.h2
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.cpp205
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.h78
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp104
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp531
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h68
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioRotationWidget.cpp8
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioScaleWidget.cpp10
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioSubPresentationRenderer.cpp9
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioTranslationWidget.cpp122
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioVisualAidWidget.cpp12
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioWidget.h3
-rw-r--r--src/Authoring/Qt3DStudio/Render/StudioWidgetImpl.h18
-rw-r--r--src/Authoring/Qt3DStudio/UI/EditCameraBar.cpp9
-rw-r--r--src/Authoring/Qt3DStudio/UI/InterpolationDlg.cpp25
-rw-r--r--src/Authoring/Qt3DStudio/UI/InterpolationDlg.h23
-rw-r--r--src/Authoring/Qt3DStudio/UI/InterpolationDlg.ui621
-rw-r--r--src/Authoring/Qt3DStudio/UI/RecentItems.cpp14
-rw-r--r--src/Authoring/Qt3DStudio/UI/RecentItems.h4
-rw-r--r--src/Authoring/Qt3DStudio/UI/SceneView.cpp9
-rw-r--r--src/Authoring/Qt3DStudio/UI/StartupDlg.cpp2
-rw-r--r--src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.cpp77
-rw-r--r--src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.h1
-rw-r--r--src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.ui257
-rw-r--r--src/Authoring/Qt3DStudio/UI/StudioPreferencesPropSheet.cpp2
-rw-r--r--src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.cpp14
-rw-r--r--src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.ui10
-rw-r--r--src/Authoring/Qt3DStudio/Workspace/Dialogs.cpp60
-rw-r--r--src/Authoring/Qt3DStudio/Workspace/Dialogs.h3
-rw-r--r--src/Authoring/Qt3DStudio/images.qrc18
-rw-r--r--src/Authoring/Qt3DStudio/images/Asset-Signal-Normal.pngbin0 -> 424 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/Asset-Signal-Normal@2x.pngbin0 -> 915 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled.pngbin0 -> 1562 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled@2x.pngbin0 -> 1829 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/Objects-Signal-Normal.pngbin0 -> 2099 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/Objects-Signal-Normal@2x.pngbin0 -> 2466 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/gradient.pngbin0 -> 1103 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/gradient@2x.pngbin0 -> 1470 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/gradient_disabled.pngbin0 -> 1101 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/gradient_disabled@2x.pngbin0 -> 1334 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/helper_grid.pngbin0 -> 119 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/helper_grid@2x.pngbin0 -> 175 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/helper_grid_disabled.pngbin0 -> 119 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/helper_grid_disabled@2x.pngbin0 -> 176 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/maximize.pngbin0 -> 1070 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/maximize@2x.pngbin0 -> 1163 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/maximize_disabled.pngbin0 -> 1066 bytes
-rw-r--r--src/Authoring/Qt3DStudio/images/maximize_disabled@2x.pngbin0 -> 1141 bytes
-rw-r--r--src/Authoring/Qt3DStudio/qml.qrc2
-rw-r--r--src/Authoring/Qt3DStudio/remotedeploymentsender.cpp13
-rw-r--r--src/Runtime/Runtime.pro20
m---------src/Runtime/ogl-runtime0
m---------src/Runtime/qt3d-runtime0
-rw-r--r--src/commonplatform.pri10
-rw-r--r--src/shared/shared.pro4
-rw-r--r--src/src.pro2
-rw-r--r--tests/auto/auto.pro10
-rw-r--r--tests/auto/qtextras/qt3dsqmlstream/qt3dsqmlstream.pro18
-rw-r--r--tests/auto/qtextras/qt3dsqmlstream/tst_qt3dsqmlstream.cpp106
-rw-r--r--tests/auto/qtextras/qtextras.pro4
-rw-r--r--tests/auto/runtime/Qt3DSRenderTestBase.cpp101
-rw-r--r--tests/auto/runtime/Qt3DSRenderTestBase.h164
-rw-r--r--tests/auto/runtime/Qt3DSRenderTestMathUtil.cpp118
-rw-r--r--tests/auto/runtime/Qt3DSRenderTestMathUtil.h50
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.cpp248
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.h59
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.cpp251
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.h59
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.cpp332
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.h62
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestClear.cpp131
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestClear.h56
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.cpp847
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.h63
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.cpp358
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.h60
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestPrimitives.cpp321
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestPrimitives.h77
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.cpp401
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.h60
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestTexture2D.cpp288
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestTexture2D.h67
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.cpp436
-rw-r--r--tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.h64
-rw-r--r--tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.cpp636
-rw-r--r--tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.h61
-rw-r--r--tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.cpp299
-rw-r--r--tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.h67
-rw-r--r--tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.cpp390
-rw-r--r--tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.h60
-rw-r--r--tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.cpp367
-rw-r--r--tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.h66
-rw-r--r--tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.cpp560
-rw-r--r--tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.h60
-rw-r--r--tests/auto/runtime/images/NVRenderTestAttribBuffers.pngbin3820 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestBackendQuery.pngbin2355 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestClear.pngbin2327 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestComputeShader.pngbin3889 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestDrawIndirectBuffer.pngbin2355 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestFboMsaa.pngbin3168 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestGeometryShader.pngbin3311 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestOcclusionQuery.pngbin2355 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestProgramPipeline.pngbin3224 -> 0 bytes
-rw-r--r--tests/auto/runtime/images/NVRenderTestTexture2D.pngbin2991 -> 0 bytes
-rw-r--r--tests/auto/runtime/runtime.pro83
-rw-r--r--tests/auto/runtime/runtime.qrc14
-rw-r--r--tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.cpp469
-rw-r--r--tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.h55
-rw-r--r--tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.cpp574
-rw-r--r--tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.h56
-rw-r--r--tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.cpp155
-rw-r--r--tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.h55
-rw-r--r--tests/auto/runtime/tst_qt3dsruntime.cpp727
-rw-r--r--tests/auto/runtime/tst_qt3dsruntime.h144
-rw-r--r--tests/auto/studio3d/q3dssurfaceviewer/q3dssurfaceviewer.pro10
-rw-r--r--tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp1516
-rw-r--r--tests/auto/studio3d/shared/presentation/animation.uip35
-rw-r--r--tests/auto/studio3d/shared/presentation/blue.uip31
-rw-r--r--tests/auto/studio3d/shared/presentation/datainput.uia18
-rw-r--r--tests/auto/studio3d/shared/presentation/datainput.uip63
-rw-r--r--tests/auto/studio3d/shared/presentation/datainput_sub.uip31
-rw-r--r--tests/auto/studio3d/shared/presentation/fonts/TitilliumWeb-Regular.ttfbin63752 -> 0 bytes
-rw-r--r--tests/auto/studio3d/shared/presentation/mixed.uip36
-rw-r--r--tests/auto/studio3d/shared/presentation/mixed_vertical.uip36
-rw-r--r--tests/auto/studio3d/shared/presentation/mouse.uip54
-rw-r--r--tests/auto/studio3d/shared/presentation/multislide.uip99
-rw-r--r--tests/auto/studio3d/shared/presentation/red.uip31
-rw-r--r--tests/auto/studio3d/shared/presentation/settings.uip31
-rw-r--r--tests/auto/studio3d/shared/shared_presentations.h39
-rw-r--r--tests/auto/studio3d/shared/shared_presentations.qrc15
-rw-r--r--tests/auto/studio3d/studio3d.pro4
-rw-r--r--tests/auto/viewer/tst_qt3dsviewer.cpp762
-rw-r--r--tests/auto/viewer/tst_qt3dsviewer.h80
-rw-r--r--tests/auto/viewer/tst_qt3dsviewer.qml62
-rw-r--r--tests/auto/viewer/viewer.pro21
-rw-r--r--tests/auto/viewer/viewer.qrc16
-rw-r--r--tests/scenes/customvertex/customvertex.uia15
-rw-r--r--tests/scenes/customvertex/materials/simple.shader29
-rw-r--r--tests/scenes/customvertex/presentations/customvertex.uip33
-rw-r--r--tests/scenes/simple_cube_animation/maps/QT-symbol.pngbin4541 -> 0 bytes
-rw-r--r--tests/scenes/simple_cube_animation/maps/materials/shadow.pngbin334 -> 0 bytes
-rw-r--r--tests/scenes/simple_cube_animation/maps/materials/spherical_checker.pngbin11066 -> 0 bytes
-rw-r--r--tests/scenes/simple_cube_animation/materials/Basic Blue.materialdef25
-rw-r--r--tests/scenes/simple_cube_animation/materials/Basic Green.materialdef25
-rw-r--r--tests/scenes/simple_cube_animation/materials/Basic Red.materialdef25
-rw-r--r--tests/scenes/simple_cube_animation/materials/Basic Texture.materialdef63
-rw-r--r--tests/scenes/simple_cube_animation/materials/Copper.materialdef14
-rw-r--r--tests/scenes/simple_cube_animation/materials/copper.shader178
-rw-r--r--tests/scenes/simple_cube_animation/presentations/simple_cube_animation.uip62
-rw-r--r--tests/scenes/simple_cube_animation/simple_cube_animation.uia16
-rw-r--r--tests/tests.pro3
444 files changed, 10534 insertions, 18436 deletions
diff --git a/.gitmodules b/.gitmodules
index 3d43dde3..aad74655 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,9 +4,6 @@
[submodule "src/3rdparty/pcre"]
path = src/3rdparty/pcre
url = ../qt3dstudio-pcre.git
-[submodule "src/Runtime/qt3d-runtime"]
- path = src/Runtime/qt3d-runtime
- url = ../qt3d-runtime.git
[submodule "src/Runtime/ogl-runtime"]
path = src/Runtime/ogl-runtime
url = ../ogl-runtime
diff --git a/.qmake.conf b/.qmake.conf
index daeeb9f2..b89275b0 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,5 +1,5 @@
load(qt_build_config)
-MODULE_VERSION = 2.5.0
+MODULE_VERSION = 2.8.0
CMAKE_MODULE_TESTS=-
diff --git a/doc/qt3dstudio-project.qdocconf b/doc/qt3dstudio-project.qdocconf
index 0f32aae9..d0c896e9 100644
--- a/doc/qt3dstudio-project.qdocconf
+++ b/doc/qt3dstudio-project.qdocconf
@@ -5,15 +5,17 @@ url = https://doc.qt.io/qt3dstudio
moduleheader =
sources.fileextensions = "*.qdoc *.html"
-sourcedirs = . \
- ../src/Viewer
+sourcedirs = src/ \
+ ../src/Runtime/ogl-runtime/src/viewer
-headerdirs = ../src/Viewer
+headerdirs = src/ \
+ ../src/Runtime/ogl-runtime/src/viewer
# TODO: Move images to doc/images
imagedirs = ./src/images
-depends = qtcore qtgui qtwidgets qtqml qtquick qtmultimedia qtdoc qt3dstudioruntime2
+depends = qtcore qtgui qtwidgets qtqml qtquick qtmultimedia qtdoc
+
qhp.projects = Qt3DStudio
diff --git a/doc/src/00-concepts.qdoc b/doc/src/00-concepts.qdoc
index 61f1d1f4..88d02d74 100644
--- a/doc/src/00-concepts.qdoc
+++ b/doc/src/00-concepts.qdoc
@@ -34,6 +34,8 @@
Qt 3D Studio is a compositing tool where you import 3D models, images and other assets to create
interactive presentations, UIs and applications.
+See \l{What's New}{what's new} in Qt 3D Studio.
+
\table
\row
\li
diff --git a/doc/src/03-studio/0-menu.qdoc b/doc/src/03-studio/0-menu.qdoc
index 7ff48cd9..fecaff8b 100644
--- a/doc/src/03-studio/0-menu.qdoc
+++ b/doc/src/03-studio/0-menu.qdoc
@@ -62,6 +62,9 @@
way to re-open a presentation that may have changed on disk, for
example via hand editing or source control updating.
\li
+ \uicontrol{Close Project} - Closes the current project, resets the user interface, and
+ shows the startup dialog window.
+\li
\uicontrol{Save Presentation} - Saves changes to the open presentation.
\li
\uicontrol{Save Project As} - Saves the open project and all its assets to a new location.
@@ -70,6 +73,9 @@
\li
\uicontrol{Data Inputs} - Manage \l{Using Data Inputs}{data inputs}.
\li
+ \uicontrol{Copy QML Code for Datainputs/Outputs} - Copies data input and data output QML
+ declarations to the clipboard.
+\li
\uicontrol{Exit} - Quits Studio (prompting to save changes).
\endlist
@@ -105,15 +111,11 @@
\list
\li
\uicontrol{Default Interpolation} - Controls whether new animation
- keyframes are created with
- \l{animations.html#interpolation}{linear or smooth interpolation}.
+ keyframes are created with linear or smooth interpolation. This setting applies only to
+ animations of \l{Ease In/Out} type.
\li
\uicontrol{Timeline Snapping Grid} - When using snapping in the
timeline, controls which ticks to snap to.
- \li
- \uicontrol{Legacy Viewer} - Enables the legacy viewer preview button in the toolbar. Legacy
- viewer uses Runtime from Qt 3D Studio 1.1, whereas the default viewer uses Runtime from
- Qt 3D Studio 2.0. Requires a restart.
\endlist
\li
\uicontrol{Editing View}
@@ -121,6 +123,9 @@
\li
\uicontrol{Preferred Startup View} - Sets default camera view
when starting Studio.
+ \li
+ \uicontrol{Helper Grid} - Sets number of lines and space between the lines of the
+ helper grid in edit camera views.
\endlist
\li
\uicontrol{Manipulator Tool Handles} - Sets the size of the manipulator tool handles.
@@ -214,9 +219,6 @@
\li
\uicontrol{Clear Guides} - Deletes all guides in the scene view.
\li
- \uicontrol{Scene Preview} - Toggles visibility of scene preview. Scene preview is a preview of
- the scene camera view available when using any of the edit views.
-\li
\uicontrol{Disable Scene Lighting} - Disable lighting from scene lights in edit views,
\endlist
@@ -240,7 +242,7 @@
press the \c{Delete} key after selecting the keyframes to delete them.
\li
\uicontrol{Set Interpolation} - Changes the in and out
- \l{animations.html#interpolation}{interpolation}
+ \l{Ease In/Out}{interpolation}
setting for the selected keyframes. This command is
also available from the context menu when right-clicking in the
animation portion of the \e{timeline palette}.
diff --git a/doc/src/03-studio/1-toolbar.qdoc b/doc/src/03-studio/1-toolbar.qdoc
index df59f339..8f3e8a5d 100644
--- a/doc/src/03-studio/1-toolbar.qdoc
+++ b/doc/src/03-studio/1-toolbar.qdoc
@@ -221,6 +221,9 @@ palette.
available space in Studio.
\endlist
\li
+ The \b{Helper Grid} toggle (shortcut: \c{Ctrl + Shift + H}) toggles the visibility of the
+ helper grid.
+\li
The \b{Shading Mode} toggle (shortcut: \c{L}) toggles a
`headlamp' attached to your edit camera. When enabled (the default)
items are lit by the edit camera such that they are always easy to
@@ -250,10 +253,6 @@ The preview toolbar buttons are used to preview your presentation.
The \b{Remote Preview} button (keyboard shortcut: \c{F6})will launch the presentation on the
connected remote device Qt 3D Studio Viewer application. This button is only enabled if you are
connected to a remote device.
- \li
- The \b{Preview with Qt 3D Runtime} button
- will launch the Qt 3D Runtime Viewer application and preview the
- application for the presentation.
\endlist
\note If there is no \c{.uia} file in the folder for the presentation, then the
diff --git a/doc/src/03-studio/4-basic-objects-palette.qdoc b/doc/src/03-studio/4-basic-objects-palette.qdoc
index 9da6ff8e..a45bdf67 100644
--- a/doc/src/03-studio/4-basic-objects-palette.qdoc
+++ b/doc/src/03-studio/4-basic-objects-palette.qdoc
@@ -113,6 +113,25 @@ of the following:
This will create a group and move the selected objects into the group.
\endlist
+\section1 Signal
+
+\table
+ \row
+ \li \image Studio-Basic-Signal.png
+\endtable
+
+A signal is a lightweight object specifically designed for triggering actions
+during timeline animations. When signal object is created, it automatically
+adds also initial \c{onActivate} action which gets triggered at the beginning
+of signal timeline. Signals can also contain \c{onDeactivate} actions which
+are triggered at the end of signal timeline. If an object contains these
+actions, its timeline bar contains markers at the beginning (\c{onActivate})
+and/or end (\c{onDeactivate}).
+
+\note Signal time bar length should be long enough (say 100ms) to make sure
+it becomes active even on less performant target hardware. Too short
+time bar might be skipped leading to actions not being triggered.
+
\section1 Text
\table
diff --git a/doc/src/03-studio/5-timeline-palette.qdoc b/doc/src/03-studio/5-timeline-palette.qdoc
index cf0c7739..9597987c 100644
--- a/doc/src/03-studio/5-timeline-palette.qdoc
+++ b/doc/src/03-studio/5-timeline-palette.qdoc
@@ -121,6 +121,13 @@ Elsewhere in the interface, a green item indicates an action on the
master slide, while a light gray item indicates an action specific to
this slide.
+When an object has \c{onActivate} or \c{onDeactivate} timeline actions
+on it, those are indicated with markers at the beginning and at the
+end of the time bar. These actions are usually used with
+\l{studio-basic-objects-palette.html#Signal}{Signal} objects.
+
+\image Studio-Timeline-SignalAction.png
+
\section2 Editing Components
Components are somewhat like mini scenes. A component has its own set of
@@ -281,13 +288,18 @@ coordinates the timing of it all.
\section2 Zooming In and Out
When working with fast animations you may wish to zoom in to see the
-contents better. To zoom the timeline, do one of the following:
+contents better. It is possible to zoom the timeline both horizontally and vertically.
+To zoom the timeline horizontally, do one of the following:
\list
\li Press \c{Alt + mouse right click} and drag the mouse left/right to zoom in/out.
\li Press \c{+} or \c{-} on the keyboard to zoom in/out.
- \li Use the slider locate in the bottom of the timeline palette
+ \li Use the slider located in the bottom of the timeline palette
\endlist
+To zoom the timeline vertically, hold down the Alt key and use the mouse scroll wheel.
+
+\note Vertical zooming only applies to expanded property graphs.
+
\section2 Setting Playhead Time
Drag the playhead by the red knob over the time measure to adjust the
@@ -364,8 +376,8 @@ from the context menu.
To apply a custom text, first do one of the following:
\list
\li
- Right-click anywhere in the timeline palette and select \uicontrol {Show All Time Bar Texts}
- from the context menu.
+ Right-click anywhere in the timeline palette and select
+ \uicontrol {Toggle Timebars Text Visibility} from the context menu.
\li
Click the
\inlineimage timeline-texts-icon.png
diff --git a/doc/src/03-studio/7-inspector-palette.qdoc b/doc/src/03-studio/7-inspector-palette.qdoc
index af2ebf33..45b9f19b 100644
--- a/doc/src/03-studio/7-inspector-palette.qdoc
+++ b/doc/src/03-studio/7-inspector-palette.qdoc
@@ -236,14 +236,34 @@ in the Inspector palette:
presentation and the layer, either in pixels or as a percentage of the
presentation's height.
\li
- \b{Ambient Occlusion} - Controls the strength of ambient
- occlusion (AO). AO is a form of approximated global illumination which
+ \b{Dynamic Resize} - The layer is resized dynamically based on the content.
+ This allows the layer texture to be the smallest possible in order to increase performance.
+ The texture is continuously resized as the content changes.
+\li
+ \b{Padding} - The resized layer can be padded. This lowers the amount of resizes
+ needed as the content changes. The layer is resized only when the content changes
+ so much that it exceeds the previous padded size. Padding is also used in reverse
+ to calculate the lower bounds. When the content changes to be smaller, the resize
+ only happens after it takes less space than the lower bounds. The padding can be
+ expressed in pixels or as percentage of the layer size.
+\li
+ \b{Combine Bounds} - When \c{Dynamic Resize} is in use, the bounds of the objects
+ inside the layer have to be calculated. When this property is disabled, all object
+ bounds are calculated separately and a more accurate layer resize is done based on
+ those separated bounds. When this property is enabled, the object bound calculations
+ are combined, causing more inaccurate but faster results.
+\li
+ \b{Ambient Occlusion} - Enables ambient occlusion (AO).
+ AO is a form of approximated global illumination which
causes non-directional self-shadowing where objects are close
- together. A value of \c{100} causes full darkness shadows; lower
- values cause the shadowing to appear lighter. A value of \c{0}
- disables ambient occlusion entirely, improving performance at a cost
- to the visual realism of 3D objects rendered in the layer. All values
- other than \c{0} have the same impact to the performance.
+ together. Disabling ambient occlusion improves performance
+ at a cost to the visual realism of 3D objects rendered in the layer.
+\li
+ \b{AO Strength} - Controls the strength of the ambient occlusion.
+ A value of \c{100} causes full darkness shadows; lower values cause the
+ shadowing to appear lighter. A value of \c{0} effectively disables ambient
+ occlusion. All values other than \c{0} have the same impact to the performance,
+ when \b{Ambient Occlusion} is toggled on.
\li
\b{AO Distance} - Roughly how far (in world units) ambient
occlusion shadows spread away from objects. The following graphic
@@ -427,7 +447,7 @@ of the camera to be rendered. Aside from special clipping effects, you
may need to adjust these values to more closely contain your content for
better results with Ambient Occlusion, or with a layer effect that uses
the depth buffer of the camera, such as the
-\l{Depth of Field}{Depth of Field effect}.}
+\l{{Depth of field HQ blur}}{Depth of Field effect}.}
\list
\li
@@ -586,6 +606,24 @@ in the Inspector palette (in addition to the
\endomit
\endlist
+\target group-properties
+\section1 Group Properties
+
+A group selected in the Timeline palette shows the usual basic properties, but has one more
+option \e{Ordered}.
+
+\list
+\li
+ \b{Ordered} - This flag changes the order which the objects are being drawn in.
+ Having \e{Ordered} enabled gives you the ability to place objects in your desired draw order
+ under the group, regardless of the object's position in the scene.
+ The last object in the group is drawn first and the first one last,
+ so the objects higher up in the group are drawn on top of the objects below them.
+ This property only affects rendering of transparent object unless the layer
+ \e{\l{best-practices-disable-depth-test.html}{Depth Test}}
+ is disabled.
+\endlist
+
\target material-properties
\section1 Material Properties
@@ -838,9 +876,9 @@ The Inspector palette shows only a single property:
\section1 Image Properties
When image maps (e.g. Diffuse, Specular, Opacity, etc.) are applied to an animated material,
-a new element appears in the scene graph as a child of the material. This element represents
-the properties that control that image, allowing them to be animated over time. Selecting one of
-these images shows the image properties in the Inspector palette.
+custom material or effect, a new element appears in the scene graph as a child of the material.
+This element represents the properties that control that image, allowing them to be animated
+over time. Selecting one of these images shows the image properties in the Inspector palette.
For basic and referenced materials, you need to first select the material in the scene graph. Then,
right-click the map property name in the inspector and select \uicontrol {Open in inspector} from
@@ -880,6 +918,14 @@ the context menu. Now the properties of the image map will show in the inspector
\li
\b{U/V Pivot} - Sets the pivot location in UV space.
\li
+ \b{Minification Filter} - Sets the minification filter for the Image. Setting
+ the filter to \c NearestMipmapNearest, \c LinearMipmapNearest or \c LinearMipmapLinear
+ enables mipmapping. If the source image doesn't have mipmaps they are autogenerated.
+ Enabling mipmapping to image with sub-presentation should be avoided since they need to be
+ generated each time the sub-presentation is updated.
+\li
+ \b{Magnification Filter} - Sets the magnification filter for the Image.
+\li
\b{Sub-Presentation} - If you specify a value here, it is
intepreted to be the \c{id} attribute of another presentation in
\omit
diff --git a/doc/src/03-studio/8-action-palette.qdoc b/doc/src/03-studio/8-action-palette.qdoc
index 501b4264..e381647d 100644
--- a/doc/src/03-studio/8-action-palette.qdoc
+++ b/doc/src/03-studio/8-action-palette.qdoc
@@ -136,35 +136,4 @@ was specified with a Path Reference then the new action will use element
This allows you to quickly
copy and paste actions to multiple elements with a minimum of editing on
each new action.
-
-\omit
-TODO: Not appropriate until we have state machine or somesuch back.
-\section1 When to Use Actions
-
-Generally, actions are appropriate for:
-
-\list
-\li
- Reporting the intention of touch interactions to the state machine
- - \e{"when the user taps on this component, it means that you should
- mute the volume"}.
-\li
- Communicating events raised by presentation behaviors - \e {"you told
- the the list manager to show the next item, but it says that there are
- no more to show"}.
-\li
- Performing trivial view changes that do not affect the state machine
- - \e{"when the user presses down on this button, make it glow a
- little"}
-\endlist
-
-Using actions beyond the above is fine for rough prototyping
-(\e{"when the user taps the `music' button tell the scene to switch
-to to the Music slide"}), but should be evaluated for implementation at
-the application level (\e{"when the user taps the `music' button,
-tell the state machine that they want to see music; separately,
-\b{only if} the state machine tells me that we should be seeing
-music then a visual action will make the scene to go to the Music
-slide"}).
-\endomit
*/
diff --git a/doc/src/03-studio/9-keyboard-shortcuts.qdoc b/doc/src/03-studio/9-keyboard-shortcuts.qdoc
index 29813176..f06a3aab 100644
--- a/doc/src/03-studio/9-keyboard-shortcuts.qdoc
+++ b/doc/src/03-studio/9-keyboard-shortcuts.qdoc
@@ -352,6 +352,10 @@ only in \e{Perspective View} and \e{Orthographic View}.
\li Shading
\li \c{L}
\li \c{L}
+ \row
+ \li Helper grid
+ \li \c{Ctrl + Shift + H}
+ \li \c{Cmd + Shift + H}
\omit
\row
\li Wireframes
@@ -549,9 +553,21 @@ only in \e{Perspective View} and \e{Orthographic View}.
\li \c{Shift + ,}
\li \c{Shift + ,}
\row
- \li Zoom timeline in/out
+ \li Zoom timeline in/out horizontally
\li \c{Alt + right mouse button + right/left mouse drag}
\li \c{Option + right mouse button + right/left mouse drag}
+ \row
+ \li Zoom property graph in/out vertically
+ \li \c{Alt + mouse scroll wheel}
+ \li \c{Option + mouse scroll wheel}
+ \row
+ \li Pan property graph vertically
+ \li \c{Alt + left mouse button + drag up/down}
+ \li \c{Option + left mouse button + drag up/down}
+ \row
+ \li Move bezier curve control point independent of the other control point
+ \li \c{Ctrl + left mouse button}
+ \li \c{Cmd + left mouse button}
\endtable
\section2 Slides
@@ -568,7 +584,7 @@ only in \e{Perspective View} and \e{Orthographic View}.
\row
\li Duplicate slide
\li \c{Ctrl + D}
- \li \c{Ctrl + D}
+ \li \c{Cmd + D}
\endtable
\section2 Action
diff --git a/doc/src/04-viewer/0-menu.qdoc b/doc/src/04-viewer/0-menu.qdoc
index 253e59ca..6075b8fe 100644
--- a/doc/src/04-viewer/0-menu.qdoc
+++ b/doc/src/04-viewer/0-menu.qdoc
@@ -36,30 +36,64 @@
\list
\li
- \b{Open...} - Open a \c{.uip} presentation or
- \c{.uia} application file to view.
+ \uicontrol {Open...} - Open a \c {.uip} presentation or \c {.uia} project file to view.
\li
- \b{Open Without Profiling...} - Same as \uicontrol Open but with certain profiling related
- features disabled in order to improve performance.
+ \uicontrol {Connect...} - Open the remote deployment port setting dialog.
\li
- \b{Remote Setup} - Switches to the remote deployment settings screen with
- instructions on how to remotely send presentations to this viewer.
+ \uicontrol {Reload} - Restart the presentation from the beginning.
\li
- \b{Reload} - Restart the presentation/application from the
- beginning.
-\li
- \b{Exit} - Quit the Viewer.
+ \uicontrol {Quit} - Quit the Viewer.
\endlist
\section1 View
\list
\li
- \b{Toggle Full Screen} - Switches to fullscreen mode. The menu bar may still
- be visible, depending on the windowing system.
+ \uicontrol {Show Matte} - Toggle matte on or off. If this is disabled, the whole screen will be
+ filled with the background color.
+\li
+ \uicontrol {Scale Mode} - Open the scale mode sub menu.
+ \list
+ \li
+ \uicontrol {Center} - Center the presentation inside the window without scaling.
+ \li
+ \uicontrol {Scale to Fit} - Scale the presentation to fit the window without extending the
+ background.
+ \li
+ \uicontrol {Scale to Fill} - Scale the presentation to fit the window while extending the
+ background to fill the window.
+ \endlist
+\li
+ \uicontrol {Stereo Mode} - Open the stereo mode sub menu.
+ \list
+ \li
+ \uicontrol {Mono} - Disable stereo mode.
+ \li
+ \uicontrol {Top-Bottom} - Switch to top-bottom stereo mode. In this mode image for left
+ eye is rendered on top and image for right eye is rendered at the bottom.
+ \li
+ \uicontrol {Left-Right} - Switch to left-right stereo mode. In this mode images for left
+ and right eye are rendered side-by-side.
+ \li
+ \uicontrol {Anaglyph (Red - Cyan)} - Switch to red-cyan anaglyph stereo mode.
+ \note Anaglyph modes do not support all features.
+ \li
+ \uicontrol {Anaglyph (Green - Magenta)} - Switch to green-magenta anaglyph stereo mode.
+ \note Anaglyph modes do not support all features.
+ \li
+ \uicontrol {Progressive Rendering} - Toggle progressive rendering on or off.
+ \li
+ \uicontrol {Increase Separation} - Increase the eye separation.
+ \li
+ \uicontrol {Decrease Separation} - Decrease the eye separation.
+\endlist
+\li
+ \uicontrol {Show Render Statistics} - Switch the render statistics on or off. Render
+ statistics include information of the FPS, frame time, and init time of the whole presentation,
+ as well as time taken by different passes for each layer.
\li
- \b{Profile and Debug} - Submenu with options to show/hide the built-in, in-scene
- profiling and information pane, and to control its scale factor.
+ \uicontrol {Full Screen} - Switch to fullscreen mode. The menu bar may still be visible,
+ depending on the windowing system.
\endlist
*/
diff --git a/doc/src/04-viewer/1-keyboard.qdoc b/doc/src/04-viewer/1-keyboard.qdoc
index 10296605..a0e61e40 100644
--- a/doc/src/04-viewer/1-keyboard.qdoc
+++ b/doc/src/04-viewer/1-keyboard.qdoc
@@ -46,12 +46,17 @@
\li \c{Ctrl + O}
\li \c{Cmd + O}
\row
+ \li Connect
+ \li \c{F9}
+ \li \c{F9}
+ \li \c{F9}
+ \row
\li Reload
\li \c{F5}
\li \c{Ctrl + R}
\li \c{F5}
\row
- \li Exit
+ \li Quit
\li \c{Ctrl + Q}
\li \c{Ctrl + Q}
\li \c{Cmd + Q}
@@ -66,58 +71,48 @@
\li Linux
\li macOS
\row
- \li Show matte
+ \li Show Matte
\li \c{Ctrl + D}
\li \c{Ctrl + D}
\li \c{Cmd + D}
\row
- \li Scale mode (toggle)
+ \li Scale Mode (toggle)
\li \c{Ctrl + Shift + S}
\li \c{Ctrl + Shift + S}
\li \c{Cmd + Shift + S}
\row
- \li Stereo mode (toggle)
+ \li Stereo Mode (toggle)
\li \c{Ctrl + Shift + T}
\li \c{Ctrl + Shift + T}
\li \c{Cmd + Shift + T}
\row
- \li Increase separation (in stereo mode)
+ \li Progressive Rendering (in stereo mode)
+ \li \c{Ctrl + Shift + P}
+ \li \c{Ctrl + Shift + P}
+ \li \c{Cmd + Shift + P}
+ \row
+ \li Increase Separation (in stereo mode)
\li \c{Ctrl + Shift + +}
\li \c{Ctrl + Shift + +}
\li \c{Cmd + Shift + +}
\row
- \li Decrease separation (in stereo mode)
+ \li Decrease Separation (in stereo mode)
\li \c{Ctrl + Shift + -}
\li \c{Ctrl + Shift + -}
\li \c{Cmd + Shift + -}
\row
- \li Full screen
+ \li Show Render Statistics
+ \li \c{F7}
+ \li \c{F7}
+ \li \c{F7}
+ \row
+ \li Full Screen
\li \c{F11}
\li \c{Ctrl + F11}
\li \c{F11}
\row
\li
\li {3, 1} To exit full screen, \c {F11}, \c {ESC} or swipe down gesture can be used.
- \row
- \li Toggle in-scene debug view
- \li \c{F10}
- \li \c{F10}
- \li \c{F10}
- \row
- \li Toggle console
- \li \c{`}
- \li \c{`}
- \li \c{`}
- \row
- \li Scale in-scene debug up
- \li \c{Ctrl + F10}
- \li \c{Ctrl + F10}
- \li \c{Cmd + F10}
- \row
- \li Scale in-scene debug down
- \li \c{Alt + F10}
- \li \c{Alt + F10}
- \li \c{Option + F10}
\endtable
*/
diff --git a/doc/src/04-viewer/2-commandline.qdoc b/doc/src/04-viewer/2-commandline.qdoc
index e45a0e78..4469cff3 100644
--- a/doc/src/04-viewer/2-commandline.qdoc
+++ b/doc/src/04-viewer/2-commandline.qdoc
@@ -37,7 +37,7 @@ for incoming connections with a presentation sent remotely.
\section1 Usage
\badcode
- q3dsviewer [options] [presentation file]
+ Qt3DViewer [options] [presentation file]
\endcode
When no filename is given, the viewer is launched in remote connection mode.
@@ -49,29 +49,77 @@ The following command line options are supported:
\li Option
\li Description
\row
- \li -?, -h, --help
+ \li -h, --help
\li Displays help for command line usage.
\row
- \li -f, --fullscreen
+ \li --sequence
+ \li Generates an image sequence. The file argument must be specified. Specifying any of
+ the \c {seq-*} arguments implies setting this option.
+ \row
+ \li --seq-start <ms>
+ \li Start time of the sequence in milliseconds. The default value is \c {0}.
+ \row
+ \li --seq-end <ms>
+ \li End time of the sequence in milliseconds. The default value is \c {1000}.
+ \row
+ \li --seq-fps <fps>
+ \li Frames per second for the sequence. The default value is \c {60}.
+ \row
+ \li --seq-interval <ms>
+ \li Time interval between frames in the sequence in milliseconds. The \c {seq-fps} argument
+ is ignored if this argument is used.
+ \row
+ \li --seq-width <pixels>
+ \li Width of the image sequence. The default value is \c {1920}.
+ \row
+ \li --seq-height <pixels>
+ \li Height of the image sequence. The default value is \c {1080}.
+ \row
+ \li --seq-outpath <path>
+ \li Output path of the image sequence. The default value is the current directory.
+ \row
+ \li --seq-outfile <file>
+ \li Output filename base for the image sequence. The default value is derived from the
+ presentation filename.
+ \row
+ \li --connect <port>
+ \li If this parameter is specified, the viewer is started in connection mode. The default
+ value is \c {36000}.
+ \row
+ \li --fullscreen
\li Starts the viewer in fullscreen mode.
\row
- \li -w, --no-main-window
- \li Disables the widget-based user interface, such as the menu bar.
- This mode simulates the operating mode typical on embedded devices:
- using a Qt platform plugin like \c eglfs, there will only be a single,
- fullscreen QWindow (or, with Qt Quick applications, QQuickWindow or
- QQuickView) present. This argument achieves the same even when running
- on a desktop operating system. Combined with \c{-f} (going fullscreen)
- this allows seeing the presentation in real full screen (no menu bar).
- \row
- \li -p, --no-profile
- \li Loads the presentation with some profiling options disabled. This
- provides minimal performance improvements.
- \row
- \li --port <port_number>
- \li Sets the port on which the viewer listens for remote connections.
- The remote connection mode is active either when launching with no
- presentation file specified, or when choosing \uicontrol{File > Remote Setup}.
+ \li --maximized
+ \li Starts the viewer in maximized mode.
+ \row
+ \li --windowgeometry <geometry>
+ \li Specifies the initial window geometry using the X11-syntax. For example:
+ \c {1000x800+50+50}
+ \row
+ \li --mattecolor <color>
+ \li Specifies custom matte color using #RRGGBB syntax. For example, white matte:
+ \c {#ffffff}
+ \row
+ \li --showstats
+ \li Show render statistics on screen.
+ \row
+ \li --scalemode <center|fit|fill>
+ \li Specifies scaling mode. The default value is \c {center}.
+ \row
+ \li --stereomode <mono|topbottom|leftright>
+ \li Specifies stereo mode. The default value is \c {mono}.
+ \row
+ \li --stereoeyeseparation <separation>
+ \li Specifies stereo eye separation. The default value is \c {0.4}.
+ \row
+ \li --enableprogressivestereo
+ \li Enables progressive stereoscopic rendering.
+ \row
+ \li --convert-shader-cache <filename>
+ \li Convert base64 dump to shader cache file.
+ \row
+ \li -v, --variants <variants>
+ \li Gives list of variant groups and variants to be loaded from the presentation. For
+ example \c {VarGroupA:var1,VarGroupB:var4}.
\endtable
-
*/
diff --git a/doc/src/04-viewer/3-remote-deployment.qdoc b/doc/src/04-viewer/3-remote-deployment.qdoc
index d2379546..544658df 100644
--- a/doc/src/04-viewer/3-remote-deployment.qdoc
+++ b/doc/src/04-viewer/3-remote-deployment.qdoc
@@ -34,7 +34,7 @@
Qt 3D Studio supports remote deployment to Qt 3D Studio Viewer. This enables seeing design changes
live in the target device, for example an Android tablet.
-\note For supported devices and operating systems see the \l{Requirements} page.
+\note For supported devices and operating systems see the \l {Requirements} page.
\section1 Setting Up the Target Device
@@ -59,39 +59,39 @@ For embedded systems you will have to compile the application on the target devi
You can run the Viewer from the command line. The default mode is connection mode. To start the
Viewer, use the following command:
\badcode
-q3dsviewer
+Qt3DViewer
\endcode
When you run the Viewer in connection mode it will display connection details, IP address and port,
right away.
-For full usage, see the \l{Viewer: Command Line Usage}{Command line usage documentation}.
+For full usage, see the \l {Viewer: Command Line Usage}{Command line usage documentation}.
\section1 Connecting to the Target Device
To connect to the target device Viewer from Qt 3D Studio, follow the steps below.
\list 1
- \li From the file menu, select \uicontrol {File > Connect to Device}.
+ \li From the menu, select \uicontrol {Edit > Connect to Device}.
\li Enter the connection information displaying in the Viewer on the target device, then press
- \uicontrol{OK}.
+ \uicontrol {OK}.
\note Previous used IP and port is automatically inserted when you click
\uicontrol {Connect to Device}.
- \li You are now connected. The Viewer on the target device should display \e{Remote Connected}.
+ \li You are now connected. The Viewer on the target device should display \e {Remote Connected}.
\endlist
\section1 Preview Presentation
-To preview the presentation on the target device, press the \uicontrol{Remote Preview} button
+To preview the presentation on the target device, press the \uicontrol {Remote Preview} button
\inlineimage remote-preview-button.png
in the Studio toolbar.
-After making changes to your presentation, press the \uicontrol{Remote Preview} button to see the
+After making changes to your presentation, press the \uicontrol {Remote Preview} button to see the
changes on the target device.
\section1 Disconnecting from the Target Device
-You can disconnect from the target device by selecting \uicontrol{File > Connect to Device}
-from the Studio file menu.
+You can disconnect from the target device by selecting \uicontrol {Edit > Connect to Device}
+from the Studio menu.
*/
diff --git a/doc/src/07-file-formats/0-uia.qdoc b/doc/src/07-file-formats/0-uia.qdoc
index 47d90531..103971d7 100644
--- a/doc/src/07-file-formats/0-uia.qdoc
+++ b/doc/src/07-file-formats/0-uia.qdoc
@@ -298,7 +298,7 @@ following (as many as you like, in any order):
id-prefixed path to any element in a presentation.
\li
The \b{\c{attribute}} attribute must match the
- \l{Attribute Names}{scripting name} of an attribute on that element.
+ scripting name of an attribute on that element.
\li
The \b{\c{value}} attribute must provide a Lua expression to
evaluate, the result of which will be set as the value on the element.
diff --git a/doc/src/07-file-formats/5-custom-material-reference.qdoc b/doc/src/07-file-formats/5-custom-material-reference.qdoc
index 4d3d93b7..8e46d7a6 100644
--- a/doc/src/07-file-formats/5-custom-material-reference.qdoc
+++ b/doc/src/07-file-formats/5-custom-material-reference.qdoc
@@ -48,8 +48,16 @@ index-of-refraction and fragment cutoff(masking).
It is also possible to write custom material without using the boilerplate code,
in which case the main function must be implemented in the shader.
-\note The Qt 3D Studio 2.0 runtime does not support multiple render passes for
-custom materials.
+For more information on the XML format see \l{Custom Materials and Effects} and
+\l{Effect Reference}.
+
+\note Some characters used in shader code such as '<' break the XML parsing.
+It is advisable to surround any shader code with <![CDATA[]]> to enable use of such characters.
+Example usage:
+
+\badcode
+<FragmentShader><![CDATA[ void main() { } ]]></FragmentShader>
+\endcode
\section1 Required Functions
@@ -489,6 +497,20 @@ void main()
\note Previous versions stated that the closing parenthesis should not be added to the main function.
This is no longer the case and the main function should add the closing parenthesis.
+\section2 Accessing Textures with Image Transformations
+
+When the custom material is generated, uniforms for the image transformation are also generated,
+as well as accessor functions to get the transformed coordinate and texture sample.
+
+For texture named \"basecolor\" the generated uniforms and functions are
+\badcode
+uniform vec3 basecolorTransformU;
+uniform vec3 basecolorTransformV;
+
+vec3 texcoordTransformed_basecolor(vec3 texcoord);
+vec4 sampleTransformed_basecolor(vec3 texcoord);
+\endcode
+
\section2 Simple Custom Material Example
\badcode
@@ -504,7 +526,7 @@ This is no longer the case and the main function should add the closing parenthe
<Shared></Shared>
<VertexShader>
</VertexShader>
- <FragmentShader>
+ <FragmentShader><![CDATA[
#define UIC_ENABLE_UV0 1
#define UIC_ENABLE_WORLD_POSITION 1
#define UIC_ENABLE_TEXTAN 0
@@ -525,7 +547,7 @@ out vec4 fragColor;
c.rgb *= vec3(red_weight, green_weight, blue_weight);
fragColor = c;
}
- </FragmentShader>
+ ]]></FragmentShader>
</Shader>
</Shaders>
<Passes >
diff --git a/doc/src/07-file-formats/6-effect-reference.qdoc b/doc/src/07-file-formats/6-effect-reference.qdoc
index a448464f..faaa08d2 100644
--- a/doc/src/07-file-formats/6-effect-reference.qdoc
+++ b/doc/src/07-file-formats/6-effect-reference.qdoc
@@ -356,6 +356,7 @@ The element attributes are:
\li name
\li \list
\li \c Stencil
+ \li \c CullFace
\endlist
\li Name of the render state
\row
@@ -435,4 +436,24 @@ The boolean operator values are:
\li \c greater-than-or-equal
\li \c always
\endlist
+
+\section2 <Culling>
+
+This element can be used to select which faces are culled by CullFace.
+
+The element attributes are:
+\table
+\header
+ \li attribute
+ \li values
+ \li description
+\row
+ \li mode
+ \li \list
+ \li \c Back - Back faces.
+ \li \c Front - Front faces.
+ \li \c All - All faces.
+ \endlist
+ \li Specifies CullFace mode.
+\endtable
*/
diff --git a/doc/src/07-file-formats/custom-materials-effects.qdoc b/doc/src/07-file-formats/custom-materials-effects.qdoc
index 7a1521cc..a083546d 100644
--- a/doc/src/07-file-formats/custom-materials-effects.qdoc
+++ b/doc/src/07-file-formats/custom-materials-effects.qdoc
@@ -170,6 +170,13 @@ A \c{property} element can have the following attributes:
\li Text
\li -
\li Creates UI dropdown list.
+\row
+ \li category
+ \li Text
+ \li
+ \li Use to group material properties into separate categories. \note Required field for
+ materials. If this is not added, the property will not be displayed in the Inspector palette.
+ Adding category with empty string will not suffice.
\endtable
The only required attribute in the \c{<property>} element is \c{name}.
@@ -304,4 +311,113 @@ identifier-like name.
<Shader name="tonemap">
\endcode
+\section2 \c{<Passes>}
+The \c{<Passes>} element can contain \c{<Pass>} elements.
+
+\section2 \c{<Pass>}
+The \c{<Pass>} element contains different properties that are applied to the pass. More details
+are provided in the \l{Effect Reference}.
+
+\section2 <Depth>
+Custom materials have an additional Depth pass element not provided to effects. It determines
+the depth function and masking used during this pass of the custom shader.
+
+The element attributes are:
+\table
+\header
+ \li attribute
+ \li values
+ \li description
+\row
+ \li func
+ \li \list
+ \li \c never
+ \li \c less
+ \li \c less-than-or-equal
+ \li \c equal
+ \li \c not-equal
+ \li \c greater
+ \li \c greater-than-or-equal
+ \li \c always
+ \endlist
+ \li Specifies the depth function used.
+\row
+ \li mask
+ \li bool
+ \li Specifies if depth is written or not. With "true" depth is written, with "false" it's not.
+\endtable
+
+\section1 Things to Note
+
+\section2 Materials
+When creating a custom material with several properties, it is a good practice to use categories
+to separate them. If there is a need to be able to change the material for the mesh, at least one
+property needs to be added to \b Materials category. This will pull in \b {Material Type} and
+\b Shader properties into the Inspector palette.
+
+Consider a custom material with the following metadata:
+\badcode
+ <MetaData >
+ <Property category="ExampleMaterial" formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png"/>
+ <Property category="ExampleMaterial" formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True"/>
+ <Property category="ExampleMaterial" formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png"/>
+ <Property category="ExampleMaterial" formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False"/>
+ <Property category="ExampleMaterial" formalName="Roughness" name="roughness" type="Float" min="0.0" max="1.0" default="0.3" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse"/>
+ <Property category="ExampleMaterial" formalName="Base color" name="base_color" type="Color" default="0.7 0.7 0.7" description="Color of the material"/>
+ </MetaData>
+\endcode
+and the same material with sensible categories defined, including \b {Material}:
+\badcode
+ <MetaData >
+ <Property category="Environment" formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png"/>
+ <Property category="Environment" formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True"/>
+ <Property category="Shadow" formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png"/>
+ <Property category="Shadow" formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False"/>
+ <Property category="Material" formalName="Roughness" name="roughness" type="Float" min="0.0" max="1.0" default="0.3" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse"/>
+ <Property category="Material" formalName="Base color" name="base_color" type="Color" default="0.7 0.7 0.7" description="Color of the material"/>
+ </MetaData>
+\endcode
+
+The first option results in
+\image materials-category-dummy.png
+and the seconds one results in
+\image materials-category-several.png
+
+\section2 Controlling Custom Properties
+When some of the properties in custom materials or effects need to be adjusted during run-time,
+the \c setAttribute API is required. The usage may differ slightly from normal usage, depending on
+the property being controlled, as all of the properties in custom materials and effects are handled
+as dynamic properties.
+
+\note Since 2.8 the custom property textures use images and are controlled the same way as standard
+material textures.
+
+\omit
+For example, a texture is not handled as an image like it is when controlling it in standard
+material.
+\endomit
+\section3 Controlling a texture in standard material
+\badcode
+<presentation id>.setAttribute("<element path to texture>", "sourcepath", "<path to image>");
+\endcode
+For example:
+\badcode
+myPresentation.setAttribute("Scene.Layer.Sphere.Default_animatable.diffusemap", "sourcepath", "../maps/myTexture.png");
+\endcode
+\section3 Controlling a texture in a custom material
+\badcode
+<presentation id>.setAttribute("<element path to material>", "sourcepath", "<path to image>");
+\endcode
+With a material that has a metadata entry as follows:
+\badcode
+<MetaData >
+ ...
+ <Property name="diffuseTexture" type="Texture" category="Material" formalName="Diffuse texture"/>
+ ...
+</MetaData>
+\endcode
+This is the way to control it:
+\badcode
+myPresentation.setAttribute("Scene.Layer.Sphere.MyMaterial.diffuseTexture", "sourcepath", "../maps/myTexture.png");
+\endcode
*/
diff --git a/doc/src/10-best-practices/100-elementvisibilities.qdoc b/doc/src/10-best-practices/100-elementvisibilities.qdoc
new file mode 100644
index 00000000..f7c3a0ea
--- /dev/null
+++ b/doc/src/10-best-practices/100-elementvisibilities.qdoc
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\title Manipulating Element Visibility
+\page bestpractices-elementvisibilities.html
+\ingroup qt3dstudio-best-practices
+
+Element visibilities are controlled with element attribute "eyeball". This attribute can be set
+per-slide for each element. See \l{Studio: Timeline Palette}.
+
+Eyeball attribute can also be controlled in Runtime with data inputs or setAttribute API.
+
+Eyeball attribute controls not only element visibility, but also entire element active state.
+Element active state determines if element participates in animations, or if it in general exists
+in the scene at any given moment. Thus, changing element eyeball state is more than just hiding or
+revealing an existing element.
+
+\section1 Using Data Inputs to Control Active State
+
+A boolean type data input can be bound to element "eyeball" property and used to control element
+active state. See \l{Using Data Inputs} for details.
+
+\section2 Master Slide Elements versus Per-slide Elements
+
+When a data input is used to change element eyeball property, runtime behavior depends on whether
+the element exists on master slide, or on a single slide.
+
+\b{For elements on master slide, data input control is persistent.} This means that after element
+visibility has been changed using a data input, element is no longer affected by visibility states
+set in slides, and will not change visibility at slide transitions. This helps avoid - often
+tricky! - bugs where element visibility is controlled by several sources.
+
+\b{For elements existing on a single slide, data input visibility control is not persistent.}
+Element visibility can be set using a data input, but when the slide containing the element is
+re-entered, element visibility will have the state that was assigned to it in Editor.
+
+\section2 SetAttribute API Visibility Control versus Data Inputs
+
+Q3DSElement::setAttribute API can also be used to directly set eyeball attribute. Visibility
+persistence does not apply to any visibility changes done using setAttribute API.
+
+\note Data input is the preferred method for controlling element attributes.
+
+\note Mixing setAttribute and data input control can lead to unexpected behavior. Due to
+performance optimizations, Q3DSDataInput::setValue API by default only generates a change event
+when the new Data Input value differs from the old one. Thus, a data input might discard value even
+though the underlying target element visibility has actually been changed by another controller.
+See \l{Best practices for dynamic visibility control} for example.
+
+\section1 Best Practices for Dynamic Visibility Control
+
+If an element on master slide must be controlled dynamically, consider the following approach:
+
+\list
+\li Use a single visibility controller instead of relying on a combination of slide transitions,
+data inputs and setAttribute calls. For example, the following sequence where element "Element"
+visibility is bound to data input \c visCtrlDI will fail and leave "Element" in non-visible state:
+\code
+visCtrlDI.setValue(true)
+Element.setAttribute("eyeball", false)
+visCtrlDI.setValue(true) // this value change will be discarded, because force=true is not set
+\endcode
+
+\li For data input -controlled elements, set visibility explicitly with data input at
+presentationReady to make sure that visibility is at a known state. This also makes sure that
+master slide element visibility is persistent and not affected by slide transitions. Use parameter
+force = true.
+
+\li Use onSlideChanged signal and data input to explicitly set element visibility at slide
+transition, especially for master slide elements. Do not rely on visibility state set in slide.
+
+\li To make sure that visibility change event is actually created regardless of data input current
+value, use force=true parameter in Q3DSdata input::setValue interface. Do not call setValue
+needlessly when force parameter is set to true, as this can have performance implications.
+\endlist
+
+\section1 Debugging Element Visibility Issues
+
+\b{Element has wrong visibility after slide change, element is on master slide, and \
+visibility (eyeball) was changed with data input before this?}
+
+Slide-based visibility states are no longer used because data input control overrides them. Make
+sure that you will do all visibility changes using data input.
+
+\b{Element visibility was changed using Q3DSElement::setAttribute, and data input \
+visibility setting now has no effect?}
+
+Do not mix setAttribute, slide-based and data input visibility control. Use force = true parameter
+for Q3DSDataInput::setValue API to make sure that data input does not discard incoming value.
+
+\b{Element is not on master slide, and data input visibility control has no effect after \
+slide change?}
+
+Element visibility might have been changed by slide transition. Data input is not creating change
+event, if the new value is not different from previously set value. Use force = true parameter to
+bypass this optimization. Also remember that for non-master slide elements, data input control is
+not persistent. Entering this slide later on will again set visibility to slide-based initial
+value.
+*/
diff --git a/doc/src/10-best-practices/30-using-sub-presentations.qdoc b/doc/src/10-best-practices/30-using-sub-presentations.qdoc
index 21aff488..c8124d6b 100644
--- a/doc/src/10-best-practices/30-using-sub-presentations.qdoc
+++ b/doc/src/10-best-practices/30-using-sub-presentations.qdoc
@@ -129,7 +129,9 @@ To add a sub-presentation to a layer, do one of the following:
One benefit of displaying a sub-presentation as a texture is that you can use Studio
presentations and QML files to map the materials of objects in your presentation. You can apply
sub-presentations to any map or image property of a material, i.e. diffuse maps, specular maps and
-displacement maps. This way you can for example create animated textures.
+displacement maps. This way you can for example create animated textures. For performance reasons
+it is best to disable mipmapping for subpresentation images by setting the minification filter to
+\c Nearest or \c Linear.
To add a sub-presentation as a texture of a 3D object, do one of the following:
\list
diff --git a/doc/src/10-best-practices/60-importing-3d-content.qdoc b/doc/src/10-best-practices/60-importing-3d-content.qdoc
index 34558574..fcfd9b61 100644
--- a/doc/src/10-best-practices/60-importing-3d-content.qdoc
+++ b/doc/src/10-best-practices/60-importing-3d-content.qdoc
@@ -182,8 +182,8 @@ UV unwrap and assign material slot IDs to your meshes.
light color, and the cast shadows property will be imported.
\li
\b{Cameras} - Perspective and orthographic cameras can be imported to Studio.
- Position, rotation and scale properties will be imported. For perspective cameras,
- field of view will also be imported.
+ Position, rotation and scale properties will be imported as well as start and end clipping.
+ For perspective cameras, field of view will also be imported.
\endlist
\section2 Other
diff --git a/doc/src/10-best-practices/80-effects.qdoc b/doc/src/10-best-practices/80-effects.qdoc
index 8a44ee15..74ad47e1 100644
--- a/doc/src/10-best-practices/80-effects.qdoc
+++ b/doc/src/10-best-practices/80-effects.qdoc
@@ -68,14 +68,67 @@ lower in the scene graph will be applied before effects that are above them.
\row
\li
\div {align="center"}
+ \image additive-gradient-icon.png
+ \b {\l{Additive color gradient}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image bloom-icon.png
+ \b {\l{Bloom}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image blur-icon.png
+ \b {\l{Blur}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image color-master-icon.png
+ \b {\l{Color master}}
+ \enddiv
+\row
+ \li
+ \div {align="center"}
+ \image chromatic-aberration-icon.png
+ \b {\l{Chromatic aberration}}
+ \enddiv
+ \li
+ \div {align="center"}
\image depth-of-field-icon.png
- \b {\l{Depth of field}}
+ \b {\l{Depth of field HQ blur}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image desaturate-icon.png
+ \b {\l{Desaturate}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image distortion-ripple-icon.png
+ \b {\l{Distortion ripple}}
+ \enddiv
+\row
+ \li
+ \div {align="center"}
+ \image distortion-sphere-icon.png
+ \b {\l{Distortion sphere}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image distortion-spiral-icon.png
+ \b {\l{Distortion spiral}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image edge-detect-icon.png
+ \b {\l{Edge detect}}
\enddiv
\li
\div {align="center"}
\image fxaa-icon.png
\b {\l{FXAA}}
\enddiv
+\row
\li
\div {align="center"}
\image gaussian-blur-icon.png
@@ -86,7 +139,6 @@ lower in the scene graph will be applied before effects that are above them.
\image hdr-bloom-tonemap-icon.png
\b {\l{HDR bloom tonemap}}
\enddiv
-\row
\li
\div {align="center"}
\image motion-blur-icon.png
@@ -97,8 +149,59 @@ lower in the scene graph will be applied before effects that are above them.
\image tiltshift-icon.png
\b{\l{Tilt shift}}
\enddiv
+\row
+ \li
+ \div {align="center"}
+ \image brush-strokes-icon.png
+ \b {\l{Brush Strokes}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image sepia-icon.png
+ \b {\l{Sepia}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image stylize-scatter-icon.png
+ \b {\l{Stylize Scatter}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image emboss-icon.png
+ \b {\l{Emboss}}
+ \enddiv
+\row
+ \li
+ \div {align="center"}
+ \image fullscreen-texture-overlay-icon.png
+ \b {\l{Fullscreen Texture Overlay}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image corona-icon.png
+ \b {\l{Corona}}
+ \enddiv
+ \li
+ \div {align="center"}
+ \image vignette-icon.png
+ \b {\l{Vignette}}
+ \enddiv
\li
+ \div {align="center"}
+ \image frame-flipper-icon.png
+ \b {\l{Frame Flipper}}
+ \enddiv
+\row
+ \li
+ \div {align="center"}
+ \image screen-space-ao-icon.png
+ \b {\l{Screen Space AO}}
+ \enddiv
\li
+ \div {align="center"}
+ \image smaa1x-icon.png
+ \b {\l{SMAA1X}}
+ \enddiv
\endtable
\enddiv
diff --git a/doc/src/10-best-practices/95-data-input.qdoc b/doc/src/10-best-practices/95-data-input.qdoc
index a71fdb30..1177e7ad 100644
--- a/doc/src/10-best-practices/95-data-input.qdoc
+++ b/doc/src/10-best-practices/95-data-input.qdoc
@@ -65,6 +65,9 @@ Q3DSPresentation in the C++ API.
\row
\li Vector3
\li 3 float values
+ \row
+ \li Vector4
+ \li 4 float values
\endtable
\section1 Manage Data Inputs
@@ -151,8 +154,6 @@ To edit a metadata key, follow the steps below:
\list 1
\li
- Double-click the desired metadata key in the list.
- \li
Edit desired values.
\li
Press \uicontrol{OK}.
@@ -176,7 +177,6 @@ To add a data input to control the timeline animation, follow the instructions b
\li Click the \inlineimage datainput-to-timeline-icon-inactive.png
icon located in the bottom of the scene graph.
\li Select the desired data input from the list by clicking it.
- \li Press \uicontrol{OK}.
\endlist
\image timeline-datainput.png
@@ -198,7 +198,6 @@ To remove the data input, repeat step 2 above. Then select \uicontrol{[No contro
\li In the slide palette, click the \inlineimage datainput-to-timeline-icon-inactive.png
icon located below the slides.
\li Select the desired data input from the list by clicking it.
- \li Press \uicontrol{OK}.
\endlist
\image slide-palette-data-input-active.png
@@ -241,6 +240,9 @@ The following data input types can be used to control object properties:
\row
\li Vector3
\li To control properties with three numeric values such as 3D coordinates or RGB colors
+ \row
+ \li Vector4
+ \li To control properties with four numeric values such as RGBA colors
\endtable
\list 1
@@ -250,7 +252,6 @@ The following data input types can be used to control object properties:
\li In the inspector palette, click the \inlineimage datainput-to-timeline-icon-inactive.png
icon next to the object property you wish to control.
\li Select the desired data input from the list by clicking it.
- \li Press \uicontrol{OK}.
\endlist
\image datainput-property-active-icon.png
diff --git a/doc/src/10-best-practices/additive-gradient.qdoc b/doc/src/10-best-practices/additive-gradient.qdoc
new file mode 100644
index 00000000..9581d342
--- /dev/null
+++ b/doc/src/10-best-practices/additive-gradient.qdoc
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Additive Color Gradient
+\page additive-color-gradient.html
+\ingroup qt3dstudio-best-practices
+
+This effect adds a full-layer vertical gradient to the scene, then additively blends it with all
+other elements on the layer. Additive blending adds the pixel values of the gradient and the
+layer, making the result lighter. White areas do not change, and black areas are the same color
+as the gradient. In the image below, the effect is applied in the right picture.
+
+\image effects-additive-gradient.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Top color
+ \li
+ The top color of the gradient.
+ \row
+ \li
+ Bottom color
+ \li
+ The bottom color of the gradient.
+\endtable
+
+\section1 Usage
+
+In the inspector palette, select the top and bottom colors of the gradient.
+
+*/
diff --git a/doc/src/10-best-practices/brush-strokes.qdoc b/doc/src/10-best-practices/brush-strokes.qdoc
new file mode 100644
index 00000000..dfb4cc56
--- /dev/null
+++ b/doc/src/10-best-practices/brush-strokes.qdoc
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Brush Strokes
+\page brush-strokes.html
+\ingroup qt3dstudio-best-practices
+
+The brush strokes effect will apply a painted look for your layer.
+\image effects-brush-strokes.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Noise
+ \li
+ Texture to be used as the brush.
+ \row
+ \li
+ Brush Angle
+ \li
+ Rotation of the brush texture.
+ \row
+ \li
+ Stroke Length
+ \li
+ Length of the brush texture.
+ \row
+ \li
+ Stroke Size
+ \li
+ Overall scale of the brush.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/chromatic-aberration.qdoc b/doc/src/10-best-practices/chromatic-aberration.qdoc
new file mode 100644
index 00000000..f212c14e
--- /dev/null
+++ b/doc/src/10-best-practices/chromatic-aberration.qdoc
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Chromatic Aberration
+\page chromatic-aberration.html
+\ingroup qt3dstudio-best-practices
+
+In real life, chromatic aberration is an optical phenomenon causing color fringes in high contrast
+areas. These color fringes are caused by different colors refracting at different angels
+splitting white light into a spectrum. This is called dispersion.
+
+In the image below, the effect is applied in the right picture.
+
+\image effects-chromatic-aberration.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Aberration amount
+ \li
+ Amount of aberration. A negative value inverses the effect.
+ \row
+ \li
+ Focus depth
+ \li
+ Dispersion scales in relation to the distance from this value.
+ \row
+ \li
+ Effect mask
+ \li
+ A grayscale texture to control position and strength of the effect. The effect is
+ strongest in white areas, and weakest in black areas.
+ \row
+ \li
+ Debug dispersion amount
+ \li
+ Allows you to see exactly how the effect works.
+\endtable
+
+\section1 Usage
+
+To make it easier to set up this effect, enable \uicontrol {Debug dispersion amount}. When enabled,
+the scene view switches to a mode showing the amount of dispersion to be applied.
+Black objects will disperse less, and white objects will disperse more.
+
+*/
diff --git a/doc/src/10-best-practices/corona.qdoc b/doc/src/10-best-practices/corona.qdoc
new file mode 100644
index 00000000..19a554d1
--- /dev/null
+++ b/doc/src/10-best-practices/corona.qdoc
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Corona
+\page corona.html
+\ingroup qt3dstudio-best-practices
+
+The corona effect creates colored rings around an object.
+
+\image effects-corona.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Horizontal Blur
+ \li
+ Horizontal amount of corona glow.
+ \row
+ \li
+ Vertical Blur
+ \li
+ Vertical amount of corona glow.
+ \row
+ \li
+ Fade Amount
+ \li
+ How quickly the effect fades away. 0 means there is no glow, and 1 means the glow is permanent.
+ \row
+ \li
+ Glow Clor
+ \li
+ The color of the glow.
+ \row
+ \li
+ Noise
+ \li
+ Texture to be used for the glow noise.
+ \row
+ \li
+ Noise Density
+ \li
+ Scale of the noise texture.
+ \row
+ \li
+ Noise Brightness
+ \li
+ Brightness of the noise texture.
+ \row
+ \li
+ Noise Amount
+ \li
+ Scale of the noise texture.
+ \row
+ \li
+ Crawl Length
+ \li
+ Length of the trail for the glow animation.
+ \row
+ \li
+ Crawl Angle
+ \li
+ Angle of the glow trail.
+\endtable
+
+*/
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/src/10-best-practices/depth-of-field-effect.qdoc b/doc/src/10-best-practices/depth-of-field-effect.qdoc
index 6e6c165d..b3a7d980 100644
--- a/doc/src/10-best-practices/depth-of-field-effect.qdoc
+++ b/doc/src/10-best-practices/depth-of-field-effect.qdoc
@@ -28,52 +28,64 @@
/*!
-\title Depth of Field
+\title Depth of Field HQ Blur
\page depth-of-field-effect.html
\ingroup qt3dstudio-best-practices
-\section1 Using Depth of Field
+The depth of field HQ effect performs a gradient blur on regions of the
+image based on their deviation from a specified distance from the camera.
+
+In the image below, the effect is applied in the right picture. Notice that the cube and
+same-distance floor are in focus while the closer cone and farther sphere are blurred.
\image Effects-DOF.png
-The \"Depth Of Field HQ Blur\" effect increasingly blurs regions of the
-image based on their deviation from a specified distance from the
-camera. (Notice that the cube and same-distance floor are in focus while
-the closer cone and farther sphere are blurred.)
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Focus distance
+ \li
+ The distance from the camera where the content is in perfect focus.
+ \row
+ \li
+ Depth of field
+ \li
+ The distance around the \c{Focus Distance} where items are fully in focus. The focus then
+ fades away to fully blurred by the same distance on both the near and far sides.
+ \row
+ \li
+ Debug focus rendering
+ \li
+ Allows you to see exactly how the focus variables work.
+\endtable
+
+\section1 Usage
For this effect to work well, you need to adjust the
-\c{Clipping Start} and \c{Clipping End} properties of the
-camera for the Layer to 'frame' the content. (You ideally want the
-largest possible value for \c{Start} and the smallest possible
-value for \c{End}.) After you do this you can use the properties of
-the effect in the Inspector palette to adjust the effect.
+\uicontrol{Clipping start} and \uicontrol{Clipping end} properties of the
+camera for the layer to frame the content. You ideally want the
+largest possible value for \uicontrol{Clipping start} and the smallest possible
+value for \uicontrol{Clipping end}. Next, adjust the properties of the effect for the desired
+result.
-\list
-\li
- The \c{Focus Distance} property specifies the distance from the
- camera where the content is in perfect focus.
-\li
- The \c{Depth of Field} property specifies a the distance around
- the \c{Focus Distance} where items are fully in focus. The focus
- then fades away to fully blurred by the same distance on both the near
- and far sides.
-\endlist
-For example, a \c{Focus Distance} of 100 and a
-\c{Depth of Field} of 20 means that everything that is between 90
-and 110 units away from the camera will be fully in focus, items at a
-distance of 70-90 and 110-130 units will experiencing variable blurring,
-and everything closer than 70 or farther than 130 will be fully blurred.
+For example, a \uicontrol{Focus distance} of 100 and a
+\uicontrol{Depth of field} of 20 means that everything that is between 90
+and 110 units away from the camera will be entirely in focus, items at a
+distance of 70-90 and 110-130 units will experience variable blurring,
+and everything closer than 70 or farther than 130 will be entirely blurred.
-To make it easier to set up this effect, turn on the
-\c{Debug Focus Rendering} checkbox for the effect:
-\image Effects-DOF-Debug.png
+To make it easier to set up this effect, enable \uicontrol{Debug focus rendering}. When enabled,
+the scene view switches to a mode showing the amount of blur to be applied. Anything completely
+fogged in white is entirely blurred, anything that is fully black is entirely in focus, and
+shades of grey represent varying amounts of blur in between. It is far easier to turn on this
+mode and adjust the values in the inspector palette until the content you want is bracketed,
+compared to performing distance calculations and entering numbers.
-When enabled the scene will switch to a mode showing the amount of blur
-to be applied. Anything completely fogged in white will be fully
-blurred, anything that is fully black will be fully in focus, and shades
-of grey represent varying amounts of blur in between. You will find it
-far easier to turn on this mode and just scrub the values in the
-Inspector palette until the content you want is bracketed, compared to
-performing distance calculations and entering numbers.
+\image Effects-DOF-Debug.png
*/
diff --git a/doc/src/10-best-practices/desaturate.qdoc b/doc/src/10-best-practices/desaturate.qdoc
new file mode 100644
index 00000000..a83f474e
--- /dev/null
+++ b/doc/src/10-best-practices/desaturate.qdoc
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Desaturate
+\page desaturate.html
+\ingroup qt3dstudio-best-practices
+
+With the desaturate effect, you can decrease the intensity of all colors in the scene.
+
+\image effects-desaturate.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Effect strength
+ \li
+ Amount of desaturation. A value of 1.0 desaturates the scene entirely. Everything is
+ completely grayscale.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/distortion-ripple.qdoc b/doc/src/10-best-practices/distortion-ripple.qdoc
new file mode 100644
index 00000000..fe720da7
--- /dev/null
+++ b/doc/src/10-best-practices/distortion-ripple.qdoc
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Distortion Ripple
+\page distortion-ripple.html
+\ingroup qt3dstudio-best-practices
+
+The distortion ripple effect adds circular ripples, moving away from the center of the effect.
+
+\image effects-distortion-ripple.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Radius
+ \li
+ The spread between the ripples.
+ \row
+ \li
+ Center
+ \li
+ The center of the effect. \c 0.5 and \c 0.5 is the center of the layer while \c 1.0 and \c 1.0
+ is the upper right corner of the layer.
+ \row
+ \li
+ Wave width
+ \li
+ Adjusts the amount of ripples.
+ \row
+ \li
+ Wave height
+ \li
+ Adjusts the distortion amount.
+ \row
+ \li
+ Ripple phase
+ \li
+ The offset of each ripple. Animate this property to achieve an effect of moving waves.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/distortion-sphere.qdoc b/doc/src/10-best-practices/distortion-sphere.qdoc
new file mode 100644
index 00000000..73941bc8
--- /dev/null
+++ b/doc/src/10-best-practices/distortion-sphere.qdoc
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Distortion Sphere
+\page distortion-sphere.html
+\ingroup qt3dstudio-best-practices
+
+The distorion sphere effect creates a 3D effect of wrapping the scene around a spherical shape.
+
+\image effects-distortion-sphere.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Radius
+ \li
+ The size of the distorted area.
+ \row
+ \li
+ Height
+ \li
+ The amount of distortion.
+ \row
+ \li
+ Center
+ \li
+ The center of the effect. \c 0.5 and \c 0.5 is the center of the layer while \c 1.0 and \c 1.0
+ is the upper right corner of the layer.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/distortion-spiral.qdoc b/doc/src/10-best-practices/distortion-spiral.qdoc
new file mode 100644
index 00000000..f9e5b66d
--- /dev/null
+++ b/doc/src/10-best-practices/distortion-spiral.qdoc
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Distortion Spiral
+\page distortion-spiral.html
+\ingroup qt3dstudio-best-practices
+
+The distortion spiral effect creates a twirl effect.
+\image effects-distortion-spiral.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Radius
+ \li
+ The size of the distorted area.
+ \row
+ \li
+ Spiral
+ \li
+ The amount of twirling.
+ \row
+ \li
+ Center
+ \li
+ The center of the effect. \c 0.5 and \c 0.5 is the center of the layer while \c 1.0 and \c 1.0
+ is the upper right corner of the layer.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/edge-detect.qdoc b/doc/src/10-best-practices/edge-detect.qdoc
new file mode 100644
index 00000000..ac4f078c
--- /dev/null
+++ b/doc/src/10-best-practices/edge-detect.qdoc
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Edge Detect
+\page edge-detect.html
+\ingroup qt3dstudio-best-practices
+
+The edge detect effect turns smooth, unchanging areas of the scene black, while areas of the
+scene with sharp color changes are brightened to highlight the edges.
+
+\image effects-edge-detect.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Amount
+ \li
+ Opacity of the effect. A value of \c 1.0 gives a fully opaque effect while \c 0.0 gives a
+ fully transparent effect.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/emboss-effect.qdoc b/doc/src/10-best-practices/emboss-effect.qdoc
new file mode 100644
index 00000000..b2a7209c
--- /dev/null
+++ b/doc/src/10-best-practices/emboss-effect.qdoc
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Emboss
+\page emboss-effect.html
+\ingroup qt3dstudio-best-practices
+
+The emboss effect creates an 3D embossed look for your layer.
+
+\image effects-emboss.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Amount
+ \li
+ Controls the depth of the emboss.
+\endtable
+
+*/
diff --git a/doc/Src/10-best-practices/exporting-from-3dsmax.qdoc b/doc/src/10-best-practices/exporting-from-3dsmax.qdoc
index 79754adc..79754adc 100644
--- a/doc/Src/10-best-practices/exporting-from-3dsmax.qdoc
+++ b/doc/src/10-best-practices/exporting-from-3dsmax.qdoc
diff --git a/doc/Src/10-best-practices/exporting-from-blender.qdoc b/doc/src/10-best-practices/exporting-from-blender.qdoc
index a326fbc6..528dcbad 100644
--- a/doc/Src/10-best-practices/exporting-from-blender.qdoc
+++ b/doc/src/10-best-practices/exporting-from-blender.qdoc
@@ -141,6 +141,41 @@ The following properties will be imported into Qt 3D Studio:
\li Cast shadows
\endlist
+Light type will be imported (and converted if needed).
+
+\table
+ \header
+ \li
+ Light type in Blender
+ \li
+ Will import to Qt 3D Studio as...
+ \row
+ \li
+ Point
+ \li
+ Point
+ \row
+ \li
+ Area
+ \li
+ Area
+ \row
+ \li
+ Sun
+ \li
+ Directional
+ \row
+ \li
+ Spot
+ \li
+ Directional
+ \row
+ \li
+ Hemi
+ \li
+ Directional
+\endtable
+
\section1 Exporting Cameras
You can export perspective and orthographic cameras from Blender to use in Qt 3D Studio.
@@ -148,6 +183,7 @@ You can export perspective and orthographic cameras from Blender to use in Qt 3D
The following properties will be imported into Qt 3D Studio:
\list
\li Position, rotation, scale
+ \li Clipping start/end
\li Focal Length (perspective camera only).
\endlist
@@ -180,12 +216,13 @@ enabled by following the steps below:
\image enable-fbx-addon-blender.png
-\endlist
-
Next, to export as FBX, follow the steps below:
\list 1
\li From the file menu, select \uicontrol {File > Export > FBX (.fbx)}.
+ \li Under the \uicontrol Main tab, set \uicontrol Forward to \c{Y Forward} and \uicontrol Up
+ to \c{Z Up}.
+ \image blender-fbx-export-axis.png
\li For animations, ensure that \uicontrol {Baked Animation} under the \uicontrol Animation
tab is checked on.
\image 3D_Content/blender-export-6.png
diff --git a/doc/Src/10-best-practices/exporting-from-maya.qdoc b/doc/src/10-best-practices/exporting-from-maya.qdoc
index 10d1525b..10d1525b 100644
--- a/doc/Src/10-best-practices/exporting-from-maya.qdoc
+++ b/doc/src/10-best-practices/exporting-from-maya.qdoc
diff --git a/doc/Src/10-best-practices/exporting-from-modo.qdoc b/doc/src/10-best-practices/exporting-from-modo.qdoc
index b8c34f77..b8c34f77 100644
--- a/doc/Src/10-best-practices/exporting-from-modo.qdoc
+++ b/doc/src/10-best-practices/exporting-from-modo.qdoc
diff --git a/doc/src/10-best-practices/frame-flipper.qdoc b/doc/src/10-best-practices/frame-flipper.qdoc
new file mode 100644
index 00000000..d56a54c8
--- /dev/null
+++ b/doc/src/10-best-practices/frame-flipper.qdoc
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Frame Flipper
+\page frame-flipper-effect.html
+\ingroup qt3dstudio-best-practices
+
+The frame flipper effect gives you the ability to flip the layer horizontally and vertically.
+
+In the image below, the left picture is vertically flipped and the right picture is
+horizontally flipped.
+
+\image effects-frame-flipper.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Flip Horizontally
+ \li
+ Flips the image upside down.
+ \row
+ \li
+ Flip Vertically
+ \li
+ Flips the image sideways.
+\endtable
+
+
+*/
diff --git a/doc/src/10-best-practices/fullscreen-texture-overlay.qdoc b/doc/src/10-best-practices/fullscreen-texture-overlay.qdoc
new file mode 100644
index 00000000..f7ae9b7d
--- /dev/null
+++ b/doc/src/10-best-practices/fullscreen-texture-overlay.qdoc
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2029 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Fullscreen Texture Overlay
+\page fullscreen-texture-overlay.html
+\ingroup qt3dstudio-best-practices
+
+With fullscreen texture overlay effect you can take any image and use it as
+texture overlay.
+
+\image effects-fullscreen-texture-overlay.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Overlay Texture
+ \li
+ Texture to use on the overlay.
+ \row
+ \li
+ Repeat
+ \li
+ How many times the texture is repeated vertically and horizontally.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/fxaa-effect.qdoc b/doc/src/10-best-practices/fxaa-effect.qdoc
index 51743000..1852d970 100644
--- a/doc/src/10-best-practices/fxaa-effect.qdoc
+++ b/doc/src/10-best-practices/fxaa-effect.qdoc
@@ -32,23 +32,38 @@
\page fxaa-effect.html
\ingroup qt3dstudio-best-practices
-\section1 Using FXAA
+The FXAA effect applies fast approximate anti-aliasing to the layer.
+FXAA is a high-speed anti-aliasing technique that removes some of the
+artifacts from the image without impacting performance as heavily as
+super-sampling would. In the image below, the effect is applied in the right picture.
\image Effects-FXAA.png
-The \"FXAA\" effect applies Fast approXimate Anti-Aliasing to the layer.
-This is a high-speed anti-aliasing technique that removes some of the
-\"jaggies\" from the image without impacting performance as heavily as
-super-sampling would.
+\section1 Usage
-\list
-\li
- Pros: easy fix for many aliasing problems; works with moving images
- (unlike \l{best-practices-antialiasing.html#progressive-aa}{Progressive Anti-Aliasing}).
-\li
- Cons: can blur and otherwise 'munge' fine text details present in the
- layer; as a screen-space heuristic technique it can sometimes leave
- sharp edges that ideally would be anti-aliased.
-\endlist
+\table
+ \header
+ \li
+ Pros
+ \li
+ Cons
+ \row
+ \li
+ \list
+ \li
+ Easy fix for many aliasing problems.
+ \li
+ Works with moving images
+ (unlike \l{best-practices-antialiasing.html#progressive-aa}{Progressive Anti-Aliasing}).
+ \endlist
+ \li
+ \list
+ \li
+ Can blur and distort fine text details.
+ \li
+ As a screen-space heuristic technique, it can sometimes leave
+ sharp edges that ideally would be anti-aliased.
+ \endlist
+\endtable
*/
diff --git a/doc/src/10-best-practices/gaussian-blur-effect.qdoc b/doc/src/10-best-practices/gaussian-blur-effect.qdoc
index 5c30f44e..1e5bbabc 100644
--- a/doc/src/10-best-practices/gaussian-blur-effect.qdoc
+++ b/doc/src/10-best-practices/gaussian-blur-effect.qdoc
@@ -32,15 +32,29 @@
\page gaussian-blur-effect.html
\ingroup qt3dstudio-best-practices
-\section1 Using Gaussian Blur
+The gaussian blur effect is simple to use and understand. It blurs all objects on the
+layer evenly.
+
+In the image below, the effect is applied in the right picture.
\image Effects-GaussianBlur.png
-The \"Gaussian Blur\" effect is one of the simplest to use and
-understand. Drop it on a Layer and adjust the \c{Blurriness}
-property in the Inspector palette. In order to keep the effect
-performant large blur values will produce a mosaic result instead of
-smooth blurriness. Play with the slider for the value to find the best
-visual result for your needs.
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Blurriness
+ \li
+ Level of blurriness.
+\endtable
+
+\section1 Usage
+
+To keep the effect performant, large blur values produce a mosaic result instead of
+smooth blurriness.
*/
diff --git a/doc/src/10-best-practices/hdr-bloom-tonemap-effect.qdoc b/doc/src/10-best-practices/hdr-bloom-tonemap-effect.qdoc
index 7349a453..f44a9a20 100644
--- a/doc/src/10-best-practices/hdr-bloom-tonemap-effect.qdoc
+++ b/doc/src/10-best-practices/hdr-bloom-tonemap-effect.qdoc
@@ -33,48 +33,65 @@
\ingroup qt3dstudio-best-practices
\target hdrbloomtonemap
-\section1 Using HDRBloomTonemap
-\image Effects-HDRBloomTonemap.png
-
-The \"HDRBloomTonemap\" effect provides two features:
+The HDR bloom tonemap effect provides two features:
-\list 1
+\list
\li
Adjust the gamma and exposure of the high-dynamic range rendered
- content to achieve the image quality you want, and
+ content to achieve the image quality you want.
\li
- Apply an adjustable 'bloom' effect to very bright areas (like the sun
+ Apply an adjustable bloom effect to very bright areas (like the sun
glinting off a car).
\endlist
-When you add an HDRBloomTonemap effect to a layer, the following
-properties are available in the Inspector palette:
-\list
-\li
- \b{Gamma} - this affects the non-linear curve of the lighting.
- Higher values will increase the exposure of mid tones, lightening the
- image (and decreasing the contrast). A value of \c{1.0} causes no
- adjustment to the image.
-\li
- \b{Exposure} - this is a linear multiplier on the lighting,
- brightening or darkening the image overall. A value of \c{0.0}
- causes no adjustment to the image.
-\li
- \b{Bloom Threshold} - lighting greater than this value will
- bloom. A value of \c{1.0} corresponds to white in the original
- render result. Lowering this value will cause more areas of the
- rendered scene to bloom; at a value of \c{0.0} everything in the
- scene will bloom.
-\list
-\li
- \e{Tip: to disable bloom and use only the tone mapping, set this to
- a sufficiently high value, like \c{999}.}
-\endlist
-\li
- \b{Bloom Falloff} - adjusts the amount of bloom. Lower values
+In the image below, the effect is applied in the right picture.
+
+\image Effects-HDRBloomTonemap.png
+
+\section1 Properties
+
+\table
+ \header
+ \li
+ Property
+ \li
+ Description
+ \row
+ \li
+ Gamma
+ \li
+ Affects the non-linear curve of the lighting.
+ Higher values increase the exposure of mid tones, lightening the
+ image (and decreasing the contrast). A value of \c{1.0} causes no
+ adjustment to the image.
+ \row
+ \li
+ Exposure
+ \li
+ A linear multiplier on the lighting,
+ brightening, or darkening the image overall. A value of \c{0.0}
+ causes no adjustment to the image.
+ \row
+ \li
+ Bloom threshold
+ \li
+ Lighting greater than this value blooms. A value of \c{1.0} corresponds to white
+ in the original render result. Lowering this value causes more areas of the
+ rendered scene to bloom; at a value of \c{0.0} everything in the
+ scene blooms.
+ \row
+ \li
+ Bloom falloff
+ \li
+ Adjusts the amount of bloom. Lower values
result in stronger bloom effect; higher values make the effect more
subtle.
-\endlist
+\endtable
+
+\section1 Usage
+
+To disable bloom and use only the tone mapping, set \uicontrol{Bloom falloff} to
+a sufficiently high value, like \c{999}.
*/
diff --git a/doc/src/10-best-practices/motion-blur-effect.qdoc b/doc/src/10-best-practices/motion-blur-effect.qdoc
index 2ea18623..534db3c9 100644
--- a/doc/src/10-best-practices/motion-blur-effect.qdoc
+++ b/doc/src/10-best-practices/motion-blur-effect.qdoc
@@ -32,16 +32,33 @@
\page motion-blur-effect.html
\ingroup qt3dstudio-best-practices
-\section1 Using Motion Blur
+The motion blur effect takes the image from the previous frame,
+blurs it, fades it by a specified amount, and draws this in the
+transparent areas of the layer. The result is that items moving
+over a transparent background leaves a ghost behind them.
\image Effects-MotionBlur.png
-The \"Motion Blur\" effect takes the image from the previous frame,
-blurs it, fades it by a specified amount, and draws this \e{in the
-transparent areas of the layer}. The end result is that items moving
-over a transparent background will leave a ghost behind them.
+\section1 Properties
-The caveats for this effect are implicit in the above description:
+\table
+ \header
+ \li
+ Property
+ \li
+ Description
+ \row
+ \li
+ Fade Amount
+ \li
+ The amount the trail fades. A value of 0 does not fade the trail at all.
+ The trail is permanent. A value of 1 fades the trail completely, more or
+ less omitting the motion blur effect.
+\endtable
+
+\section1 Usage
+
+When using this effect, you should be aware of the following caveats:
\list
\li
@@ -50,12 +67,13 @@ The caveats for this effect are implicit in the above description:
them.
\li
Only the transparent regions are drawn to. If a moving object passes
- in front of another object on the same layer, there will be no motion
+ in front of another object on the same layer, there is no motion
trail passing over the object.
\endlist
-In the simple image shown above the blue ring is placed on a second
-Layer underneath the Layer with the motion blur effect applied. This
-both allows the 'needle' to leave a blur trail over top of the ring, and
+
+In the image shown above the blue ring is placed on a second
+layer underneath the layer with the motion blur effect applied. This
+both allows the needle to leave a blur trail over the ring, and
also prevents the ring from having a blurry blue halo around it.
*/
diff --git a/doc/src/10-best-practices/practices-index.qdoc b/doc/src/10-best-practices/practices-index.qdoc
index 22c17646..f34c1067 100644
--- a/doc/src/10-best-practices/practices-index.qdoc
+++ b/doc/src/10-best-practices/practices-index.qdoc
@@ -43,6 +43,8 @@
\li \l {Blend Mode}
\li \l {3D Assets}
\li \l {Applying Layer Effects}
+\li \l {Manipulating Element Visibility}
+
\endlist
//! [toc]
diff --git a/doc/src/10-best-practices/screen-space-ao.qdoc b/doc/src/10-best-practices/screen-space-ao.qdoc
new file mode 100644
index 00000000..fbfee194
--- /dev/null
+++ b/doc/src/10-best-practices/screen-space-ao.qdoc
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Screen Space AO
+\page screen-space-ao-effect.html
+\ingroup qt3dstudio-best-practices
+
+Screen space ambient occlusion efficiently approximates the ambient occlusion of you layer
+in real time. It is independent from the layers complexity and works with dynamic scenes.
+
+\image effects-screen-space-ao.png
+
+\table
+ \header
+ \li
+ Pros
+ \li
+ Cons
+ \row
+ \li
+ \list
+ \li
+ Independent from scene complexity.
+ \li
+ No data pre-processing needed.
+ \li
+ Works with dynamic scenes.
+ \li
+ Works in the same consistent way for every pixel on the screen.
+ \li
+ No CPU usage.
+ \endlist
+ \li
+ \list
+ \li
+ Rather local and in many cases view-dependent, as it is dependent on
+ adjacent texel depths which may be generated by any geometry whatsoever.
+ \li
+ Hard to correctly smooth/blur out the noise without bleeding onto objects.
+ \endlist
+\endtable
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Filter Size
+ \li
+ Controls the shadows size.
+ \row
+ \li
+ Distance Scale
+ \li
+ How strong the shadows are.
+ \row
+ \li
+ Distance Bias
+ \li
+ Controls distance offset.
+\endtable
+
+
+\section1 Usage
+
+The layer which the effect is applied to requires depth prepass for the effect to work.
+Make sure in your layer's advanced options "disable depth prepass" is unchecked.
+
+*/
diff --git a/doc/src/10-best-practices/sepia.qdoc b/doc/src/10-best-practices/sepia.qdoc
new file mode 100644
index 00000000..c8633f31
--- /dev/null
+++ b/doc/src/10-best-practices/sepia.qdoc
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Sepia
+\page sepia.html
+\ingroup qt3dstudio-best-practices
+
+Sepia effect will give your layer a warm color tint.
+
+\image effects-sepia.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Amount
+ \li
+ Controls how strong the tint is.
+\endtable
+
+*/
diff --git a/doc/src/10-best-practices/smaa1x.qdoc b/doc/src/10-best-practices/smaa1x.qdoc
new file mode 100644
index 00000000..94fb5958
--- /dev/null
+++ b/doc/src/10-best-practices/smaa1x.qdoc
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title SMAA1X
+\page smaa.html
+\ingroup qt3dstudio-best-practices
+
+Subpixel Morphological Antialiasing is a very efficient GPU-based MLAA implementation,
+capable of handling subpixel features seamlessly, and featuring an improved
+and advanced pattern detection & handling mechanism.
+
+\image Effects-smaa1x.png
+
+
+*/
diff --git a/doc/src/10-best-practices/stylize-scatter.qdoc b/doc/src/10-best-practices/stylize-scatter.qdoc
new file mode 100644
index 00000000..fb212c66
--- /dev/null
+++ b/doc/src/10-best-practices/stylize-scatter.qdoc
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Stylize Scatter
+\page stylize-scatter-effect.html
+\ingroup qt3dstudio-best-practices
+
+The scatter effect scatters the layers pixels around their original
+positions, giving it a smeared look.
+
+\image effects-stylize-scatter.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Scatter Amount
+ \li
+ Controls the scatter amount and displacement area size.
+ \row
+ \li
+ Grain
+ \li
+ Controls the direction where the pixels are displaced.
+ \row
+ \li
+ Randomize Every Frame
+ \li
+ If set to true, the displacement is calculated again for every frame.
+\endtable
+
+\section1 Usage
+
+
+
+*/
diff --git a/doc/src/10-best-practices/tilt-shift-effect.qdoc b/doc/src/10-best-practices/tilt-shift-effect.qdoc
index d2c43fb7..ab0c748a 100644
--- a/doc/src/10-best-practices/tilt-shift-effect.qdoc
+++ b/doc/src/10-best-practices/tilt-shift-effect.qdoc
@@ -32,27 +32,60 @@
\page tilt-shift-effect.html
\ingroup qt3dstudio-best-practices
-\section1 Using Tilt Shift
+The tilt shift effect simulates depth of field in a simple and performant manner.
+Instead of blurring based on the depth buffer, it blurs everything except for a horizontal
+or vertical stripe on the layer.
\image Effects-TiltShift.png
-The \"Tilt Shift\" effect simulates depth of field in a much simpler
-(and more performant) manner. Instead of blurring based on the depth
-buffer, it simply blurs everything except for horizontal stripe on the
-layer. The effect is controlled by the properties:
-
-\list
-\li
- \c{Focus Position} - the vertical placement of the center of
- effect (the 'focused region') on the screen, from top to bottom.
-\li
- \c{Focus Width} - the vertical size of the in-focus region.
-\li
- \c{Blur Amount} - how much the not-in-focus regions are blurred.
-\endlist
-As with the Depth of Field effect, this effect has a
-\c{Debug Rendering} option that you can enable to see where the
-blur will be applied to the Layer. (See above for further description.)
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Focus position
+ \li
+ The vertical placement of the center of the focused area on the screen. A value
+ 0.5 will put the center in the middle of the screen.
+ \row
+ \li
+ Focus width
+ \li
+ The height of the focused area.
+ \row
+ \li
+ Debug rendering
+ \li
+ Allows you to see exactly how the focus variables work.
+ \row
+ \li
+ Blur amount
+ \li
+ The amount of blur applied to the unfocused areas.
+ \row
+ \li
+ Vertical
+ \li
+ Makes the effect work vertically instead of horizontally.
+ \row
+ \li
+ Invert blur
+ \li
+ Inverts the blur so that the center is blurred while the other areas are sharp.
+\endtable
+
+\section1 Usage
+
+To make it easier to set up this effect, enable \uicontrol{Debug focus rendering}. When enabled,
+the scene view switches to a mode showing the amount of blur to be applied. Anything completely
+fogged in white is entirely blurred, anything that is fully black is entirely in focus, and
+shades of grey represent varying amounts of blur in between. It is far easier to turn on this
+mode and adjust the values in the inspector palette until the content you want is bracketed,
+compared to performing distance calculations and entering numbers.
+
\image Effects-TiltShift-Debug.png
*/
diff --git a/doc/src/10-best-practices/vignette.qdoc b/doc/src/10-best-practices/vignette.qdoc
new file mode 100644
index 00000000..1b3aaf4b
--- /dev/null
+++ b/doc/src/10-best-practices/vignette.qdoc
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Vignette
+\page vignette-effect.html
+\ingroup qt3dstudio-best-practices
+
+The vignette effect darkens the corners of your layer.
+
+\image effects-vignette.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Strength
+ \li
+ Changes the opacity of the vignette.
+ \row
+ \li
+ Radius
+ \li
+ Adjust the size of the vignette
+\endtable
+
+*/
diff --git a/doc/src/11-quick-start-guides/quick-start-guide.qdoc b/doc/src/11-quick-start-guides/quick-start-guide.qdoc
index 5a6a6dbf..2c35bb78 100644
--- a/doc/src/11-quick-start-guides/quick-start-guide.qdoc
+++ b/doc/src/11-quick-start-guides/quick-start-guide.qdoc
@@ -116,11 +116,20 @@ textures and maps.
\image objectTimeline.png "Object in timeline"
+\section2 Creating groups
+By selecting multiple objects and clicking \e{Group Objects} from \e{Edit} list or using a
+keyboard shortcut \e{Ctrl+G} you can create a group that contains the objects you had selected.
+
+\image editListGroupObjects.png "Group Objects in Edit list"
+
\section2 Related Content
\table
\row
\li \inlineimage moreinfoicon.png
+ \li \l{studio-inspector-palette.html#group-properties} {Studio: Inspector Palette: Group}
+ \row
+ \li \inlineimage moreinfoicon.png
\li \l{studio-inspector-palette.html#material-properties} {Studio: Inspector Palette: Material}
\endtable
diff --git a/doc/src/animations.qdoc b/doc/src/animations.qdoc
index b094d4b5..3b11f179 100644
--- a/doc/src/animations.qdoc
+++ b/doc/src/animations.qdoc
@@ -71,6 +71,20 @@ playhead in the timeline palette, or by running the presentation in the Studio o
Moving the playhead to a new position, and then changing the value of a property with animation
enabled will create a new keyframe.
+You can click the arrow icon next to the object with animated properties to expand it, this will
+display all animated properties and keyframes.
+
+\image object-animated-properties.png
+
+Furthermore, double-click one of the properties to display the property graph. The property graph
+displays the property animation curves and allows you to edit them.
+
+\image object-animation-channels.png
+
+You can toggle channel visibility by clicking the channel icon on the left side of the scene graph
+(Ctrl + left mouse click to multi select). This function is only available if the animated
+property has more than one channel.
+
\section1 Edit Animations
\section2 Insert Keyframes
@@ -154,7 +168,20 @@ To copy keyframes from one element to another, follow the steps below:
the context menu.
\endlist
-\section2 Interpolation
+\section1 Animation Types
+
+There are three different types of animations in Studio. These are described below.
+
+To change animation type, right-click the property row in the timeline and select
+\uicontrol{Animation Type}.
+
+\image select-animation-type.png
+
+\section2 Linear
+
+With linear interpolation the value changes at the same rate from one value to the next.
+
+\section2 Ease In/Out
As the playhead moves from one keyframe to the next, the Qt 3D Studio
Runtime can perform \e {linear interpolation}, \e {smooth
@@ -173,10 +200,31 @@ keyframe.
\image Studio-Timeline-Interpolation.png
-\note If you find that you are constantly setting your keyframes from
-Smooth to Linear, or vice-versa, you may wish to change the
-\uicontrol{Default Interpolation} setting for new keyframes in the
-\l{studio-menu.html#edit}{Application Preferences}.
+\note You can set the default interpolation values for ease in/out animations
+in the \l{studio-menu.html#edit}{studio preferences}.
+
+\section2 Bezier
+
+Bezier animations are using a bezier curve to define the animation. This gives you much more control
+of the animation and interpolation.
+
+Two or more end points define a bezier curve. Each end point represents the channel value
+of a keyframe. These end points have two control points (handles), or if they are located in the
+beginning or end of the timeline, one control point.
+
+\image bezier-curves.png
+
+\section3 Control Points
+
+Once you have created your animation, you can adjust it by moving the control points. To display
+the control points, first select the end point. Then, to move the control point, drag it with the
+left mouse button. If the end point has two control points, both will move simultaneously. To
+move just one, hold down the Ctrl key while dragging. You cannot move control points past previous
+or next keyframe.
+
+\section3 End Points
+To move an end point horizontally, you will need to move the actual keyframe on the timeline bar. To
+move it vertically, grab it with the mouse and drag it up/down.
\section1 Import Animations
diff --git a/doc/src/bloom.qdoc b/doc/src/bloom.qdoc
new file mode 100644
index 00000000..ee17022a
--- /dev/null
+++ b/doc/src/bloom.qdoc
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Bloom
+\page bloom.html
+\ingroup qt3dstudio-best-practices
+
+The bloom effect gives bright areas in the scene a glow effect and light bleeding to add
+realism to the scene. Shortly described, all parts of the scene lighter than the
+\uicontrol {Threshold of the lumino} value are extracted from the scene. Next, they are blurred,
+brightened, and finally applied on top of the scene.
+
+In the image below, the effect is applied in the right picture.
+
+\image effects-bloom.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Threshold of the lumino
+ \li
+ Objects brighter than this will be part of the filter.
+\endtable
+
+*/
diff --git a/doc/src/blur.qdoc b/doc/src/blur.qdoc
new file mode 100644
index 00000000..c6671d67
--- /dev/null
+++ b/doc/src/blur.qdoc
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Blur
+\page blur.html
+\ingroup qt3dstudio-best-practices
+
+This is a simple blur effect which basically makes several copies of the layer, adds increased
+transparency and offsets the positions of the copies. This creates a blur effect.
+
+\image effects-blur.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Blur amount
+ \li
+ Controls the distance of separated images.
+\endtable
+
+\section1 Usage
+
+The \uicontrol{Blur amount} controls the distance between the images created by the blur effect.
+*/
diff --git a/doc/src/color-master.qdoc b/doc/src/color-master.qdoc
new file mode 100644
index 00000000..c6397abf
--- /dev/null
+++ b/doc/src/color-master.qdoc
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title Color Master
+\page color-master.html
+\ingroup qt3dstudio-best-practices
+
+This effect allows you to control the RGB color levels and saturation of the scene.
+
+In the image below, the effect is applied in the right picture.
+
+\image effects-color-master.png
+
+\section1 Properties
+
+\table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li
+ Red amount
+ \li
+ Controls the amount of red.
+ \row
+ \li
+ Green amount
+ \li
+ Controls the amount of green.
+ \row
+ \li
+ Blue amount
+ \li
+ Controls the amount of blue.
+ \row
+ \li
+ Saturation
+ \li
+ Controls the intensity of the colors.
+\endtable
+
+*/
diff --git a/doc/src/comparison.qdoc b/doc/src/comparison.qdoc
index 19f12e14..6e18e3ba 100644
--- a/doc/src/comparison.qdoc
+++ b/doc/src/comparison.qdoc
@@ -30,9 +30,6 @@
\title Comparison of Qt 3D and Qt 3D Studio
\page comparison-qt3d-qt3dstudio.html
-In short, Qt 3D Studio is built on top of Qt 3D. The flexible architecture of Qt 3D makes it
-suitable to build 3D runtimes, or engines, such as Qt 3D Studio.
-
\section1 Qt 3D
Qt 3D is programmer-oriented engine building toolkit and great for both simple and complex scenes.
@@ -72,7 +69,7 @@ Below, we list some common use cases and how they apply to the two:
\li
Suitable.
\li
- Not possible.
+ Creating meshes and materials dynamically is supported.
\row
\li
Using existing materials and effects.
diff --git a/doc/src/glossary.qdoc b/doc/src/glossary.qdoc
index 950b64be..5e63078b 100644
--- a/doc/src/glossary.qdoc
+++ b/doc/src/glossary.qdoc
@@ -40,86 +40,88 @@ This page provides short explanations of terms used in Qt 3D Studio.
Meaning
\row
\li
- \l{Studio: Action Palette}{Action}
+ \target actions
+ \l {Studio: Action Palette#Creating Actions}{Action}
\li
Actions provide a way to create interactivity in a \l presentation without scripting.
\row
\li
- \l{Studio: Action Palette}{Action palette}
+ \l {Studio: Action Palette}{Action palette}
\li
- The action palette is used to manage \l {action}{actions} for the selected element.
+ The action palette is used to manage \l actions for the selected element.
\row
\li
\target {animation portion}
- \l{Studio: Timeline Palette#Animation portion}{Animation Portion}
+ \l {Studio: Timeline Palette#Animation portion}{Animation Portion}
\li
- To the right of the \l{scene graph} in the \l{timeline palette} is the actual \l timeline.
- The \l{time bar}{time bars} for each element control element lifespan.
+ To the right of the \l {scene graph} in the \l {timeline palette} is the actual timeline.
+ The \l {time bar}{time bars} for each element control element lifespan.
The \l keyframe markers control the timing of the animation. The \l playhead allows the
preview of animation effects.
\row
\li
\target application
- \l{About Qt 3D Studio#Concepts}{Application}
+ \l {About Qt 3D Studio#Application}{Application}
\li
Your application is the entry point of your \l project. It is represented by a single
- \l{uia}{.uia file} at the root of your project folder. This file references the
- \l presentation and \l{sub-presentation}{sub-presentations} in your project.
+ \l {uia}{.uia file} at the root of your project folder. This file references the
+ \l presentation and \l {sub-presentation}{sub-presentations} in your project.
The application is what is displayed by the \l Viewer.
\row
\li
\target asset
- Asset
+ \l {Studio: Project Palette#Using Assets}{Asset}
\li
- Assets are elements which you can use in your \l presentation. Assets can be images, 3D
- models, \l{effect}{effects}, fonts, \l{material}{materials}, \l{shader}{shaders},
- \l {behavior}{scripts} and \l{sub-presentation}{sub-presentations}.
+ Assets are elements which you can use in your \l presentation. Assets can be
+ \l {2D Assets}{images}, \l {3D Assets}{3D models}, \l {effect}{effects},
+ \l {Studio: Project Palette#Fonts}{fonts}, \l {material}{materials}, \l {shader}{shaders},
+ \l {behavior}{scripts} and \l {sub-presentation}{sub-presentations}.
\row
\li
- Asset library
+ \l {Studio: Project Palette#Importing Assets from the Asset Library}{Asset library}
\li
- Included in \l studio is a set of \l{asset}{assets} ranging from images to 3d models.
+ Included in \l studio is a set of \l {asset}{assets} ranging from images to 3d models.
\row
\li
- \l{Studio: Basic Objects Palette}{Basic objects palette}
+ \l {Studio: Basic Objects Palette}{Basic objects palette}
\li
The Basic objects palette provides a mechanism for creating objects unique to a
\l presentation, not represented by a file on disk in your \l {project palette}.
\row
\li
\target behavior
- \l{Using Behavior Scripts}{Behavior}
+ \l {Using Behavior Scripts}{Behavior}
\li
Behavior scripts can be applied to objects to give the specific object a certain behavior.
\row
\li
- \l{Studio: Basic Objects Palette#Component}{Component}
+ \l {Studio: Basic Objects Palette#Component}{Component}
\li
Components are somewhat like mini-scenes. Although they are 3D geometry (not a 2D
composition of rendered layers), they have their own \l {slide}{slides} and
- \l {timeline}{timelines}.
+ \l {timeline palette}{timelines}.
\row
\li
- \l{Using Data Inputs}{Data input}
+ \l {Using Data Inputs}{Data input}
\li
- This makes it possible to control \l timeline animations, object properties and
- \l{slide}{slides} with data.
+ This makes it possible to control \l {Studio: Timeline Palette#Data Input}{timeline}
+ animations, object properties and \l {slide}{slides} with data.
\row
\li
- \l{Studio: Toolbar#Edit Cameras}{Edit cameras}
+ \l {Studio: Toolbar#Edit Cameras}{Edit cameras}
\li
Sometimes you want to move around the 3D space of your scene in the editor without
adjusting the final rendered view. \l Studio calls this concept edit cameras.
\row
\li
\target effect
- \l{Applying Layer Effects}{Effect}
+ \l {Applying Layer Effects}{Effect}
\li
- Each \l layer in a \l presentation may have one or more post-processing effects
- applied to the visual result
+ Each \l layer in a \l presentation may have one or more
+ \l {Applying Layer Effects}{post-processing effects} applied to the visual result.
\row
\li
- \l{Studio: Basic Objects Palette#Group}{Group}
+ \l {Studio: Basic Objects Palette#Group}{Group}
\li
A group is an empty transform element. Attaching models to the group
(placing them as children of the group in the \l {timeline palette}) allows you to
@@ -132,48 +134,48 @@ This page provides short explanations of terms used in Qt 3D Studio.
\e .import files.
\row
\li
- \l{Studio: Inspector Palette}{Inspector palette}
+ \l {Studio: Inspector Palette}{Inspector palette}
\li
The inspector palette is used to control values and animations of element properties.
\row
\li
- \l{Animations#Interpolation}{Interpolation}
+ \l {Animations#Animation Types}{Interpolation}
\li
Interpolation defines the easing of \l keyframe animations.
\row
\li
\target keyframe
- \l{Animations}{Keyframe}
+ \l {Animations}{Keyframe}
\li
A keyframe is a a time marker that stores the value of a property.
A keyframe can for example define the X position for an element. To create an animation,
- add another keyframe for the X position of the same element but in another position on the
- \l timeline. \l Studio will determine the correct X position for all frames between the
- two keyframes.
+ add another \l {Animations#Insert Keyframes}{keyframe} for the X position of the same element
+ but in another position on the timeline. \l Studio will determine the correct X position
+ for all frames between the two keyframes.
\row
\li
\target layer
- \l{About Qt 3D Studio#Concepts}{Layer}
+ \l {About Qt 3D Studio#Layer}{Layer}
\li
A single Studio \l presentation combines one or more layers. The visual result of each
layer comes from rendering a 3D scene, 2D scene (via an orthographic camera),
- or \l{sub-presentation}{sub-presentation}. Layers are then composited with items on upper
+ or \l {sub-presentation}{sub-presentation}. Layers are then composited with items on upper
layers drawing on top of the content on lower layers.
\row
\li
- \l{Studio: Slide Palette#The Master Slide}{Master slide}
+ \l {Studio: Slide Palette#The Master Slide}{Master slide}
\li
Each scene and \l component have one master slide.
Elements placed on this \l slide exist on all slides of that scene or \l component.
\row
\li
- \l{Materials and Shaders#Materials}{Material}
+ \l {Materials and Shaders#Materials}{Material}
\li
Materials define how object surfaces are rendered in \l studio and \l viewer. You can create
your own basic materials, save them in your \l project, and assign them to objects.
\row
\li
- \l{Studio: Scene View and Matte#Matte}{Matte}
+ \l {Studio: Scene View and Matte#Matte}{Matte}
\li
Surrounding the \l {scene view} is the matte. The matte may not be visible if your
\l presentation is larger than the available space.
@@ -185,128 +187,135 @@ This page provides short explanations of terms used in Qt 3D Studio.
\row
\li
\target playhead
- \l{Animations}{Playhead}
+ \l {Animations}{Playhead}
\li
- The playhead in the \l timeline is used to set the time for new keyframes, and for previewing
- animations.
+ The \l {Studio: Timeline Palette#Setting Playhead Time}{playhead} in the timeline is used to
+ set the time for new keyframes, and for previewing animations.
\row
\li
\target presentation
- \l{About Qt 3D Studio#Concepts}{Presentation}
+ \l {About Qt 3D Studio#Presentation}{Presentation}
\li
- Presentations are represented by \l{uip}{.uip files} in your project. A presentation
- has one or more \l{layer}{layers} composited to the screen, comprised of 2D assets
+ Presentations are represented by \l {uip}{.uip files} in your project. A presentation
+ has one or more \l {layer}{layers} composited to the screen, comprised of 2D assets
and 3D assets created in other applications.
Each application can only have one main presentation shown on screen (specified by the
\l {uia}{.uia file}) but this presentation may reference other
- \l{sub-presentation}{sub-presentations}, either on flat layers or as images and textures
+ \l {sub-presentation}{sub-presentations}, either on flat layers or as images and textures
drawn in a scene.
\row
\li
\target project
- \l{About Qt 3D Studio#Concepts}{Project}
+ \l {About Qt 3D Studio#Project}{Project}
\li
A project is simply a folder on your computer holding all the assets needed for your
\l application. When you start a new project, a default folder structure will be created.
\row
\li
\target {project palette}
- \l{Studio: Project Palette}{Project palette}
+ \l {Studio: Project Palette}{Project palette}
\li
The project palette displays the files and folders on disk for your \l project.
Only files usable by \l Studio are displayed in the palette.
\row
\li
- QML Stream
+ \target {qml stream}
+ \l {About Qt 3D Studio#QML}{QML Stream}
\li
- A QML stream is a \e .qml file used as a \l{sub-presentation}.
+ A QML stream is a \e .qml file used as a \l {sub-presentation}.
\row
\li
- \l{Studio: Scene Camera Palette}{Scene Camera palette}
+ \l {Studio: Scene Camera Palette}{Scene Camera palette}
\li
The scene camera palette allows you to zoom in to pixel perfect level with the scene camera.
\row
\li
\target {scene graph}
- \l{Studio: Timeline Palette#Scene Graph}{Scene graph}
+ \l {Studio: Timeline Palette#Scene Graph}{Scene graph}
\li
- The left half of the \l{timeline palette} shows the scene graph where all elements in your
+ The left half of the \l {timeline palette} shows the scene graph where all elements in your
\l presentation for the current \l slide.
\row
\li
\target {scene view}
- \l{Studio: Scene View and Matte#Scene View}{Scene view}
+ \l {Studio: Scene View and Matte#Scene View}{Scene view}
\li
The scene view is the center region of \l Studio, showing you the visual result of rendering
- and compositing the \l{layer}{layers} of your \l presentation, and also allowing you to
+ and compositing the \l {layer}{layers} of your \l presentation, and also allowing you to
select and transform elements graphically.
\row
\li
\target shader
- \l{Materials}{Shader}
+ \l {Materials and Shaders#Shaders}{Shader}
\li
Shaders are arbitrary GLSL Shaders, wrapped in a file format providing an artist-friendly
interface for adjusting properties in \l studio.
\row
\li
- \l{Studio:Slide Palette}{Slide}
+ \l {Studio: Basic Objects Palette#Signal}{Signal}
+ \li
+ A signal is a lightweight object specifically designed for triggering \l actions during
+ \l {Studio: Timeline Palette#Action Indicators}{timeline} animations.
+ \row
+ \li
+ \l {Studio:Slide Palette#Using Slides}{Slide}
\li
A Studio \l presentation combines 3D assets with animations and slides.
Slides can be thought of as states and provide visual variations within the \l presentation.
\row
\li
- \l{Studio:Slide Palette}{Slide palette}
+ \l {Studio:Slide Palette}{Slide palette}
\li
The slide palette shows all slides in a \l presentation or a \l component.
\row
\li
\target studio
- \l{About Qt 3D Studio#Concepts}{Studio}
+ \l {About Qt 3D Studio#Applications}{Studio}
\li
An authoring tool for creating interactive 3D presentations and applications.
\row
\li
\target {sub-presentation}
- \l{Using Sub-Presentations}{Sub-presentation}
+ \l {Using Sub-Presentations}{Sub-presentation}
\li
- Sub-Presentations is a feature which allows a \l studio \l presentation (\l{uia}{.uia file})
- or a QML file to be embedded in a \l studio \l presentation.
+ Sub-Presentation is a feature which allows a \l studio \l presentation (\l {uip}{.uip file})
+ or a \l {qml stream}{QML} file to be embedded in a \l studio \l presentation.
\row
\li
\target {time bar}
- \l{Studio: Timeline Palette#Adjusting Time Bars}{Time bar}
+ \l {Studio: Timeline Palette#Adjusting Time Bars}{Time bar}
\li
- Each element has a time bar in the \l timeline. The time bar control the lifespan
- during which the element is active.
+ Each element has a time bar in the \l {timeline palette}{timeline}. The time bar control the
+ lifespan during which the element is active.
\row
\li
\target {timeline palette}
- \l{Studio: Timeline Palette}{Timeline palette}
+ \l {Studio: Timeline Palette}{Timeline palette}
\li
The timeline palette provides direct access to all elements in your scene,
- and also gives you control over the animation and timing within a \l slide.
+ and also gives you control over the animation and timing within a \l slide.
The timeline palette is comprised of two connected sections: the \l {scene graph} and the
\l {animation portion}.
\row
\li
\target uia
- \l{About Qt 3D Studio#Concepts}{.uia file}
+ \l {About Qt 3D Studio#Application}{.uia file}
\li
- The \e .uia file is the application file, it is by default located in the root folder of
- your \l project.
+ The \e .uia file is the application file, and it is located in the root folder of
+ your \l project by default.
\row
\li
\target uip
- \l{About Qt 3D Studio#Concepts}{.uip file}
+ \l {About Qt 3D Studio#Presentation}{.uip file}
\li
- The \e .iup file is a presentation file. A \l project can have one or more presentation files
+ The \e .uip file is a presentation file. A \l project can have one or more presentation files
located in \e presentations folder of your \l project.
\row
\li
\target viewer
- \l{About Qt 3D Studio#Concepts}{Viewer}
+ \l {About Qt 3D Studio#Applications}{Viewer}
\li
A runtime player to test and deploy interfaces created in \l Studio.
\endtable
diff --git a/doc/src/images/ApplicationPreferences.png b/doc/src/images/ApplicationPreferences.png
index 69b57677..a191d256 100644
--- a/doc/src/images/ApplicationPreferences.png
+++ b/doc/src/images/ApplicationPreferences.png
Binary files differ
diff --git a/doc/src/images/Effects-DOF-Debug.png b/doc/src/images/Effects-DOF-Debug.png
index b623935c..86714239 100644
--- a/doc/src/images/Effects-DOF-Debug.png
+++ b/doc/src/images/Effects-DOF-Debug.png
Binary files differ
diff --git a/doc/src/images/Effects-TiltShift-Debug.png b/doc/src/images/Effects-TiltShift-Debug.png
index dfea44ef..c8253bae 100644
--- a/doc/src/images/Effects-TiltShift-Debug.png
+++ b/doc/src/images/Effects-TiltShift-Debug.png
Binary files differ
diff --git a/doc/src/images/Studio-Basic-Signal.png b/doc/src/images/Studio-Basic-Signal.png
new file mode 100644
index 00000000..ba241de9
--- /dev/null
+++ b/doc/src/images/Studio-Basic-Signal.png
Binary files differ
diff --git a/doc/src/images/Studio-SceneView.png b/doc/src/images/Studio-SceneView.png
index 6b7fd212..e9b4bbdf 100644
--- a/doc/src/images/Studio-SceneView.png
+++ b/doc/src/images/Studio-SceneView.png
Binary files differ
diff --git a/doc/src/images/Studio-Timeline-Animation.png b/doc/src/images/Studio-Timeline-Animation.png
index c8247be9..bacd47c4 100644
--- a/doc/src/images/Studio-Timeline-Animation.png
+++ b/doc/src/images/Studio-Timeline-Animation.png
Binary files differ
diff --git a/doc/src/images/Studio-Timeline-SceneGraph.png b/doc/src/images/Studio-Timeline-SceneGraph.png
index b39908b3..0f8cb5b8 100644
--- a/doc/src/images/Studio-Timeline-SceneGraph.png
+++ b/doc/src/images/Studio-Timeline-SceneGraph.png
Binary files differ
diff --git a/doc/src/images/Studio-Timeline-SignalAction.png b/doc/src/images/Studio-Timeline-SignalAction.png
new file mode 100644
index 00000000..e8f24e3b
--- /dev/null
+++ b/doc/src/images/Studio-Timeline-SignalAction.png
Binary files differ
diff --git a/doc/src/images/Studio-Toolbar-EditCameras.png b/doc/src/images/Studio-Toolbar-EditCameras.png
index 44eb20c8..22fd58bc 100644
--- a/doc/src/images/Studio-Toolbar-EditCameras.png
+++ b/doc/src/images/Studio-Toolbar-EditCameras.png
Binary files differ
diff --git a/doc/src/images/addAssets.png b/doc/src/images/addAssets.png
index 0aeb610b..c3384fad 100644
--- a/doc/src/images/addAssets.png
+++ b/doc/src/images/addAssets.png
Binary files differ
diff --git a/doc/src/images/additive-gradient-icon.png b/doc/src/images/additive-gradient-icon.png
new file mode 100644
index 00000000..efb7ab70
--- /dev/null
+++ b/doc/src/images/additive-gradient-icon.png
Binary files differ
diff --git a/doc/src/images/bezier-curves.png b/doc/src/images/bezier-curves.png
new file mode 100644
index 00000000..5a0a0319
--- /dev/null
+++ b/doc/src/images/bezier-curves.png
Binary files differ
diff --git a/doc/src/images/blender-fbx-export-axis.png b/doc/src/images/blender-fbx-export-axis.png
new file mode 100644
index 00000000..2a5b234f
--- /dev/null
+++ b/doc/src/images/blender-fbx-export-axis.png
Binary files differ
diff --git a/doc/src/images/bloom-icon.png b/doc/src/images/bloom-icon.png
new file mode 100644
index 00000000..c46a905d
--- /dev/null
+++ b/doc/src/images/bloom-icon.png
Binary files differ
diff --git a/doc/src/images/blur-icon.png b/doc/src/images/blur-icon.png
new file mode 100644
index 00000000..aa5bf441
--- /dev/null
+++ b/doc/src/images/blur-icon.png
Binary files differ
diff --git a/doc/src/images/brush-strokes-icon.png b/doc/src/images/brush-strokes-icon.png
new file mode 100644
index 00000000..4a3b7194
--- /dev/null
+++ b/doc/src/images/brush-strokes-icon.png
Binary files differ
diff --git a/doc/src/images/chromatic-aberration-icon.png b/doc/src/images/chromatic-aberration-icon.png
new file mode 100644
index 00000000..584ccdff
--- /dev/null
+++ b/doc/src/images/chromatic-aberration-icon.png
Binary files differ
diff --git a/doc/src/images/color-master-icon.png b/doc/src/images/color-master-icon.png
new file mode 100644
index 00000000..e0853660
--- /dev/null
+++ b/doc/src/images/color-master-icon.png
Binary files differ
diff --git a/doc/src/images/corona-icon.png b/doc/src/images/corona-icon.png
new file mode 100644
index 00000000..31cbfa68
--- /dev/null
+++ b/doc/src/images/corona-icon.png
Binary files differ
diff --git a/doc/src/images/datainput-meta.png b/doc/src/images/datainput-meta.png
index 2e399dc1..aeee877a 100644
--- a/doc/src/images/datainput-meta.png
+++ b/doc/src/images/datainput-meta.png
Binary files differ
diff --git a/doc/src/images/desaturate-icon.png b/doc/src/images/desaturate-icon.png
new file mode 100644
index 00000000..454b5baa
--- /dev/null
+++ b/doc/src/images/desaturate-icon.png
Binary files differ
diff --git a/doc/src/images/distortion-ripple-icon.png b/doc/src/images/distortion-ripple-icon.png
new file mode 100644
index 00000000..c9f3a92f
--- /dev/null
+++ b/doc/src/images/distortion-ripple-icon.png
Binary files differ
diff --git a/doc/src/images/distortion-sphere-icon.png b/doc/src/images/distortion-sphere-icon.png
new file mode 100644
index 00000000..0a01e33a
--- /dev/null
+++ b/doc/src/images/distortion-sphere-icon.png
Binary files differ
diff --git a/doc/src/images/distortion-spiral-icon.png b/doc/src/images/distortion-spiral-icon.png
new file mode 100644
index 00000000..66458fe2
--- /dev/null
+++ b/doc/src/images/distortion-spiral-icon.png
Binary files differ
diff --git a/doc/src/images/edge-detect-icon.png b/doc/src/images/edge-detect-icon.png
new file mode 100644
index 00000000..e2a0dfbf
--- /dev/null
+++ b/doc/src/images/edge-detect-icon.png
Binary files differ
diff --git a/doc/src/images/editListGroupObjects.png b/doc/src/images/editListGroupObjects.png
new file mode 100644
index 00000000..f454ffc7
--- /dev/null
+++ b/doc/src/images/editListGroupObjects.png
Binary files differ
diff --git a/doc/src/images/effects-additive-gradient.png b/doc/src/images/effects-additive-gradient.png
new file mode 100644
index 00000000..99553408
--- /dev/null
+++ b/doc/src/images/effects-additive-gradient.png
Binary files differ
diff --git a/doc/src/images/effects-bloom.png b/doc/src/images/effects-bloom.png
new file mode 100644
index 00000000..98849272
--- /dev/null
+++ b/doc/src/images/effects-bloom.png
Binary files differ
diff --git a/doc/src/images/effects-blur.png b/doc/src/images/effects-blur.png
new file mode 100644
index 00000000..53594a2a
--- /dev/null
+++ b/doc/src/images/effects-blur.png
Binary files differ
diff --git a/doc/src/images/effects-brush-strokes.png b/doc/src/images/effects-brush-strokes.png
new file mode 100644
index 00000000..9d9b7c46
--- /dev/null
+++ b/doc/src/images/effects-brush-strokes.png
Binary files differ
diff --git a/doc/src/images/effects-chromatic-aberration.png b/doc/src/images/effects-chromatic-aberration.png
new file mode 100644
index 00000000..92f0305e
--- /dev/null
+++ b/doc/src/images/effects-chromatic-aberration.png
Binary files differ
diff --git a/doc/src/images/effects-color-master.png b/doc/src/images/effects-color-master.png
new file mode 100644
index 00000000..40c4c2fe
--- /dev/null
+++ b/doc/src/images/effects-color-master.png
Binary files differ
diff --git a/doc/src/images/effects-corona.png b/doc/src/images/effects-corona.png
new file mode 100644
index 00000000..3e40ec53
--- /dev/null
+++ b/doc/src/images/effects-corona.png
Binary files differ
diff --git a/doc/src/images/effects-desaturate.png b/doc/src/images/effects-desaturate.png
new file mode 100644
index 00000000..0a01bea5
--- /dev/null
+++ b/doc/src/images/effects-desaturate.png
Binary files differ
diff --git a/doc/src/images/effects-distortion-ripple.png b/doc/src/images/effects-distortion-ripple.png
new file mode 100644
index 00000000..16acd406
--- /dev/null
+++ b/doc/src/images/effects-distortion-ripple.png
Binary files differ
diff --git a/doc/src/images/effects-distortion-sphere.png b/doc/src/images/effects-distortion-sphere.png
new file mode 100644
index 00000000..26918d55
--- /dev/null
+++ b/doc/src/images/effects-distortion-sphere.png
Binary files differ
diff --git a/doc/src/images/effects-distortion-spiral.png b/doc/src/images/effects-distortion-spiral.png
new file mode 100644
index 00000000..16a72ed0
--- /dev/null
+++ b/doc/src/images/effects-distortion-spiral.png
Binary files differ
diff --git a/doc/src/images/effects-edge-detect.png b/doc/src/images/effects-edge-detect.png
new file mode 100644
index 00000000..b5033849
--- /dev/null
+++ b/doc/src/images/effects-edge-detect.png
Binary files differ
diff --git a/doc/src/images/effects-emboss.png b/doc/src/images/effects-emboss.png
new file mode 100644
index 00000000..2014f3bc
--- /dev/null
+++ b/doc/src/images/effects-emboss.png
Binary files differ
diff --git a/doc/src/images/effects-frame-flipper.png b/doc/src/images/effects-frame-flipper.png
new file mode 100644
index 00000000..1c7a37e2
--- /dev/null
+++ b/doc/src/images/effects-frame-flipper.png
Binary files differ
diff --git a/doc/src/images/effects-fullscreen-texture-overlay.png b/doc/src/images/effects-fullscreen-texture-overlay.png
new file mode 100644
index 00000000..af15778e
--- /dev/null
+++ b/doc/src/images/effects-fullscreen-texture-overlay.png
Binary files differ
diff --git a/doc/src/images/effects-screen-space-ao.png b/doc/src/images/effects-screen-space-ao.png
new file mode 100644
index 00000000..7062d04f
--- /dev/null
+++ b/doc/src/images/effects-screen-space-ao.png
Binary files differ
diff --git a/doc/src/images/effects-sepia.png b/doc/src/images/effects-sepia.png
new file mode 100644
index 00000000..1d46583f
--- /dev/null
+++ b/doc/src/images/effects-sepia.png
Binary files differ
diff --git a/doc/src/images/effects-smaa1x.png b/doc/src/images/effects-smaa1x.png
new file mode 100644
index 00000000..6ce6ab91
--- /dev/null
+++ b/doc/src/images/effects-smaa1x.png
Binary files differ
diff --git a/doc/src/images/effects-stylize-scatter.png b/doc/src/images/effects-stylize-scatter.png
new file mode 100644
index 00000000..e249f49d
--- /dev/null
+++ b/doc/src/images/effects-stylize-scatter.png
Binary files differ
diff --git a/doc/src/images/effects-vignette.png b/doc/src/images/effects-vignette.png
new file mode 100644
index 00000000..f3e0d27c
--- /dev/null
+++ b/doc/src/images/effects-vignette.png
Binary files differ
diff --git a/doc/src/images/emboss-icon.png b/doc/src/images/emboss-icon.png
new file mode 100644
index 00000000..c59098d5
--- /dev/null
+++ b/doc/src/images/emboss-icon.png
Binary files differ
diff --git a/doc/src/images/frame-flipper-icon.png b/doc/src/images/frame-flipper-icon.png
new file mode 100644
index 00000000..2c34e609
--- /dev/null
+++ b/doc/src/images/frame-flipper-icon.png
Binary files differ
diff --git a/doc/src/images/fullscreen-texture-overlay-icon.png b/doc/src/images/fullscreen-texture-overlay-icon.png
new file mode 100644
index 00000000..9fbda5c7
--- /dev/null
+++ b/doc/src/images/fullscreen-texture-overlay-icon.png
Binary files differ
diff --git a/doc/src/images/materials-category-dummy.png b/doc/src/images/materials-category-dummy.png
new file mode 100644
index 00000000..5e66e737
--- /dev/null
+++ b/doc/src/images/materials-category-dummy.png
Binary files differ
diff --git a/doc/src/images/materials-category-several.png b/doc/src/images/materials-category-several.png
new file mode 100644
index 00000000..5ef32fb3
--- /dev/null
+++ b/doc/src/images/materials-category-several.png
Binary files differ
diff --git a/doc/src/images/new-data-input.png b/doc/src/images/new-data-input.png
index 486fd0ff..a52166a9 100644
--- a/doc/src/images/new-data-input.png
+++ b/doc/src/images/new-data-input.png
Binary files differ
diff --git a/doc/src/images/object-amination-channels.png b/doc/src/images/object-amination-channels.png
new file mode 100644
index 00000000..c629aeae
--- /dev/null
+++ b/doc/src/images/object-amination-channels.png
Binary files differ
diff --git a/doc/src/images/object-animated-properties.png b/doc/src/images/object-animated-properties.png
new file mode 100644
index 00000000..172a765e
--- /dev/null
+++ b/doc/src/images/object-animated-properties.png
Binary files differ
diff --git a/doc/src/images/object-animation-channels.png b/doc/src/images/object-animation-channels.png
new file mode 100644
index 00000000..c629aeae
--- /dev/null
+++ b/doc/src/images/object-animation-channels.png
Binary files differ
diff --git a/doc/src/images/screen-space-ao-icon.png b/doc/src/images/screen-space-ao-icon.png
new file mode 100644
index 00000000..ad9c0468
--- /dev/null
+++ b/doc/src/images/screen-space-ao-icon.png
Binary files differ
diff --git a/doc/src/images/select-animation-type.png b/doc/src/images/select-animation-type.png
new file mode 100644
index 00000000..32fa2b1a
--- /dev/null
+++ b/doc/src/images/select-animation-type.png
Binary files differ
diff --git a/doc/src/images/sepia-icon.png b/doc/src/images/sepia-icon.png
new file mode 100644
index 00000000..d248ee2e
--- /dev/null
+++ b/doc/src/images/sepia-icon.png
Binary files differ
diff --git a/doc/src/images/smaa1x-icon.png b/doc/src/images/smaa1x-icon.png
new file mode 100644
index 00000000..c6a989fc
--- /dev/null
+++ b/doc/src/images/smaa1x-icon.png
Binary files differ
diff --git a/doc/src/images/stylize-scatter-icon.png b/doc/src/images/stylize-scatter-icon.png
new file mode 100644
index 00000000..b9747566
--- /dev/null
+++ b/doc/src/images/stylize-scatter-icon.png
Binary files differ
diff --git a/doc/src/images/timeline-datainput.png b/doc/src/images/timeline-datainput.png
index be359d63..6cfb3366 100644
--- a/doc/src/images/timeline-datainput.png
+++ b/doc/src/images/timeline-datainput.png
Binary files differ
diff --git a/doc/src/images/variant-tags-panel.png b/doc/src/images/variant-tags-panel.png
index b5f8f29d..0ec3aa9f 100644
--- a/doc/src/images/variant-tags-panel.png
+++ b/doc/src/images/variant-tags-panel.png
Binary files differ
diff --git a/doc/src/images/vignette-icon.png b/doc/src/images/vignette-icon.png
new file mode 100644
index 00000000..bc130d01
--- /dev/null
+++ b/doc/src/images/vignette-icon.png
Binary files differ
diff --git a/doc/src/layers.qdoc b/doc/src/layers.qdoc
index 6bec78dc..016ee81f 100644
--- a/doc/src/layers.qdoc
+++ b/doc/src/layers.qdoc
@@ -116,4 +116,15 @@ the order objects are rendered.
\l{Using Variant Tags}{Variant tags} makes it possible to exclude layers during loading to
optimize performance.
+\section2 Dynamic Resize
+The Dynamic Resize property causes the layer to be dynamically resized based on the content.
+This makes the layer texture as small as it can be while still showing all the content.
+Thus effects like SSAA can be done more efficiently on the layer, since the empty space around
+the content doesn't take up computing power. This can also, depending on the hardware, cause
+performance problems due to constant resizing. This can be mitigated with the Padding property.
+While resizing may cause problems on the GPU side, the content bounds calculation also takes time
+on the CPU. If more inaccurate bounds are enough, Combine Bounds can be used to have less
+calculations per object in the layer. The user has to balance the performance cost of the resize
+to the performance gain of the lower texture size when evaluating the use of this feature.
+
*/
diff --git a/doc/src/materials-shaders.qdoc b/doc/src/materials-shaders.qdoc
index c361bcbe..390d2e0e 100644
--- a/doc/src/materials-shaders.qdoc
+++ b/doc/src/materials-shaders.qdoc
@@ -82,7 +82,7 @@ To create a new basic material, do one of the following:
\li
\list 1
\li
- Anywhere in the project palette, right-click and select
+ Right-click the \uicontrol materials folder in the project palette and select
\uicontrol {Create > Basic Material} from the context menu.
\li
A new material is now created in the \uicontrol materials folder. In the inspector palette
@@ -113,7 +113,7 @@ To apply a material to an object, do one of the following:
material to the top-most material slot.
\image assign-material.png
\li
- First, select the material in the scene graph. Then, in the inspector palette, set desired
+ First, select the material slot in the scene graph. Then, in the inspector palette, set desired
material as the \uicontrol{Source Material} property.
\image assign-material-inspector.png
\endlist
diff --git a/doc/src/whatsnew.qdoc b/doc/src/whatsnew.qdoc
new file mode 100644
index 00000000..5a68ce67
--- /dev/null
+++ b/doc/src/whatsnew.qdoc
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+
+\title What's New
+\page whatsnew.html
+
+\section1 New Features in Qt 3D Studio 2.8
+
+\section2 Image Filtering
+
+It is now possible to specify
+\l{studio-inspector-palette.html#Image Properties}{minification and magnification filters} for
+the Images. This enables mipmapping for the textures.
+
+\section2 Custom Material and Effect Textures
+
+The Custom Material and Effect Textures have been converted to use Images. This means that the same
+image properties as previously only available for the standard materials can now be used to change
+the texture properties for the user-defined shaders. In order to support the image transformation,
+new per-texture uniforms and functions have been added to access transformed texture coordinates and
+texture sample. See \l{custom-material-reference.html#Accessing Textures with Image Transformations}
+{Accessing Textures with Image Transformations} how to use them in the shaders.
+
+When old presentation is opened for the first time with Studio Editor, it needs to convert
+the old texture paths into Images. If the presentation has sub-presentations they should be opened
+separately to ensure that the whole presentation has the same presentation version.
+
+Controlling the Custom property texture using API has been changed to reflect this change. They
+can now be controlled the same way as standard material textures.
+See \l {custom-materials-effects.html#Controlling Custom Properties}{Controlling Custom Properties}
+for more details.
+
+\section2 Timeline Signals
+
+It is now possible to trigger actions from timeline using the new
+\l{studio-basic-objects-palette.html#Signal}{Signal} type.
+
+*/
diff --git a/doc/style/qt5-sidebar.html b/doc/style/qt5-sidebar.html
index 765cf6ff..0259d2ca 100644
--- a/doc/style/qt5-sidebar.html
+++ b/doc/style/qt5-sidebar.html
@@ -1,7 +1,6 @@
<div class="sectionlist normallist">
<div class="heading">
- <a name="reference"></a>
- <h2 id="reference">Qt 3D Studio</h2>
+ <h2>Qt 3D Studio</h2>
</div>
<div class="indexboxcont indexboxbar">
<ul>
@@ -11,8 +10,18 @@
<li><a href="scripting.html">Scripting</a></li>
<li><a href="deployment.html">Deployment</a></li>
<li><a href="getting-help.html">Getting Help</a></li>
- <li><a href="runtime/index.html">Runtime</a></li>
- <li><a href="runtime/qt3d-runtime-qml.html">QML API Reference</a></li>
- <li><a href="runtime/qt3d-runtime-cpp.html">C++ API Reference</a></li>
</ul>
</div>
+</div>
+<div class="sectionlist normallist">
+ <div class="heading">
+ <h2>OpenGL Runtime</h2>
+ </div>
+ <div class="indexboxcont indexboxbar">
+ <ul>
+ <li><a href="openglruntime/index.html">Table of Contents</a></li>
+ <li><a href="openglruntime/qtstudio3d-opengl-qmlmodule.html">QML API Reference</a></li>
+ <li><a href="openglruntime/openglruntime-module.html">C++ API Reference</a></li>
+ </ul>
+ </div>
+</div>
diff --git a/product_dependencies.yaml b/product_dependencies.yaml
new file mode 100644
index 00000000..b6035e89
--- /dev/null
+++ b/product_dependencies.yaml
@@ -0,0 +1,3 @@
+dependencies:
+ ../../qt/tqtc-qt5.git:
+ ref: "b76f628f02c32c28fecb7b7cfa561f9861fd3326"
diff --git a/qt3dstudio.pro b/qt3dstudio.pro
index 62f7e50d..e1c60dd8 100644
--- a/qt3dstudio.pro
+++ b/qt3dstudio.pro
@@ -9,11 +9,6 @@ requires(qtHaveModule(quick))
requires(qtHaveModule(qml))
requires(qtHaveModule(opengl))
-#TODO: QT3DS-3660 fix developer builds of Qt 3D Studio editor
-linux:{
-requires(!contains(QT_CONFIG,private_tests))
-}
-
SUBDIRS += \
doc
@@ -31,7 +26,7 @@ load(qt_parts)
# Qt3DStudio and Qt3DViewer executables/application bundles are installed to.
# The required Qt libraries are copied into that directory/bundles.
!build_pass|!debug_and_release {
- !mingw:win32|macos {
+ win32|macos {
macos {
deploytool = macdeployqt
exesuffix = .app
@@ -67,9 +62,9 @@ load(qt_parts)
# copy QtStudio3D.dll
release {
- QTSTUDIO3D_LIB = Qt5Studio3D.dll
+ QTSTUDIO3D_LIB = Qt5Studio3D$${QT_LIBINFIX}.dll
} else {
- QTSTUDIO3D_LIB = Qt5Studio3Dd.dll
+ QTSTUDIO3D_LIB = Qt5Studio3D$${QT_LIBINFIX}d.dll
}
QMAKE_EXTRA_TARGETS += copyStudio3D
deployTarget.depends += copyStudio3D
@@ -104,33 +99,6 @@ load(qt_parts)
$$DEPLOY_TOOL $$shell_quote(\$(DEPLOY_DIR)/Qt3DViewer$${exesuffix}) \
$$EXTRA_DEPLOY_OPTIONS
}
-
- greaterThan(QT_MAJOR_VERSION, 5)|greaterThan(QT_MINOR_VERSION, 10) {
- # Viewer 2.0
- win32 {
- # Viewer 2.0 has similar issues with dependent library naming as viewer 1.0,
- # but it only has one library that is causing problems and no qml (so far),
- # so lets just copy the problem lib over to where windeployqt can find it,
- # i.e. under Qt's bin dir. This pollutes the Qt's bin dir a bit, but as the main
- # use case for this is gathering installer content in CI after everything is
- # already built, this shouldn't be a problem.
- release {
- RUNTIME2_LIB = Qt53DStudioRuntime2.dll
- } else {
- RUNTIME2_LIB = Qt53DStudioRuntime2d.dll
- }
- QMAKE_EXTRA_TARGETS += copyRuntime2
- deployTarget.depends += copyRuntime2
- copyRuntime2.commands = \
- $$QMAKE_COPY $$shell_quote($$shell_path( \
- $$OUT_PWD/src/Runtime/qt3d-runtime/bin/$$RUNTIME2_LIB)) \
- $$shell_quote($$shell_path($$[QT_INSTALL_BINS]/$$RUNTIME2_LIB))
- }
-
- deployTarget.commands += && \
- $$DEPLOY_TOOL $$shell_quote(\$(DEPLOY_DIR)/q3dsviewer$${exesuffix}) \
- $$EXTRA_DEPLOY_OPTIONS
- }
} else {
# Create a dummy target for other platforms
deployTarget.commands = @echo deployqt target is not supported for this platform.
diff --git a/src/3rdparty/ColladaDOM b/src/3rdparty/ColladaDOM
-Subproject 7c7d1bab302c9101695026936a946adf6ecf282
+Subproject 89383cf7d69e3721fc284456fb055c97a0d0013
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp
index 104225f0..beb4b358 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp
+++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp
@@ -131,6 +131,7 @@ void CmdDataModel::DataModelUndo()
Undo(m_Consumer->m_TransactionList);
RunUndoNotifications();
m_Doc.UpdateDatainputMap();
+ m_Doc.ensureActiveCamera();
}
}
@@ -153,6 +154,7 @@ void CmdDataModel::DataModelRedo()
Redo(m_Consumer->m_TransactionList);
RunDoNotifications();
m_Doc.UpdateDatainputMap();
+ m_Doc.ensureActiveCamera();
}
}
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModelChangeKeyframe.h b/src/Authoring/Client/Code/Core/Commands/CmdDataModelChangeKeyframe.h
index 692e9634..08c28a79 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdDataModelChangeKeyframe.h
+++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModelChangeKeyframe.h
@@ -43,16 +43,13 @@
#include "CmdDataModelBase.h"
#include "Qt3DSDMStudioSystem.h"
-class CCmdDataModelSetKeyframeTime : public CCmdDataModelBase<float>
+class CCmdDataModelSetKeyframeTime : public CCmdDataModelBase<long>
{
-protected: // Members
- qt3dsdm::Qt3DSDMKeyframeHandle m_Keyframe;
-public: // Construction
- //@param inTime is in secs
- CCmdDataModelSetKeyframeTime(CDoc *inDoc, qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, float inTime)
- : CCmdDataModelBase(inDoc, inTime)
- , m_Keyframe(inKeyframe)
+public:
+ CCmdDataModelSetKeyframeTime(CDoc *doc, qt3dsdm::Qt3DSDMKeyframeHandle keyframe, long time)
+ : CCmdDataModelBase(doc, time)
+ , m_Keyframe(keyframe)
{
}
~CCmdDataModelSetKeyframeTime() {}
@@ -61,26 +58,25 @@ public: // Construction
{
qt3dsdm::IAnimationCore *theAnimationCore = m_Doc->GetStudioSystem()->GetAnimationCore();
qt3dsdm::TKeyframe theKeyframe = theAnimationCore->GetKeyframeData(m_Keyframe);
- theKeyframe = SetKeyframeSeconds(theKeyframe, m_Value);
+ theKeyframe = setKeyframeTime(theKeyframe, m_Value);
theAnimationCore->SetKeyframeData(m_Keyframe, theKeyframe);
}
- //======================================================================
- // ToString
- //======================================================================
QString ToString() override
{
return QObject::tr("Set Keyframe Time");
}
+
+protected:
+ qt3dsdm::Qt3DSDMKeyframeHandle m_Keyframe;
};
class CCmdDataModelSetKeyframeValue : public CCmdDataModelBase<float>
{
-protected: // Members
+protected:
qt3dsdm::Qt3DSDMKeyframeHandle m_Keyframe;
-public: // Construction
- //@param inTime is in secs
+public:
CCmdDataModelSetKeyframeValue(CDoc *inDoc, qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe,
float inValue)
: CCmdDataModelBase(inDoc, inValue)
@@ -93,13 +89,10 @@ public: // Construction
{
qt3dsdm::IAnimationCore *theAnimationCore = m_Doc->GetStudioSystem()->GetAnimationCore();
qt3dsdm::TKeyframe theKeyframe = theAnimationCore->GetKeyframeData(m_Keyframe);
- theKeyframe = SetKeyframeValue(theKeyframe, m_Value);
+ theKeyframe = setKeyframeValue(theKeyframe, m_Value);
theAnimationCore->SetKeyframeData(m_Keyframe, theKeyframe);
}
- //======================================================================
- // ToString
- //======================================================================
QString ToString() override
{
return QObject::tr("Set Keyframe Value");
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h b/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h
index 0d99aa7f..c07170c2 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h
+++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h
@@ -28,13 +28,8 @@
****************************************************************************/
#ifndef INCLUDED_CMD_DATAMODEL_INSERTKEYFRAME_H
-#define INCLUDED_CMD_DATAMODEL_INSERTKEYFRAME_H 1
+#define INCLUDED_CMD_DATAMODEL_INSERTKEYFRAME_H
-#pragma once
-
-//==============================================================================
-// Include
-//==============================================================================
#include "Cmd.h"
#include "CmdDataModel.h"
#include "Doc.h"
@@ -51,74 +46,60 @@ public:
struct STimeKeyframeData
{
qt3dsdm::Qt3DSDMPropertyHandle m_Property;
- float m_KeyframeTime;
- qt3dsdm::SGetOrSetKeyframeInfo m_Infos[3];
+ long m_KeyframeTime;
+ qt3dsdm::SGetOrSetKeyframeInfo m_Infos[4];
size_t m_ValidInfoCount;
- STimeKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inKeyframeTime,
+ STimeKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, long inKeyframeTime,
qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount)
: m_Property(inProperty)
, m_KeyframeTime(inKeyframeTime)
{
- m_ValidInfoCount = inInfoCount <= 3 ? inInfoCount : 3;
- for (size_t idx = 0, end = m_ValidInfoCount; idx < end; ++idx) {
+ m_ValidInfoCount = inInfoCount <= 4 ? inInfoCount : 4;
+ for (size_t idx = 0, end = m_ValidInfoCount; idx < end; ++idx)
m_Infos[idx] = inInfos[idx];
- }
}
};
protected:
typedef std::vector<STimeKeyframeData> TKeyframeDataList;
-protected: // Members
CDoc *m_Doc;
qt3dsdm::Qt3DSDMInstanceHandle m_Instance;
TKeyframeDataList m_KeyframeDataList;
-public: // Construction
- //@param inTime is in secs
- CCmdDataModelInsertKeyframe(CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance,
- qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inKeyframeTime,
- qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount)
+public:
+ CCmdDataModelInsertKeyframe(CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance)
: qt3dsdm::CmdDataModel(*inDoc)
, m_Doc(inDoc)
- , m_Instance(inInstance)
- {
- AddKeyframeData(inProperty, inKeyframeTime, inInfos, inInfoCount);
- }
+ , m_Instance(inInstance) {}
~CCmdDataModelInsertKeyframe() {}
- void AddKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inTime,
+ void AddKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, long inTime,
qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount)
{
m_KeyframeDataList.push_back(STimeKeyframeData(inProperty, inTime, inInfos, inInfoCount));
}
- //======================================================================
- // Do/Redo
- //======================================================================
unsigned long Do() override
{
if (!ConsumerExists()) {
qt3dsdm::SScopedDataModelConsumer __scopedConsumer(*this);
qt3dsdm::IStudioAnimationSystem *theAnimationSystem =
m_Doc->GetStudioSystem()->GetAnimationSystem();
- // if there are existing keyframes exist at the same times, the values are overridden. (
- // That's how it always work in studio anyways )
- for (size_t i = 0; i < m_KeyframeDataList.size(); ++i)
+ // Keyframes at same time are overridden (only 1 keyframe allowed at a point in time)
+ for (size_t i = 0; i < m_KeyframeDataList.size(); ++i) {
theAnimationSystem->SetOrCreateKeyframe(
m_Instance, m_KeyframeDataList[i].m_Property,
m_KeyframeDataList[i].m_KeyframeTime, m_KeyframeDataList[i].m_Infos,
m_KeyframeDataList[i].m_ValidInfoCount);
+ }
} else {
DataModelRedo();
}
return 0;
}
- //======================================================================
- // Undo
- //======================================================================
unsigned long Undo() override
{
if (ConsumerExists()) {
@@ -127,9 +108,6 @@ public: // Construction
return 0;
}
- //======================================================================
- // ToString
- //======================================================================
QString ToString() override
{
return QObject::tr("Insert Keyframe");
diff --git a/src/Authoring/Client/Code/Core/Core/Core.cpp b/src/Authoring/Client/Code/Core/Core/Core.cpp
index 61ff4d3b..839031ff 100644
--- a/src/Authoring/Client/Code/Core/Core/Core.cpp
+++ b/src/Authoring/Client/Code/Core/Core/Core.cpp
@@ -136,12 +136,12 @@ bool CCore::LoadBuildConfigurations()
void CCore::InitAndValidateBuildConfiguration()
{
Q3DStudio::CBuildConfiguration *theConfig =
- m_BuildConfigurations.GetConfiguration(CStudioPreferences::GetPreviewConfig());
+ m_BuildConfigurations.GetConfiguration(CStudioPreferences::previewConfig());
if (!theConfig) {
Q3DStudio::CBuildConfigurations::TBuildConfigurations &theConfigurations =
m_BuildConfigurations.GetConfigurations();
if (theConfigurations.size()) {
- CStudioPreferences::SetPreviewConfig(theConfigurations.begin()->first);
+ CStudioPreferences::setPreviewConfig(theConfigurations.begin()->first);
theConfig = theConfigurations.begin()->second;
}
}
@@ -152,12 +152,13 @@ void CCore::InitAndValidateBuildConfiguration()
for (theConfigPropIter = theConfigProperties.begin();
theConfigPropIter != theConfigProperties.end(); ++theConfigPropIter) {
const QString &thePropName = theConfigPropIter->GetName();
- QString theStoredValue = CStudioPreferences::GetPreviewProperty(thePropName);
+ QString theStoredValue = CStudioPreferences::previewProperty(thePropName);
if (!theConfigPropIter->HasValue(theStoredValue)) {
// add this property in
- if (theConfigPropIter->GetAcceptableValues().size())
- CStudioPreferences::SetPreviewProperty(
+ if (theConfigPropIter->GetAcceptableValues().size()) {
+ CStudioPreferences::setPreviewProperty(
thePropName, theConfigPropIter->GetValue(0).GetName());
+ }
}
}
}
@@ -229,7 +230,9 @@ bool CCore::OnNewDocument(const QString &inDocument, bool isNewProject, bool sil
m_projectFile.ensureProjectFile();
}
+ g_StudioApp.getRenderer().MakeContextCurrent();
m_Doc->CloseDocument();
+ g_StudioApp.getRenderer().ReleaseContext();
QString theDocument = inDocument;
diff --git a/src/Authoring/Client/Code/Core/Core/Dispatch.cpp b/src/Authoring/Client/Code/Core/Core/Dispatch.cpp
index 4a1e0905..2f80038c 100644
--- a/src/Authoring/Client/Code/Core/Core/Dispatch.cpp
+++ b/src/Authoring/Client/Code/Core/Core/Dispatch.cpp
@@ -121,7 +121,12 @@ void CDispatch::RemoveReloadListener(IReloadListener *inListener)
void CDispatch::FireReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
- m_ReloadListeners.FireEvent(&IReloadListener::OnReloadEffectInstance, inInstance);
+ m_ReloadListeners.FireEvent(&IReloadListener::onReloadEffectInstance, inInstance);
+}
+
+void CDispatch::fireReloadMaterialInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
+{
+ m_ReloadListeners.FireEvent(&IReloadListener::onReloadMaterialInstance, inInstance);
}
void CDispatch::AddDocumentBufferCacheListener(IDocumentBufferCacheListener *inListener)
@@ -621,9 +626,9 @@ void CDispatch::FireOnRefreshResourceFail(const QString &inResourceName,
void CDispatch::FireOnUndefinedDatainputsFail(
const QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle,
- qt3dsdm::Qt3DSDMPropertyHandle>> *map)
+ qt3dsdm::Qt3DSDMPropertyHandle>> *map, bool askFromUser)
{
- m_FailListeners.FireEvent(&CFailListener::OnUndefinedDatainputsFail, map);
+ m_FailListeners.FireEvent(&CFailListener::OnUndefinedDatainputsFail, map, askFromUser);
}
void CDispatch::AddRendererListener(CRendererListener *inListener)
diff --git a/src/Authoring/Client/Code/Core/Core/Dispatch.h b/src/Authoring/Client/Code/Core/Core/Dispatch.h
index e727af7f..3429310a 100644
--- a/src/Authoring/Client/Code/Core/Core/Dispatch.h
+++ b/src/Authoring/Client/Code/Core/Core/Dispatch.h
@@ -106,6 +106,7 @@ public:
void AddReloadListener(IReloadListener *inListener);
void RemoveReloadListener(IReloadListener *inListener);
void FireReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
+ void fireReloadMaterialInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
void AddDocumentBufferCacheListener(IDocumentBufferCacheListener *inListener);
void RemoveDocumentBufferCacheListener(IDocumentBufferCacheListener *inListener);
@@ -194,10 +195,10 @@ public:
void FireOnErrorFail(const QString &inText);
void FireOnRefreshResourceFail(const QString &inResourceName,
const QString &inDescription);
- void FireOnUndefinedDatainputsFail(
- const QMultiMap<QString,
- QPair<qt3dsdm::Qt3DSDMInstanceHandle,
- qt3dsdm::Qt3DSDMPropertyHandle>> *map);
+ void FireOnUndefinedDatainputsFail(const QMultiMap<QString,
+ QPair<qt3dsdm::Qt3DSDMInstanceHandle,
+ qt3dsdm::Qt3DSDMPropertyHandle>> *map,
+ bool askFromUser);
void AddRendererListener(CRendererListener *inListener);
void RemoveRendererListener(CRendererListener *inListener);
diff --git a/src/Authoring/Client/Code/Core/Core/DispatchListeners.h b/src/Authoring/Client/Code/Core/Core/DispatchListeners.h
index 252464e3..4887d0cb 100644
--- a/src/Authoring/Client/Code/Core/Core/DispatchListeners.h
+++ b/src/Authoring/Client/Code/Core/Core/DispatchListeners.h
@@ -277,7 +277,7 @@ public:
virtual void OnUndefinedDatainputsFail(
const QMultiMap<QString,
QPair<qt3dsdm::Qt3DSDMInstanceHandle,
- qt3dsdm::Qt3DSDMPropertyHandle>> *map) = 0;
+ qt3dsdm::Qt3DSDMPropertyHandle>> *map, bool askFromUser) = 0;
};
class IDataModelListener
@@ -302,7 +302,8 @@ public:
class IReloadListener
{
public:
- virtual void OnReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) = 0;
+ virtual void onReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) = 0;
+ virtual void onReloadMaterialInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) = 0;
};
class IDocumentBufferCacheListener
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
index 7d1b11a5..9d7837f6 100644
--- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
@@ -81,6 +81,7 @@ CClientDataModelBridge::CClientDataModelBridge(
, m_Camera(inDefinitions->m_Camera)
, m_Text(inDefinitions->m_Text)
, m_Group(inDefinitions->m_Group)
+ , m_Signal(inDefinitions->m_Signal)
, m_Component(inDefinitions->m_Component)
, m_Behavior(inDefinitions->m_Behavior)
, m_Scene(inDefinitions->m_Scene)
@@ -214,6 +215,9 @@ Qt3DSDMInstanceHandle CClientDataModelBridge::CreateAssetInstance(Q3DStudio::CId
case OBJTYPE_GROUP:
m_DataCore->DeriveInstance(theNewInstance, m_Group.m_Instance);
break;
+ case OBJTYPE_SIGNAL:
+ m_DataCore->DeriveInstance(theNewInstance, m_Signal.m_Instance);
+ break;
case OBJTYPE_COMPONENT:
m_DataCore->DeriveInstance(theNewInstance, m_Component.m_Instance);
break;
@@ -288,6 +292,7 @@ qt3dsdm::Qt3DSDMPropertyHandle CClientDataModelBridge::GetImportId()
{
return m_SceneAsset.m_ImportId;
}
+
qt3dsdm::Qt3DSDMPropertyHandle CClientDataModelBridge::GetNameProperty() const
{
return GetObjectDefinitions().m_Named.m_NameProp;
@@ -519,7 +524,7 @@ void CClientDataModelBridge::SetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHa
}
Q3DStudio::CString CClientDataModelBridge::GetName(
- qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle, bool renameMaterials) const
+ qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle, bool renameMaterials)
{
IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem();
TDataStrPtr theString;
@@ -575,12 +580,29 @@ std::wstring GetInstanceType(IPropertySystem *inPropertySystem, Qt3DSDMInstanceH
// Find which material that uses this image instance
bool CClientDataModelBridge::GetMaterialFromImageInstance(
qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::Qt3DSDMInstanceHandle &outMaterialInstance,
- qt3dsdm::Qt3DSDMPropertyHandle &outProperty) const
+ qt3dsdm::Qt3DSDMPropertyHandle &outProperty)
{
IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem();
SLong4 theDeletedImageLong4 =
GetNamedInstancePropertyValue<SLong4>(thePropertySystem, inInstance, L"id");
+ auto iter = m_cachedImageParents.find(inInstance);
+ if (iter != m_cachedImageParents.end()) {
+ // We have to recheck the property
+ qt3dsdm::Qt3DSDMInstanceHandle theInstance = iter->second.first;
+ qt3dsdm::Qt3DSDMPropertyHandle theProperty = iter->second.second;
+ SValue value = GetInstancePropertyValue(thePropertySystem, theInstance, theProperty);
+ if (!value.empty() && value.getType() == qt3dsdm::DataModelDataType::Long4) {
+ SLong4 theLong4PropertyValue = value.getData<SLong4>();
+ if (theLong4PropertyValue == theDeletedImageLong4) {
+ outMaterialInstance = theInstance;
+ outProperty = theProperty;
+ return true;
+ }
+ }
+ m_cachedImageParents.erase(iter);
+ }
+
TInstanceHandleList theInstances;
m_DataCore->GetInstancesDerivedFrom(
theInstances, m_DefaultMaterial.m_Instance); // Get all default material instances
@@ -604,6 +626,8 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance(
if (theDeletedImageLong4 == theLong4PropertyValue) {
outMaterialInstance = theInstance;
outProperty = theProperty;
+ m_cachedImageParents.insert({inInstance,
+ std::make_pair(theInstance, theProperty)});
return true;
}
}
@@ -611,6 +635,7 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance(
}
}
+ theInstances.clear();
m_DataCore->GetInstancesDerivedFrom(
theInstances, m_CustomMaterial.m_Instance); // Get all custom material instances
theInstanceCount = theInstances.size();
@@ -627,12 +652,16 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance(
AdditionalMetaDataType::Value theAdditionalMetaDataType =
thePropertySystem->GetAdditionalMetaDataType(theInstance, theProperty);
- if (theAdditionalMetaDataType == AdditionalMetaDataType::Image) {
- SLong4 theLong4PropertyValue = GetSpecificInstancePropertyValue<SLong4>(
+ if (theAdditionalMetaDataType == AdditionalMetaDataType::Image
+ || theAdditionalMetaDataType == AdditionalMetaDataType::Texture) {
+ SValue propertyValue = GetInstancePropertyValue(
thePropertySystem, theInstance, theProperty);
- if (theDeletedImageLong4 == theLong4PropertyValue) {
+ if (propertyValue.getType() == qt3dsdm::DataModelDataType::Long4
+ && theDeletedImageLong4 == propertyValue.getData<SLong4>()) {
outMaterialInstance = theInstance;
outProperty = theProperty;
+ m_cachedImageParents.insert({inInstance,
+ std::make_pair(theInstance, theProperty)});
return true;
}
}
@@ -1171,34 +1200,55 @@ Qt3DSDMInstanceHandle CClientDataModelBridge::getMaterialReference(Qt3DSDMInstan
return Qt3DSDMInstanceHandle();
}
-bool CClientDataModelBridge::isMaterialContainer(Qt3DSDMInstanceHandle instance) const
+bool CClientDataModelBridge::isMaterialContainer(Qt3DSDMInstanceHandle instance,
+ Qt3DSDMInstanceHandle materialContainer) const
+{
+ return instance.Valid() && instance == materialContainer;
+}
+
+bool CClientDataModelBridge::isMaterialContainer(Qt3DSDMInstanceHandle instance)
+{
+ return instance.Valid() && instance == getMaterialContainer();
+}
+
+bool CClientDataModelBridge::isInsideMaterialContainer(Qt3DSDMInstanceHandle instance)
{
- return instance == getMaterialContainer();
+ return isInsideMaterialContainer(instance, GetParentInstance(instance), getMaterialContainer());
}
-bool CClientDataModelBridge::isInsideMaterialContainer(Qt3DSDMInstanceHandle instance) const
+bool CClientDataModelBridge::isInsideMaterialContainer(
+ qt3dsdm::Qt3DSDMInstanceHandle instance, qt3dsdm::Qt3DSDMInstanceHandle parentInstance,
+ qt3dsdm::Qt3DSDMInstanceHandle materialContainer)
{
- auto parentInstance = GetParentInstance(instance);
- if (parentInstance.Valid() && isMaterialContainer(parentInstance))
+ Q_UNUSED(instance);
+ if (parentInstance.Valid() && isMaterialContainer(parentInstance, materialContainer))
return true;
//Check if an image inside a material inside the material container
parentInstance = GetParentInstance(parentInstance);
if (parentInstance.Valid())
- return isMaterialContainer(parentInstance);
+ return isMaterialContainer(parentInstance, materialContainer);
return false;
}
bool CClientDataModelBridge::isInsideMaterialContainerAndNotReferenced(
- Qt3DSDMInstanceHandle instance) const
+ qt3dsdm::Qt3DSDMInstanceHandle instance)
+{
+ return isInsideMaterialContainerAndNotReferenced(instance, GetParentInstance(instance),
+ getMaterialContainer());
+}
+
+bool CClientDataModelBridge::isInsideMaterialContainerAndNotReferenced(
+ Qt3DSDMInstanceHandle instance, qt3dsdm::Qt3DSDMInstanceHandle parentInstance,
+ Qt3DSDMInstanceHandle materialContainer)
{
- if (isInsideMaterialContainer(instance)) {
+ if (isInsideMaterialContainer(instance, parentInstance, materialContainer)) {
QVector<Qt3DSDMInstanceHandle> usedMats;
m_Doc->getUsedSharedMaterials(usedMats);
bool isReferenced = false;
for (auto &usedMat : qAsConst(usedMats)) {
- if (usedMat == instance || usedMat == GetParentInstance(instance)) {
+ if (usedMat == instance || usedMat == parentInstance) {
isReferenced = true;
break;
}
@@ -1218,12 +1268,12 @@ QString CClientDataModelBridge::getMaterialContainerName() const
return QStringLiteral("__Container");
}
-QString CClientDataModelBridge::getMaterialContainerParentPath() const
+QString CClientDataModelBridge::getMaterialContainerParentPath()
{
return GetName(m_Doc->GetSceneInstance()).toQString();
}
-QString CClientDataModelBridge::getMaterialContainerPath() const
+QString CClientDataModelBridge::getMaterialContainerPath()
{
return getMaterialContainerParentPath() + QStringLiteral(".") + getMaterialContainerName();
}
@@ -1237,7 +1287,21 @@ bool CClientDataModelBridge::isDefaultMaterial(Qt3DSDMInstanceHandle instance) c
&& GetSourcePath(instance) == getDefaultMaterialName();
}
-Qt3DSDMInstanceHandle CClientDataModelBridge::getMaterialContainer() const
+bool CClientDataModelBridge::isBasicMaterial(Qt3DSDMInstanceHandle instance)
+{
+ if (!instance.Valid() || !m_DataCore->IsInstance(instance))
+ return false;
+
+ if (GetObjectType(instance) == OBJTYPE_REFERENCEDMATERIAL) {
+ const auto refMaterial = getMaterialReference(instance);
+ if (refMaterial.Valid() && isInsideMaterialContainer(refMaterial))
+ return true;
+ }
+
+ return false;
+}
+
+Qt3DSDMInstanceHandle CClientDataModelBridge::getMaterialContainer()
{
IObjectReferenceHelper *objRefHelper = m_Doc->GetDataModelObjectReferenceHelper();
if (objRefHelper) {
@@ -1262,37 +1326,6 @@ TInstanceHandleList CClientDataModelBridge::GetItemBaseInstances() const
}
/**
- * Get list of values from all instances derived from inParentInstance
- */
-std::vector<SValue> CClientDataModelBridge::GetValueList(Qt3DSDMInstanceHandle inParentInstance,
- Qt3DSDMPropertyHandle inProperty,
- IValueFilter *inFilter) const
-{
- std::vector<SValue> theValueList;
- TInstanceHandleList theInstances;
- m_DataCore->GetInstancesDerivedFrom(theInstances, inParentInstance);
-
- // Iterate through each instance derived from inParentInstance and get the inProperty property
- // value.
- for (TInstanceHandleList::const_iterator theIter = theInstances.begin();
- theIter != theInstances.end(); ++theIter) {
- // Skip the parent instance.
- if (*theIter == inParentInstance)
- continue;
-
- if (!GetParentInstance(*theIter).Valid())
- continue;
-
- if (isInsideMaterialContainerAndNotReferenced(*theIter))
- continue;
-
- GetValueListFromAllSlides(*theIter, inProperty, theValueList, inFilter);
- }
-
- return theValueList;
-}
-
-/**
* Get list of values from all slides
*/
void CClientDataModelBridge::GetValueListFromAllSlides(Qt3DSDMInstanceHandle inInstance,
@@ -1349,15 +1382,111 @@ struct SValueListFilter : public IValueFilter
}
};
+std::vector<SValue> CClientDataModelBridge::getSourcePathListFromInstances(
+ const std::vector<Qt3DSDMInstanceHandle> &inParentInstance,
+ const std::vector<Qt3DSDMPropertyHandle> &inProperty,
+ IValueFilter *inFilter)
+{
+ IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem();
+
+ auto getImageIds = [this, thePropertySystem](TInstanceHandleList instances) {
+ std::vector<std::pair<SLong4, qt3dsdm::Qt3DSDMInstanceHandle>> imageIds;
+ for (TInstanceHandleList::const_iterator theIter = instances.begin();
+ theIter != instances.end(); ++theIter) {
+ TPropertyHandleList theProperties;
+ auto theInstance = *theIter;
+ thePropertySystem->GetAggregateInstanceProperties(theInstance, theProperties);
+ size_t thePropertyCount = theProperties.size();
+ for (size_t thePropertyIndex = 0; thePropertyIndex < thePropertyCount;
+ ++thePropertyIndex) {
+ Qt3DSDMPropertyHandle theProperty = theProperties[thePropertyIndex];
+ AdditionalMetaDataType::Value theAdditionalMetaDataType =
+ thePropertySystem->GetAdditionalMetaDataType(theInstance, theProperty);
+
+ if (theAdditionalMetaDataType == AdditionalMetaDataType::Image) {
+ theProperties.push_back(theProperty);
+ SLong4 theLong4PropertyValue = GetSpecificInstancePropertyValue<SLong4>(
+ thePropertySystem, theInstance, theProperty);
+ imageIds.push_back(std::make_pair(theLong4PropertyValue, theInstance));
+ }
+ }
+ }
+ return imageIds;
+ };
+
+ auto materialContainer = getMaterialContainer();
+
+ // Get all image parent instances
+ TInstanceHandleList parentInstances;
+ m_DataCore->GetInstancesDerivedFrom(parentInstances, m_DefaultMaterial.m_Instance);
+ m_DataCore->GetInstancesDerivedFrom(parentInstances, m_CustomMaterial.m_Instance);
+ m_DataCore->GetInstancesDerivedFrom(parentInstances, m_Layer.m_Instance);
+
+ // Get all image properties
+ std::vector<std::pair<SLong4, qt3dsdm::Qt3DSDMInstanceHandle>> imageIdsParents
+ = getImageIds(parentInstances);
+
+ auto getValueList = [this, thePropertySystem, materialContainer](std::vector<SValue> &theValueList,
+ Qt3DSDMInstanceHandle parentInstance,
+ Qt3DSDMPropertyHandle property, IValueFilter *inFilter,
+ const std::vector<std::pair<SLong4, qt3dsdm::Qt3DSDMInstanceHandle>> &imageIdsParents) {
+ TInstanceHandleList theInstances;
+ m_DataCore->GetInstancesDerivedFrom(theInstances, parentInstance);
+
+ auto findParent = [](std::vector<std::pair<SLong4, qt3dsdm::Qt3DSDMInstanceHandle>> pairs,
+ const SLong4 &long4) -> qt3dsdm::Qt3DSDMInstanceHandle {
+ for (auto iter = pairs.begin(); iter != pairs.end(); iter++) {
+ if (iter->first == long4)
+ return iter->second;
+ }
+ return {};
+ };
+
+ Q3DStudio::TGraphPtr theGraph = m_Doc->GetAssetGraph();
+
+ // Iterate through each instance derived from inParentInstance and get the inProperty property
+ // value.
+ for (TInstanceHandleList::const_iterator theIter = theInstances.begin();
+ theIter != theInstances.end(); ++theIter) {
+ auto instance = *theIter;
+ // Skip the parent instance.
+ if (*theIter == m_SceneAsset.m_Instance)
+ continue;
+
+ qt3dsdm::Qt3DSDMInstanceHandle parentInstance;
+ if (IsImageInstance(instance)) {
+ // find the image from the image properties
+ SLong4 theDeletedImageLong4 =
+ GetNamedInstancePropertyValue<SLong4>(thePropertySystem, instance, L"id");
+ parentInstance = findParent(imageIdsParents, theDeletedImageLong4);
+ } else if (theGraph->IsExist(instance)) {
+ parentInstance = theGraph->GetParent(instance);
+ }
+
+ if (!parentInstance.Valid())
+ continue;
+
+ if (isInsideMaterialContainerAndNotReferenced(*theIter, parentInstance, materialContainer))
+ continue;
+
+ GetValueListFromAllSlides(*theIter, property, theValueList, inFilter);
+ }
+ };
+ std::vector<SValue> theValueList;
+ for (int i = 0; i < inParentInstance.size(); i++)
+ getValueList(theValueList, inParentInstance[i], inProperty[i], inFilter, imageIdsParents);
+ return theValueList;
+}
+
/**
* Get SourcePath list from all instances
*/
-std::set<QString> CClientDataModelBridge::GetSourcePathList() const
+std::set<QString> CClientDataModelBridge::GetSourcePathList()
{
// Get the source path property list
SValueListFilter theFilter(*this);
- std::vector<SValue> theValueList =
- GetValueList(m_SceneAsset.m_Instance, m_SceneAsset.m_SourcePath, &theFilter);
+ auto theValueList = getSourcePathListFromInstances({m_SceneAsset.m_Instance},
+ {m_SceneAsset.m_SourcePath}, &theFilter);
// Translate from SValue to QString and also remove the identifier
std::set<QString> theSourcePathList;
@@ -1373,10 +1502,11 @@ std::set<QString> CClientDataModelBridge::GetSourcePathList() const
/**
* Get Font file list from all Text instances
*/
-std::set<QString> CClientDataModelBridge::GetFontFileList() const
+std::set<QString> CClientDataModelBridge::GetFontFileList()
{
// Get the font name property list
- std::vector<SValue> theValueList = GetValueList(m_Text.m_Instance, m_Text.m_Font);
+ std::vector<SValue> theValueList = getSourcePathListFromInstances({m_Text.m_Instance},
+ {m_Text.m_Font}, nullptr);
std::set<QString> theFontNameList;
for (auto &val : theValueList) {
QString font = get<QString>(val);
@@ -1417,7 +1547,7 @@ std::set<QString> CClientDataModelBridge::GetFontFileList() const
static void GetDynamicObjecTextures(IDataCore &inDataCore, IPropertySystem &inPropertySystem,
Qt3DSDMInstanceHandle inBaseInstance,
std::vector<SValue> &outValues,
- const CClientDataModelBridge &inBridge)
+ CClientDataModelBridge &inBridge)
{
std::vector<SValue> &theValueList(outValues);
// Get all effect instances
@@ -1466,7 +1596,7 @@ static void GetDynamicObjecTextures(IDataCore &inDataCore, IPropertySystem &inPr
/**
* Get texture list from all effect instances
*/
-std::set<QString> CClientDataModelBridge::GetDynamicObjectTextureList() const
+std::set<QString> CClientDataModelBridge::GetDynamicObjectTextureList()
{
std::vector<SValue> theValueList;
@@ -1482,21 +1612,46 @@ std::set<QString> CClientDataModelBridge::GetDynamicObjectTextureList() const
// Translate from SValue to QString and also remove the identifier
std::set<QString> theSourcePathList;
for (auto &val : theValueList) {
- Q3DStudio::CFilePath theSourcePath = qt3dsdm::get<QString>(val);
- if (!theSourcePath.filePath().isEmpty())
- theSourcePathList.insert(theSourcePath.toQString());
+ if (val.getType() == qt3dsdm::DataModelDataType::String) {
+ Q3DStudio::CFilePath theSourcePath = qt3dsdm::get<QString>(val);
+ if (!theSourcePath.filePath().isEmpty())
+ theSourcePathList.insert(theSourcePath.toQString());
+ }
}
return theSourcePathList;
}
-std::set<QString> CClientDataModelBridge::getRenderableList() const
+TInstanceHandleList CClientDataModelBridge::GetShaderInstances()
+{
+ TInstanceHandleList theCustomMatInstances;
+ TInstanceHandleList theEffectInstances;
+ m_DataCore->GetInstancesDerivedFrom(theCustomMatInstances, m_CustomMaterial.m_Instance);
+ m_DataCore->GetInstancesDerivedFrom(theEffectInstances, m_Effect.m_Instance);
+
+ TInstanceHandleList cleanedMatInstances;
+ for (const auto &it : theCustomMatInstances) {
+ if (it != m_CustomMaterial.m_Instance)
+ cleanedMatInstances.insert(cleanedMatInstances.end(), it);
+ }
+ TInstanceHandleList cleanedFxInstances;
+
+ // Pick only effects that are not base instances, and which have a valid parent
+ for (const auto &it : theEffectInstances) {
+ if (it != m_Effect.m_Instance && GetParentInstance(it).Valid())
+ cleanedFxInstances.insert(cleanedFxInstances.end(), it);
+ }
+
+ cleanedFxInstances.insert(cleanedFxInstances.end(), cleanedMatInstances.begin(),
+ cleanedMatInstances.end());
+ return cleanedFxInstances;
+}
+
+std::set<QString> CClientDataModelBridge::getRenderableList()
{
- std::vector<SValue> valueList
- = GetValueList(m_Layer.m_Instance, m_SceneAsset.m_SourcePath, nullptr);
- std::vector<SValue> imageList
- = GetValueList(m_SceneImage.m_Instance, m_SceneImage.m_SubPresentation, nullptr);
- valueList.insert(valueList.end(), imageList.begin(), imageList.end());
+ auto valueList = getSourcePathListFromInstances(
+ {m_Layer.m_Instance, m_SceneImage.m_Instance},
+ {m_SceneAsset.m_SourcePath, m_SceneImage.m_SubPresentation}, nullptr);
std::set<QString> idList;
for (auto &val : valueList) {
@@ -1562,6 +1717,7 @@ bool CClientDataModelBridge::CanDelete(qt3dsdm::Qt3DSDMInstanceHandle inInstance
case OBJTYPE_MODEL:
case OBJTYPE_TEXT:
case OBJTYPE_GROUP:
+ case OBJTYPE_SIGNAL:
case OBJTYPE_CAMERA:
case OBJTYPE_LIGHT:
case OBJTYPE_IMAGE:
@@ -1670,7 +1826,7 @@ Q3DStudio::CId CClientDataModelBridge::GetGUID(qt3dsdm::Qt3DSDMInstanceHandle in
}
qt3dsdm::Qt3DSDMInstanceHandle
-CClientDataModelBridge::GetParentInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const
+CClientDataModelBridge::GetParentInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
if (IsImageInstance(inInstance)) {
qt3dsdm::Qt3DSDMInstanceHandle theParentInstance;
@@ -1705,6 +1861,8 @@ CClientDataModelBridge::GetObjectType(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
return OBJTYPE_CAMERA;
else if (theType == L"Group")
return OBJTYPE_GROUP;
+ else if (theType == L"Signal")
+ return OBJTYPE_SIGNAL;
else if (theType == L"Component")
return OBJTYPE_COMPONENT;
else if (theType == L"Image" || theType == L"LibraryImage")
@@ -1760,6 +1918,11 @@ bool CClientDataModelBridge::IsGroupInstance(qt3dsdm::Qt3DSDMInstanceHandle inIn
return m_DataCore->IsInstanceOrDerivedFrom(inInstance, m_Group.m_Instance);
}
+bool CClientDataModelBridge::IsSignalInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const
+{
+ return m_DataCore->IsInstanceOrDerivedFrom(inInstance, m_Signal.m_Instance);
+}
+
bool CClientDataModelBridge::IsActionInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const
{
return m_DataCore->IsInstanceOrDerivedFrom(inInstance, m_ActionItem.m_Instance);
@@ -2246,3 +2409,9 @@ CClientDataModelBridge::GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle
{
return m_DataCore->GetAggregateInstancePropertyByName(inInstance, inPropertyName);
}
+
+bool CClientDataModelBridge::hasAggregateInstanceProperty(Qt3DSDMInstanceHandle inInstance,
+ Qt3DSDMPropertyHandle inProperty) const
+{
+ return m_DataCore->HasAggregateInstanceProperty(inInstance, inProperty);
+}
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h
index aa7a5dee..f0f5004d 100644
--- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h
+++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h
@@ -37,6 +37,7 @@
#include "Graph.h"
#include "Pt.h"
#include "Qt3DSDMMetaData.h"
+#include "Qt3DSDMAnimation.h"
#include "Qt3DSDMComposerTypeDefinitions.h"
class CDoc;
@@ -74,6 +75,7 @@ typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Light>
typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Camera> SDataModelCamera;
typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Text> SDataModelText;
typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Group> SDataModelGroup;
+typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Signal> SDataModelSignal;
typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Component> SDataModelComponent;
typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Behavior> SDataModelBehavior;
typedef qt3dsdm::SComposerObjectDefinition<qt3dsdm::ComposerObjectTypes::Scene> SDataModelScene;
@@ -132,6 +134,7 @@ class CClientDataModelBridge
SDataModelCamera &m_Camera;
SDataModelText &m_Text;
SDataModelGroup &m_Group;
+ SDataModelSignal &m_Signal;
SDataModelComponent &m_Component;
SDataModelBehavior &m_Behavior;
SDataModelScene &m_Scene;
@@ -163,6 +166,8 @@ class CClientDataModelBridge
qt3dsdm::TInstanceHandleList m_CacheMaterialInstances;
qt3dsdm::TInstanceHandleList m_CacheModelInstances;
+ std::unordered_map<int, std::pair<int, int>> m_cachedImageParents;
+
public:
CClientDataModelBridge(qt3dsdm::IDataCore *inDataCore, qt3dsdm::ISlideCore *inSlideCore,
qt3dsdm::ISlideGraphCore *inSlideGraphCore,
@@ -229,6 +234,7 @@ public:
const SDataModelCamera &GetCamera() const { return m_Camera; }
const SDataModelText &GetText() const { return m_Text; }
const SDataModelGroup &GetGroup() const { return m_Group; }
+ const SDataModelSignal &GetSignal() const { return m_Signal; }
const SDataModelComponent &GetComponent() const { return m_Component; }
const SDataModelBehavior &GetBehavior() const { return m_Behavior; }
const SDataModelScene &GetScene() const { return m_Scene; }
@@ -245,7 +251,7 @@ public:
// Operations which likely don't belong on this class
bool GetMaterialFromImageInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3dsdm::Qt3DSDMInstanceHandle &outMaterialInstance,
- qt3dsdm::Qt3DSDMPropertyHandle &outProperty) const;
+ qt3dsdm::Qt3DSDMPropertyHandle &outProperty);
bool GetLayerFromImageProbeInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3dsdm::Qt3DSDMInstanceHandle &outLayerInstance,
qt3dsdm::Qt3DSDMPropertyHandle &outProperty) const;
@@ -294,6 +300,8 @@ public:
qt3dsdm::Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(
qt3dsdm::Qt3DSDMInstanceHandle inInstance,
const qt3dsdm::TCharStr &inStr);
+ bool hasAggregateInstanceProperty(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
+ qt3dsdm::Qt3DSDMPropertyHandle inProperty) const;
// helpers
void BeginRender(); // enable cache to increase performance
@@ -327,7 +335,7 @@ public:
void SetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle, const Q3DStudio::CString &inName);
Q3DStudio::CString GetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle,
- bool renameMaterials = false) const;
+ bool renameMaterials = false);
// Helper for old methods in CAsset
bool IsInActiveComponent(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
@@ -344,19 +352,21 @@ public:
QString GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
Q3DStudio::CString getSubpresentation(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
qt3dsdm::Qt3DSDMInstanceHandle getMaterialReference(qt3dsdm::Qt3DSDMInstanceHandle instance);
- bool isMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance) const;
- bool isInsideMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance) const;
- bool isInsideMaterialContainerAndNotReferenced(qt3dsdm::Qt3DSDMInstanceHandle instance) const;
+ bool isMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance);
+ bool isInsideMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance);
+ bool isInsideMaterialContainerAndNotReferenced(qt3dsdm::Qt3DSDMInstanceHandle instance);
QString getDefaultMaterialName() const;
QString getMaterialContainerName() const;
- QString getMaterialContainerParentPath() const;
- QString getMaterialContainerPath() const;
+ QString getMaterialContainerParentPath();
+ QString getMaterialContainerPath();
bool isDefaultMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance) const;
- qt3dsdm::Qt3DSDMInstanceHandle getMaterialContainer() const;
- std::set<QString> GetSourcePathList() const;
- std::set<QString> GetFontFileList() const;
- std::set<QString> GetDynamicObjectTextureList() const;
- std::set<QString> getRenderableList() const;
+ bool isBasicMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance);
+ qt3dsdm::Qt3DSDMInstanceHandle getMaterialContainer();
+ std::set<QString> GetSourcePathList();
+ std::set<QString> GetFontFileList();
+ std::set<QString> GetDynamicObjectTextureList();
+ qt3dsdm::TInstanceHandleList GetShaderInstances();
+ std::set<QString> getRenderableList();
bool IsLockedAtAll(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
bool IsDuplicateable(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
bool IsMultiSelectable(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
@@ -369,8 +379,7 @@ public:
IValueFilter *inFilter = nullptr) const;
Q3DStudio::CId GetGUID(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
- qt3dsdm::Qt3DSDMInstanceHandle GetParentInstance(
- qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
+ qt3dsdm::Qt3DSDMInstanceHandle GetParentInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
// TODO: EStudioObjectType and EASSETTYPE can't co-exist, one must go. Think EStudioObjectType
// should win since things are better classified
@@ -378,6 +387,7 @@ public:
bool IsBehaviorInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
bool IsCameraInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
bool IsGroupInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
+ bool IsSignalInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
bool IsActionInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
bool IsComponentInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
bool IsLayerInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const;
@@ -405,11 +415,20 @@ protected:
qt3dsdm::Qt3DSDMInstanceHandle GetChildByName(qt3dsdm::Qt3DSDMInstanceHandle inParent,
Q3DStudio::CString inChildName,
qt3dsdm::Qt3DSDMInstanceHandle skipInstance);
- std::vector<qt3dsdm::SValue> GetValueList(qt3dsdm::Qt3DSDMInstanceHandle inParentInstance,
- qt3dsdm::Qt3DSDMPropertyHandle inProperty,
- IValueFilter *inFilter = nullptr) const;
private:
+ std::vector<qt3dsdm::SValue> getSourcePathListFromInstances(
+ const std::vector<qt3dsdm::Qt3DSDMInstanceHandle> &inParentInstance,
+ const std::vector<qt3dsdm::Qt3DSDMPropertyHandle> &inProperty,
+ IValueFilter *inFilter);
+ bool isMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance,
+ qt3dsdm::Qt3DSDMInstanceHandle materialContainer) const;
+ bool isInsideMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance,
+ qt3dsdm::Qt3DSDMInstanceHandle parentInstance,
+ qt3dsdm::Qt3DSDMInstanceHandle materialContainer);
+ bool isInsideMaterialContainerAndNotReferenced(qt3dsdm::Qt3DSDMInstanceHandle instance,
+ qt3dsdm::Qt3DSDMInstanceHandle parentInstance,
+ qt3dsdm::Qt3DSDMInstanceHandle materialContainer);
qt3dsdm::Qt3DSDMInstanceHandle GetInstanceByGUIDDerivedFrom(qt3dsdm::SLong4 inLong4,
qt3dsdm::Qt3DSDMInstanceHandle inParentHandle,
qt3dsdm::Qt3DSDMPropertyHandle inProperty);
diff --git a/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp b/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp
index 2391952f..7efcc82f 100644
--- a/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp
@@ -38,8 +38,16 @@ using namespace Q3DStudio::ComposerImport;
using namespace qt3ds::foundation;
namespace {
-// base class between performing refresh and performing
-// imports
+// base class between performing refresh and performing imports
+
+// convert imported keyframes times from seconds to millis to be compatible with the animation
+// system. The assumption is that keyframes are imported as EaseInOut type which has 4 values per
+// keyframe
+inline void convertSecondsToMillis(const float *animData, QT3DSU32 numFloats)
+{
+ for (int i = 0; i < numFloats; i += 4)
+ const_cast<float *>(animData)[i] *= 1000.f;
+}
struct STCharPtrHash
{
@@ -112,13 +120,13 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd
, m_Root(root)
, m_Slide(slide)
, m_StartTime(inStartTime)
- , m_ImportObj(NULL)
+ , m_ImportObj(nullptr)
{
m_Editor.BeginAggregateOperation();
}
// Fires the 'do' notifications
- ~SComposerImportInterface() { m_Editor.EndAggregateOperation(); }
+ ~SComposerImportInterface() override { m_Editor.EndAggregateOperation(); }
// IComposerEditorInterface
@@ -154,7 +162,7 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd
void AddInstanceMap(Qt3DSDMInstanceHandle instanceHandle, TImportId inImportId) override
{
- if (inImportId == NULL || *inImportId == 0) {
+ if (inImportId == nullptr || *inImportId == 0) {
assert(0);
return;
}
@@ -319,6 +327,11 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd
m_Editor.setMaterialReferenceByPath(instance, materialName.toQString());
m_Editor.SetName(instance, materialName);
m_Editor.setMaterialSourcePath(instance, sourcePath);
+ m_Editor.SetSpecificInstancePropertyValue(
+ 0, instance, L"importid", std::make_shared<CDataStr>(desc.m_Id));
+ m_Editor.SetSpecificInstancePropertyValue(
+ 0, instance, L"importfile",
+ std::make_shared<CDataStr>(m_Relativeimportfile.toCString()));
}
void UpdateInstanceProperties(TImportId inInstance, const PropertyValue *propertBuffer,
@@ -392,6 +405,7 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd
Qt3DSDMInstanceHandle hdl(FindInstance(inInstance));
if (hdl.Valid()) {
if (m_Editor.IsAnimationArtistEdited(m_Slide, hdl, propName, propSubIndex) == false) {
+ convertSecondsToMillis(animData, numFloats);
Qt3DSDMAnimationHandle anim = m_Editor.CreateOrSetAnimation(
m_Slide, hdl, propName, propSubIndex, animType, animData, numFloats, false);
m_Editor.SetIsArtistEdited(anim, false);
@@ -424,7 +438,7 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE
SSlideInstanceIdMapIterator(TImportId inImportId, TIdMultiMap &inItems,
qt3dsdm::IStringTable &inStringTable)
- : m_CurrentItems(NULL)
+ : m_CurrentItems(nullptr)
, m_CurrentTreeIdx(0)
, m_CurrentTreeEnd(0)
, m_Id(inStringTable.RegisterStr(inImportId))
@@ -435,7 +449,7 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE
{
m_CurrentTreeIdx = 0;
m_CurrentTreeEnd = 0;
- m_CurrentItems = NULL;
+ m_CurrentItems = nullptr;
TIdMultiMap::const_iterator theFind = inItems.find(m_Id);
if (theFind != inItems.end()) {
m_CurrentItems = &theFind->second;
@@ -641,6 +655,11 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE
m_Editor.setMaterialReferenceByPath(instance, materialName.toQString());
m_Editor.SetName(instance, materialName);
m_Editor.setMaterialSourcePath(instance, sourcePath);
+ m_Editor.SetSpecificInstancePropertyValue(
+ 0, instance, L"importid", std::make_shared<CDataStr>(desc.m_Id));
+ m_Editor.SetSpecificInstancePropertyValue(
+ 0, instance, L"importfile",
+ std::make_shared<CDataStr>(m_Relativeimportfile.toCString()));
// Insert the referenced material to the map
// so that the child structure remains the same
insert_unique(refInserter.first->second,
@@ -657,6 +676,12 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE
m_StringTable);
theIterator.IsDone() == false; theIterator.Next()) {
Qt3DSDMInstanceHandle hdl = theIterator.GetCurrentInstance();
+
+ // Skip property setting for reference materials, as they have the same import id
+ // as the actual materials in the container (required to make parent-child logic work)
+ if (m_Editor.GetObjectTypeName(hdl) == "ReferencedMaterial")
+ continue;
+
for (QT3DSU32 idx = 0; idx < propertyBufferSize; ++idx) {
const PropertyValue &value(propertBuffer[idx]);
SValue theValue(value.m_Value);
@@ -758,8 +783,8 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE
theIterator.GetCurrentInstance(), propName, propSubIndex)
&& m_Editor.IsAnimationArtistEdited(theIterator.GetCurrentSlide(),
theIterator.GetCurrentInstance(), propName,
- propSubIndex)
- == false) {
+ propSubIndex) == false) {
+ convertSecondsToMillis(animData, numFloats);
Qt3DSDMAnimationHandle anim = m_Editor.CreateOrSetAnimation(
theIterator.GetCurrentSlide(), theIterator.GetCurrentInstance(), propName,
propSubIndex, animType, animData, numFloats, false);
@@ -777,6 +802,7 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE
if (!m_Editor.AnimationExists(theIterator.GetCurrentSlide(),
theIterator.GetCurrentInstance(), propName,
propSubIndex)) {
+ convertSecondsToMillis(animData, numFloats);
Qt3DSDMAnimationHandle anim = m_Editor.CreateOrSetAnimation(
theIterator.GetCurrentSlide(), theIterator.GetCurrentInstance(), propName,
propSubIndex, animType, animData, numFloats, false);
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index c10b56bc..e0d2479b 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -74,7 +74,7 @@
#include <QtCore/qtimer.h>
#include <QtGui/qvalidator.h>
-const long UIP_VERSION = 6; // current version (latest supported)
+const long UIP_VERSION = 7; // current version (latest supported)
const long LAST_SUPPORTED_UIP_VERSION = 1;
IMPLEMENT_OBJECT_COUNTER(CDoc)
@@ -253,19 +253,17 @@ void CDoc::RemoveDatainputBindings(
const QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle,
qt3dsdm::Qt3DSDMPropertyHandle>> *map)
{
- // We might be altering several attributes, aggregate them together
- m_SceneEditor->BeginAggregateOperation();
const auto uniqueKeys = map->uniqueKeys();
for (const auto &name : uniqueKeys) {
const auto values = map->values(name);
for (const auto &pair : values) {
+ // Use a batch transaction and close it here afterwards.
SetInstancePropertyControlled(pair.first, Q3DStudio::CString(),
pair.second, Q3DStudio::CString::fromQString(name),
false, true);
}
}
- m_SceneEditor->EndAggregateOperation();
// if SetInstancePropertyControlled fails for some reason, we might not have open transaction.
if (isTransactionOpened())
closeTransaction();
@@ -370,9 +368,8 @@ void CDoc::SetInstancePropertyControlled(
Q3DStudio::ScopedDocumentEditor(*this, QObject::tr("Set controlled"), __FILE__, __LINE__)
->SetInstancePropertyValue(instance, ctrldElemPropHandle, controlledProperty);
} else {
- if (!isTransactionOpened())
- OpenTransaction(QObject::tr("Set multiple controlled"), __FILE__, __LINE__);
- SetInstancePropertyValue(instance, L"controlledproperty", controlledProperty);
+ maybeOpenTransaction(QObject::tr("Set multiple controlled"), __FILE__, __LINE__)
+ .SetInstancePropertyValue(instance, ctrldElemPropHandle, controlledProperty);
}
}
@@ -626,7 +623,7 @@ void CDoc::NotifyActiveSlideChanged(qt3dsdm::Qt3DSDMSlideHandle inNewActiveSlide
if (theLastActiveSlide != inNewActiveSlide) {
SetActiveSlideChange(inNewActiveSlide);
if (inIgnoreLastDisplayTime)
- m_StudioSystem->GetSlideSystem()->SetComponentSeconds(
+ m_StudioSystem->GetSlideSystem()->SetComponentTime(
m_StudioSystem->GetSlideSystem()->GetMasterSlide(inNewActiveSlide), 0);
}
@@ -762,6 +759,58 @@ void CDoc::SetActiveLayer(qt3dsdm::Qt3DSDMInstanceHandle inLayerInstance)
m_ActiveLayer = inLayerInstance;
}
+qt3dsdm::Qt3DSDMInstanceHandle CDoc::getActiveCamera(qt3dsdm::Qt3DSDMInstanceHandle inLayer) const
+{
+ return m_ActiveCameras[inLayer];
+}
+
+void CDoc::setActiveCamera(qt3dsdm::Qt3DSDMInstanceHandle inCameraLayer,
+ qt3dsdm::Qt3DSDMInstanceHandle inCameraInstance)
+{
+ QT3DS_ASSERT(inCameraLayer.Valid());
+ m_ActiveCameras.insert(inCameraLayer, inCameraInstance);
+}
+
+bool CDoc::ensureActiveCamera()
+{
+ m_ActiveCameras.clear();
+
+ qt3dsdm::IDataCore &theCore(*m_StudioSystem->GetFullSystem()->GetCoreSystem()->GetDataCore());
+ CClientDataModelBridge *theBridge = m_StudioSystem->GetClientDataModelBridge();
+ qt3dsdm::TInstanceHandleList cameraInstances;
+
+ theCore.GetInstancesDerivedFrom(cameraInstances,
+ theBridge->GetObjectDefinitions().m_Camera.m_Instance);
+
+ bool camerasModified = false;
+
+ qt3dsdm::SValue valCamEyeball;
+ qt3dsdm::Qt3DSDMInstanceHandle cameraLayer;
+
+ for (const auto &inst : qAsConst(cameraInstances)) {
+ GetPropertySystem()->GetInstancePropertyValue
+ (inst, theBridge->GetSceneAsset().m_Eyeball.m_Property, valCamEyeball);
+
+ cameraLayer = theBridge->GetResidingLayer(inst);
+ // Skip over instances without a valid layer. This also skips over the base camera instance
+ // that is included in the list we get.
+ if (!cameraLayer.Valid())
+ continue;
+ if (qt3dsdm::get<bool>(valCamEyeball)) {
+ // Set the first camera that has eyeball=true on this layer to be active and others to
+ // inactive. We might have several active cameras in old presentations,
+ // or in presentations modified by hand.
+ if (!getActiveCamera(cameraLayer).Valid()) {
+ setActiveCamera(cameraLayer, inst);
+ } else {
+ camerasModified = true;
+ SetInstancePropertyValue(inst, L"eyeball", false);
+ m_Core->GetDispatch()->FireImmediateRefreshInstance(inst);
+ }
+ }
+ }
+ return camerasModified;
+}
/**
* Deselects all the items and keyframes that are currently selected.
*/
@@ -809,12 +858,13 @@ void CDoc::CutObject(qt3dsdm::TInstanceHandleList inInstances)
using namespace Q3DStudio;
if (theContinueCutFlag) {
- CFilePath thePath(GetDocumentReader().CopySceneGraphObjects(inInstances));
+ CFilePath thePath(GetDocumentReader().CopySceneGraphObjects(inInstances, true));
Qt3DSFile theFile(thePath);
CStudioClipboard::CopyObjectToClipboard(
theFile, false, false,
m_StudioSystem->GetClientDataModelBridge()->GetObjectType(inInstances[0]));
SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Cut Object"))->DeleteInstances(inInstances);
+ m_firstPasteAfterCut = true;
}
}
@@ -825,11 +875,12 @@ void CDoc::CopyObject(qt3dsdm::TInstanceHandleList inInstances)
if (inInstances.empty())
return;
using namespace Q3DStudio;
- CFilePath thePath(GetDocumentReader().CopySceneGraphObjects(inInstances));
+ CFilePath thePath(GetDocumentReader().CopySceneGraphObjects(inInstances, false));
Qt3DSFile theFile(thePath);
CStudioClipboard::CopyObjectToClipboard(
theFile, false, false,
m_StudioSystem->GetClientDataModelBridge()->GetObjectType(inInstances[0]));
+ m_firstPasteAfterCut = false;
}
void CDoc::PasteObject(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
@@ -841,7 +892,9 @@ void CDoc::PasteObject(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
Qt3DSFile theTempAPFile = CStudioClipboard::GetObjectFromClipboard(false, dummy);
SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Paste Object"))
->PasteSceneGraphObject(theTempAPFile.GetAbsolutePath(), theInstance, true,
- DocumentEditorInsertType::LastChild, CPt());
+ DocumentEditorInsertType::LastChild, CPt(),
+ m_firstPasteAfterCut);
+ m_firstPasteAfterCut = false;
}
}
@@ -854,7 +907,9 @@ void CDoc::PasteObjectMaster(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
Qt3DSFile theTempAPFile = CStudioClipboard::GetObjectFromClipboard(false, dummy);
SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Paste Object"))
->PasteSceneGraphObjectMaster(theTempAPFile.GetAbsolutePath(), theInstance, true,
- DocumentEditorInsertType::LastChild, CPt());
+ DocumentEditorInsertType::LastChild, CPt(),
+ m_firstPasteAfterCut);
+ m_firstPasteAfterCut = false;
}
}
@@ -1163,16 +1218,22 @@ void CDoc::OnSlideDeleted(qt3dsdm::Qt3DSDMSlideHandle inSlide)
void CDoc::OnInstanceDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
+ using namespace qt3dsdm;
+ CClientDataModelBridge &theBridge(*m_StudioSystem->GetClientDataModelBridge());
+ SComposerObjectDefinitions &theDefinitions(theBridge.GetObjectDefinitions());
+ IDataCore &theCore(*m_StudioSystem->GetFullSystem()->GetCoreSystem()->GetDataCore());
+
if (GetSelectedInstance() == inInstance)
DeselectAllItems();
if (m_ActiveLayer == inInstance)
m_ActiveLayer = 0;
- using namespace qt3dsdm;
- CClientDataModelBridge &theBridge(*m_StudioSystem->GetClientDataModelBridge());
- SComposerObjectDefinitions &theDefinitions(theBridge.GetObjectDefinitions());
- IDataCore &theCore(*m_StudioSystem->GetFullSystem()->GetCoreSystem()->GetDataCore());
+ auto instanceLayer = theBridge.GetResidingLayer(inInstance);
+ if (m_ActiveCameras[instanceLayer] == inInstance) {
+ m_ActiveCameras.remove(instanceLayer);
+ }
+
if (theCore.IsInstanceOrDerivedFrom(inInstance, theDefinitions.m_SlideOwner.m_Instance)) {
Qt3DSDMSlideHandle theSlide = theBridge.GetComponentActiveSlide(inInstance);
if (theSlide == m_ActiveSlide) {
@@ -1208,15 +1269,15 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
{
using namespace qt3dsdm;
const auto bridge = m_StudioSystem->GetClientDataModelBridge();
+ bool isInsideMaterialContainer = bridge->isInsideMaterialContainer(inInstance);
// Save the material definition upon undo and redo
- if (m_Core->GetCmdStack()->isUndoingOrRedoing() &&
- bridge->isInsideMaterialContainer(inInstance)) {
+ if (m_Core->GetCmdStack()->isUndoingOrRedoing() && isInsideMaterialContainer) {
getSceneEditor()->saveIfMaterial(inInstance);
}
// If a material inside the material container is renamed, the file has to be renamed too
// and the referenced materials that refer to that renamed material
- if (inProperty == bridge->GetNameProperty() && bridge->isInsideMaterialContainer(inInstance)) {
+ if (inProperty == bridge->GetNameProperty() && isInsideMaterialContainer) {
const auto sceneEditor = getSceneEditor();
const QString dirPath = GetDocumentDirectory();
@@ -1385,7 +1446,7 @@ bool CDoc::isPlayHeadAtEnd()
return m_CurrentViewTime >= GetLatestEndTime();
}
-void CDoc::OnComponentSeconds()
+void CDoc::OnComponentTime()
{
long theTime = GetCurrentClientTime();
@@ -1424,8 +1485,8 @@ void CDoc::DoNotifyTimeChanged(long inNewTime)
// Update DataModel
qt3dsdm::Qt3DSDMSlideHandle theMasterSlide =
m_StudioSystem->GetSlideSystem()->GetMasterSlide(GetActiveSlide());
- // TODO: fix precision issue from converting to/from float & long. choose 1 type
- m_StudioSystem->GetSlideSystem()->SetComponentSeconds(theMasterSlide, (float)inNewTime / 1000);
+
+ m_StudioSystem->GetSlideSystem()->SetComponentTime(theMasterSlide, inNewTime);
}
/**
@@ -1491,7 +1552,7 @@ bool CDoc::IsPlaying()
long CDoc::GetCurrentClientTime()
{
if (m_ActiveSlide.Valid())
- return m_StudioSystem->GetSlideSystem()->GetComponentSecondsLong(m_ActiveSlide);
+ return m_StudioSystem->GetSlideSystem()->GetComponentTime(m_ActiveSlide);
return 0;
}
@@ -1676,6 +1737,9 @@ void CDoc::CloseDocument()
// Clear the modified flag - no data loaded
SetModifiedFlag(false);
+
+ // Invalidate document path, so isValid() returns false
+ m_DocumentPath.clear();
}
/**
@@ -2113,13 +2177,28 @@ void CDoc::LoadPresentationFile(CBufferedInputStream *inInputStream)
m_StudioSystem->GetFullSystem()->GetSignalSender()->SendActiveSlide(theMasterSlide, 1,
theChildSlide);
- if (uipVersion < 6) {
+ if (uipVersion < 6 || g_StudioApp.IsConvertingPresentationOn()) {
QTimer::singleShot(0, [=](){
// uipVersion 6 introduced vec4 colors
- g_StudioApp.GetDialogs()->DisplayMessageBox(
- tr("Old Presentation Version"),
- tr("Some custom materials, effects, and behaviors may not work correctly."),
- Qt3DSMessageBox::ICON_WARNING, false);
+ if (g_StudioApp.IsConvertingPresentationOn() && uipVersion < 6) {
+ g_StudioApp.GetDialogs()->DisplayMessageBox(
+ tr("Old Presentation Version and Texture Paths"),
+ tr("Some custom materials, effects, and behaviors may not work correctly.\n" \
+ "Converting custom material and effect textures into images."),
+ Qt3DSMessageBox::ICON_WARNING, false);
+ g_StudioApp.SetConvertingPresentationOff();
+ } else if (g_StudioApp.IsConvertingPresentationOn()) {
+ g_StudioApp.GetDialogs()->DisplayMessageBox(
+ tr("Old Texture Paths"),
+ tr("Converting custom material and effect textures into images."),
+ Qt3DSMessageBox::ICON_WARNING, false);
+ g_StudioApp.SetConvertingPresentationOff();
+ } else {
+ g_StudioApp.GetDialogs()->DisplayMessageBox(
+ tr("Old Presentation Version"),
+ tr("Some custom materials, effects, and behaviors may not work correctly."),
+ Qt3DSMessageBox::ICON_WARNING, false);
+ }
});
}
@@ -2165,11 +2244,9 @@ int CDoc::LoadStudioData(CBufferedInputStream *inInputStream)
CreateDOMReader(*inInputStream, theVersion);
if (!theReaderPtr)
throw CInvalidFileFormatException();
-
+ g_StudioApp.setDocumentVersion(theVersion);
IDOMReader &theReader(*theReaderPtr);
- theReader.Att("version", theVersion);
-
CProjectSettingsSerializer theProjectSettingsSerializer(
m_Core->GetStudioProjectSettings());
theReader.Serialize(L"ProjectSettings", theProjectSettingsSerializer);
@@ -2221,8 +2298,8 @@ void CDoc::ResetDataCore()
// Setup defaults
qt3dsdm::IStudioAnimationSystem *theAnimationSystem = GetStudioSystem()->GetAnimationSystem();
- theAnimationSystem->SetInterpolation(CStudioPreferences::GetInterpolation());
- theAnimationSystem->SetAutoKeyframe(CStudioPreferences::IsAutosetKeyframesOn());
+ theAnimationSystem->SetInterpolation(CStudioPreferences::isInterpolation());
+ theAnimationSystem->SetAutoKeyframe(CStudioPreferences::isAutosetKeyframesOn());
}
void CDoc::SetupDataCoreSignals()
@@ -2244,11 +2321,11 @@ void CDoc::SetupDataCoreSignals()
m_Connections.push_back(theSlideProvider->ConnectBeforeSlideDeleted(
std::bind(&CDoc::OnSlideDeleted, this, std::placeholders::_1)));
m_Connections.push_back(
- m_StudioSystem->GetFullSystem()->GetSignalProvider()->ConnectComponentSeconds(
- std::bind(&CDoc::OnComponentSeconds, this)));
+ m_StudioSystem->GetFullSystem()->GetSignalProvider()->ConnectComponentTime(
+ std::bind(&CDoc::OnComponentTime, this)));
m_Connections.push_back(
m_StudioSystem->GetFullSystem()->GetSignalProvider()->ConnectActiveSlide(
- std::bind(&CDoc::OnComponentSeconds, this)));
+ std::bind(&CDoc::OnComponentTime, this)));
// listener to keep track of datainput bindings
m_Connections.push_back(
@@ -2271,7 +2348,7 @@ std::shared_ptr<Q3DStudio::IComposerSerializer> CDoc::CreateSerializer()
*theFullSystem.GetActionSystem(), *theCoreSystem.GetSlideGraphCore(),
theClientBridge.GetObjectDefinitions(), m_ImportFailedHandler,
*theCoreSystem.GetGuideSystem(), *GetSceneGraph()->GetPathManager(),
- *theFullSystem.GetPropertySystem());
+ *theFullSystem.GetPropertySystem(), m_DocumentPath);
}
std::shared_ptr<Q3DStudio::IComposerSerializer> CDoc::CreateTransactionlessSerializer()
@@ -2290,7 +2367,7 @@ std::shared_ptr<Q3DStudio::IComposerSerializer> CDoc::CreateTransactionlessSeria
*theCoreSystem.GetTransactionlessSlideGraphCore(),
theClientBridge.GetObjectDefinitions(), m_ImportFailedHandler,
*theCoreSystem.GetGuideSystem(), *GetSceneGraph()->GetPathManager(),
- *theFullSystem.GetPropertySystem());
+ *theFullSystem.GetPropertySystem(), m_DocumentPath);
}
std::shared_ptr<qt3dsdm::IDOMWriter> CDoc::CreateDOMWriter()
@@ -2430,6 +2507,7 @@ void CDoc::SavePresentationFile(CBufferedOutputStream *inOutputStream)
using namespace qt3dsdm;
using namespace Q3DStudio;
+ g_StudioApp.setDocumentVersion(UIP_VERSION);
std::shared_ptr<IDOMWriter> theWriterPtr(CreateDOMWriter());
IDOMWriter &theWriter(*theWriterPtr);
@@ -2467,12 +2545,13 @@ void CDoc::SavePresentationFile(CBufferedOutputStream *inOutputStream)
m_DocumentBufferCache->GetOrCreateImageBuffer(CFilePath(theIter->first));
}
+ auto textureList = theBridge.GetDynamicObjectTextureList();
+ for (auto texture : textureList)
+ m_DocumentBufferCache->GetOrCreateImageBuffer(CFilePath(texture));
+
std::vector<pair<Q3DStudio::CString, SImageTextureData>> theImageBuffers;
m_DocumentBufferCache->GetImageBuffers(theImageBuffers);
- // Remove buffers that aren't in the map.
- erase_if(theImageBuffers, SBufferFilter(sourcePathToInstanceMap,
- *m_StudioSystem->GetFullSystem()->GetCoreSystem()->GetStringTablePtr()));
if (!theImageBuffers.empty()) {
// Ensure the source paths are always written out in the same order to keep source
// control reasonable
@@ -2481,23 +2560,32 @@ void CDoc::SavePresentationFile(CBufferedOutputStream *inOutputStream)
IDOMWriter::Scope __BufferData(theWriter, L"BufferData");
for (size_t idx = 0, end = theImageBuffers.size(); idx < end; ++idx) {
SImageTextureData theBuffer = theImageBuffers[idx].second;
- if (theBuffer.m_TextureFlags.HasTransparency()) {
- IDOMWriter::Scope __ImageScope(theWriter, L"ImageBuffer");
- theWriter.Att(L"sourcepath", theImageBuffers[idx].first.c_str());
- theWriter.Att("hasTransparency", true);
- }
+ IDOMWriter::Scope __ImageScope(theWriter, L"ImageBuffer");
+ theWriter.Att(L"sourcepath", theImageBuffers[idx].first.c_str());
+ // Writing boolean in wide text results just in "T" or "F" on Linux
+ theWriter.Att("hasTransparency", theBuffer.m_TextureFlags.HasTransparency());
+ if (theBuffer.m_TextureFlags.HasOpaquePixels())
+ theWriter.Att("hasOpaquePixels", true);
}
}
}
std::shared_ptr<IComposerSerializer> theSerializer(CreateSerializer());
- theSerializer->SerializeScene(theWriter);
+ theSerializer->SerializeScene(theWriter, GetDocumentDirectory());
SBufferedOutputStreamOutStream theStream(*inOutputStream);
CDOMSerializer::WriteXMLHeader(theStream);
CDOMSerializer::Write(*theWriter.GetTopElement(), theStream);
}
+bool CDoc::canSetKeyframeInterpolation() const
+{
+ if (m_KeyframesManager)
+ return m_KeyframesManager->canSetKeyframeInterpolation();
+
+ return false;
+}
+
void CDoc::SetKeyframeInterpolation()
{
if (m_KeyframesManager)
@@ -2782,7 +2870,7 @@ void CDoc::ScheduleRemoveComponentInstances(qt3dsdm::Qt3DSDMInstanceHandle inIns
void CDoc::SetDefaultKeyframeInterpolation(bool inSmooth)
{
- CStudioPreferences::SetInterpolation(inSmooth);
+ CStudioPreferences::setInterpolation(inSmooth);
GetStudioSystem()->GetAnimationSystem()->SetInterpolation(inSmooth);
}
@@ -2826,9 +2914,9 @@ void CDoc::OnPresentationDeactivated()
* @param outMats list of scene materials
*/
void CDoc::getSceneMaterials(qt3dsdm::Qt3DSDMInstanceHandle inParent,
- QVector<qt3dsdm::Qt3DSDMInstanceHandle> &outMats) const
+ QVector<qt3dsdm::Qt3DSDMInstanceHandle> &outMats)
{
- const CClientDataModelBridge *bridge = m_StudioSystem->GetClientDataModelBridge();
+ CClientDataModelBridge *bridge = m_StudioSystem->GetClientDataModelBridge();
for (long i = 0, count = m_AssetGraph->GetChildCount(inParent); i < count; ++i) {
qt3dsdm::Qt3DSDMInstanceHandle theChild(m_AssetGraph->GetChild(inParent, i));
if (!bridge->isMaterialContainer(theChild) && !bridge->isInsideMaterialContainer(theChild)
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h
index 47f25fc8..0d05880b 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.h
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.h
@@ -277,6 +277,7 @@ public:
bool canPasteObjects() const;
bool canPasteKeyframes() const;
bool canPasteActions() const;
+ bool canSetKeyframeInterpolation() const;
bool canPaste() const; // objects, keyframes, or actions
bool canCopy() const; // objects, keyframes, or actions
@@ -291,6 +292,13 @@ public:
void SetActiveLayer(qt3dsdm::Qt3DSDMInstanceHandle inLayerInstance);
qt3dsdm::Qt3DSDMSlideHandle GetActiveSlide();
+ qt3dsdm::Qt3DSDMInstanceHandle getActiveCamera(qt3dsdm::Qt3DSDMInstanceHandle inLayer) const;
+ void setActiveCamera(qt3dsdm::Qt3DSDMInstanceHandle inCameraLayer,
+ qt3dsdm::Qt3DSDMInstanceHandle inCameraInstance);
+ // Ensure that only one camera per layer is active.
+ // Returns true if additional cameras were inactivated.
+ bool ensureActiveCamera();
+
void SetPlayMode(EPlayMode inPlayMode, long inRestoreTime = -1);
bool IsPlaying();
long GetCurrentClientTime();
@@ -300,7 +308,7 @@ public:
// IDoc
virtual qt3dsdm::Qt3DSDMInstanceHandle GetActiveRootInstance();
long GetCurrentViewTime() const override;
- virtual void OnComponentSeconds();
+ virtual void OnComponentTime();
// Notify time changed and set the playback clock to this time.
void NotifyTimeChanged(long inNewTime) override;
// Notify time changed.
@@ -395,7 +403,7 @@ public:
bool preUndo() override;
void getSceneMaterials(qt3dsdm::Qt3DSDMInstanceHandle inParent,
- QVector<qt3dsdm::Qt3DSDMInstanceHandle> &outMats) const;
+ QVector<qt3dsdm::Qt3DSDMInstanceHandle> &outMats);
void getSceneReferencedMaterials(qt3dsdm::Qt3DSDMInstanceHandle inParent,
QVector<qt3dsdm::Qt3DSDMInstanceHandle> &outMats) const;
void getUsedSharedMaterials(QVector<qt3dsdm::Qt3DSDMInstanceHandle> &outMats) const;
@@ -467,6 +475,8 @@ protected:
qt3dsdm::Qt3DSDMInstanceHandle m_SceneInstance; // Pointer to the root level Scene object.
qt3dsdm::Qt3DSDMSlideHandle m_ActiveSlide; // The currently active Slide Handle.
qt3dsdm::Qt3DSDMInstanceHandle m_ActiveLayer; // The currently active layer.
+ // The currently active camera per-layer
+ QMap<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMInstanceHandle> m_ActiveCameras;
CPlaybackClock *m_PlaybackClock; // Playback clock. This is used when user clicks "Play"
CCore *m_Core;
bool m_IsModified;
@@ -504,6 +514,9 @@ protected:
Q3DStudio::CRect m_ClientSize;
Q3DStudio::CRect m_SceneRect; // The dimensions of the active scene view
+ // Indicate that the paste operation is first after cut operation
+ bool m_firstPasteAfterCut = false;
+
private:
bool m_playbackPreviewOn = false;
QString m_presentationId;
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp
index 1ff4bd5a..e64a3a6f 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp
@@ -135,6 +135,22 @@ struct SDocBufferCache : public IDocumentBufferCache
}
}
+ void reloadImageSet(const QSet<QString> &imageSet, bool flipCompressedTextures) override
+ {
+ auto bufMan = GetBufferManager();
+ if (bufMan) {
+ bufMan->unloadSet(imageSet);
+ bufMan->loadSet(imageSet, flipCompressedTextures);
+ }
+ }
+
+ void reloadAll(bool flipCompressedTextures) override
+ {
+ auto bufMan = GetBufferManager();
+ if (bufMan)
+ bufMan->reloadAll(flipCompressedTextures);
+ }
+
// Names are declared in the same order as the primitives
// offset by the empty primitive
const wchar_t **GetPrimitiveNames() override
@@ -230,10 +246,8 @@ struct SDocBufferCache : public IDocumentBufferCache
return entry->second.m_ImageBuffer;
CFilePath thePath(m_Doc.GetResolvedPathToDoc(inPath));
SImageTextureData retval;
- if (thePath.IsFile() && GetBufferManager()) {
- retval = GetBufferManager()->LoadRenderImage(
- GetBufferManager()->GetStringTable().RegisterStr(thePath.toCString()));
- }
+ if (thePath.IsFile() && GetBufferManager())
+ retval = GetBufferManager()->LoadRenderImage(thePath.toQString());
if (retval.m_Texture)
m_Buffers.insert(
make_pair(m_StringTablePtr->RegisterStr(inPath.toCString()), SModelBufferOrImage(retval)));
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index ac3c3b31..f2627e05 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -92,6 +92,11 @@
#include "StudioProjectSettings.h"
#include "StudioApp.h"
#include "StudioUtils.h"
+#include "Qt3DSDMHandles.h"
+#include "IStudioRenderer.h"
+#include "Qt3DSRenderBufferManager.h"
+#include "Qt3DSRenderDynamicObjectSystem.h"
+#include "Qt3DSRenderUIPSharedTranslation.h"
namespace {
@@ -155,7 +160,7 @@ class CDocEditor : public Q3DStudio::IInternalDocumentEditor
ISlideSystem &m_SlideSystem;
ISlideCore &m_SlideCore;
ISlideGraphCore &m_SlideGraphCore;
- IAnimationCore &m_AnimationCore;
+ IAnimationCore &m_animCore;
CClientDataModelBridge &m_Bridge;
IPropertySystem &m_PropertySystem;
IMetaData &m_MetaData;
@@ -182,7 +187,7 @@ public:
, m_SlideSystem(*m_StudioSystem.GetFullSystem()->GetSlideSystem())
, m_SlideCore(*m_StudioSystem.GetFullSystem()->GetCoreSystem()->GetSlideCore())
, m_SlideGraphCore(*m_StudioSystem.GetFullSystem()->GetCoreSystem()->GetSlideGraphCore())
- , m_AnimationCore(*m_StudioSystem.GetFullSystem()->GetAnimationCore())
+ , m_animCore(*m_StudioSystem.GetFullSystem()->GetAnimationCore())
, m_Bridge(*m_StudioSystem.GetClientDataModelBridge())
, m_PropertySystem(*m_StudioSystem.GetPropertySystem())
, m_MetaData(*m_StudioSystem.GetActionMetaData())
@@ -241,7 +246,7 @@ public:
Qt3DSDMSlideHandle theMaster = theSlideInfo.m_MasterSlide;
Qt3DSDMSlideHandle theActiveSlide = theSlideInfo.m_ActiveSlide;
if (theAssociatedSlide == theMaster || theAssociatedSlide == theActiveSlide) {
- long theViewTime = theSlideInfo.m_ComponentMilliseconds;
+ long theViewTime = theSlideInfo.m_ComponentTime;
return eyeballVal && theStart <= theViewTime && theEnd > 0 && theEnd >= theViewTime;
}
}
@@ -287,7 +292,8 @@ public:
if (m_SlideCore.GetSpecificInstancePropertyValue(theAssociatedSlide, instance, inProperty,
theGuid)
|| m_DataCore.GetInstancePropertyValue(instance, inProperty, theGuid)) {
- return m_Bridge.GetInstanceByGUID(get<SLong4>(theGuid));
+ if (theGuid.getType() == qt3dsdm::DataModelDataType::Long4)
+ return m_Bridge.GetInstanceByGUID(get<SLong4>(theGuid));
}
return TInstanceHandle();
}
@@ -423,7 +429,7 @@ public:
void GetPathToInstanceMap(TCharPtrToSlideInstanceMap &outInstanceMap,
qt3dsdm::Qt3DSDMPropertyHandle property,
- bool checkMaterialContainers = true,
+ bool skipMaterialContainers = true,
bool includeIdentifiers = true) const
{
SComposerObjectDefinitions &theDefinitions(m_Bridge.GetObjectDefinitions());
@@ -434,7 +440,7 @@ public:
for (size_t idx = 0, end = existing.size(); idx < end; ++idx) {
Qt3DSDMInstanceHandle theAsset(existing[idx]);
- if (checkMaterialContainers && m_Bridge.isInsideMaterialContainer(theAsset))
+ if (skipMaterialContainers && m_Bridge.isInsideMaterialContainer(theAsset))
continue;
thePaths.clear();
@@ -457,12 +463,12 @@ public:
}
void GetSourcePathToInstanceMap(TCharPtrToSlideInstanceMap &outInstanceMap,
- bool checkMaterialContainers = true,
+ bool skipMaterialContainers = true,
bool includeIdentifiers = true) const override
{
SComposerObjectDefinitions &theDefinitions(m_Bridge.GetObjectDefinitions());
GetPathToInstanceMap(outInstanceMap, theDefinitions.m_Asset.m_SourcePath,
- checkMaterialContainers, includeIdentifiers);
+ skipMaterialContainers, includeIdentifiers);
}
void GetImportPathToInstanceMap(TCharPtrToSlideInstanceMap &outInstanceMap) const override
@@ -666,7 +672,7 @@ public:
theSlide = m_SlideSystem.GetMasterSlide(theSlide);
inSlide = theSlide;
}
- return m_AnimationCore.GetAnimation(inSlide, instance, propHdl, subIndex).Valid();
+ return m_animCore.GetAnimation(inSlide, instance, propHdl, subIndex).Valid();
}
bool IsAnimationArtistEdited(TSlideHandle inSlide, Qt3DSDMInstanceHandle instance,
@@ -690,14 +696,14 @@ public:
}
Qt3DSDMAnimationHandle animHandle =
- m_AnimationCore.GetAnimation(inSlide, instance, propHdl, subIndex);
+ m_animCore.GetAnimation(inSlide, instance, propHdl, subIndex);
if (animHandle.Valid() == false)
return false;
- return m_AnimationCore.IsArtistEdited(animHandle);
+ return m_animCore.IsArtistEdited(animHandle);
}
pair<std::shared_ptr<qt3dsdm::IDOMWriter>, CFilePath>
- DoCopySceneGraphObject(const TInstanceHandleList &inInstances)
+ DoCopySceneGraphObject(const TInstanceHandleList &inInstances, bool preserveFileIds)
{
if (inInstances.empty())
return pair<std::shared_ptr<qt3dsdm::IDOMWriter>, CFilePath>();
@@ -705,7 +711,8 @@ public:
std::shared_ptr<IDOMWriter> theWriter(m_Doc.CreateDOMWriter());
TInstanceHandleList theInstances = ToGraphOrdering(inInstances);
m_Doc.CreateSerializer()->SerializeSceneGraphObjects(*theWriter, theInstances,
- GetActiveSlide(inInstances[0]));
+ GetActiveSlide(inInstances[0]),
+ preserveFileIds);
CFilePath theFile = WriteWriterToFile(*theWriter, L"SceneGraph");
return make_pair(theWriter, theFile);
}
@@ -714,7 +721,7 @@ public:
std::shared_ptr<qt3dsdm::IDOMReader>
CopySceneGraphObjectsToMemory(const qt3dsdm::TInstanceHandleList &instanceList)
{
- return DoCopySceneGraphObject(instanceList).first->CreateDOMReader();
+ return DoCopySceneGraphObject(instanceList, false).first->CreateDOMReader();
}
// Exposed through document reader interface
@@ -760,7 +767,7 @@ public:
return theFinalPath;
}
- CFilePath CopySceneGraphObjects(TInstanceHandleList inInstances) override
+ CFilePath CopySceneGraphObjects(TInstanceHandleList inInstances, bool preserveFileIds) override
{
if (inInstances.empty())
return L"";
@@ -771,7 +778,7 @@ public:
if (!shouldCopy)
return L"";
- return DoCopySceneGraphObject(inInstances).second;
+ return DoCopySceneGraphObject(inInstances, preserveFileIds).second;
}
CFilePath CopyAction(Qt3DSDMActionHandle inAction, Qt3DSDMSlideHandle inSlide) override
@@ -1064,6 +1071,18 @@ public:
m_Bridge.GetOrCreateGraphRoot(retval);
}
+ // Only one camera is active by default. If we already have one active, set the new camera
+ // to inactive.
+ if (inType == ComposerObjectTypes::Camera) {
+ auto cameraLayer = m_Bridge.GetResidingLayer(retval);
+ if (!m_Doc.getActiveCamera(cameraLayer).Valid()) {
+ m_Doc.setActiveCamera(cameraLayer, retval);
+ } else {
+ SetInstancePropertyValue(
+ retval, m_Bridge.GetSceneAsset().m_Eyeball.m_Property, false);
+ }
+ }
+
// if we did not set time range earlier, let's set it now to match parent
TInstanceHandle handle = FinalizeAddOrDrop(retval, inParent, inInsertType, inPosition,
!setTimeRange, selectCreatedInstance, false);
@@ -1164,8 +1183,15 @@ public:
if (!m_Bridge.GetMaterialFromImageInstance(instance, theParent, theProperty))
m_Bridge.GetLayerFromImageProbeInstance(instance, theParent, theProperty);
- if (theParent.Valid())
- m_PropertySystem.SetInstancePropertyValue(theParent, theProperty, SLong4());
+ if (theParent.Valid()) {
+ auto type = m_PropertySystem.GetAdditionalMetaDataType(theParent, theProperty);
+ if (type == AdditionalMetaDataType::Image) {
+ m_PropertySystem.SetInstancePropertyValue(theParent, theProperty, SLong4());
+ } else if (type == AdditionalMetaDataType::Texture) {
+ m_PropertySystem.SetInstancePropertyValue(theParent, theProperty,
+ std::make_shared<CDataStr>(Q3DStudio::CString()));
+ }
+ }
} else if (m_Bridge.IsBehaviorInstance(instance) || m_Bridge.IsEffectInstance(instance)
|| m_Bridge.IsCustomMaterialInstance(instance)) {
// Check if this is the last instance that uses the same sourcepath property
@@ -1421,6 +1447,24 @@ public:
SetName(theMaterial, materialName);
}
+ const dynamic::SPropertyDefinition *findDynamicProperty(const SMetaDataDynamicObject &dynObj,
+ CRegisteredString name)
+ {
+ for (int i = 0; i < dynObj.m_Properties.size(); i++) {
+ if (dynObj.m_Properties[i].m_Name == name)
+ return &dynObj.m_Properties[i];
+ }
+ return nullptr;
+ }
+
+ bool isDynamicObjectInstance(TInstanceHandle instance) const
+ {
+ return m_DataCore.IsInstanceOrDerivedFrom(
+ instance, m_Bridge.GetObjectDefinitions().m_CustomMaterial.m_Instance)
+ || m_DataCore.IsInstanceOrDerivedFrom(
+ instance, m_Bridge.GetObjectDefinitions().m_Effect.m_Instance);
+ }
+
// Normal way in to the system.
void SetInstancePropertyValue(TInstanceHandle instance, TPropertyHandle propName,
const SValue &value, bool inAutoDelete = true) override
@@ -1429,25 +1473,64 @@ public:
AdditionalMetaDataType::Value theProperytMetaData =
thePropertySystem.GetAdditionalMetaDataType(instance, propName);
TSlideHandle theNewSlide(GetSlideForProperty(instance, propName));
- if (theProperytMetaData == AdditionalMetaDataType::Image) {
+ if (theProperytMetaData == AdditionalMetaDataType::Image
+ || theProperytMetaData == AdditionalMetaDataType::Texture) {
TDataStrPtr theImageSourcePath = get<TDataStrPtr>(value);
bool hasValue = theImageSourcePath && theImageSourcePath->GetLength() > 0;
qt3dsdm::Qt3DSDMInstanceHandle theImageInstance =
GetImageInstanceForProperty(instance, propName);
+ SMetaDataDynamicObject *dynObj = nullptr;
+ if (isDynamicObjectInstance(instance)) {
+ TInstanceHandleList parents;
+ m_DataCore.GetInstanceParents(instance, parents);
+ if (parents.size() > 0)
+ dynObj = m_MetaData.GetDynamicObjectByInstance(parents[0]);
+ }
if (hasValue) {
- if (theImageInstance.Valid() == false)
+ bool imageInstanceCreated = false;
+ if (theImageInstance.Valid() == false) {
theImageInstance = CreateImageInstanceForMaterialOrLayer(instance, propName);
+ imageInstanceCreated = true;
+ }
if (theImageInstance) {
SetInstancePropertyValue(theImageInstance, m_Bridge.GetSourcePathProperty(),
value, inAutoDelete);
+ SetInstancePropertyValue(theImageInstance, m_Bridge.GetNameProperty(),
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(thePropertySystem
+ .GetName(propName).wide_str())));
+ if (dynObj && (g_StudioApp.IsConvertingPresentationOn()
+ || imageInstanceCreated)) {
+ // In this case we are just loading the presentation and need to convert old-style
+ // texture paths into images.
+ // Set the image defaults from the dynamic object
+ const dynamic::SPropertyDefinition *dynamicProperty
+ = findDynamicProperty(*dynObj, m_StringTable.GetRenderStringTable()
+ .RegisterStr(thePropertySystem.GetName(propName).c_str()));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_MinFilter,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_MinFilterOp))));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_MagFilter,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_MagFilterOp))));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_TilingU,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_CoordOp))));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_TilingV,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_CoordOp))));
+ }
// Clear subpresentation value
SetInstancePropertyValue(theImageInstance,
m_Bridge.GetSceneImage().m_SubPresentation,
std::make_shared<CDataStr>(Q3DStudio::CString()),
inAutoDelete);
}
-
} else {
if (theImageInstance.Valid()) {
TSlideHandle theInstanceSlide = GetAssociatedSlide(instance);
@@ -1511,7 +1594,7 @@ public:
m_AssetGraph.GetParent(instance), instance, theNewSlide, docDir, log,
std::bind(CPerformImport::ImportToComposerFromImportFile,
std::placeholders::_1, std::placeholders::_2),
- DocumentEditorInsertType::Unknown, CPt(), times.first);
+ DocumentEditorInsertType::Unknown, CPt(), times.first, false);
}
thePropertySystem.SetInstancePropertyValue(instance, propName, value);
} else if (propName == m_Bridge.GetObjectDefinitions().m_Path.m_PathType
@@ -1571,6 +1654,20 @@ public:
}
// Now set the property for reals
thePropertySystem.SetInstancePropertyValue(instance, propName, value);
+ } else if (propName == m_Bridge.GetSceneAsset().m_Eyeball
+ && m_Bridge.IsCameraInstance(instance)) {
+ auto cameraLayer = m_Bridge.GetResidingLayer(instance);
+ auto activeCamera = m_Doc.getActiveCamera(cameraLayer);
+ if ((instance != activeCamera) && get<bool>(value)) {
+ // Only one camera per layer should be active. Set the previous one to inactive if
+ // we are activating another one.
+ if (activeCamera.Valid())
+ thePropertySystem.SetInstancePropertyValue(activeCamera, propName, false);
+ m_Doc.setActiveCamera(cameraLayer, instance);
+ } else if (!get<bool>(value) && activeCamera == instance) {
+ m_Doc.setActiveCamera(cameraLayer, {}); // Inactivating current active camera.
+ }
+ thePropertySystem.SetInstancePropertyValue(instance, propName, value);
} else {
if (propName != m_Bridge.GetAlias().m_ReferencedNode.m_Property) {
thePropertySystem.SetInstancePropertyValue(instance, propName, value);
@@ -1852,6 +1949,7 @@ public:
// Keep material names the same so that if you change the material type
// any relative path links will still work.
// Next bug is harder (keep id's the same).
+ Q3DStudio::CString fileId = GetFileId(instance);
Q3DStudio::CString theName = GetName(instance);
SLong4 theGuid = m_Bridge.GetInstanceGUID(instance);
TInstanceHandle nextChild = m_AssetGraph.GetSibling(instance, true);
@@ -1911,6 +2009,9 @@ public:
m_Bridge.GetObjectDefinitions().m_Lightmaps.m_LightmapShadow,
theLightmapShadowValue, false);
+ m_DataCore.SetInstancePropertyValue(newMaterial,
+ m_Bridge.GetObjectDefinitions().m_Asset.m_FileId,
+ std::make_shared<CDataStr>(fileId.c_str()));
SetName(newMaterial, theName, false);
m_Bridge.SetInstanceGUID(newMaterial, theGuid);
// Copy all actions from old material instance to new material instance
@@ -2031,7 +2132,7 @@ public:
&& name != QLatin1String("timebartext");
}
- void saveIfMaterial(Qt3DSDMInstanceHandle instance)
+ void saveIfMaterial(Qt3DSDMInstanceHandle instance) override
{
Qt3DSDMInstanceHandle material;
if (m_Bridge.isInsideMaterialContainer(instance)) {
@@ -2123,7 +2224,8 @@ public:
}
const QFileInfo fileInfo(file);
- writeProperty(file, QStringLiteral("path"), fileInfo.absoluteFilePath());
+ writeProperty(file, QStringLiteral("path"),
+ projDir.relativeFilePath(fileInfo.absoluteFilePath()));
QMapIterator<QString, Qt3DSDMInstanceHandle> i(textureHandles);
while (i.hasNext()) {
@@ -2496,6 +2598,16 @@ public:
void copyMaterialProperties(Qt3DSDMInstanceHandle src, Qt3DSDMInstanceHandle dst) override
{
+ const EStudioObjectType matType = m_Bridge.GetObjectType(src);
+ QString materialTypeString;
+ if (matType == OBJTYPE_CUSTOMMATERIAL)
+ materialTypeString = m_Bridge.GetSourcePath(src);
+ else if (matType == OBJTYPE_MATERIAL)
+ materialTypeString = QStringLiteral("Standard Material");
+ else
+ return;
+ SetMaterialType(dst, materialTypeString);
+
const auto srcSlide = m_SlideSystem.GetApplicableSlide(src);
const auto dstSlide = m_SlideSystem.GetApplicableSlide(dst);
const auto name = GetName(dst);
@@ -2542,8 +2654,7 @@ public:
TSlideHandle inDestSlide, TInstanceHandle inDestInstance)
{
m_SlideCore.CopyProperties(inSourceSlide, inSourceInstance, inDestSlide, inDestInstance);
- m_AnimationCore.CopyAnimations(inSourceSlide, inSourceInstance, inDestSlide,
- inDestInstance);
+ m_animCore.CopyAnimations(inSourceSlide, inSourceInstance, inDestSlide, inDestInstance);
}
void UnlinkProperty(TInstanceHandle instance, TPropertyHandle propName) override
@@ -2726,7 +2837,7 @@ public:
}
SetTimeRange(inInstance, theTimeRange.first + inOffset, theTimeRange.second + inOffset);
// Offset all the keyframes linked to animations of this instance by this offset.
- m_AnimationCore.OffsetAnimations(m_Doc.GetActiveSlide(), inInstance, inOffset);
+ m_animCore.OffsetAnimations(m_Doc.GetActiveSlide(), inInstance, inOffset);
// Offset children time as well
CGraphIterator theChildren;
@@ -2809,8 +2920,8 @@ public:
}
template <typename TKeyframeType>
- void AddKeyframes(Qt3DSDMAnimationHandle animHandle, const float *keyframeValues, long numValues,
- long inOffsetInSeconds)
+ void AddKeyframes(Qt3DSDMAnimationHandle animHandle, const float *keyframeValues,
+ long numValues, long timeOffset)
{
long numFloatsPerKeyframe = sizeof(TKeyframeType) / sizeof(float);
if (numValues % numFloatsPerKeyframe) {
@@ -2820,27 +2931,74 @@ public:
long numKeyframes = numValues / numFloatsPerKeyframe;
for (long idx = 0; idx < numKeyframes; ++idx) {
TKeyframeType theData(keyframes[idx]);
- theData.m_KeyframeSeconds += inOffsetInSeconds;
- m_AnimationCore.InsertKeyframe(animHandle, theData);
+ theData.m_time += timeOffset;
+ m_animCore.InsertKeyframe(animHandle, theData);
}
}
- void SetKeyframeTime(TKeyframeHandle inKeyframe, long inTime) override
+ void SetKeyframeTime(TKeyframeHandle kfHandle, long time) override
{
- float theTimeinSecs = static_cast<float>(inTime) / 1000.f;
- // round off to 4 decimal place to workaround precision issues
- // TODO: fix this, either all talk float OR long. choose one.
- theTimeinSecs = ceilf(theTimeinSecs * 10000.0f) / 10000.0f;
- TKeyframe theData = m_AnimationCore.GetKeyframeData(inKeyframe);
- // Function programming paradigm, returns new value instead of changing
- // current value.
- theData = qt3dsdm::SetKeyframeSeconds(theData, theTimeinSecs);
- m_AnimationCore.SetKeyframeData(inKeyframe, theData);
+ TKeyframe kfData = m_animCore.GetKeyframeData(kfHandle);
+
+ // offset control points for bezier keyframes
+ offsetBezier(kfData, time - getKeyframeTime(kfData));
+
+ // Functional programming paradigm, returns new value instead of changing current value.
+ kfData = qt3dsdm::setKeyframeTime(kfData, time);
+ m_animCore.SetKeyframeData(kfHandle, kfData);
+
+ // For bezier keyframes check that control points of the moved keyframe and the keyframes
+ // before and after it don't go beyond its adjacent keyframes times.
+ Qt3DSDMAnimationHandle anim = m_animCore.GetAnimationForKeyframe(kfHandle);
+ EAnimationType animType = m_animCore.GetAnimationInfo(anim).m_AnimationType;
+ if (animType == EAnimationTypeBezier) {
+ TKeyframeHandleList keyframes;
+ m_animCore.GetKeyframes(anim, keyframes);
+ for (size_t i = 0; i < keyframes.size(); ++i) {
+ if (keyframes[i] == kfHandle) {
+ SBezierKeyframe kfCurr = get<SBezierKeyframe>(m_animCore.GetKeyframeData(
+ kfHandle));
+ if (i > 0) { // check overlap with prev keyframe
+ SBezierKeyframe kfPrev = get<SBezierKeyframe>(m_animCore.GetKeyframeData(
+ keyframes[i - 1]));
+ if (kfPrev.m_OutTangentTime > kfCurr.m_time)
+ kfPrev.m_OutTangentTime = kfCurr.m_time;
+
+ if (kfCurr.m_InTangentTime < kfPrev.m_time)
+ kfCurr.m_InTangentTime = kfPrev.m_time;
+
+ m_animCore.SetKeyframeData(keyframes[i - 1], kfPrev);
+
+ // Mahmoud_TODO: trim the value proportinally also so that the control
+ // point lines maintains the same slope after the time is trimmed
+ }
+
+ if (i < keyframes.size() - 1) { // check overlap with next keyframe
+ SBezierKeyframe kfNext = get<SBezierKeyframe>(m_animCore.GetKeyframeData(
+ keyframes[i + 1]));
+ if (kfNext.m_InTangentTime < kfCurr.m_time)
+ kfNext.m_InTangentTime = kfCurr.m_time;
+
+ if (kfCurr.m_OutTangentTime > kfNext.m_time)
+ kfCurr.m_OutTangentTime = kfNext.m_time;
+
+ m_animCore.SetKeyframeData(keyframes[i + 1], kfNext);
+ }
+ m_animCore.SetKeyframeData(kfHandle, kfCurr);
+ break;
+ }
+ }
+ }
+ }
+
+ void setBezierKeyframeValue(TKeyframeHandle kfHandle, const TKeyframe &kfData) override
+ {
+ m_animCore.SetKeyframeData(kfHandle, kfData);
}
void DeleteAllKeyframes(Qt3DSDMAnimationHandle inAnimation) override
{
- m_AnimationCore.DeleteAllKeyframes(inAnimation);
+ m_animCore.DeleteAllKeyframes(inAnimation);
}
void KeyframeProperty(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty,
@@ -2854,52 +3012,48 @@ public:
const wchar_t *propName, long subIndex, EAnimationType animType,
const float *keyframeValues, long numValues, bool /*inUserEdited*/) override
{
- Qt3DSDMPropertyHandle propHdl =
- m_DataCore.GetAggregateInstancePropertyByName(instance, propName);
- if (propHdl.Valid() == false) {
+ Qt3DSDMPropertyHandle property = m_DataCore.GetAggregateInstancePropertyByName(instance,
+ propName);
+ if (!property.Valid()) {
QT3DS_ASSERT(false);
return 0;
}
- if (inSlide.Valid() == false) {
+ if (!inSlide.Valid()) {
Qt3DSDMSlideHandle theSlide = m_SlideSystem.GetAssociatedSlide(instance);
- if (theSlide.Valid() == false) {
+ if (!theSlide.Valid()) {
assert(0);
return 0;
}
- if (m_SlideSystem.IsPropertyLinked(instance, propHdl))
+ if (m_SlideSystem.IsPropertyLinked(instance, property))
theSlide = m_SlideSystem.GetMasterSlide(theSlide);
inSlide = theSlide;
}
Qt3DSDMAnimationHandle animHandle =
- m_AnimationCore.GetAnimation(inSlide, instance, propHdl, subIndex);
+ m_animCore.GetAnimation(inSlide, instance, property, subIndex);
- if (animHandle.Valid() == true)
- m_AnimationCore.DeleteAnimation(animHandle);
+ if (animHandle.Valid())
+ m_animCore.DeleteAnimation(animHandle);
animHandle =
- m_AnimationCore.CreateAnimation(inSlide, instance, propHdl, subIndex, animType, false);
+ m_animCore.CreateAnimation(inSlide, instance, property, subIndex, animType, false);
long theStartTime = GetTimeRange(instance).first;
- long theTimeOffsetInSeconds = long(theStartTime / 1000.f);
switch (animType) {
case EAnimationTypeLinear:
- AddKeyframes<SLinearKeyframe>(animHandle, keyframeValues, numValues,
- theTimeOffsetInSeconds);
+ AddKeyframes<SLinearKeyframe>(animHandle, keyframeValues, numValues, theStartTime);
break;
case EAnimationTypeBezier:
- AddKeyframes<SBezierKeyframe>(animHandle, keyframeValues, numValues,
- theTimeOffsetInSeconds);
+ AddKeyframes<SBezierKeyframe>(animHandle, keyframeValues, numValues, theStartTime);
break;
case EAnimationTypeEaseInOut:
AddKeyframes<SEaseInEaseOutKeyframe>(animHandle, keyframeValues, numValues,
- theTimeOffsetInSeconds);
+ theStartTime);
break;
default:
QT3DS_ASSERT(false);
- AddKeyframes<SLinearKeyframe>(animHandle, keyframeValues, numValues,
- theTimeOffsetInSeconds);
+ AddKeyframes<SLinearKeyframe>(animHandle, keyframeValues, numValues, theStartTime);
break;
}
return animHandle;
@@ -2914,9 +3068,9 @@ public:
return false;
}
Qt3DSDMAnimationHandle animHandle =
- m_AnimationCore.GetAnimation(inSlide, instance, propHdl, subIndex);
+ m_animCore.GetAnimation(inSlide, instance, propHdl, subIndex);
if (animHandle.Valid()) {
- m_AnimationCore.DeleteAnimation(animHandle);
+ m_animCore.DeleteAnimation(animHandle);
return true;
}
return false;
@@ -2924,7 +3078,7 @@ public:
void SetIsArtistEdited(Qt3DSDMAnimationHandle inAnimation, bool inEdited = true) override
{
- m_AnimationCore.SetIsArtistEdited(inAnimation, inEdited);
+ m_animCore.SetIsArtistEdited(inAnimation, inEdited);
}
qt3dsdm::Qt3DSDMInstanceHandle
@@ -3000,11 +3154,13 @@ public:
bool inGenerateUniqueName,
DocumentEditorInsertType::Enum inInsertType,
const CPt &inPosition,
+ bool preserveFileIds,
bool notifyRename = true)
{
std::shared_ptr<IComposerSerializer> theSerializer = m_Doc.CreateSerializer();
TInstanceHandleList retval = theSerializer->SerializeSceneGraphObject(
- *inReader, m_Doc.GetDocumentDirectory(), inNewRoot, GetActiveSlide(inNewRoot));
+ *inReader, m_Doc.GetDocumentDirectory(), inNewRoot, GetActiveSlide(inNewRoot),
+ preserveFileIds);
for (size_t idx = 0, end = retval.size(); idx < end; ++idx) {
qt3dsdm::Qt3DSDMInstanceHandle theInstance(retval[idx]);
if (inInsertType == DocumentEditorInsertType::NextSibling)
@@ -3023,7 +3179,8 @@ public:
TInstanceHandle inNewRoot,
bool inGenerateUniqueName,
DocumentEditorInsertType::Enum inInsertType,
- const CPt &inPosition) override
+ const CPt &inPosition,
+ bool preserveFileIds) override
{
qt3ds::QT3DSI32 theVersion = 0;
std::shared_ptr<IDOMReader> theReader = m_Doc.CreateDOMReader(
@@ -3031,13 +3188,14 @@ public:
if (!theReader)
return TInstanceHandleList();
return DoPasteSceneGraphObject(theReader, inNewRoot, inGenerateUniqueName, inInsertType,
- inPosition, false);
+ inPosition, preserveFileIds, false);
}
virtual TInstanceHandleList
PasteSceneGraphObjectMaster(const CFilePath &inFilePath, TInstanceHandle inNewRoot,
bool inGenerateUniqueName,
- DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition) override
+ DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition,
+ bool preserveFileIds) override
{
qt3ds::QT3DSI32 theVersion = 0;
std::shared_ptr<IDOMReader> theReader = m_Doc.CreateDOMReader(
@@ -3048,7 +3206,8 @@ public:
std::shared_ptr<IComposerSerializer> theSerializer = m_Doc.CreateSerializer();
TInstanceHandleList retval = theSerializer->SerializeSceneGraphObject(
*theReader, m_Doc.GetDocumentDirectory(), inNewRoot,
- m_Doc.GetStudioSystem()->GetSlideSystem()->GetMasterSlide(GetActiveSlide(inNewRoot)));
+ m_Doc.GetStudioSystem()->GetSlideSystem()->GetMasterSlide(GetActiveSlide(inNewRoot)),
+ preserveFileIds);
for (size_t idx = 0, end = retval.size(); idx < end; ++idx) {
qt3dsdm::Qt3DSDMInstanceHandle theInstance(retval[idx]);
if (inInsertType == DocumentEditorInsertType::NextSibling)
@@ -3253,7 +3412,7 @@ public:
// Paste into the master slide of the new component
TInstanceHandleList insertedHandles = theSerializer->SerializeSceneGraphObject(
*theReader,m_Doc.GetDocumentDirectory(), component,
- m_SlideSystem.GetMasterSlide(theComponentSlide));
+ m_SlideSystem.GetMasterSlide(theComponentSlide), true);
// Restore the original time range for all objects.
if (insertedHandles.size()) {
@@ -3278,19 +3437,10 @@ public:
if (oldType == "ReferencedMaterial") {
Qt3DSDMInstanceHandle refMaterial = m_Bridge.getMaterialReference(instance);
- if (refMaterial.Valid()) {
- const Q3DStudio::CString refType = GetObjectTypeName(refMaterial);
- QString v;
- if (refType == "CustomMaterial")
- v = m_Bridge.GetSourcePath(refMaterial);
- else
- v = QStringLiteral("Standard Material");
-
- SetMaterialType(instance, v);
+ if (refMaterial.Valid())
copyMaterialProperties(refMaterial, instance);
- } else {
+ else
SetMaterialType(instance, QStringLiteral("Standard Material"));
- }
const auto name = GetName(instance);
if (!name.toQString().endsWith(QLatin1String("_animatable")))
@@ -3336,7 +3486,7 @@ public:
theSerializer->SerializeSceneGraphObject(
*theReader, m_Doc.GetDocumentDirectory(),
targetComponent,
- m_SlideSystem.GetMasterSlide(theComponentSlide));
+ m_SlideSystem.GetMasterSlide(theComponentSlide), true);
if (insertedHandles.size()) {
// Restore the original time range for all objects.
@@ -3381,7 +3531,7 @@ public:
{
qt3dsdm::TInstanceHandleList theInstances(ToGraphOrdering(inInstances));
std::shared_ptr<IDOMReader> theReader(CopySceneGraphObjectsToMemory(theInstances));
- return DoPasteSceneGraphObject(theReader, inDest, true, inInsertType, CPt(), false);
+ return DoPasteSceneGraphObject(theReader, inDest, true, inInsertType, CPt(), false, false);
}
Qt3DSDMActionHandle AddAction(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inOwner,
@@ -3515,6 +3665,8 @@ public:
int newSlideIndex = m_SlideSystem.GetSlideIndex(theNewSlide);
m_SlideSystem.SetActiveSlide(inMasterSlide, newSlideIndex);
m_Doc.NotifyActiveSlideChanged(theNewSlide, true);
+ // Make sure layer is reseted
+ m_Doc.SetActiveLayer(0);
CheckSlideGroupPlayThroughTo(theNewSlide);
Qt3DSDMInstanceHandle theInstance = m_Doc.GetSelectedInstance();
if (theInstance.Valid() && GetAssociatedSlide(theInstance) != inMasterSlide)
@@ -3578,6 +3730,18 @@ public:
m_Bridge.GetObjectDefinitions().m_Named.m_NameProp,
std::make_shared<CDataStr>(theNewName.c_str()));
+ // Change non-masterslide instance names to unique.
+ TInstanceHandleList slideInstances;
+ m_SlideSystem.GetAssociatedInstances(theNewSlide, slideInstances);
+ for (size_t idx = 0, end = slideInstances.size(); idx < end; ++idx) {
+ TInstanceHandle theInstance(slideInstances[idx]);
+ if (m_SlideSystem.GetApplicableSlide(theInstance)
+ != m_SlideSystem.GetMasterSlide(theInstance)
+ && !m_Bridge.GetName(theInstance).IsEmpty()) {
+ SetName(theInstance, m_Bridge.GetName(theInstance), true);
+ }
+ }
+
// Ensure the active slide change gets recorded in the transaction system so that
// undo will place us back at the old slide before things start reading from the object
// model.
@@ -3586,6 +3750,8 @@ public:
m_Doc.SetActiveSlideWithTransaction(theNewSlide);
m_Doc.NotifyActiveSlideChanged(theNewSlide, true);
+ // Make sure layer is reseted
+ m_Doc.SetActiveLayer(0);
CheckSlideGroupPlayThroughTo(theNewSlide);
return theNewSlide;
}
@@ -3718,7 +3884,8 @@ public:
Qt3DSDMInstanceHandle inRoot, Qt3DSDMSlideHandle inSlide, Q3DStudio::CString inDocDir,
STranslationLog &inTranslationLog,
function<SImportResult(IComposerEditorInterface &, Q3DStudio::CString)> inImportFunction,
- DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition, long inStartTime)
+ DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition, long inStartTime,
+ bool selectAfterImport)
{
CFilePath outputDir(inImportFilePath.GetDirectory());
bool alwaysKeepDirectory = outputDir.Exists();
@@ -3761,7 +3928,7 @@ public:
// Do not check for unique name as we set it anyway after getting new handle
Qt3DSDMInstanceHandle retval =
FinalizeAddOrDrop(importToComposer->GetRoot(), inParent, inInsertType,
- inPosition, inStartTime == -1, true, false);
+ inPosition, inStartTime == -1, selectAfterImport, false);
SetName(retval, theRelPath.GetFileStem(), true);
updateMaterialFiles();
@@ -3821,7 +3988,7 @@ public:
inParent, 0, inSlide, docDir, translator.m_TranslationLog,
std::bind(CPerformImport::ImportToComposer, translator,
std::placeholders::_1, std::placeholders::_2), inDropType,
- inPosition, inStartTime);
+ inPosition, inStartTime, true);
if (retval.Valid()) {
CFilePath theRelativeImport = m_Doc.GetRelativePathToDoc(outputFileName);
m_ImportFileToDAEMap.insert(
@@ -3844,7 +4011,7 @@ public:
return DoImport(inFullPathToDocument, inFullPathToDocument, inParent, 0, inSlide, docDir,
log, std::bind(CPerformImport::ImportToComposerFromImportFile,
std::placeholders::_1, std::placeholders::_2),
- inDropType, inPosition, inStartTime);
+ inDropType, inPosition, inStartTime, true);
}
QString findUniqueMaterialName(const QString &name, const QString &importPath)
@@ -4009,18 +4176,6 @@ public:
inStartTime == -1);
}
- static void *l_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
- {
- Q_UNUSED(ud)
- Q_UNUSED(osize)
-
- if (nsize == 0) {
- free(ptr);
- return nullptr;
- } else
- return realloc(ptr, nsize);
- }
-
QString LoadScriptFile(const CFilePath &inFile)
{
QString retval;
@@ -4097,12 +4252,25 @@ public:
theHandler->DisplayImportFailed(inSrcPath, resultDialogStr, true);
}
+ template <typename T>
+ const wchar_t *MapEnum(T enumValue) {
+ SEnumNameMap *map = SEnumParseMap<T>::GetMap();
+ while (map->m_Enum != -1) {
+ if (map->m_Enum == enumValue)
+ return map->m_WideName;
+ map = map + 1;
+ }
+ return nullptr;
+ }
+
// Apply meta data to a new dynamic instance. This sets up the default properties to
// be what the meta data specifies.
void ApplyDynamicMetaData(Qt3DSDMInstanceHandle inDynamicInstance,
- Qt3DSDMInstanceHandle inDynamic)
+ Qt3DSDMInstanceHandle inDynamic,
+ const SMetaDataDynamicObject &dynObj)
{
std::vector<SMetaDataLoadWarning> theWarnings;
+
// For all of the object std::ref properties, check if they have an absolute path
// reference (path starts with "Scene". If they do, then attempt to resolve the reference.
vector<Qt3DSDMMetaDataPropertyHandle> theProperties;
@@ -4172,6 +4340,62 @@ public:
m_DataCore.SetInstancePropertyValue(inDynamic, theInfo.m_Property, theRef);
}
}
+ } else if (theInfo.m_CompleteType == CompleteMetaDataType::Texture
+ && GetValueType(theInfo.m_DefaultValue) == DataModelDataType::String) {
+ SValue value;
+ m_DataCore.GetInstancePropertyValue(inDynamic, theInfo.m_Property, value);
+ // Set default value to the instance
+ if (!value.empty()) {
+ TDataStrPtr theImageSourcePath = get<TDataStrPtr>(value);
+ bool hasValue = theImageSourcePath && theImageSourcePath->GetLength() > 0;
+ qt3dsdm::Qt3DSDMInstanceHandle theImageInstance =
+ GetImageInstanceForProperty(inDynamicInstance, theInfo.m_Property);
+ const dynamic::SPropertyDefinition *dynamicProperty
+ = findDynamicProperty(dynObj, m_StringTable.GetRenderStringTable().
+ RegisterStr(theInfo.m_Name.wide_str()));
+ if (hasValue || (dynamicProperty && dynamicProperty->m_ImagePath.IsValid())) {
+ if (!theImageInstance.Valid()) {
+ theImageInstance = CreateImageInstanceForMaterialOrLayer(
+ inDynamicInstance, theInfo.m_Property);
+ if (dynamicProperty) {
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_MinFilter,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_MinFilterOp))));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_MagFilter,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_MagFilterOp))));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_TilingU,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_CoordOp))));
+ m_PropertySystem.SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetObjectDefinitions().m_Image.m_TilingV,
+ std::make_shared<CDataStr>(
+ Q3DStudio::CString(MapEnum(dynamicProperty->m_CoordOp))));
+ if (!hasValue) {
+ value = std::make_shared<CDataStr>(
+ Q3DStudio::CString(dynamicProperty->m_ImagePath.c_str()));
+ }
+ }
+ }
+ if (theImageInstance) {
+ SetInstancePropertyValue(theImageInstance, m_Bridge.GetNameProperty(),
+ std::make_shared<CDataStr>(Q3DStudio::CString(
+ m_PropertySystem.GetName(theInfo.m_Property).wide_str())));
+ SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetSourcePathProperty(), value);
+ // Clear subpresentation value
+ SetInstancePropertyValue(theImageInstance,
+ m_Bridge.GetSceneImage().m_SubPresentation,
+ make_shared<CDataStr>(Q3DStudio::CString()));
+ }
+ } else {
+ m_DataCore.SetInstancePropertyValue(inDynamicInstance, theInfo.m_Property,
+ make_shared<CDataStr>(Q3DStudio::CString()));
+ }
+ }
}
}
}
@@ -4239,11 +4463,12 @@ public:
}
}
if (theParentInstance.Valid()) {
+ SMetaDataDynamicObject dynObj;
TInstanceHandle retval(IDocumentEditor::CreateSceneGraphInstance(
theParentInstance, inParent, inSlide, m_DataCore, m_SlideSystem,
m_Bridge.GetObjectDefinitions(), m_AssetGraph, m_MetaData));
- ApplyDynamicMetaData(retval, theParentInstance);
+ ApplyDynamicMetaData(retval, theParentInstance, dynObj);
if (inStartTime != -1)
SetStartTime(retval, inStartTime);
@@ -4438,7 +4663,6 @@ public:
if (theRelativePath.toCString() == GetSourcePath(existing[idx]))
theParentInstance = existing[idx];
}
-
if (theParentInstance.Valid() == false) {
if (theShaderFile.Exists()) {
theParentInstance = m_DataCore.CreateInstance();
@@ -4463,18 +4687,31 @@ public:
IDocumentEditor::fixDefaultTexturePaths(theParentInstance);
DisplayLoadWarnings(shaderFile, theWarnings, QString());
} else {
- if (theHandler)
+ if (theHandler) {
theHandler->DisplayImportFailed(theShaderFile.toQString(),
QObject::tr("Unable to load Shader File"),
false);
+ }
return 0;
}
}
+ const SMetaDataDynamicObject *dynObj;
+ dynObj = m_MetaData.GetDynamicObjectByInstance(theParentInstance);
+ if (!dynObj) {
+ if (theHandler) {
+ theHandler->DisplayImportFailed(theShaderFile.toQString(),
+ QObject::tr("Unable to load Shader File"),
+ false);
+ }
+ return 0;
+ }
TInstanceHandle retval(IDocumentEditor::CreateSceneGraphInstance(
theParentInstance, inParent, inSlide, m_DataCore, m_SlideSystem,
m_Bridge.GetObjectDefinitions(), m_AssetGraph, m_MetaData, inTargetId));
+ ApplyDynamicMetaData(retval, theParentInstance, *dynObj);
+
if (inStartTime != -1)
SetStartTime(retval, inStartTime);
@@ -4602,10 +4839,13 @@ public:
// Precondition is that our source path to instance map
// has all of the source-path-to-instance hooks already looked up.
- void DoRefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile)
+ void DoRefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile,
+ const CFilePath &importFilePath)
{
ScopedBoolean __ignoredDirs(m_IgnoreDirChange);
vector<CFilePath> importFileList;
+ if (importFilePath.Exists() && importFilePath.IsFile())
+ importFileList.push_back(importFilePath.filePath());
// Find which import files use this dae file.
for (TCharPtrToSlideInstanceMap::iterator theIter = m_SourcePathInstanceMap.begin(),
@@ -4639,75 +4879,73 @@ public:
// OK, for each import file
// 1. Find each group in the system using that import file as its source path.
// 2. for each group we find, build a map of import id->item that we will use to
- // communicate the import changes to the item.
- // 4. Run the refresh process using a composer editor that runs off of our
- // mappings
+ // communicate the import changes to the item.
+ // 4. Run the refresh process using a composer editor that runs off of our mappings
TIdMultiMap theGroupIdMap;
for (size_t importIdx = 0, end = importFileList.size(); importIdx < end; ++importIdx) {
theGroupIdMap.clear();
CFilePath theImportFilePath = importFileList[importIdx];
CFilePath theImportRelativePath = m_Doc.GetRelativePathToDoc(theImportFilePath);
TCharPtrToSlideInstanceMap::iterator theIter =
- m_SourcePathInstanceMap.find(m_StringTable.RegisterStr(theImportRelativePath.toCString()));
- if (theIter == m_SourcePathInstanceMap.end())
- continue;
- // First pass just build the group id entries. This avoids us copying hashtables which
- // may
- // be quite expensive
- for (TSlideInstanceList::iterator theSlideInst = theIter->second.begin(),
- theSlideInstEnd = theIter->second.end();
- theSlideInst != theSlideInstEnd; ++theSlideInst) {
- TInstanceHandle theRoot = theSlideInst->second;
- TSlideHandle theSlide = theSlideInst->first;
-
- // For a depth first search of all children of this object *in this slide*,
- // if they have an import id then add them to the map.
- DepthFirstAddImportChildren(theSlide, theRoot, theGroupIdMap, theAddedInstances);
- TIdMultiMap::iterator theGroupId =
- theGroupIdMap
- .insert(make_pair(m_StringTable.GetWideStr(GetImportId(theRoot)),
- vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>()))
- .first;
- insert_unique(theGroupId->second, make_pair(theSlide, theRoot));
- theAddedInstances.insert(theRoot);
- }
- // Since some objects may be completely free standing, we need to go through *all*
- // objects.
- // Unfortunately the first revision of the system didn't put import paths on objects so
- // we need both the above loop *and* to consider every object who's import path matches
- // out import document's relative path.
- theIter = theImportPaths.find(m_StringTable.RegisterStr(theImportRelativePath.toCString()));
- TSlideHandleList theAssociatedSlides;
- if (theIter != theImportPaths.end()) {
- vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>> &theInstances =
- theIter->second;
- for (size_t freeInstanceIdx = 0, end = theInstances.size(); freeInstanceIdx < end;
- ++freeInstanceIdx) {
- if (theAddedInstances.find(theInstances[freeInstanceIdx].second)
- != theAddedInstances.end())
- continue;
- theAssociatedSlides.clear();
- Qt3DSDMInstanceHandle theInstance(theInstances[freeInstanceIdx].second);
- GetAllAssociatedSlides(theInstance, theAssociatedSlides);
- TIdMultiMap::iterator theInstanceId =
- theGroupIdMap
- .insert(
- make_pair(m_StringTable.GetWideStr(GetImportId(theInstance)),
- vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>()))
- .first;
- for (size_t slideIdx = 0, slideEnd = theAssociatedSlides.size();
- slideIdx < slideEnd; ++slideIdx)
- insert_unique(theInstanceId->second,
- make_pair(theAssociatedSlides[slideIdx], theInstance));
- theAddedInstances.insert(theInstance);
+ m_SourcePathInstanceMap.find(m_StringTable.RegisterStr(theImportRelativePath
+ .toCString()));
+ if (theIter != m_SourcePathInstanceMap.end()) {
+ // First pass just build the group id entries. This avoids us copying hashtables
+ // which may be quite expensive
+ for (TSlideInstanceList::iterator theSlideInst = theIter->second.begin(),
+ theSlideInstEnd = theIter->second.end();
+ theSlideInst != theSlideInstEnd; ++theSlideInst) {
+ TInstanceHandle theRoot = theSlideInst->second;
+ TSlideHandle theSlide = theSlideInst->first;
+
+ // For a depth first search of all children of this object *in this slide*,
+ // if they have an import id then add them to the map.
+ DepthFirstAddImportChildren(theSlide, theRoot, theGroupIdMap,
+ theAddedInstances);
+ TIdMultiMap::iterator theGroupId
+ = theGroupIdMap.insert({m_StringTable.GetWideStr(GetImportId(theRoot)),
+ {}}).first;
+ insert_unique(theGroupId->second, make_pair(theSlide, theRoot));
+ theAddedInstances.insert(theRoot);
+ }
+ // Since some objects may be completely free standing, we need to go through *all*
+ // objects.
+ // Unfortunately the first revision of the system didn't put import paths on objects
+ // so we need both the above loop *and* to consider every object who's import path
+ // matches out import document's relative path.
+ theIter = theImportPaths.find(m_StringTable.RegisterStr(theImportRelativePath
+ .toCString()));
+ TSlideHandleList theAssociatedSlides;
+ if (theIter != theImportPaths.end()) {
+ vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>> &theInstances
+ = theIter->second;
+ for (size_t i = 0, end = theInstances.size(); i < end; ++i) {
+ if (theAddedInstances.find(theInstances[i].second)
+ != theAddedInstances.end()) {
+ continue;
+ }
+ theAssociatedSlides.clear();
+ Qt3DSDMInstanceHandle theInstance(theInstances[i].second);
+ GetAllAssociatedSlides(theInstance, theAssociatedSlides);
+ TIdMultiMap::iterator theInstanceId
+ = theGroupIdMap
+ .insert({m_StringTable.GetWideStr(GetImportId(theInstance)),
+ {}}).first;
+ for (size_t slideIdx = 0, slideEnd = theAssociatedSlides.size();
+ slideIdx < slideEnd; ++slideIdx) {
+ insert_unique(theInstanceId->second,
+ make_pair(theAssociatedSlides[slideIdx], theInstance));
+ }
+ theAddedInstances.insert(theInstance);
+ }
}
}
- //
// OK, we have distinct maps sorted on a per-slide basis for all trees of children
// of this asset. We now need to attempt to run the refresh algorithm.
- qt3dsimp::ImportPtrOrError theImportPtr = qt3dsimp::Import::Load(theImportFilePath.toCString());
+ qt3dsimp::ImportPtrOrError theImportPtr
+ = qt3dsimp::Import::Load(theImportFilePath.toCString());
if (!theImportPtr.m_Value) {
QT3DS_ASSERT(false);
continue;
@@ -4727,7 +4965,8 @@ public:
Q3DStudio::CString::ENDOFSTRING, false)
&& oldExtension.Compare(CDialogs::GetWideDAEFileExtension(),
Q3DStudio::CString::ENDOFSTRING, false)) {
- SColladaTranslator *colladaTranslator = new SColladaTranslator(inNewFile.toQString());
+ SColladaTranslator *colladaTranslator
+ = new SColladaTranslator(inNewFile.toQString());
translationLog = &(colladaTranslator->m_TranslationLog);
translator = colladaTranslator;
#ifdef QT_3DSTUDIO_FBX
@@ -4763,18 +5002,21 @@ public:
updateMaterialFiles();
}
- void RefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile) override
+ void RefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile,
+ const CFilePath &importFilePath) override
{
CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch());
+
theDispatch.FireOnProgressBegin(
QObject::tr("Refreshing Import "), QFileInfo(inNewFile.toQString()).fileName());
ScopedBoolean __ignoredDirs(m_IgnoreDirChange);
try {
m_SourcePathInstanceMap.clear();
GetSourcePathToInstanceMap(m_SourcePathInstanceMap, true, false);
- DoRefreshImport(inOldFile, inNewFile);
+ DoRefreshImport(inOldFile, inNewFile, importFilePath);
} catch (...) {
}
+
theDispatch.FireOnProgressEnd();
}
@@ -5115,6 +5357,8 @@ public:
if (selectedInstances.size() > 0) {
bool boolValue = false;
SValue value;
+ qt3dsdm::Qt3DSDMInstanceHandle firstFoundCamera;
+ qt3dsdm::Qt3DSDMInstanceHandle foundCameraLayer;
for (size_t idx = 0, end = selectedInstances.size(); idx < end; ++idx) {
qt3dsdm::Qt3DSDMInstanceHandle handle(selectedInstances[idx]);
if (handle.Valid()) {
@@ -5123,7 +5367,21 @@ public:
propertySystem->GetInstancePropertyValue(handle, property, value);
boolValue = !qt3dsdm::get<bool>(value);
}
- propertySystem->SetInstancePropertyValue(handle, property, boolValue);
+ // First found camera is the one that ends up being activated if there are
+ // several in selection, per-layer. Skip the rest if setting eyeball to true.
+ // It is ok to deactivate (hide) all cameras, though.
+ if (m_DataCore.IsInstanceOrDerivedFrom(
+ handle, m_Bridge.GetObjectDefinitions().m_Camera.m_Instance)) {
+ auto currCameraLayer = m_Bridge.GetResidingLayer(handle);
+ if ((!firstFoundCamera.Valid() || boolValue)
+ && !(foundCameraLayer == currCameraLayer)) {
+ firstFoundCamera = handle;
+ foundCameraLayer = currCameraLayer;
+ } else if (boolValue) {
+ continue;
+ }
+ }
+ SetInstancePropertyValue(handle, property, boolValue);
}
}
}
@@ -5215,23 +5473,27 @@ public:
}
m_SourcePathInstanceMap.clear();
- GetSourcePathToInstanceMap(m_SourcePathInstanceMap);
+ GetSourcePathToInstanceMap(m_SourcePathInstanceMap, false);
TInstanceHandleList theParents;
SComposerObjectDefinitions &theDefinitions(m_Bridge.GetObjectDefinitions());
+ QSet<QString> imageLoadSet;
+
+ g_StudioApp.getRenderer().MakeContextCurrent();
for (size_t fileIdx = 0, fileEnd = inList.size(); fileIdx < fileEnd; ++fileIdx) {
const SFileModificationRecord &theRecord(inList[fileIdx]);
- CString theExtension = theRecord.m_File.GetExtension();
- bool isImport = theExtension.Compare(L"import", CString::ENDOFSTRING, false);
+ QString theExtension = theRecord.m_File.GetExtension().toQString().toLower();
+ bool isImport = theExtension == QLatin1String("import");
CFilePath theRelativePath(m_Doc.GetRelativePathToDoc(theRecord.m_File));
const wchar_t *theString(
m_DataCore.GetStringTable().RegisterStr(theRelativePath.toCString()));
- if ((theExtension.CompareNoCase(L"ttf")
- || theExtension.CompareNoCase(L"otf")) // should use CDialogs::IsFontFileExtension
+ if (CDialogs::fontExtensions().contains(theExtension)
&& m_Doc.GetSceneGraph() && m_Doc.GetSceneGraph()->GetTextRenderer()) {
m_Doc.GetSceneGraph()->GetTextRenderer()->ReloadFonts();
+ if (m_Doc.GetSceneGraph()->GetDistanceFieldRenderer())
+ m_Doc.GetSceneGraph()->GetDistanceFieldRenderer()->ReloadFonts();
CFilePath thePath = m_Doc.GetDocumentDirectory();
CFilePath theFontCache = CFilePath::CombineBaseAndRelative(thePath, L"fontcache");
theFontCache.DeleteThisDirectory(true);
@@ -5286,9 +5548,9 @@ public:
if (theInsertResult.second == false)
theInsertResult.first->second = theDAERelativePath;
}
- } else if (theExtension.Compare(L"qml", CString::ENDOFSTRING, false)
+ } else if (CDialogs::behaviorExtensions().contains(theExtension)
&& theRecord.m_ModificationType != FileModificationType::Created
- && theInstances.empty() == false) {
+ && !theInstances.empty()) {
// First, refresh the parent behavior.
if (!hasDispatchNotificationScope) {
theDispatch.FireBeginDataModelNotifications();
@@ -5331,38 +5593,74 @@ public:
}
}
}
- } else if (theExtension.Compare(L"effect", CString::ENDOFSTRING, false)
+ } else if (CDialogs::effectExtensions().contains(theExtension)
&& theRecord.m_ModificationType != FileModificationType::Created
- && theInstances.empty() == false) {
- CString theNameStr = GetName(theInstances[0].second);
+ && !theInstances.empty()) {
std::vector<SMetaDataLoadWarning> theWarnings;
NVScopedRefCounted<qt3ds::render::IRefCountedInputStream> theStream(
m_InputStreamFactory->GetStreamForFile(theRecord.m_File.toQString()));
if (theStream) {
- m_MetaData.LoadEffectInstance(m_StringTable.GetNarrowStr(theRelativePath.toCString()),
+ m_MetaData.LoadEffectInstance(m_StringTable.GetNarrowStr(
+ theRelativePath.toCString()),
theInstances[0].second,
- TCharStr(theNameStr),
+ theRelativePath.GetFileStem().c_str(),
theWarnings, *theStream);
IDocumentEditor::fixDefaultTexturePaths(theInstances[0].second);
}
+ QList<qt3dsdm::Qt3DSDMInstanceHandle> insts;
for (size_t i = 0; i < theInstances.size(); ++i) {
theDispatch.FireReloadEffectInstance(theInstances[i].second);
- theDispatch.FireImmediateRefreshInstance(theInstances[i].second);
+ insts.append(theInstances[i].second);
+ }
+ theDispatch.FireImmediateRefreshInstance(&insts[0], theInstances.size());
+
+ } else if (CDialogs::shaderExtensions().contains(theExtension)
+ && theRecord.m_ModificationType != FileModificationType::Created
+ && !theInstances.empty()) {
+ std::vector<SMetaDataLoadWarning> theWarnings;
+ NVScopedRefCounted<qt3ds::render::IRefCountedInputStream> theStream(
+ m_InputStreamFactory->GetStreamForFile(theRecord.m_File.toQString()));
+ if (theStream) {
+ m_MetaData.LoadMaterialInstance(m_StringTable.GetNarrowStr(
+ theRelativePath.toCString()),
+ theInstances[0].second,
+ theRelativePath.GetFileStem().c_str(),
+ theWarnings,
+ *theStream);
+ IDocumentEditor::fixDefaultTexturePaths(theInstances[0].second);
}
+
+ for (size_t i = 0; i < theInstances.size(); ++i)
+ theDispatch.fireReloadMaterialInstance(theInstances[i].second);
+ } else if (CDialogs::mapExtensions().contains(theExtension)
+ && theRecord.m_ModificationType != FileModificationType::Created
+ && !theInstances.empty()) {
+ imageLoadSet.insert(theRecord.m_File.toQString());
}
// There used to be an extension here for meshes
// but that causes the product to delete materials in some cases which loses work.
- // so that experiment failed and we will just have to let the users manually updated
- // their
- // meshes through the dropdown if they need them updated.
+ // so that experiment failed and we will just have to let the users manually update
+ // their meshes through the dropdown if they need them updated.
+ }
+
+
+ if (!imageLoadSet.isEmpty()) {
+ auto settings = m_Doc.GetCore()->GetStudioProjectSettings();
+ m_Doc.GetBufferCache().reloadImageSet(
+ IBufferManager::resolveImageSet(imageLoadSet,
+ settings->getPreferCompressedTextures()),
+ settings->getFlipCompressedTextures());
}
+
+ g_StudioApp.getRenderer().ReleaseContext();
+
if (hasProgressFired)
theDispatch.FireOnProgressEnd();
- if (requestRender && m_Doc.GetSceneGraph())
- m_Doc.GetSceneGraph()->RequestRender();
if (hasDispatchNotificationScope)
theDispatch.FireEndDataModelNotifications();
+ if (requestRender && m_Doc.GetSceneGraph())
+ m_Doc.GetSceneGraph()->RenderNow();
}
};
}
@@ -5383,24 +5681,37 @@ void IDocumentEditor::DisplayImportErrors(const QString &inImportSource,
for (size_t idx = 0; idx < inTranslationLog.m_Warnings.size(); ++idx) {
const std::pair<ESceneGraphWarningCode, Q3DStudio::CString> &warning(
inTranslationLog.m_Warnings[idx]);
- const wchar_t *formatStr = L"Unrecognized warning";
+ const wchar_t *formatStr = L"Unrecognized warning: \"%ls\"";
switch (warning.first) {
case ESceneGraphWarningCode_OnlySupportTriangles:
- formatStr = L"Model %ls contains geometric elements other than triangles";
+ formatStr = L"Model \"%ls\" contains geometric elements other than triangles";
break;
case ESceneGraphWarningCode_TrianglesDuplicateSemantic:
formatStr = L"Triangle contains duplicate semantics, ex: 1 triangle has multiple "
L"TEXCOORD (multiple UV maps)";
break;
case ESceneGraphWarningCode_MissingSourceFile:
- formatStr = L"Couldn't find a source image file %ls";
+ formatStr = L"Couldn't find a source image file \"%ls\"";
break;
case ESceneGraphWarningCode_LockedDestFile:
- formatStr = L"An image or mesh file %ls is not writeable";
+ formatStr = L"An image or mesh file \"%ls\" is not writeable";
break;
case ESceneGraphWarningCode_VertexBufferTooLarge:
formatStr = L"A single mesh exceeds the maximum vertex count of 65535";
break;
+ case ESceneGraphWarningCode_MissingMaterial:
+ formatStr = L"Materials are missing from mesh \"%ls\", it was not created";
+ break;
+ case ESceneGraphWarningCode_UnsupportedLight:
+ formatStr = L"Light type for \"%ls\" is not supported, it was converted to Directional";
+ break;
+ case ESceneGraphWarningCode_Rotations:
+ formatStr = L"Rotation issue: %ls";
+ break;
+ case ESceneGraphWarningCode_UnknownMaterial:
+ formatStr = L"Unknown material type(s) encountered. Some material properties may be "
+ "incorrect. Make sure your FBX export settings are correct.";
+ break;
default:
break;
}
@@ -5446,16 +5757,17 @@ void IDocumentEditor::fixDefaultTexturePaths(Qt3DSDMInstanceHandle instance)
= propertySystem->GetAdditionalMetaDataType(instance, prop);
if (additionalMetaDataType == AdditionalMetaDataType::Texture) {
propertySystem->GetInstancePropertyValue(instance, prop, value);
- TDataStrPtr strPtr = get<TDataStrPtr>(value);
- const QString strValue = QString::fromWCharArray(strPtr->GetData());
- const QString docRelative = docDir.relativeFilePath(strValue);
- const QString projRelative = projDir.relativeFilePath(strValue);
- if (!QFileInfo(docRelative).exists() && !QFileInfo(projRelative).exists()) {
- // Convert path to presentation relative
- const QVariant newVarValue = QVariant::fromValue(
- docDir.relativeFilePath(projDir.absoluteFilePath(strValue)));
- const SValue newValue = newVarValue;
- propertySystem->SetInstancePropertyValue(instance, prop, newValue);
+ if (value.getType() == DataModelDataType::String) {
+ TDataStrPtr strPtr = get<TDataStrPtr>(value);
+ const QString strValue = QString::fromWCharArray(strPtr->GetData());
+ const QString docRelative = docDir.relativeFilePath(strValue);
+ if (!QFileInfo(docDir.filePath(docRelative)).exists()) {
+ // Convert path to presentation relative
+ const QVariant newVarValue = QVariant::fromValue(
+ docDir.relativeFilePath(projDir.absoluteFilePath(strValue)));
+ const SValue newValue = newVarValue;
+ propertySystem->SetInstancePropertyValue(instance, prop, newValue);
+ }
}
}
}
@@ -5499,6 +5811,11 @@ Qt3DSDMInstanceHandle IDocumentEditor::CreateSceneGraphInstance(
TInstanceHandle theDerivationParent(inMaster);
inDataCore.DeriveInstance(retval, theDerivationParent);
+ // Clear file id derived from the parent
+ // This happens for custom shaders and causes id conflicts (QT3DS-4018)
+ inDataCore.SetInstancePropertyValue(retval, inObjectDefs.m_Asset.m_FileId,
+ std::make_shared<CDataStr>(L""));
+
if (inParent.Valid())
inAssetGraph.AddChild(inParent, retval);
else
diff --git a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp
index 07b24bc6..d3355260 100644
--- a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp
@@ -48,9 +48,14 @@
#include "Qt3DSRenderPathManager.h"
#include "Qt3DSDMGuides.h"
#include "foundation/Qt3DSLogging.h"
+#include "Qt3DSRenderDynamicObjectSystem.h"
+
#include <unordered_map>
#include <unordered_set>
+#include <QtCore/qrandom.h>
+#include <QtCore/qdatetime.h>
+
using namespace qt3dsdm;
using namespace std;
using namespace Q3DStudio;
@@ -120,47 +125,60 @@ using std::hash;
template <typename TOperator>
static void HandleKeyframe(SLinearKeyframe &inKeyframe, TOperator &inOperator)
{
- inOperator(inKeyframe.m_KeyframeSeconds);
- inOperator(inKeyframe.m_KeyframeSeconds);
+ float kfTime = float(inKeyframe.m_time / 1000.f);
+
+ inOperator(kfTime);
+ inOperator(inKeyframe.m_value);
+
+ inKeyframe.m_time = long(kfTime * 1000.f);
}
template <typename TOperator>
static void HandleKeyframe(SBezierKeyframe &inKeyframe, TOperator &inOperator)
{
- inOperator(inKeyframe.m_KeyframeSeconds);
- inOperator(inKeyframe.m_KeyframeValue);
- inOperator(inKeyframe.m_InTangentTime);
+ float kfTime = float(inKeyframe.m_time / 1000.f);
+ float tangentInTime = float(inKeyframe.m_InTangentTime / 1000.f);
+ float tangentOutTime = float(inKeyframe.m_OutTangentTime / 1000.f);
+
+ inOperator(kfTime);
+ inOperator(inKeyframe.m_value);
+ inOperator(tangentInTime);
inOperator(inKeyframe.m_InTangentValue);
- inOperator(inKeyframe.m_OutTangentTime);
+ inOperator(tangentOutTime);
inOperator(inKeyframe.m_OutTangentValue);
+
+ inKeyframe.m_time = long(kfTime * 1000.f);
+ inKeyframe.m_InTangentTime = long(tangentInTime * 1000.f);
+ inKeyframe.m_OutTangentTime = long(tangentOutTime * 1000.f);
}
template <typename TOperator>
static void HandleKeyframe(SEaseInEaseOutKeyframe &inKeyframe, TOperator &inOperator)
{
- inOperator(inKeyframe.m_KeyframeSeconds);
- inOperator(inKeyframe.m_KeyframeValue);
+ float kfTime = float(inKeyframe.m_time / 1000.f);
+ inOperator(kfTime);
+ inOperator(inKeyframe.m_value);
inOperator(inKeyframe.m_EaseIn);
inOperator(inKeyframe.m_EaseOut);
+
+ inKeyframe.m_time = long(kfTime * 1000.f);
}
-template <typename TItemType>
-struct SVectorWriteOperator
+struct KeyframeWriter
{
- vector<TItemType> &m_Vector;
- SVectorWriteOperator(vector<TItemType> &vec)
- : m_Vector(vec)
+ vector<float> &m_vector;
+ KeyframeWriter(vector<float> &vec)
+ : m_vector(vec)
{
}
- void operator()(const TItemType &inValue) { m_Vector.push_back(inValue); }
+ void operator()(const float &inValue) { m_vector.push_back(inValue); }
};
-template <typename TItemType>
-struct SMemReadOperator
+struct KeyframeReader
{
- const TItemType *m_Ptr;
- const TItemType *m_End;
- SMemReadOperator(const TItemType *s, const TItemType *e)
+ const float *m_Ptr;
+ const float *m_End;
+ KeyframeReader(const float *s, const float *e)
: m_Ptr(s)
, m_End(e)
{
@@ -168,7 +186,7 @@ struct SMemReadOperator
bool IsDone() { return m_Ptr >= m_End; }
- void operator()(TItemType &outValue)
+ void operator()(float &outValue)
{
if (m_Ptr < m_End) {
outValue = *m_Ptr;
@@ -183,7 +201,7 @@ template <typename TKeyframeType>
static void WriteKeyframes(TKeyframeHandleList &inKeyframes, IAnimationCore &inCore,
vector<float> &outValues)
{
- SVectorWriteOperator<float> theOperator(outValues);
+ KeyframeWriter theOperator(outValues);
for (size_t idx = 0, end = inKeyframes.size(); idx < end; ++idx) {
TKeyframe theKeyframeVariant(inCore.GetKeyframeData(inKeyframes[idx]));
TKeyframeType theData(get<TKeyframeType>(theKeyframeVariant));
@@ -195,7 +213,7 @@ template <typename TKeyframeType>
static void ReadKeyframes(Qt3DSDMAnimationHandle inAnimation, IAnimationCore &inCore,
const float *inStart, const float *inEnd)
{
- SMemReadOperator<float> theOperator(inStart, inEnd);
+ KeyframeReader theOperator(inStart, inEnd);
while (theOperator.IsDone() == false) {
TKeyframeType theData;
HandleKeyframe(theData, theOperator);
@@ -290,22 +308,21 @@ struct SMetaDataPropertyEraser
};
using std::unordered_set;
using std::unordered_map;
-using std::tuple;
// Algorithm to write is to run through the graph, starting at the root instances
// and write out the instances as we come to them.
struct SComposerSerializerImpl : public IComposerSerializer
{
- typedef unordered_set<Qt3DSDMInstanceHandle, hash<int>> TInstanceSet;
- typedef unordered_set<Qt3DSDMSlideHandle, hash<int>> TSlideSet;
- typedef unordered_set<Qt3DSDMActionHandle, hash<int>> TActionSet;
- typedef vector<Qt3DSDMInstanceHandle> TInstanceList;
typedef unordered_map<int, TCharPtr> THandleToIdMap;
typedef unordered_map<TCharPtr, int> TIdToHandleMap;
typedef unordered_map<SLong4, int> TGUIDToHandleMap;
typedef unordered_map<int, SLong4> THandleToGUIDMap;
typedef unordered_map<Qt3DSDMInstanceHandle, int, hash<int>> TInstanceIntMap;
typedef unordered_map<Qt3DSDMInstanceHandle, TCharPtr, hash<int>> TInstanceToSiblingMap;
+ typedef unordered_set<Qt3DSDMInstanceHandle, hash<int>> TInstanceSet;
+ typedef unordered_set<Qt3DSDMSlideHandle, hash<int>> TSlideSet;
+ typedef unordered_set<Qt3DSDMActionHandle, hash<int>> TActionSet;
+ typedef vector<Qt3DSDMInstanceHandle> TInstanceList;
IDataCore &m_DataCore;
IMetaData &m_MetaData;
@@ -323,19 +340,16 @@ struct SComposerSerializerImpl : public IComposerSerializer
qt3ds::render::IPathManager &m_PathManager;
IPropertySystem &m_propertySystem;
- // The instances we have discovered when we are writing
+ Qt3DSDMSlideHandle m_ActiveSlide;
+ Qt3DSDMSlideHandle m_ActiveSlideParent;
+
+ // The unique ids for instances
THandleToIdMap m_HandleToIdMap;
TIdToHandleMap m_IdToHandleMap;
-
TGUIDToHandleMap m_GUIDToHandleMap;
THandleToGUIDMap m_HandleToGUIDMap;
-
- Qt3DSDMSlideHandle m_ActiveSlide;
- Qt3DSDMSlideHandle m_ActiveSlideParent;
-
THandleToIdMap m_ActionToIdMap;
TIdToHandleMap m_IdToActionMap;
-
THandleToIdMap m_SlideToIdMap;
TIdToHandleMap m_IdToSlideMap;
@@ -365,6 +379,9 @@ struct SComposerSerializerImpl : public IComposerSerializer
Option<int> m_UIPVersion;
+ QRandomGenerator m_randomGenerator;
+ QString m_documentPath;
+
SComposerSerializerImpl(IDataCore &inDataCore, IMetaData &inMetaData, ISlideCore &inSlideCore,
IAnimationCore &inAnimationCore, IActionCore &inActionCore,
CGraph &inAssetGraph, ISlideSystem &inSlideSystem,
@@ -372,7 +389,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
SComposerObjectDefinitions &inObjectDefinitions,
std::shared_ptr<Q3DStudio::IImportFailedHandler> inFailedHandler,
IGuideSystem &inGuideSystem, qt3ds::render::IPathManager &inPathManager,
- IPropertySystem &inPropSystem)
+ IPropertySystem &inPropSystem, const QString &documentPath)
: m_DataCore(inDataCore)
, m_MetaData(inMetaData)
, m_SlideCore(inSlideCore)
@@ -391,7 +408,9 @@ struct SComposerSerializerImpl : public IComposerSerializer
, m_Foundation(Q3DStudio::Foundation::SStudioFoundation::Create())
, m_InputStreamFactory(qt3ds::render::IInputStreamFactory::Create(*m_Foundation.m_Foundation))
, m_PreserveFileIds(true)
+ , m_documentPath(documentPath)
{
+ m_randomGenerator.seed(quint32(QTime::currentTime().msecsSinceStartOfDay()));
}
void reset()
@@ -402,15 +421,15 @@ struct SComposerSerializerImpl : public IComposerSerializer
m_GUIDToHandleMap.clear();
m_HandleToGUIDMap.clear();
- m_ActiveSlide = 0;
- m_ActiveSlideParent = 0;
-
m_ActionToIdMap.clear();
m_IdToActionMap.clear();
m_SlideToIdMap.clear();
m_IdToSlideMap.clear();
+ m_ActiveSlide = 0;
+ m_ActiveSlideParent = 0;
+
m_InstanceSet.clear();
m_SlideSet.clear();
m_ExternalReferences.clear();
@@ -430,6 +449,13 @@ struct SComposerSerializerImpl : public IComposerSerializer
TCharPtr AddId(const wstring &inId, Qt3DSDMInstanceHandle inHandle)
{
TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str());
+ if (m_IdToHandleMap.find(theIdStr) != m_IdToHandleMap.end()
+ && m_IdToHandleMap.find(theIdStr)->second != inHandle) {
+ m_ImportFailedHandler->DisplayImportFailed(
+ m_documentPath, QObject::tr("Duplicate object id detected: ")
+ + QString::fromWCharArray(theIdStr), false);
+ return theIdStr;
+ }
m_IdToHandleMap.insert(make_pair(theIdStr, inHandle));
m_HandleToIdMap.insert(make_pair(inHandle, theIdStr));
if (m_PreserveFileIds)
@@ -452,16 +478,39 @@ struct SComposerSerializerImpl : public IComposerSerializer
TCharPtr AddActionId(const wstring &inId, Qt3DSDMActionHandle inHandle)
{
TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str());
+ if (m_IdToActionMap.find(theIdStr) != m_IdToActionMap.end()
+ && m_IdToActionMap.find(theIdStr)->second != inHandle) {
+ m_ImportFailedHandler->DisplayImportFailed(
+ m_documentPath, QObject::tr("Duplicate action id detected: ")
+ + QString::fromWCharArray(theIdStr), false);
+ return theIdStr;
+ }
m_IdToActionMap.insert(make_pair(theIdStr, inHandle));
m_ActionToIdMap.insert(make_pair(inHandle, theIdStr));
+ if (m_PreserveFileIds) {
+ m_DataCore.SetInstancePropertyValue(m_ActionCore.GetActionInstance(inHandle),
+ m_ObjectDefinitions.m_Action.m_FileId,
+ std::make_shared<CDataStr>(inId.c_str()));
+ }
return theIdStr;
}
TCharPtr AddSlideId(const wstring &inId, Qt3DSDMSlideHandle inHandle)
{
TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str());
+ if (m_IdToActionMap.find(theIdStr) != m_IdToActionMap.end()
+ && m_IdToActionMap.find(theIdStr)->second != inHandle) {
+ m_ImportFailedHandler->DisplayImportFailed(
+ m_documentPath, QObject::tr("Duplicate slide id detected: ")
+ + QString::fromWCharArray(theIdStr), false);
+ return theIdStr;
+ }
m_IdToSlideMap.insert(make_pair(theIdStr, inHandle));
m_SlideToIdMap.insert(make_pair(inHandle, theIdStr));
+ if (m_PreserveFileIds)
+ m_DataCore.SetInstancePropertyValue(m_SlideCore.GetSlideInstance(inHandle),
+ m_ObjectDefinitions.m_Slide.m_FileId,
+ std::make_shared<CDataStr>(inId.c_str()));
return theIdStr;
}
@@ -569,30 +618,69 @@ struct SComposerSerializerImpl : public IComposerSerializer
return GetInstanceName(inInstance);
}
- TCharPtr GetId(const wstring &inIdStem)
+ TCharPtr GetId(const wstring &inIdStem, CDataModelHandle instance)
{
// Create an ID for this instance
- wstring theTypeStr(inIdStem);
- wstring theTypeStem(theTypeStr);
- wstring::size_type thePos = theTypeStem.find_last_of('_');
- if (thePos != wstring::npos && thePos < theTypeStem.size() - 2) {
- if (theTypeStem[thePos + 1] >= '0' && theTypeStem[thePos + 1] <= '1')
- theTypeStem = theTypeStem.substr(0, thePos);
- }
- QT3DSU32 idIdx = 1;
+ if (m_PreserveFileIds) {
+ // permanent id
+ QString stem = instanceId(instance);
+ if (stem.isEmpty())
+ stem = QString::fromWCharArray(inIdStem.c_str());
+ int pos = stem.lastIndexOf(QLatin1Char('_'));
+ if (pos > 0) {
+ // Already has unique id
+ bool isNumber;
+ stem.mid(pos+2).toInt(&isNumber);
+ if (stem.at(pos+1) == QLatin1Char('u') && isNumber) {
+ QByteArray warr;
+ warr.resize(sizeof(wchar_t) * (stem.length() + 1));
+ warr.fill(0);
+ stem.toWCharArray(reinterpret_cast<wchar_t *>(warr.data()));
+ return m_StringTable.RegisterStr(reinterpret_cast<wchar_t *>(warr.data()));
+ }
+ }
- while (m_IdToActionMap.find(m_StringTable.RegisterStr(theTypeStr.c_str()))
- != m_IdToActionMap.end()
- || m_IdToHandleMap.find(m_StringTable.RegisterStr(theTypeStr.c_str()))
- != m_IdToHandleMap.end()
- || m_IdToSlideMap.find(m_StringTable.RegisterStr(theTypeStr.c_str()))
- != m_IdToSlideMap.end()) {
- wchar_t theBuffer[16];
- swprintf(theBuffer, 16, L"_%03d", idIdx);
- theTypeStr = theTypeStem + theBuffer;
- ++idIdx;
+ // Create an ID for this instance
+ QByteArray buffer;
+ wchar_t *str;
+ do {
+ int rid = m_randomGenerator.bounded(65536);
+ QString nid = QStringLiteral("%1_u%2").arg(stem).arg(rid);
+ buffer.resize((nid.length() + 1) * sizeof(wchar_t));
+ buffer.fill(0);
+ str = reinterpret_cast<wchar_t *>(buffer.data());
+ nid.toWCharArray(str);
+ } while (m_IdToActionMap.find(m_StringTable.RegisterStr(str)) != m_IdToActionMap.end()
+ || m_IdToHandleMap.find(m_StringTable.RegisterStr(str))
+ != m_IdToHandleMap.end()
+ || m_IdToSlideMap.find(m_StringTable.RegisterStr(str))
+ != m_IdToSlideMap.end());
+
+ return m_StringTable.RegisterStr(str);
+ } else {
+ // temporary id
+ wstring theTypeStr(inIdStem);
+ wstring theTypeStem(theTypeStr);
+ wstring::size_type thePos = theTypeStem.find_last_of('_');
+ if (thePos != wstring::npos && thePos < theTypeStem.size() - 2) {
+ if (theTypeStem[thePos + 1] >= '0' && theTypeStem[thePos + 1] <= '9')
+ theTypeStem = theTypeStem.substr(0, thePos);
+ }
+ QT3DSU32 idIdx = 1;
+
+ while (m_IdToActionMap.find(m_StringTable.RegisterStr(theTypeStr.c_str()))
+ != m_IdToActionMap.end()
+ || m_IdToHandleMap.find(m_StringTable.RegisterStr(theTypeStr.c_str()))
+ != m_IdToHandleMap.end()
+ || m_IdToSlideMap.find(m_StringTable.RegisterStr(theTypeStr.c_str()))
+ != m_IdToSlideMap.end()) {
+ wchar_t theBuffer[16];
+ swprintf(theBuffer, 16, L"_%03d", idIdx);
+ theTypeStr = theTypeStem + theBuffer;
+ ++idIdx;
+ }
+ return m_StringTable.RegisterStr(theTypeStr.c_str());
}
- return m_StringTable.RegisterStr(theTypeStr.c_str());
}
TCharPtr GetInstanceId(Qt3DSDMInstanceHandle inInstance)
@@ -647,13 +735,13 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
if (theProperty.Valid()) {
theIdStr.append(m_DataCore.GetProperty(theProperty).m_Name.wide_str());
- theNewId = GetId(theIdStr);
+ theNewId = GetId(theIdStr, inInstance);
}
}
}
if (IsTrivial(theNewId))
- theNewId = GetId(theName.wide_str());
+ theNewId = GetId(theName.wide_str(), inInstance);
return AddId(theNewId, inInstance);
}
@@ -667,13 +755,23 @@ struct SComposerSerializerImpl : public IComposerSerializer
wstring theActionName(GetInstanceName(inInstance, inSlide));
theActionName.append(L"-Action");
-
- TCharPtr theNewId = GetId(theActionName);
+ TCharPtr theNewId;
+ if (m_PreserveFileIds) {
+ Qt3DSDMInstanceHandle actionInstance = m_ActionCore.GetActionInstance(inAction);
+ SValue theValue;
+ if (m_DataCore.GetInstancePropertyValue(
+ actionInstance, m_ObjectDefinitions.m_Action.m_FileId, theValue)) {
+ TDataStrPtr fileId(get<TDataStrPtr>(theValue));
+ theNewId = fileId->GetData();
+ if (!IsTrivial(theNewId))
+ return AddSlideId(GetId(theNewId, actionInstance), inSlide);
+ return AddSlideId(GetId(theActionName, actionInstance), inSlide);
+ }
+ }
+ theNewId = GetId(theActionName, inInstance);
return AddActionId(theNewId, inAction);
}
- // If this function is called with an invalid instance and we don't already have an id
- // then we assume we have an external reference and lookup the instance via the component id.
TCharPtr GetSlideId(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance)
{
QT3DS_ASSERT(inSlide.Valid());
@@ -697,7 +795,21 @@ struct SComposerSerializerImpl : public IComposerSerializer
theSlideName.append(L"-");
theSlideName.append(GetSlideName(inSlide));
- TCharPtr theNewId = GetId(theSlideName);
+ TCharPtr theNewId;
+ if (m_PreserveFileIds) {
+ Qt3DSDMInstanceHandle slideInstance = m_SlideCore.GetSlideInstance(inSlide);
+ SValue theValue;
+ if (m_DataCore.GetInstancePropertyValue(
+ slideInstance, m_ObjectDefinitions.m_Slide.m_FileId, theValue)) {
+ TDataStrPtr fileId(get<TDataStrPtr>(theValue));
+ theNewId = fileId->GetData();
+ if (!IsTrivial(theNewId))
+ return AddSlideId(GetId(theNewId, slideInstance), inSlide);
+ return AddSlideId(GetId(theSlideName, slideInstance), inSlide);
+ }
+ }
+
+ theNewId = GetId(theSlideName, inInstance);
return AddSlideId(theNewId, inSlide);
}
@@ -721,6 +833,24 @@ struct SComposerSerializerImpl : public IComposerSerializer
return SLong4();
}
+ QString instanceId(CDataModelHandle inInstance) {
+ SValue theInstanceIdValue;
+ TDataStrPtr theNamePtr;
+ if (!m_DataCore.GetInstancePropertyValue(
+ inInstance, m_ObjectDefinitions.m_Asset.m_FileId, theInstanceIdValue)) {
+ if (!m_DataCore.GetInstancePropertyValue(
+ inInstance, m_ObjectDefinitions.m_Slide.m_FileId, theInstanceIdValue)) {
+ m_DataCore.GetInstancePropertyValue(
+ inInstance, m_ObjectDefinitions.m_Action.m_FileId, theInstanceIdValue);
+ }
+ }
+ theNamePtr = qt3dsdm::get<TDataStrPtr>(theInstanceIdValue);
+ if (theNamePtr && !IsTrivial(theNamePtr->GetData()))
+ return theNamePtr->toQString();
+ return {};
+ }
+
+
void GetAllInstanceGuids()
{
TInstanceHandleList theInstances;
@@ -739,9 +869,23 @@ struct SComposerSerializerImpl : public IComposerSerializer
theInstance, m_ObjectDefinitions.m_Asset.m_FileId, theInstanceIdValue)) {
TDataStrPtr theNamePtr = qt3dsdm::get<TDataStrPtr>(theInstanceIdValue);
if (theNamePtr && !IsTrivial(theNamePtr->GetData())) {
- const wchar_t *theId = GetId(theNamePtr->GetData());
+ const wchar_t *theId = GetId(theNamePtr->GetData(), theInstance);
AddId(theId, theInstance);
}
+ } else if (m_DataCore.GetInstancePropertyValue(
+ theInstance, m_ObjectDefinitions.m_Slide.m_FileId, theInstanceIdValue)) {
+ TDataStrPtr theNamePtr = qt3dsdm::get<TDataStrPtr>(theInstanceIdValue);
+ if (theNamePtr && !IsTrivial(theNamePtr->GetData())) {
+ const wchar_t *theId = GetId(theNamePtr->GetData(), theInstance);
+ AddSlideId(theId, theInstance);
+ }
+ } else if (m_DataCore.GetInstancePropertyValue(
+ theInstance, m_ObjectDefinitions.m_Action.m_FileId, theInstanceIdValue)) {
+ TDataStrPtr theNamePtr = qt3dsdm::get<TDataStrPtr>(theInstanceIdValue);
+ if (theNamePtr && !IsTrivial(theNamePtr->GetData())) {
+ const wchar_t *theId = GetId(theNamePtr->GetData(), theInstance);
+ AddActionId(theId, theInstance);
+ }
}
}
}
@@ -834,9 +978,15 @@ struct SComposerSerializerImpl : public IComposerSerializer
} else {
m_TempBuffer.clear();
WCharTWriter theWriter(m_TempBuffer);
- WStrOps<SValue>().ToBuf(theValue, theWriter);
-
- if (GetValueType(theValue) == DataModelDataType::String || m_TempBuffer.size()) {
+ if (theValueType == DataModelDataType::String || !theValue.empty()) {
+ // QT3DS-3993: store line feeds as replacement chars in UIP
+ if (theValueType == DataModelDataType::String) {
+ TDataStrPtr strPtr = get<TDataStrPtr>(theValue);
+ auto strValue = QString::fromWCharArray(strPtr->GetData());
+ strValue.replace("\n", LINE_BREAK_SUBSTITUTE);
+ theValue = std::make_shared<CDataStr>(CString::fromQString(strValue));
+ }
+ WStrOps<SValue>().ToBuf(theValue, theWriter);
char buffer[] = { 0, 0, 0, 0 };
m_TempBuffer.write(buffer, 4);
theValueStr.assign((const wchar_t *)m_TempBuffer.begin());
@@ -865,8 +1015,13 @@ struct SComposerSerializerImpl : public IComposerSerializer
return SStringOrInt(std::make_shared<CDataStr>(inValue));
}
- if (inType == DataModelDataType::String)
- return std::make_shared<CDataStr>(inValue);
+ if (inType == DataModelDataType::String) {
+ // QT3DS-3993: store line feeds as replacement chars in UIP
+ auto valueStr = std::make_shared<CDataStr>(inValue);
+ auto val = QString::fromStdWString(valueStr->GetData());
+ val.replace(LINE_BREAK_SUBSTITUTE, "\n");
+ return std::make_shared<CDataStr>(CString::fromQString(val));
+ }
qt3ds::foundation::ConvertUTF(
reinterpret_cast<const qt3ds::foundation::TWCharEASTLConverter::TCharType *>(inValue), 0,
@@ -916,6 +1071,19 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
}
+ SLong4 ParseGUID(TCharPtr inValue)
+ {
+ // One of two things, either an ID reference *or* pure string.
+ if (IsTrivial(inValue))
+ return SLong4();
+ if (inValue[0] == '#') {
+ // absolute reference.
+ Qt3DSDMInstanceHandle theInstance = GetInstanceById(inValue + 1);
+ return theInstance.Valid() ? GetInstanceGuid(theInstance) : SLong4();
+ }
+ return SLong4();
+ }
+
void SerializePropertyList(qt3dsdm::IDOMWriter &inWriter, TPropertyHandleValuePairList &inList)
{
sort(inList.begin(), inList.end(), SAttributeNameSorter(m_DataCore));
@@ -977,7 +1145,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
SMetaDataPropertyInfo thePropertyInfo(
m_MetaData.GetMetaDataPropertyInfo(theMetaDataProperty));
wstring theName = thePropertyInfo.m_Name.wide_str();
- size_t theArity = get<1>(GetDatatypeAnimatableAndArity(thePropertyInfo.GetDataType()));
+ size_t theArity = getDatatypeAnimatableArity(thePropertyInfo.GetDataType());
if (theArity > 1) {
theName.append(L".");
switch (theInfo.m_Index) {
@@ -1081,12 +1249,8 @@ struct SComposerSerializerImpl : public IComposerSerializer
return;
}
SMetaDataPropertyInfo theInfo(m_MetaData.GetMetaDataPropertyInfo(theProperty));
- std::tuple<bool, size_t> theAnimAndArity = GetDatatypeAnimatableAndArity(theInfo.GetDataType());
- if (std::get<0>(theAnimAndArity) == false) {
- QT3DS_ASSERT(false);
- return;
- }
- if (std::get<1>(theAnimAndArity) <= subIndex) {
+ size_t theArity = getDatatypeAnimatableArity(theInfo.GetDataType());
+ if (theArity == 0 || theArity <= subIndex) {
QT3DS_ASSERT(false);
return;
}
@@ -1470,6 +1634,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
erase_if(outList, SPropertyMatches(m_ObjectDefinitions.m_Slide.m_ComponentId));
erase_if(outList, SPropertyMatches(m_ObjectDefinitions.m_Named.m_NameProp));
erase_if(outList, SPropertyMatches(m_ObjectDefinitions.m_Typed.m_TypeProp));
+ erase_if(outList, SPropertyMatches(m_ObjectDefinitions.m_Slide.m_FileId));
}
Option<pair<Qt3DSDMPropertyHandle, SValue>> ParseValue(Qt3DSDMInstanceHandle inInstance,
@@ -1485,7 +1650,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
void ParseInstanceProperties(IDOMReader &inReader, Qt3DSDMInstanceHandle inInstance,
- vector<pair<TCharPtr, TCharPtr>> &outExtraAttributes,
+ QVector<pair<TCharPtr, TCharPtr>> &outExtraAttributes,
TPropertyHandleValuePairList &outProperties)
{
bool hasNoLifetime =
@@ -1512,7 +1677,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
void ParseAndSetInstanceProperties(IDOMReader &inReader, Qt3DSDMSlideHandle inSlide,
Qt3DSDMInstanceHandle inInstance,
- vector<pair<TCharPtr, TCharPtr>> &outExtraAttributes,
+ QVector<pair<TCharPtr, TCharPtr>> &outExtraAttributes,
TPropertyHandleValuePairList &ioProperties)
{
outExtraAttributes.clear();
@@ -1526,13 +1691,28 @@ struct SComposerSerializerImpl : public IComposerSerializer
// is to preserve behavior on old presentations that relied on hardcoding.
bool hasMappingAsProbe = false;
bool hasTilingH = false;
+ bool isDynamicObjectInstance
+ = m_DataCore.IsInstanceOrDerivedFrom(inInstance,
+ m_ObjectDefinitions.m_CustomMaterial.m_Instance)
+ || m_DataCore.IsInstanceOrDerivedFrom(inInstance,
+ m_ObjectDefinitions.m_Effect.m_Instance);
for (size_t idx = 0, end = ioProperties.size(); idx < end; ++idx) {
+ auto &prop = ioProperties[idx];
if (ioProperties[idx].first == m_ObjectDefinitions.m_Image.m_TilingU)
hasTilingH = true;
if (ioProperties[idx].first == m_ObjectDefinitions.m_Image.m_TextureMapping
&& ioProperties[idx].second.toQVariant() == QVariant("Light Probe")) {
hasMappingAsProbe = true;
}
+ if (prop.second.getType() == qt3dsdm::DataModelDataType::String
+ && isDynamicObjectInstance) {
+ qt3dsdm::TDataStrPtr value = qt3dsdm::get<qt3dsdm::TDataStrPtr>(prop.second);
+ QString string = QString::fromWCharArray(value->GetData());
+ if (string.startsWith(QLatin1Char('#'))) {
+ SLong4 guid = ParseGUID(value->GetData());
+ prop.second = SValue(guid);
+ }
+ }
}
if (!hasTilingH && hasMappingAsProbe) {
@@ -1652,6 +1832,34 @@ struct SComposerSerializerImpl : public IComposerSerializer
// Write out the properties for the active slide.
TPropertyHandleValuePairList theValues;
GetSpecificInstancePropertyValues(inInstance, theValues);
+ bool isDynamicObjectInstance
+ = m_DataCore.IsInstanceOrDerivedFrom(inInstance,
+ m_ObjectDefinitions.m_CustomMaterial.m_Instance)
+ || m_DataCore.IsInstanceOrDerivedFrom(inInstance,
+ m_ObjectDefinitions.m_Effect.m_Instance);
+
+ if (isDynamicObjectInstance) {
+ // Remove default string values from serialized values
+ TInstanceHandleList parents;
+ m_DataCore.GetInstanceParents(inInstance, parents);
+ SMetaDataDynamicObject *dynObj = m_MetaData.GetDynamicObjectByInstance(parents[0]);
+ if (!dynObj)
+ return false;
+ for (int i = 0; i < dynObj->m_Properties.size(); i++) {
+ auto &prop = dynObj->m_Properties[i];
+ for (auto iter = theValues.begin(); iter != theValues.end(); iter++) {
+ const pair<Qt3DSDMPropertyHandle, SValue> &theValue(*iter);
+ TCharStr theName(m_DataCore.GetProperty(theValue.first).m_Name);
+ CRegisteredString name = m_StringTable.GetRenderStringTable()
+ .RegisterStr(theName.c_str());
+ if (name == prop.m_Name && prop.m_DataType
+ == qt3ds::render::NVRenderShaderDataTypes::NVRenderTexture2DPtr) {
+ theValues.erase(iter);
+ break;
+ }
+ }
+ }
+ }
SerializePropertyList(inWriter, theValues);
if (theMasterRef.size())
@@ -1742,10 +1950,6 @@ struct SComposerSerializerImpl : public IComposerSerializer
m_NewInstancesToSiblings.insert(std::make_pair(theNewInstance, theSiblingRef + 1));
SLong4 theGuid = GetGuid(theNewInstance, m_ObjectDefinitions.m_Guided.m_GuidProp);
- if (m_PreserveFileIds)
- m_DataCore.SetInstancePropertyValue(theNewInstance,
- m_ObjectDefinitions.m_Asset.m_FileId,
- std::make_shared<CDataStr>(theId));
SetId(theId, theNewInstance);
AddGuid(theGuid, theNewInstance);
@@ -1786,7 +1990,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
TPropertyHandleValuePairList theValues;
- vector<pair<TCharPtr, TCharPtr>> theExtraAtts;
+ QVector<pair<TCharPtr, TCharPtr>> theExtraAtts;
ParseAndSetInstanceProperties(inReader, 0, theNewInstance, theExtraAtts, theValues);
ReadInstanceProperties(inReader);
@@ -2109,7 +2313,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
{
IDOMReader::Scope __stateScope(inReader);
TPropertyHandleValuePairList theValues;
- vector<pair<TCharPtr, TCharPtr>> theExtraAtts;
+ QVector<pair<TCharPtr, TCharPtr>> theExtraAtts;
ParseAndSetInstanceProperties(inReader, 0, m_SlideCore.GetSlideInstance(inSlide),
theExtraAtts, theValues);
// Slides require a two-pass parsing system because slides can refer to each other via id.
@@ -2385,7 +2589,8 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
void DoSerializeScene(IDOMWriter &inWriter, const Qt3DSDMInstanceHandle *inTopInstances,
- QT3DSU32 inCount, bool inWriteParentRefs = false)
+ QT3DSU32 inCount, bool inWriteParentRefs = false,
+ const Q3DStudio::CFilePath *inDocumentDirectory = nullptr)
{
GetAllInstanceGuids();
{
@@ -2411,15 +2616,27 @@ struct SComposerSerializerImpl : public IComposerSerializer
QT3DS_ASSERT(false);
continue;
}
- IDOMWriter::Scope instScope(inWriter, theType->wide_str());
- inWriter.Att(L"id", GetInstanceId(theMaster));
- // Write out all the properties that are on the instance but are not on *this*
- // instance in the meta data.
- TPropertyHandleValuePairList theProperties;
- GetSpecificInstancePropertyValues(theMaster, theProperties);
- erase_if(theProperties,
- SMetaDataPropertyEraser(theMaster, m_ObjectDefinitions));
- SerializePropertyList(inWriter, theProperties);
+ SValue value;
+ m_DataCore.GetInstancePropertyValue(theMaster,
+ m_ObjectDefinitions.m_Asset.m_SourcePath,
+ value);
+ if (!value.empty()) {
+ CFilePath sourcePath(value.getData<qt3dsdm::TDataStrPtr>()->GetData());
+ CFilePath theFullPath = CFilePath::CombineBaseAndRelative(
+ (inDocumentDirectory ? (*inDocumentDirectory) : CFilePath()),
+ sourcePath);
+ if (!inDocumentDirectory || theFullPath.Exists()) {
+ IDOMWriter::Scope instScope(inWriter, theType->wide_str());
+ inWriter.Att(L"id", GetInstanceId(theMaster));
+ // Write out all the properties that are on the instance but are not on *this*
+ // instance in the meta data.
+ TPropertyHandleValuePairList theProperties;
+ GetSpecificInstancePropertyValues(theMaster, theProperties);
+ erase_if(theProperties,
+ SMetaDataPropertyEraser(theMaster, m_ObjectDefinitions));
+ SerializePropertyList(inWriter, theProperties);
+ }
+ }
}
}
inWriter.MoveBefore(L"Classes", L"Graph");
@@ -2517,7 +2734,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
theMaster = m_DataCore.CreateInstance();
m_DataCore.DeriveInstance(theMaster, theCanonicalType);
TPropertyHandleValuePairList theValues;
- vector<pair<TCharPtr, TCharPtr>> theExtraAtts;
+ QVector<pair<TCharPtr, TCharPtr>> theExtraAtts;
m_SourcePathToMasterInstances.insert(
make_pair(m_StringTable.RegisterStr(theSourcePath), theMaster));
@@ -2676,7 +2893,8 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
};
- void SerializeScene(IDOMWriter &inWriter) override
+ void SerializeScene(IDOMWriter &inWriter,
+ const Q3DStudio::CFilePath &inDocumentDirectory) override
{
reset();
ScopedPreserveFileIds __preserveFileIds(m_PreserveFileIds);
@@ -2690,7 +2908,7 @@ struct SComposerSerializerImpl : public IComposerSerializer
if (theGraphRoots.empty())
return;
QT3DS_ASSERT(theGraphRoots.size() == 1);
- DoSerializeScene(inWriter, &theGraphRoots[0], 1);
+ DoSerializeScene(inWriter, &theGraphRoots[0], 1, false, &inDocumentDirectory);
TGuideHandleList theGuides = m_GuideSystem.GetAllGuides();
// sort the guides by handle value to keep the file as stable as possible.
std::sort(theGuides.begin(), theGuides.end());
@@ -2735,26 +2953,28 @@ struct SComposerSerializerImpl : public IComposerSerializer
// new root.
virtual qt3dsdm::TInstanceHandleList
SerializeSceneGraphObject(IDOMReader &inReader, const CFilePath &inDocumentDirectory,
- Qt3DSDMInstanceHandle inNewRoot, Qt3DSDMSlideHandle inActiveSlide) override
+ Qt3DSDMInstanceHandle inNewRoot, Qt3DSDMSlideHandle inActiveSlide,
+ bool preserveFileIds) override
{
reset();
m_ActiveSlide = inActiveSlide;
- m_PreserveFileIds = false;
+ m_PreserveFileIds = preserveFileIds;
return DoSerializeScene(inReader, inDocumentDirectory, inNewRoot);
}
// Write this instance and its children (and possibly its slides) to a writer.
// Equivalent to the older partial serialization system
void SerializeSceneGraphObjects(IDOMWriter &inWriter,
- const TInstanceHandleList &inInstances,
- Qt3DSDMSlideHandle inActiveSlide) override
+ const TInstanceHandleList &inInstances,
+ Qt3DSDMSlideHandle inActiveSlide,
+ bool preserveFileIds) override
{
if (inInstances.empty())
return;
reset();
QT3DS_ASSERT(inActiveSlide.Valid());
m_ActiveSlide = inActiveSlide;
- m_PreserveFileIds = false;
+ m_PreserveFileIds = preserveFileIds;
// It is fine if the parent is invalid
m_ActiveSlideParent = m_SlideCore.GetParentSlide(m_ActiveSlide);
DoSerializeScene(inWriter, inInstances.data(), (QT3DSU32)inInstances.size());
@@ -2844,8 +3064,8 @@ struct SComposerSerializerImpl : public IComposerSerializer
}
Qt3DSDMSlideHandle SerializeSlide(qt3dsdm::IDOMReader &inReader,
- const CFilePath &inDocumentDirectory,
- qt3dsdm::Qt3DSDMSlideHandle inMaster, int newIndex) override
+ const CFilePath &inDocumentDirectory,
+ qt3dsdm::Qt3DSDMSlideHandle inMaster, int newIndex) override
{
reset();
m_PreserveFileIds = false;
@@ -2867,13 +3087,15 @@ struct SComposerSerializerImpl : public IComposerSerializer
std::shared_ptr<IComposerSerializer> IComposerSerializer::CreateGraphSlideSerializer(
IDataCore &inDataCore, IMetaData &inMetaData, ISlideCore &inSlideCore,
IAnimationCore &inAnimationCore, IActionCore &inActionCore, CGraph &inAssetGraph,
- ISlideSystem &inSlideSystem, IActionSystem &inActionSystem, ISlideGraphCore &inSlideGraphCore,
- SComposerObjectDefinitions &inObjectDefinitions,
- std::shared_ptr<Q3DStudio::IImportFailedHandler> inFailedHandler, IGuideSystem &inGuideSystem,
- qt3ds::render::IPathManager &inPathManager, IPropertySystem &inPropSystem)
+ ISlideSystem &inSlideSystem, IActionSystem &inActionSystem,
+ ISlideGraphCore &inSlideGraphCore, SComposerObjectDefinitions &inObjectDefinitions,
+ std::shared_ptr<Q3DStudio::IImportFailedHandler> inFailedHandler,
+ IGuideSystem &inGuideSystem, qt3ds::render::IPathManager &inPathManager,
+ IPropertySystem &inPropSystem, const QString &documentPath)
{
- return std::shared_ptr<SComposerSerializerImpl>(new SComposerSerializerImpl(
- inDataCore, inMetaData, inSlideCore, inAnimationCore, inActionCore, inAssetGraph,
- inSlideSystem, inActionSystem, inSlideGraphCore, inObjectDefinitions, inFailedHandler,
- inGuideSystem, inPathManager, inPropSystem));
+ return std::shared_ptr<SComposerSerializerImpl>(
+ new SComposerSerializerImpl(
+ inDataCore, inMetaData, inSlideCore, inAnimationCore, inActionCore, inAssetGraph,
+ inSlideSystem, inActionSystem, inSlideGraphCore, inObjectDefinitions, inFailedHandler,
+ inGuideSystem, inPathManager, inPropSystem, documentPath));
}
diff --git a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h
index 98fba780..b7e5ed96 100644
--- a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h
+++ b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h
@@ -65,7 +65,8 @@ protected:
virtual ~IComposerSerializer() {}
public:
// Empty graph roots means use the actual graph roots in the asset graph
- virtual void SerializeScene(qt3dsdm::IDOMWriter &inWriter) = 0;
+ virtual void SerializeScene(qt3dsdm::IDOMWriter &inWriter,
+ const Q3DStudio::CFilePath &inDocumentDirectory) = 0;
// Write properties into the active slide until we get to a slide owner, then create new slides.
// inActiveSlide may be zero if the top item we find happens to be a scene or a component.
// The graph roots hold the top items
@@ -77,13 +78,15 @@ public:
// Equivalent to the older partial serialization system
virtual void SerializeSceneGraphObjects(qt3dsdm::IDOMWriter &inWriter,
const qt3dsdm::TInstanceHandleList &inInstances,
- qt3dsdm::Qt3DSDMSlideHandle inActiveSlide) = 0;
+ qt3dsdm::Qt3DSDMSlideHandle inActiveSlide,
+ bool preserveFileIds) = 0;
// Read a partial serialization into this slide, attaching the instance as the last child of the
// new root.
virtual qt3dsdm::TInstanceHandleList SerializeSceneGraphObject(
qt3dsdm::IDOMReader &inReader, const Q3DStudio::CFilePath &inDocumentDirectory,
- qt3dsdm::Qt3DSDMInstanceHandle inNewRoot, qt3dsdm::Qt3DSDMSlideHandle inActiveSlide) = 0;
+ qt3dsdm::Qt3DSDMInstanceHandle inNewRoot, qt3dsdm::Qt3DSDMSlideHandle inActiveSlide,
+ bool preserveFileIds) = 0;
// Save and load just a single action
virtual void SerializeAction(qt3dsdm::IDOMWriter &inWriter, qt3dsdm::Qt3DSDMSlideHandle inSlide,
@@ -103,14 +106,15 @@ public:
friend class std::shared_ptr<IComposerSerializer>;
static std::shared_ptr<IComposerSerializer> CreateGraphSlideSerializer(
- qt3dsdm::IDataCore &inDataCore, qt3dsdm::IMetaData &inMetaData, qt3dsdm::ISlideCore &inSlideCore,
+ qt3dsdm::IDataCore &inDataCore, qt3dsdm::IMetaData &inMetaData,
+ qt3dsdm::ISlideCore &inSlideCore,
qt3dsdm::IAnimationCore &inAnimationCore, qt3dsdm::IActionCore &inActionCore,
CGraph &inAssetGraph, qt3dsdm::ISlideSystem &inSlideSystem,
qt3dsdm::IActionSystem &inActionSystem, qt3dsdm::ISlideGraphCore &inSlideGraphCore,
qt3dsdm::SComposerObjectDefinitions &inObjectDefinitions,
std::shared_ptr<Q3DStudio::IImportFailedHandler> inFailedHandler,
qt3dsdm::IGuideSystem &inGuideSystem, qt3ds::render::IPathManager &inPathManager,
- qt3dsdm::IPropertySystem &inPropSystem);
+ qt3dsdm::IPropertySystem &inPropSystem, const QString &documentPath);
};
}
diff --git a/src/Authoring/Client/Code/Core/Doc/IDocSceneGraph.h b/src/Authoring/Client/Code/Core/Doc/IDocSceneGraph.h
index c86dea9e..1bebfedf 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDocSceneGraph.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDocSceneGraph.h
@@ -54,6 +54,7 @@ public:
friend class std::shared_ptr<IDocSceneGraph>;
virtual ITextRenderer *GetTextRenderer() = 0;
+ virtual ITextRenderer *GetDistanceFieldRenderer() = 0;
virtual QT3DSVec3 GetIntendedPosition(qt3dsdm::Qt3DSDMInstanceHandle inHandle, CPt inPoint) = 0;
virtual qt3dsdm::Qt3DSDMInstanceHandle getObjectAt(const QPoint &pt) = 0;
virtual IBufferManager *GetBufferManager() = 0;
@@ -62,6 +63,7 @@ public:
// Request that this object renders. May be ignored if a transaction
// is ongoing so we don't get multiple rendering per transaction.
virtual void RequestRender() = 0;
+ virtual void RenderNow() = 0;
};
}
#endif
diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentBufferCache.h b/src/Authoring/Client/Code/Core/Doc/IDocumentBufferCache.h
index 674de9f4..13616aee 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDocumentBufferCache.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDocumentBufferCache.h
@@ -96,6 +96,10 @@ public:
// Takes a *relative* path from the document
virtual void InvalidateBuffer(const CFilePath &inSourcePath) = 0;
+ virtual void reloadImageSet(const QSet<QString> &imageSet, bool flipCompressedTextures) = 0;
+
+ virtual void reloadAll(bool flipCompressedTextures) = 0;
+
// Don't send events but just clear everything out. Used on document::close
virtual void Clear() = 0;
diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
index d49f8062..14fcd5fb 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h
@@ -306,7 +306,9 @@ public:
long numValues, bool inUserEdited = true) = 0;
virtual bool RemoveAnimation(TSlideHandle inSlide, TInstanceHandle instance,
const wchar_t *propName, long subIndex) = 0;
- virtual void SetKeyframeTime(TKeyframeHandle inKeyframe, long inTimeInMilliseconds) = 0;
+ virtual void SetKeyframeTime(TKeyframeHandle inKeyframe, long inTime) = 0;
+ virtual void setBezierKeyframeValue(TKeyframeHandle kfHandle,
+ const qt3dsdm::TKeyframe &kfData) = 0;
virtual void DeleteAllKeyframes(Qt3DSDMAnimationHandle inAnimation) = 0;
virtual void KeyframeProperty(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty,
bool inDoDiffValue) = 0;
@@ -320,11 +322,13 @@ public:
virtual qt3dsdm::TInstanceHandleList
PasteSceneGraphObject(const CFilePath &inFilePath, Qt3DSDMInstanceHandle inNewRoot,
bool inGenerateUniqueName, DocumentEditorInsertType::Enum inInsertType,
- const CPt &inPosition) = 0;
+ const CPt &inPosition,
+ bool preserveFileIds) = 0;
virtual qt3dsdm::TInstanceHandleList PasteSceneGraphObjectMaster(
const CFilePath &inFilePath, Qt3DSDMInstanceHandle inNewRoot, bool inGenerateUniqueName,
- DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition) = 0;
+ DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition,
+ bool preserveFileIds) = 0;
virtual void RearrangeObjects(const qt3dsdm::TInstanceHandleList &inInstances,
TInstanceHandle inDest,
@@ -458,7 +462,8 @@ public:
// Refresh an import or dae file
// Absolute path to the file.
- virtual void RefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile) = 0;
+ virtual void RefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile,
+ const CFilePath &importFilePath) = 0;
virtual bool CleanUpMeshes() = 0;
diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h b/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h
index 010a9fe6..be2f739a 100644
--- a/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h
+++ b/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h
@@ -152,9 +152,11 @@ public:
// Get a map from string table string (datacore.GetStringTable().RegisterStr()) to
// a list of slide/instance pairs that indicate, for a given source path, which instances
// link to that source path and under which slide.
- // Pass in true if you want the map keys to include the identifiers (#1, #2).
+ // Set skipMaterialContainers true if you are not interested in source paths for materials
+ // inside material container.
+ // Set includeIdentifiers true if you want the map keys to include the identifiers (#1, #2).
virtual void GetSourcePathToInstanceMap(TCharPtrToSlideInstanceMap &outInstanceMap,
- bool checkMaterialContainers = true,
+ bool skipMaterialContainers = true,
bool includeIdentifiers = true) const = 0;
// Get a map from string table string to list of slide/instance pairs that indicates, for a
// given source path,
@@ -213,13 +215,14 @@ public:
// Given the active slide on the document (which we query) and an instance,
// produce a temporary file (Qt3DSFile::GetTemporaryFile) and serialize this object
// to that temporary file.
- virtual CFilePath CopySceneGraphObjects(qt3dsdm::TInstanceHandleList inInstances) = 0;
+ virtual CFilePath CopySceneGraphObjects(qt3dsdm::TInstanceHandleList inInstances,
+ bool preserveFileIds) = 0;
- CFilePath CopySceneGraphObject(Qt3DSDMInstanceHandle inInstance)
+ CFilePath CopySceneGraphObject(Qt3DSDMInstanceHandle inInstance, bool preserveFileIds)
{
qt3dsdm::TInstanceHandleList theInstances;
theInstances.push_back(inInstance);
- return CopySceneGraphObjects(theInstances);
+ return CopySceneGraphObjects(theInstances, preserveFileIds);
}
// Copy the object just to a DOM representation, don't serialize to file.
@@ -276,6 +279,8 @@ inline EStudioObjectType GetStudioObjectType(qt3dsdm::ComposerObjectTypes::Enum
return OBJTYPE_MODEL;
case ComposerObjectTypes::Group:
return OBJTYPE_GROUP;
+ case ComposerObjectTypes::Signal:
+ return OBJTYPE_SIGNAL;
case ComposerObjectTypes::Image:
return OBJTYPE_IMAGE;
case ComposerObjectTypes::Text:
diff --git a/src/Authoring/Client/Code/Core/Doc/IKeyframesManager.h b/src/Authoring/Client/Code/Core/Doc/IKeyframesManager.h
index df028c3f..692e7d0c 100644
--- a/src/Authoring/Client/Code/Core/Doc/IKeyframesManager.h
+++ b/src/Authoring/Client/Code/Core/Doc/IKeyframesManager.h
@@ -35,10 +35,11 @@ class IKeyframesManager
public:
virtual ~IKeyframesManager() {}
- virtual bool HasSelectedKeyframes() = 0;
- virtual bool HasDynamicKeyframes() = 0;
- virtual bool CanPerformKeyframeCopy() = 0;
- virtual bool CanPerformKeyframePaste() = 0;
+ virtual bool HasSelectedKeyframes() const = 0;
+ virtual bool HasDynamicKeyframes() const = 0;
+ virtual bool CanPerformKeyframeCopy() const = 0;
+ virtual bool CanPerformKeyframePaste() const = 0;
+ virtual bool canSetKeyframeInterpolation() const = 0;
virtual void CopyKeyframes() = 0;
virtual bool RemoveKeyframes(bool inPerformCopy) = 0;
virtual void PasteKeyframes() = 0;
diff --git a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp
index 61044c90..3a2f625e 100644
--- a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp
@@ -30,11 +30,9 @@
#include "Qt3DSCommonPrecompile.h"
#include "StudioProjectSettings.h"
#include "Core.h"
-#include "Preferences.h"
#include "Doc.h"
#include "CoreConst.h"
#include "Dispatch.h"
-#include "CommonConstants.h"
#include "StudioPreferences.h"
#include "Qt3DSLargeInteger.h"
#include "CColor.h"
@@ -70,10 +68,11 @@ void CStudioProjectSettings::reset()
// Reset the internal variables
m_author.clear();
m_company.clear();
- m_presentationSize = CStudioPreferences::GetDefaultClientSize();
+ m_presentationSize = CStudioPreferences::defaultClientSize();
m_maintainAspect = false;
m_rotatePresentation = false;
m_preferCompressedTextures = false;
+ m_flipCompressedTextures = false;
}
//==============================================================================
@@ -148,3 +147,11 @@ void CStudioProjectSettings::setPreferCompressedTextures(bool inFlag)
m_core->GetDoc()->SetModifiedFlag();
}
}
+
+void CStudioProjectSettings::setFlipCompressedTextures(bool inFlag)
+{
+ if (m_flipCompressedTextures != inFlag) {
+ m_flipCompressedTextures = inFlag;
+ m_core->GetDoc()->SetModifiedFlag();
+ }
+}
diff --git a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h
index 4fe476a9..2f86eac0 100644
--- a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h
+++ b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h
@@ -61,6 +61,9 @@ public:
bool getPreferCompressedTextures() const { return m_preferCompressedTextures; }
void setPreferCompressedTextures(bool inFlag);
+ bool getFlipCompressedTextures() const { return m_flipCompressedTextures; }
+ void setFlipCompressedTextures(bool inFlag);
+
void reset();
protected:
@@ -71,6 +74,7 @@ protected:
bool m_maintainAspect;
bool m_rotatePresentation;
bool m_preferCompressedTextures;
+ bool m_flipCompressedTextures;
CCore *m_core;
};
diff --git a/src/Authoring/Client/Code/Core/Types/Rotation3.h b/src/Authoring/Client/Code/Core/Types/Rotation3.h
index 661febe1..767d94d5 100644
--- a/src/Authoring/Client/Code/Core/Types/Rotation3.h
+++ b/src/Authoring/Client/Code/Core/Types/Rotation3.h
@@ -35,10 +35,8 @@
namespace Q3DStudio {
-#ifndef __CommonConstants_H__
const double QT3DS_DEGREES_TO_RADIANS = (6.2831856f / 360.0f);
const double QT3DS_RADIANS_TO_DEGREES = (360.0f / 6.2831856f);
-#endif
class CRotation3 : public CVector3
{
diff --git a/src/Authoring/Client/Code/Core/Utility/HotKeys.cpp b/src/Authoring/Client/Code/Core/Utility/HotKeys.cpp
index a47c2eb8..278bf23b 100644
--- a/src/Authoring/Client/Code/Core/Utility/HotKeys.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/HotKeys.cpp
@@ -566,6 +566,16 @@ bool CHotKeys::IsKeyDown(Qt::KeyboardModifier inKeyCode)
return qApp->keyboardModifiers() & inKeyCode;
}
+bool CHotKeys::isCtrlDown()
+{
+ return qApp->keyboardModifiers() & Qt::ControlModifier;
+}
+
+bool CHotKeys::isAltDown()
+{
+ return qApp->keyboardModifiers() & Qt::AltModifier;
+}
+
//=============================================================================
/**
* Retrieves the current status of the various modifier keys.
diff --git a/src/Authoring/Client/Code/Core/Utility/HotKeys.h b/src/Authoring/Client/Code/Core/Utility/HotKeys.h
index 75376322..27dc8fb9 100644
--- a/src/Authoring/Client/Code/Core/Utility/HotKeys.h
+++ b/src/Authoring/Client/Code/Core/Utility/HotKeys.h
@@ -238,6 +238,8 @@ public:
void ReleaseHotKeys();
static bool IsKeyDown(Qt::KeyboardModifier inKeyCode);
+ static bool isCtrlDown();
+ static bool isAltDown();
static Qt::KeyboardModifiers GetCurrentKeyModifiers();
static bool isFocusOnControlThatWantsKeys();
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
index 121bd747..c02d2e99 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
@@ -58,6 +58,7 @@ bool CStudioObjectTypes::AcceptableParent(EStudioObjectType inChild, EStudioObje
case OBJTYPE_LIGHT:
case OBJTYPE_MODEL:
case OBJTYPE_GROUP:
+ case OBJTYPE_SIGNAL:
case OBJTYPE_PATH:
case OBJTYPE_COMPONENT:
theAcceptible = (inParent == OBJTYPE_LAYER) || (inParent == OBJTYPE_CAMERA)
@@ -132,6 +133,10 @@ const QString &CStudioObjectTypes::GetNormalIconName(EStudioObjectType inType)
static QString theString = QStringLiteral("Objects-Group-Normal.png");
return theString;
}
+ case OBJTYPE_SIGNAL: {
+ static QString theString = QStringLiteral("Objects-Signal-Normal.png");
+ return theString;
+ }
case OBJTYPE_ALIAS: {
static QString theString = QStringLiteral("Objects-Alias-Normal.png");
return theString;
@@ -234,6 +239,10 @@ const QString &CStudioObjectTypes::GetDisabledIconName(EStudioObjectType inType)
static QString theString = QStringLiteral("Objects-Group-Disabled.png");
return theString;
}
+ case OBJTYPE_SIGNAL: {
+ static QString theString = QStringLiteral("Objects-Signal-Disabled.png");
+ return theString;
+ }
case OBJTYPE_ALIAS: {
static QString theString = QStringLiteral("Objects-Alias-Disabled.png");
return theString;
@@ -335,6 +344,10 @@ const QString &CStudioObjectTypes::GetHighlightIconName(EStudioObjectType inType
static QString theString = QStringLiteral("Objects-Group-Normal.png");
return theString;
}
+ case OBJTYPE_SIGNAL: {
+ static QString theString = QStringLiteral("Objects-Signal-Normal.png");
+ return theString;
+ }
case OBJTYPE_PATH: {
static QString theString = QStringLiteral("Objects-Path-Normal.png");
return theString;
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h
index 79eafc19..dc57d4c8 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h
+++ b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.h
@@ -67,6 +67,7 @@ enum EStudioObjectType {
OBJTYPE_PROJECT = 0x02000000,
OBJTYPE_QML_STREAM = 0x04000000,
OBJTYPE_MATERIALDATA = 0x08000000,
+ OBJTYPE_SIGNAL = 0x10000000,
// filters
OBJTYPE_IS_VARIANT = OBJTYPE_LAYER | OBJTYPE_TEXT | OBJTYPE_MODEL | OBJTYPE_GROUP
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
index d9ed32c4..3fe5f377 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp
@@ -30,30 +30,24 @@
#include "Qt3DSCommonPrecompile.h"
#include "StudioPreferences.h"
-#include "Preferences.h"
#include "CColor.h"
#include "MasterP.h"
-#include "CommonConstants.h"
#include <QtGui/qpalette.h>
#include <QtQml/qqmlcontext.h>
-
-static ::CColor s_BaseColor;
-static ::CColor s_DarkBaseColor;
-static ::CColor s_NormalColor;
-static ::CColor s_MasterColor;
-static ::CColor s_MouseOverHighlightColor;
-static ::CColor s_ButtonDownColor;
-static ::CColor s_DisabledTextColor;
+#include <QtCore/qsettings.h>
static QColor s_studioColor1;
static QColor s_studioColor2;
static QColor s_studioColor3;
static QColor s_studioColor4;
+static QColor s_buttonDownColor;
+static QColor s_mouseOverHighlightColor;
static QColor s_backgroundColor;
static QColor s_guideColor;
static QColor s_selectionColor;
static QColor s_textColor;
+static QColor s_disabledTextColor;
static QColor s_masterColor;
static QColor s_disabledColor;
static QColor s_dataInputColor;
@@ -62,6 +56,8 @@ static QColor s_projectReferencedColor;
static QColor s_xAxisColor;
static QColor s_yAxisColor;
static QColor s_zAxisColor;
+static QColor s_wAxisColor;
+static QColor s_helperGridColor;
static QColor s_inspectorGroupHeaderColor;
static QColor s_variantsSlideViewBGColor;
static QLinearGradient s_welcomeBackgroundGradient;
@@ -88,7 +84,8 @@ static QColor s_timelineFilterButtonSelectedColor;
static QColor s_timelineFilterButtonHoveredColor;
static QColor s_timelineRowCommentBgColor;
static QColor s_timelinePressedKeyframeColor; // pressed keyframe from multiple selection
-static QColor s_invalidDataInputIndicatorColor;
+static QColor s_timelineActionColor;
+static QColor s_invalidDataIndicatorColor;
static int s_fontSize;
static int s_controlBaseHeight;
@@ -96,13 +93,12 @@ static int s_idWidth;
static int s_valueWidth;
static QSize s_browserPopupSize;
+static QSettings s_preferences(QStringLiteral("The Qt Company"),
+ QStringLiteral("Qt 3D Studio"));
+
#define STRINGIFY(x) STRINGIFY2(x)
#define STRINGIFY2(x) #x
-// Statics
-const ::CColor CStudioPreferences::EDITVIEW_DEFAULTBGCOLOR = ::CColor("#262829");
-std::unique_ptr<CPreferences> CStudioPreferences::m_preferences = nullptr;
-
CStudioPreferences::CStudioPreferences()
{
}
@@ -111,46 +107,19 @@ CStudioPreferences::~CStudioPreferences()
{
}
-//==============================================================================
-/**
- * Loads the default preferences from the registry. Must be called after the
- * registry root has been set up, and before calling any of the Get functions.
- */
-void CStudioPreferences::loadPreferences(const QString &filePath)
+void CStudioPreferences::loadPreferences()
{
- if (!m_preferences)
- m_preferences = std::unique_ptr<CPreferences>(new CPreferences);
-
- m_preferences->SetPreferencesFile(filePath);
-
- s_BaseColor = m_preferences->GetColorValue(QStringLiteral("BaseColor"), ::CColor("#262829"),
- QStringLiteral("Preferences"));
-
- s_NormalColor = m_preferences->GetColorValue(QStringLiteral("NormalColor"), ::CColor("#ffffff"),
- QStringLiteral("Preferences"));
- s_MasterColor = m_preferences->GetColorValue(QStringLiteral("MasterColor"), ::CColor("#5caa15"),
- QStringLiteral("Preferences"));
-
- s_DarkBaseColor = s_BaseColor;
- s_DarkBaseColor.SetLuminance(s_DarkBaseColor.GetLuminance() - 0.10f);
-
- s_MouseOverHighlightColor = s_BaseColor;
- s_MouseOverHighlightColor.SetLuminance(s_MouseOverHighlightColor.GetLuminance() - 0.05f);
-
- s_ButtonDownColor = s_DarkBaseColor; // CPreferences::GetUserPreferences( "Preferences"
- // ).GetColorValue( "ButtonDownColor", ::CColor( 118, 202,
- // 8 ) );
-
- s_DisabledTextColor = ::CColor(128, 128, 128);
-
s_studioColor1 = QColor("#262829");
s_studioColor2 = QColor("#404244");
s_studioColor3 = QColor("#727476");
s_studioColor4 = QColor("#959596");
+ s_buttonDownColor = s_studioColor1.lighter(90);
+ s_mouseOverHighlightColor = s_studioColor1.lighter(95);
s_backgroundColor = QColor("#2e2f30");
s_guideColor = QColor("#f4be04");
s_selectionColor = QColor("#23516D");
s_textColor = QColor("#ffffff");
+ s_disabledTextColor = QColor("#808080");
s_masterColor = QColor("#5caa15");
s_disabledColor = s_studioColor3;
s_dataInputColor = QColor("#ff5102");
@@ -158,7 +127,9 @@ void CStudioPreferences::loadPreferences(const QString &filePath)
s_projectReferencedColor = QColor("#aaaa00");
s_xAxisColor = QColor("#ca2f2e");
s_yAxisColor = QColor("#64cd35");
- s_zAxisColor = QColor("#1e9fcd");
+ s_zAxisColor = QColor("#068ac2");
+ s_wAxisColor = QColor("#fc0388");
+ s_helperGridColor = QColor("#515151");
s_inspectorGroupHeaderColor = QColor("#111111");
s_variantsSlideViewBGColor = QColor("#111111");
@@ -188,8 +159,9 @@ void CStudioPreferences::loadPreferences(const QString &filePath)
s_timelineRowSubpDescendantColor = QColor("#a263ff");
s_timelineRowCommentBgColor = QColor("#d0000000");
s_timelinePressedKeyframeColor = QColor("#ffff00");
+ s_timelineActionColor = QColor("#f4be04");
- s_invalidDataInputIndicatorColor = QColor("#ff2121");
+ s_invalidDataIndicatorColor = QColor("#ff2121");
s_fontSize = 12;
s_controlBaseHeight = 22;
@@ -200,679 +172,446 @@ void CStudioPreferences::loadPreferences(const QString &filePath)
void CStudioPreferences::savePreferences()
{
- m_preferences->save();
+ s_preferences.sync();
}
-//==============================================================================
-/**
- * Returns the state of the legacy viewer
- * @return true if the legacy viewer is active
- */
-bool CStudioPreferences::IsLegacyViewerActive()
+//
+// Settings to save in QSettings
+//
+
+// MainWindow settings
+//
+QByteArray CStudioPreferences::windowGeometry(int version)
{
- return m_preferences->GetValue("LegacyViewerActive", true);
+ QString geoKey = QStringLiteral("MainWindow/MainWindowGeometry")
+ + QString::number(version);
+ return s_preferences.value(geoKey).toByteArray();
}
-//==============================================================================
-/**
- * Sets the state of the legacy viewer
- * @param inActiveFlag true if the legacy viewer is active
- */
-void CStudioPreferences::SetLegacyViewerActive(bool inActive)
+void CStudioPreferences::setWindowGeometry(const QByteArray &geometry, int version)
{
- m_preferences->SetValue("LegacyViewerActive", inActive);
+ QString geoKey = QStringLiteral("MainWindow/MainWindowGeometry")
+ + QString::number(version);
+ s_preferences.setValue(geoKey, geometry);
}
-//==============================================================================
-/**
- * Returns the state of the timeline snapping grid
- * @return true if the snapping grid is active
- */
-bool CStudioPreferences::IsTimelineSnappingGridActive()
+void CStudioPreferences::resetWindowGeometry(int version)
{
- return m_preferences->GetValue(QStringLiteral("SnappingGridActive"), true);
+ QString geoKey = QStringLiteral("MainWindow/MainWindowGeometry")
+ + QString::number(version);
+ s_preferences.remove(geoKey);
}
-//==============================================================================
-/**
- * Sets the state of the timeline snapping grid
- * @param inActiveFlag true if the snapping grid is active
- */
-void CStudioPreferences::SetTimelineSnappingGridActive(bool inActive)
+bool CStudioPreferences::containsWindowState(int version)
{
- m_preferences->SetValue(QStringLiteral("SnappingGridActive"), inActive);
+ QString stateKey = QStringLiteral("MainWindow/MainWindowState")
+ + QString::number(version);
+ return s_preferences.contains(stateKey);
}
-//==============================================================================
-/**
- * Gets the timeline snapping grid resolution
- * @return Index value for the snapping resolution:
- * (See StudioConst.h for these values)
- */
-ESnapGridResolution CStudioPreferences::GetTimelineSnappingGridResolution()
+QByteArray CStudioPreferences::windowState(int version)
{
- return (ESnapGridResolution)m_preferences->GetLongValue(
- QStringLiteral("SnappingGridResolution"), (long)SNAPGRID_SECONDS);
+ QString stateKey = QStringLiteral("MainWindow/MainWindowState")
+ + QString::number(version);
+ return s_preferences.value(stateKey).toByteArray();
}
-//==============================================================================
-/**
- * Sets the timeline snapping grid resolution
- * @param inSnappingResolution Index value for the snapping resolution:
- * (See StudioConst.h for these values)
- */
-void CStudioPreferences::SetTimelineSnappingGridResolution(ESnapGridResolution inResolution)
+void CStudioPreferences::setWindowState(const QByteArray &state, int version)
{
- m_preferences->SetLongValue(QStringLiteral("SnappingGridResolution"), (long)inResolution);
+ QString stateKey = QStringLiteral("MainWindow/MainWindowState")
+ + QString::number(version);
+ s_preferences.setValue(stateKey, state);
}
-/**
- * Get the fill mode to render the geometries when in editing view
- * @return true to render as solid, else as wireframe
- */
-bool CStudioPreferences::GetEditViewFillMode()
+void CStudioPreferences::resetWindowState(int version)
{
- return m_preferences->GetValue(QStringLiteral("EditViewFillMode"), true);
+ QString stateKey = QStringLiteral("MainWindow/MainWindowState")
+ + QString::number(version);
+ s_preferences.remove(stateKey);
}
-//==============================================================================
-/**
- * Set the fill mode to render the geometries when in editing view
- * @param inRenderAsSolid true to render as solid, else as wireframe
- */
-void CStudioPreferences::SetEditViewFillMode(bool inRenderAsSolid)
+// Viewing settings
+//
+bool CStudioPreferences::isEditViewFillMode()
{
- m_preferences->SetValue(QStringLiteral("EditViewFillMode"), inRenderAsSolid);
+ return s_preferences.value(QStringLiteral("Viewing/EditViewFillMode"), true).toBool();
}
-//==============================================================================
-/**
- * Get the preferred startup view. -1 means the scene view and positive value
- * means the index of the editing camera, thus the view
- */
-long CStudioPreferences::GetPreferredStartupView()
+void CStudioPreferences::setEditViewFillMode(bool inRenderAsSolid)
{
- return m_preferences->GetLongValue(QStringLiteral("PreferredStartupView"),
- PREFERREDSTARTUP_DEFAULTINDEX);
+ s_preferences.setValue(QStringLiteral("Viewing/EditViewFillMode"), inRenderAsSolid);
}
-//==============================================================================
-/**
- * Set the preferred startup view. -1 means the scene view and positive value
- * means the index of the editing camera, thus the view
- * @param inStartupView the preferred startup view of new presentation.
- */
-void CStudioPreferences::SetPreferredStartupView(long inStartupView)
+int CStudioPreferences::preferredStartupView()
{
- m_preferences->SetLongValue(QStringLiteral("PreferredStartupView"), inStartupView);
+ return s_preferences.value(QStringLiteral("Viewing/PreferredStartupView"),
+ PREFERREDSTARTUP_DEFAULTINDEX).toInt();
}
-//==============================================================================
-/**
- * Indicates whether or not auto keyframing is turned on.
- * Fetches the autoset keyframes preference from the registry.
- * @return true if autoset keyframes is turned on, otherwise false
- */
-bool CStudioPreferences::IsAutosetKeyframesOn()
+void CStudioPreferences::setPreferredStartupView(int inStartupView)
{
- return m_preferences->GetValue(QStringLiteral("AutosetKeyframes"), true);
+ s_preferences.setValue(QStringLiteral("Viewing/PreferredStartupView"), int(inStartupView));
}
-//==============================================================================
-/**
- * Sets the autoset keyframe preference.
- * Saves the autoset keyframes preference in the registry.
- * @param inEnable TRUE to enable autosetting of keyframes
- */
-void CStudioPreferences::SetAutosetKeyframesOn(bool inEnable)
+bool CStudioPreferences::isDontShowGLVersionDialog()
{
- m_preferences->SetValue(QStringLiteral("AutosetKeyframes"), inEnable);
+ return s_preferences.value(QStringLiteral("Viewing/DontShowGLVersionDialog"), false).toBool();
}
-//==============================================================================
-/**
- * Indicates whether or not displaying bounding box is turned on.
- * Fetches the displaying bounding box preference from the registry.
- * @return true if displaying bounding box is turned on, otherwise false
- */
-bool CStudioPreferences::IsBoundingBoxesOn()
+void CStudioPreferences::setDontShowGLVersionDialog(bool inValue)
{
- return m_preferences->GetValue(QStringLiteral("BoundingBoxes"), true);
+ s_preferences.setValue(QStringLiteral("Viewing/DontShowGLVersionDialog"), inValue);
}
-//==============================================================================
-/**
- * Sets the preference to whether display the bounding box
- * Saves the bounding box displaying preference in the registry.
- * @param inEnable TRUE to enable display the bounding box
- */
-void CStudioPreferences::SetBoundingBoxesOn(bool inEnable)
+QSize CStudioPreferences::defaultClientSize()
{
- m_preferences->SetValue(QStringLiteral("BoundingBoxes"), inEnable);
+ QSize theSize;
+ theSize.setWidth(s_preferences.value(QStringLiteral("Viewing/DefaultClientWidth"),
+ DEFAULT_CLIENT_WIDTH).toInt());
+ theSize.setHeight(s_preferences.value(QStringLiteral("Viewing/DefaultClientHeight"),
+ DEFAULT_CLIENT_HEIGHT).toInt());
+ return theSize;
}
-//==============================================================================
-/**
- * Indicates whether or not displaying pivot point is turned on.
- * Fetches the displaying pivot point preference from the registry.
- * @return true if displaying pivot point is turned on, otherwise false
- */
-bool CStudioPreferences::ShouldDisplayPivotPoint()
+void CStudioPreferences::setDefaultClientSize(int width, int height)
{
- return m_preferences->GetValue(QStringLiteral("Display Pivot Point"), true);
+ s_preferences.setValue(QStringLiteral("Viewing/DefaultClientWidth"), width);
+ s_preferences.setValue(QStringLiteral("Viewing/DefaultClientHeight"), height);
}
-//==============================================================================
-/**
- * Sets the preference to whether display the pivot point
- * Saves the pivot point displaying preference in the registry.
- * @param inEnable TRUE to enable display the pivot point
- */
-void CStudioPreferences::SetDisplayPivotPoint(bool inEnable)
+bool CStudioPreferences::isEditModeLightingEnabled()
{
- return m_preferences->SetValue(QStringLiteral("Display Pivot Point"), inEnable);
+ return s_preferences.value(QStringLiteral("Viewing/EditModeLightingEnabled"), true).toBool();
}
-//==============================================================================
-/**
- * Indicates whether or not displaying geometry as wireframe.
- * Fetches the displaying wireframe mode preference from the registry.
- * @return true if displaying wireframe mode is turned on, otherwise false
- */
-bool CStudioPreferences::IsWireframeModeOn()
+void CStudioPreferences::setEditModeLightingEnabled(bool enabled)
{
- return m_preferences->GetValue(QStringLiteral("WireframeMode"), true);
+ s_preferences.setValue(QStringLiteral("Viewing/EditModeLightingEnabled"), enabled);
}
-//==============================================================================
-/**
- * Sets the preference to whether display geometry in wireframe mode
- * Saves thewireframe mode displaying preference in the registry.
- * @param inEnable TRUE to enable display the bounding box
- */
-void CStudioPreferences::SetWireframeModeOn(bool inEnable)
+bool CStudioPreferences::containsShowWelcomeScreen()
{
- m_preferences->SetValue(QStringLiteral("WireframeMode"), inEnable);
+ return s_preferences.contains(QStringLiteral("Viewing/ShowWelcomeScreen"));
}
-//==============================================================================
-/**
- * Indicates whether or not to show tooltips on inspector palette.
- * Retrieves tooltip visibility preference from the registry.
- * @return true if tooltips should be shown, false if tooltips should not be shown.
- */
-bool CStudioPreferences::ShouldShowTooltips()
+bool CStudioPreferences::isShowWelcomeScreen()
{
- return m_preferences->GetValue(QStringLiteral("ShowTooltips"), true);
+ return s_preferences.value(QStringLiteral("Viewing/ShowWelcomeScreen")).toBool();
}
-//==============================================================================
-/**
- * Indicates whether or not to show tooltips on inspector palette.
- * Saves tooltip visibility preference in the registry.
- * @param inEnable true if tooltips should be shown, false if tooltips should not be shown.
- */
-void CStudioPreferences::SetShowTooltips(bool inShowTooltips)
+void CStudioPreferences::setShowWelcomeScreen(bool show)
{
- m_preferences->SetValue(QStringLiteral("ShowTooltips"), inShowTooltips);
+ s_preferences.setValue(QStringLiteral("Viewing/ShowWelcomeScreen"), show);
}
-//==============================================================================
-/**
- * Returns the preferred location of the timeline's splitter bar.
- */
-long CStudioPreferences::GetTimelineSplitterLocation()
+// Timeline settings
+//
+bool CStudioPreferences::isTimelineSnappingGridActive()
{
- return m_preferences->GetLongValue(QStringLiteral("TimelineSplitterLoc"), 250,
- QStringLiteral("Timeline"));
+ return s_preferences.value(QStringLiteral("Timeline/SnappingGridActive"), true).toBool();
}
-//==============================================================================
-/**
- * Stores the location of the splitter bar in the timeline.
- * @param inLocation location of the splitter
- */
-void CStudioPreferences::SetTimelineSplitterLocation(long inLocation)
+void CStudioPreferences::setTimelineSnappingGridActive(bool inActive)
{
- m_preferences->SetLongValue(QStringLiteral("TimelineSplitterLoc"), inLocation,
- QStringLiteral("Timeline"));
+ s_preferences.setValue(QStringLiteral("Timeline/SnappingGridActive"), inActive);
}
-//==============================================================================
-/**
- * Gets the preferred method of interpolation.
- * Indicates whether the user prefers smooth or linear interpolation by default.
- * @return true indicates that smooth interpolation is preferred, false indicates linear
- *interpolation.
- */
-bool CStudioPreferences::GetInterpolation()
+ESnapGridResolution CStudioPreferences::timelineSnappingGridResolution()
{
- return m_preferences->GetValue(QStringLiteral("InterpolationPreference"), true);
+ return ESnapGridResolution(s_preferences.value(
+ QStringLiteral("Timeline/SnappingGridResolution"),
+ SNAPGRID_SECONDS).toInt());
}
-//==============================================================================
-/**
- * Saves the preferred interpolation method in the registry.
- * @param inSmooth true indicates smooth interpolation, false indicates linear
- */
-void CStudioPreferences::SetInterpolation(bool inSmooth)
+void CStudioPreferences::setTimelineSnappingGridResolution(ESnapGridResolution inResolution)
{
- m_preferences->SetValue(QStringLiteral("InterpolationPreference"), inSmooth);
+ s_preferences.setValue(QStringLiteral("Timeline/SnappingGridResolution"), int(inResolution));
}
-//==============================================================================
-/**
- * Gets the snapping range of the timebars from the registry.
- * @return New range in milliseconds.
- */
-long CStudioPreferences::GetSnapRange()
+bool CStudioPreferences::isAutosetKeyframesOn()
{
- return m_preferences->GetLongValue(QStringLiteral("SnapRange"), DEFAULT_SNAPRANGE);
+ return s_preferences.value(QStringLiteral("Timeline/AutosetKeyframes"), true).toBool();
}
-//==============================================================================
-/**
- * Sets the snapping range of the timebars by saving value in registry.
- * @param inSnapRange New range in milliseconds.
- */
-void CStudioPreferences::SetSnapRange(long inSnapRange)
+void CStudioPreferences::setAutosetKeyframesOn(bool inEnable)
{
- m_preferences->SetLongValue(QStringLiteral("SnapRange"), inSnapRange);
+ s_preferences.setValue(QStringLiteral("Timeline/AutosetKeyframes"), inEnable);
}
-//==============================================================================
-/**
- * Gets the delay between auto saves from the registry.
- * @return autosave delay in minutes.
- */
-long CStudioPreferences::GetAutoSaveDelay()
+double CStudioPreferences::timelineSplitterLocation()
{
- // default delay is 10 minutes (600 seconds)
- return m_preferences->GetLongValue(QStringLiteral("Delay"), DEFAULT_AUTOSAVE_DELAY,
- QStringLiteral("AutoSave"));
+ return s_preferences.value(QStringLiteral("Timeline/SplitterLocation"), 250).toDouble();
}
-//==============================================================================
-/**
- * Sets the delay between auto saves by saving value in registry.
- * @param inDelay New autosave delay in minutes.
- */
-void CStudioPreferences::SetAutoSaveDelay(long inAutoSaveDelay)
+void CStudioPreferences::setTimelineSplitterLocation(double inLocation)
{
- m_preferences->SetLongValue(QStringLiteral("Delay"), inAutoSaveDelay,
- QStringLiteral("AutoSave"));
+ s_preferences.setValue(QStringLiteral("Timeline/SplitterLocation"), inLocation);
}
-//==============================================================================
-/**
- * Returns true if Auto Saving is turned on.
- * AutoSaving is turned ON by default.
- *
- * @return true if autosaving is on.
- */
-bool CStudioPreferences::GetAutoSavePreference()
+bool CStudioPreferences::isInterpolation()
{
- return m_preferences->GetValue(QStringLiteral("Preference"), true, QStringLiteral("AutoSave"));
+ return s_preferences.value(QStringLiteral("Timeline/InterpolationPreference"), true).toBool();
}
-//==============================================================================
-/**
- * Sets user preference of whether to autosave.
- * @param inActive user autosave preference.
- */
-void CStudioPreferences::SetAutoSavePreference(bool inActive)
+void CStudioPreferences::setInterpolation(bool inSmooth)
{
- m_preferences->SetValue(QStringLiteral("Preference"), inActive, QStringLiteral("AutoSave"));
+ s_preferences.setValue(QStringLiteral("Timeline/InterpolationPreference"), inSmooth);
}
-//==============================================================================
-/**
- * Gets the default object lifetime.
- * The Preferences dialog can change the default object lifetime. When an
- * object is created, this is how long it should be alive for by default.
- * The value is stored in the registry.
- * @return New lifetime in milliseconds.
- */
-long CStudioPreferences::GetDefaultObjectLifetime()
+double CStudioPreferences::snapRange()
{
- return m_preferences->GetLongValue(QStringLiteral("DefaultObjectLifetime"), DEFAULT_LIFETIME);
+ return s_preferences.value(QStringLiteral("Timeline/SnapRange"), DEFAULT_SNAPRANGE).toDouble();
}
-//==============================================================================
-/**
- * Sets the default object lifetime.
- * The Preferences dialog can change the default object lifetime. When an
- * object is created, this is how long it should be alive for by default.
- * The value is stored in the registry.
- * @param inAmount New lifetime in milliseconds.
- */
-void CStudioPreferences::SetDefaultObjectLifetime(long inLifetime)
+void CStudioPreferences::setSnapRange(double inSnapRange)
{
- m_preferences->SetLongValue(QStringLiteral("DefaultObjectLifetime"), inLifetime);
+ s_preferences.setValue(QStringLiteral("Timeline/SnapRange"), inSnapRange);
}
-//==============================================================================
-/**
- * Gets the current timebar setting.
- * Timebars will be able to display different information such as user-defined
- * comments or the start/end time of the timebar. This setting toggles between
- * the two modes. The values are stored in the registry.
- * @return true if time is being displayed
- */
-bool CStudioPreferences::GetTimebarDisplayTime()
+bool CStudioPreferences::isTimebarDisplayTime()
{
- return m_preferences->GetValue(QStringLiteral("TimebarSetting"), false);
+ return s_preferences.value(QStringLiteral("Timeline/DisplayTime"), false).toBool();
}
-//==============================================================================
-/**
- * Sets the timebar setting.
- * The Preferences dialog can change the default timebar setting. A timebar
- * can show either time information, or comments entered by the user. The value
- * is stored in the registry and preserved between sessions.
- * @param inShowTime True if the time should be shown
- */
-void CStudioPreferences::SetTimebarDisplayTime(bool inDisplayTime)
+void CStudioPreferences::setTimebarDisplayTime(bool inDisplayTime)
{
- m_preferences->SetValue(QStringLiteral("TimebarSetting"), inDisplayTime);
+ s_preferences.setValue(QStringLiteral("Timeline/DisplayTime"), inDisplayTime);
}
-//==============================================================================
-/**
- * Gets the advance property expanded flag
- * When an object is selected, this universal flag is used for either toggle
- * the advance properties on or off but will not be visually available in
- * the application preference dialog and default to false.
- * @return The expanded flag
- */
-bool CStudioPreferences::GetAdvancePropertyExpandedFlag()
+long CStudioPreferences::timeAdvanceAmount()
{
- return m_preferences->GetValue(QStringLiteral("AdvancePropertyFlag"), false);
+ return s_preferences.value(QStringLiteral("Timeline/TimeAdvance"),
+ DEFAULT_TIME_ADVANCE).toInt();
}
-//==============================================================================
-/**
- * Sets the expanded flag for object when toggled
- * @param inAdvancePropertyFlag Save the last toggle flag
- */
-void CStudioPreferences::SetAdvancePropertyExpandedFlag(bool inAdvancePropertyFlag)
+void CStudioPreferences::setTimeAdvanceAmount(long inTime)
{
- m_preferences->SetValue(QStringLiteral("AdvancePropertyFlag"), inAdvancePropertyFlag);
+ s_preferences.setValue(QStringLiteral("Timeline/TimeAdvance"), int(inTime));
}
-QString CStudioPreferences::GetPreviewConfig()
+long CStudioPreferences::bigTimeAdvanceAmount()
{
- return m_preferences->GetStringValue(QStringLiteral("Preview.Config"));
+ return s_preferences.value(QStringLiteral("Timeline/BigTimeAdvance"),
+ DEFAULT_BIG_TIME_ADVANCE).toInt();
}
-void CStudioPreferences::SetPreviewConfig(const QString &inValue)
+void CStudioPreferences::setBigTimeAdvanceAmount(long inTime)
{
- m_preferences->SetStringValue(QStringLiteral("Preview.Config"), inValue);
+ s_preferences.setValue(QStringLiteral("Timeline/BigTimeAdvance"), int(inTime));
}
-// Preview Properties at the registry are prepend with Preview.
-QString CStudioPreferences::GetPreviewProperty(const QString &inName)
+// VisualAids settings
+//
+bool CStudioPreferences::isBoundingBoxesOn()
{
- QString theName = QStringLiteral("Preview.") + inName;
- return m_preferences->GetStringValue(theName);
+ return s_preferences.value(QStringLiteral("VisualAids/BoundingBoxes"), true).toBool();
}
-void CStudioPreferences::SetPreviewProperty(const QString &inName, const QString &inValue)
+void CStudioPreferences::setBoundingBoxesOn(bool inEnable)
{
- QString theName = QStringLiteral("Preview.") + inName;
- m_preferences->SetStringValue(theName, inValue);
+ s_preferences.setValue(QStringLiteral("VisualAids/BoundingBoxes"), inEnable);
}
-//=============================================================================
-/**
- * Get whether we should show OpenGL Version Warning or Error Dialog
- * This is used to disable / enable OpenGL Version checking
- * @return true if user don't want to see the GL Version warning dialog
- */
-bool CStudioPreferences::GetDontShowGLVersionDialog()
+bool CStudioPreferences::isPivotPointOn()
{
- return m_preferences->GetValue(QStringLiteral("DontShowGLVersionDialog"), false);
+ return s_preferences.value(QStringLiteral("VisualAids/DisplayPivotPoint"), true).toBool();
}
-//=============================================================================
-/**
- * Set whether we should show OpenGL Version Warning or Error Dialog
- * This is used to disable / enable OpenGL Version checking
- */
-void CStudioPreferences::SetDontShowGLVersionDialog(bool inValue)
+void CStudioPreferences::setPivotPointOn(bool inEnable)
{
- m_preferences->SetValue(QStringLiteral("DontShowGLVersionDialog"), inValue);
+ s_preferences.setValue(QStringLiteral("VisualAids/DisplayPivotPoint"), inEnable);
}
-QSize CStudioPreferences::GetDefaultClientSize()
+bool CStudioPreferences::isWireframeModeOn()
{
- QSize theSize;
- theSize.setWidth(m_preferences->GetLongValue(QStringLiteral("DefaultClientWidth"),
- DEFAULT_CLIENT_WIDTH));
- theSize.setHeight(m_preferences->GetLongValue(QStringLiteral("DefaultClientHeight"),
- DEFAULT_CLIENT_HEIGHT));
- return theSize;
+ return s_preferences.value(QStringLiteral("VisualAids/WireframeMode"), true).toBool();
}
-void CStudioPreferences::SetDefaultClientSize(int width, int height)
+void CStudioPreferences::setWireframeModeOn(bool inEnable)
{
- m_preferences->SetLongValue(QStringLiteral("DefaultClientWidth"), (long)width);
- m_preferences->SetLongValue(QStringLiteral("DefaultClientHeight"), (long)height);
+ s_preferences.setValue(QStringLiteral("VisualAids/WireframeMode"), inEnable);
}
-int CStudioPreferences::getNumRecentItems()
+bool CStudioPreferences::isTooltipsOn()
{
- return m_preferences->GetLongValue(QStringLiteral("RecentValid"));
+ return s_preferences.value(QStringLiteral("VisualAids/ShowTooltips"), true).toBool();
}
-void CStudioPreferences::setNumRecentItems(int n)
+void CStudioPreferences::setTooltipsOn(bool inShowTooltips)
{
- m_preferences->SetLongValue(QStringLiteral("RecentValid"), n);
+ s_preferences.setValue(QStringLiteral("VisualAids/ShowTooltips"), inShowTooltips);
}
-QString CStudioPreferences::getRecentItem(int index)
+bool CStudioPreferences::isHelperGridOn()
{
- return m_preferences->GetStringValue(QStringLiteral("RecentItem") + QString::number(index));
+ return s_preferences.value(QStringLiteral("VisualAids/ShowHelperGrid"), true).toBool();
}
-void CStudioPreferences::setRecentItem(int index, const QString &path)
+void CStudioPreferences::setHelperGridOn(bool showGrid)
{
- m_preferences->SetStringValue(QStringLiteral("RecentItem") + QString::number(index), path);
- savePreferences();
+ s_preferences.setValue(QStringLiteral("VisualAids/ShowHelperGrid"), showGrid);
}
-//==============================================================================
-/**
- * Get the amount of time that the playhead should be advanced/reduced when the
- * '.' and ',' keys are used.
- */
-long CStudioPreferences::GetTimeAdvanceAmount()
+bool CStudioPreferences::isAxisHelperOn()
{
- return m_preferences->GetLongValue(QStringLiteral("TimeAdvance"), DEFAULT_TIME_ADVANCE);
+ return s_preferences.value(QStringLiteral("VisualAids/ShowAxisHelper"), true).toBool();
}
-//==============================================================================
-/**
- * Sets the amount of time that the playhead should be advanced/reduced when the
- * '.' and ',' keys are used.
- */
-void CStudioPreferences::SetTimeAdvanceAmount(long inTime)
+void CStudioPreferences::setAxisHelperOn(bool showAxisHelper)
{
- m_preferences->SetLongValue(QStringLiteral("TimeAdvance"), inTime);
+ s_preferences.setValue(QStringLiteral("VisualAids/ShowAxisHelper"), showAxisHelper);
}
-//==============================================================================
-/**
- * Get the amount of time that the playhead should be advanced/reduced when the
- * '<' and '>' keys are used.
- */
-long CStudioPreferences::GetBigTimeAdvanceAmount()
+int CStudioPreferences::helperGridLines()
{
- return m_preferences->GetLongValue(QStringLiteral("BigTimeAdvance"), DEFAULT_BIG_TIME_ADVANCE);
+ return s_preferences.value(QStringLiteral("VisualAids/HelperGridLines"), 10).toInt();
}
-//==============================================================================
-/**
- * Set the amount of time that the playhead should be advanced/reduced when the
- * '<' and '>' keys are used.
- */
-void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime)
+void CStudioPreferences::setHelperGridLines(int lines)
{
- m_preferences->SetLongValue(QStringLiteral("BigTimeAdvance"), inTime);
+ s_preferences.setValue(QStringLiteral("VisualAids/HelperGridLines"), lines);
}
-/**
- * Retrieves the color that should be used when the mouse goes over a row, such
- * as in the timeline or inspector palettes.
- */
-::CColor CStudioPreferences::GetMouseOverHighlightColor()
+int CStudioPreferences::helperGridSpacing()
{
- return s_MouseOverHighlightColor;
+ return s_preferences.value(QStringLiteral("VisualAids/HelperGridSpacing"), 100).toInt();
}
-/**
- * Returns the normal color used for non-master items and text throughout the UI
- */
-::CColor CStudioPreferences::GetNormalColor()
+void CStudioPreferences::setHelperGridSpacing(int spacing)
{
- return s_NormalColor;
+ s_preferences.setValue(QStringLiteral("VisualAids/HelperGridSpacing"), spacing);
}
-//=============================================================================
-/**
- * Returns the color for master items and text throughout the UI
- */
-::CColor CStudioPreferences::GetMasterColor()
+float CStudioPreferences::selectorLineWidth()
{
- return s_MasterColor;
+ return s_preferences.value(QStringLiteral("VisualAids/SelectorLineWidth"),
+ DEFAULT_SELECTOR_WIDTH).toFloat() / 10.0f;
}
-//=============================================================================
-/**
- * Returns the color for inactive items and text throughout the UI
- */
-::CColor CStudioPreferences::GetInactiveColor()
+void CStudioPreferences::setSelectorLineWidth(float width)
{
- return s_disabledColor;
+ s_preferences.setValue(QStringLiteral("VisualAids/SelectorLineWidth"), int(width * 10.0f));
}
-/**
- * @return default color for object timebars in the timeline (if not specified by one of these other
- * functions)
- */
-::CColor CStudioPreferences::GetObjectTimebarColor()
+float CStudioPreferences::selectorLineLength()
{
- return ::CColor("#788ac5");
+ return s_preferences.value(QStringLiteral("VisualAids/SelectorLineLength"),
+ DEFAULT_SELECTOR_LENGTH).toFloat();
}
-//=============================================================================
-/**
- * @return default colors for specific timebars in the timeline
- */
-::CColor CStudioPreferences::GetLayerTimebarColor()
+void CStudioPreferences::setSelectorLineLength(float length)
{
- return ::CColor("#e7e0cd");
+ s_preferences.setValue(QStringLiteral("VisualAids/SelectorLineLength"), length);
}
-/**
- * Color when text is disabled
- */
-::CColor CStudioPreferences::GetDisabledTextColor()
+// Autosave settings
+//
+int CStudioPreferences::autoSaveDelay()
{
- return s_DisabledTextColor;
+ // default delay is 10 minutes (600 seconds)
+ return s_preferences.value(QStringLiteral("Autosave/Delay"), DEFAULT_AUTOSAVE_DELAY).toInt();
}
-//==============================================================================
-/**
- * Colors for bounding boxes
- */
-::CColor CStudioPreferences::GetSingleBoundingBoxColor()
+void CStudioPreferences::setAutoSaveDelay(int inAutoSaveDelay)
{
- return ::CColor("#ff0000");
+ s_preferences.setValue(QStringLiteral("Autosave/Delay"), inAutoSaveDelay);
}
-::CColor CStudioPreferences::GetGroupBoundingBoxColor()
+bool CStudioPreferences::isAutoSavePreference()
{
- return ::CColor("#ff0000");
+ return s_preferences.value(QStringLiteral("Autosave/Preference"), true).toBool();
}
-QColor CStudioPreferences::GetXAxisColor()
+void CStudioPreferences::setAutoSavePreference(bool inActive)
{
- return s_xAxisColor;
+ s_preferences.setValue(QStringLiteral("Autosave/Preference"), inActive);
}
-QColor CStudioPreferences::GetYAxisColor()
+// Preview settings
+//
+QString CStudioPreferences::previewConfig()
{
- return s_yAxisColor;
+ return s_preferences.value(QStringLiteral("Preview/Config")).toString();
}
-QColor CStudioPreferences::GetZAxisColor()
+void CStudioPreferences::setPreviewConfig(const QString &inValue)
{
- return s_zAxisColor;
+ s_preferences.setValue(QStringLiteral("Preview/Config"), inValue);
}
-/**
- * Colors for rulers and guides
- */
-::CColor CStudioPreferences::GetRulerBackgroundColor()
+QString CStudioPreferences::previewProperty(const QString &inName)
{
- return s_studioColor1;
+ QString theName = QStringLiteral("Preview/") + inName;
+ return s_preferences.value(theName).toString();
}
-::CColor CStudioPreferences::GetRulerTickColor()
+void CStudioPreferences::setPreviewProperty(const QString &inName, const QString &inValue)
{
- return s_studioColor3;
+ QString theName = QStringLiteral("Preview/") + inName;
+ s_preferences.setValue(theName, inValue);
}
-::CColor CStudioPreferences::GetGuideColor()
+QString CStudioPreferences::remoteDeploymentIP()
{
- return ::CColor("#7a5f02"); // #f4be04 plus faked alpha 50%
+ return s_preferences.value(QStringLiteral("Preview/LastRemoteDeploymentIP"),
+ QStringLiteral("127.0.0.1")).toString();
}
-::CColor CStudioPreferences::GetGuideSelectedColor()
+void CStudioPreferences::setRemoteDeploymentIP(const QString &ip)
{
- return s_guideColor;
+ s_preferences.setValue(QStringLiteral("Preview/LastRemoteDeploymentIP"), ip);
}
-::CColor CStudioPreferences::GetGuideFillColor()
+QString CStudioPreferences::remoteDeploymentPort()
{
- return ::CColor("#140F00"); // #f4be04 plus faked alpha 8%
+ return s_preferences.value(QStringLiteral("Preview/LastRemoteDeploymentPort"),
+ QStringLiteral("36000")).toString();
}
-::CColor CStudioPreferences::GetGuideFillSelectedColor()
+void CStudioPreferences::setRemoteDeploymentPort(const QString &port)
{
- return ::CColor("#7a5f02"); // #f4be04 plus faked alpha 50%
+ s_preferences.setValue(QStringLiteral("Preview/LastRemoteDeploymentPort"), port);
}
-//==============================================================================
-/**
- * Font face name for dialog
- */
-QString CStudioPreferences::GetFontFaceName()
+// Recent settings
+//
+int CStudioPreferences::numRecentItems()
{
- return QStringLiteral("Segoe UI");
+ return s_preferences.value(QStringLiteral("Recent/Valid"), 0).toInt();
}
-float CStudioPreferences::getSelectorLineWidth()
+void CStudioPreferences::setNumRecentItems(int numberOfItems)
{
- return m_preferences->GetLongValue("SelectorLineWidth", DEFAULT_SELECTOR_WIDTH) / 10.0f;
+ s_preferences.setValue(QStringLiteral("Recent/Valid"), numberOfItems);
}
-void CStudioPreferences::setSelectorLineWidth(float width)
+QString CStudioPreferences::recentItem(int index)
{
- m_preferences->SetLongValue("SelectorLineWidth", int(width * 10.0f));
+ return s_preferences.value(QStringLiteral("Recent/Item") + QString::number(index)).toString();
}
-float CStudioPreferences::getSelectorLineLength()
+void CStudioPreferences::setRecentItem(int index, const QString &path)
{
- return float(m_preferences->GetLongValue("SelectorLineLength", DEFAULT_SELECTOR_LENGTH));
+ s_preferences.setValue(QStringLiteral("Recent/Item") + QString::number(index), path);
}
-void CStudioPreferences::setSelectorLineLength(float length)
+//
+// Pop-up warning settings
+//
+void CStudioPreferences::setDoNotShowImportWarnings(bool inDoNotShowImportWarnings)
{
- m_preferences->SetLongValue("SelectorLineLength", int(length));
+ s_preferences.setValue(QStringLiteral("PopUps/DoNotShowImportWarnings"),
+ inDoNotShowImportWarnings);
}
+bool CStudioPreferences::doNotShowImportWarnings()
+{
+ return s_preferences.value(QStringLiteral("PopUps/DoNotShowImportWarnings")).toBool();
+}
+
+//
+// Other settings
+//
void CStudioPreferences::setQmlContextProperties(QQmlContext *qml)
{
qml->setContextProperty(QStringLiteral("_studioColor1"), s_studioColor1);
@@ -880,7 +619,7 @@ void CStudioPreferences::setQmlContextProperties(QQmlContext *qml)
qml->setContextProperty(QStringLiteral("_studioColor3"), s_studioColor3);
qml->setContextProperty(QStringLiteral("_studioColor4"), s_studioColor4);
qml->setContextProperty(QStringLiteral("_backgroundColor"), s_backgroundColor);
- qml->setContextProperty(QStringLiteral("_buttonDownColor"), s_ButtonDownColor.getQColor());
+ qml->setContextProperty(QStringLiteral("_buttonDownColor"), s_buttonDownColor);
qml->setContextProperty(QStringLiteral("_guideColor"), s_guideColor);
qml->setContextProperty(QStringLiteral("_selectionColor"), s_selectionColor);
qml->setContextProperty(QStringLiteral("_textColor"), s_textColor);
@@ -891,6 +630,9 @@ void CStudioPreferences::setQmlContextProperties(QQmlContext *qml)
qml->setContextProperty(QStringLiteral("_xAxisColor"), s_xAxisColor);
qml->setContextProperty(QStringLiteral("_yAxisColor"), s_yAxisColor);
qml->setContextProperty(QStringLiteral("_zAxisColor"), s_zAxisColor);
+ qml->setContextProperty(QStringLiteral("_wAxisColor"), s_wAxisColor);
+ qml->setContextProperty(QStringLiteral("_invalidDataIndicatorColor"),
+ s_invalidDataIndicatorColor);
qml->setContextProperty(QStringLiteral("_fontSize"), s_fontSize);
qml->setContextProperty(QStringLiteral("_controlBaseHeight"), s_controlBaseHeight);
qml->setContextProperty(QStringLiteral("_idWidth"), s_idWidth);
@@ -901,6 +643,111 @@ void CStudioPreferences::setQmlContextProperties(QQmlContext *qml)
s_variantsSlideViewBGColor);
}
+QString CStudioPreferences::fontFaceName()
+{
+ return QStringLiteral("Segoe UI");
+}
+
+::CColor CStudioPreferences::mouseOverHighlightColor()
+{
+ return s_mouseOverHighlightColor;
+}
+
+::CColor CStudioPreferences::normalColor()
+{
+ return s_textColor;
+}
+
+::CColor CStudioPreferences::inactiveColor()
+{
+ return s_disabledColor;
+}
+
+::CColor CStudioPreferences::objectTimebarColor()
+{
+ return ::CColor("#788ac5");
+}
+
+::CColor CStudioPreferences::layerTimebarColor()
+{
+ return ::CColor("#e7e0cd");
+}
+
+::CColor CStudioPreferences::disabledTextColor()
+{
+ return s_disabledTextColor;
+}
+
+::CColor CStudioPreferences::singleBoundingBoxColor()
+{
+ return ::CColor("#ff0000");
+}
+
+::CColor CStudioPreferences::groupBoundingBoxColor()
+{
+ return ::CColor("#ff0000");
+}
+
+QColor CStudioPreferences::xAxisColor()
+{
+ return s_xAxisColor;
+}
+
+QColor CStudioPreferences::yAxisColor()
+{
+ return s_yAxisColor;
+}
+
+QColor CStudioPreferences::zAxisColor()
+{
+ return s_zAxisColor;
+}
+
+QColor CStudioPreferences::wAxisColor()
+{
+ return s_wAxisColor;
+}
+
+QColor CStudioPreferences::helperGridColor()
+{
+ return s_helperGridColor;
+}
+
+QColor CStudioPreferences::bezierControlColor()
+{
+ return QColor("#f4bd04");
+}
+
+::CColor CStudioPreferences::rulerBackgroundColor()
+{
+ return s_studioColor1;
+}
+
+::CColor CStudioPreferences::rulerTickColor()
+{
+ return s_studioColor3;
+}
+
+::CColor CStudioPreferences::guideNormalColor()
+{
+ return ::CColor("#7a5f02"); // #f4be04 plus faked alpha 50%
+}
+
+::CColor CStudioPreferences::guideSelectedColor()
+{
+ return s_guideColor;
+}
+
+::CColor CStudioPreferences::guideFillColor()
+{
+ return ::CColor("#140F00"); // #f4be04 plus faked alpha 8%
+}
+
+::CColor CStudioPreferences::guideFillSelectedColor()
+{
+ return ::CColor("#7a5f02"); // #f4be04 plus faked alpha 50%
+}
+
QColor CStudioPreferences::studioColor1()
{
return s_studioColor1;
@@ -1016,7 +863,6 @@ QColor CStudioPreferences::timelineRowColorDndSource()
return s_timelineRowColorDndSource;
}
-// get subpresentation target color
QColor CStudioPreferences::timelineRowColorDndTargetSP()
{
return s_timelineRowColorDndTargetSP;
@@ -1082,9 +928,14 @@ QColor CStudioPreferences::timelinePressedKeyframeColor()
return s_timelinePressedKeyframeColor;
}
-QColor CStudioPreferences::invalidDataInputIndicatorColor()
+QColor CStudioPreferences::timelineActionColor()
{
- return s_invalidDataInputIndicatorColor;
+ return s_timelineActionColor;
+}
+
+QColor CStudioPreferences::invalidDataIndicatorColor()
+{
+ return s_invalidDataIndicatorColor;
}
int CStudioPreferences::fontSize()
@@ -1112,30 +963,10 @@ QSize CStudioPreferences::browserPopupSize()
return s_browserPopupSize;
}
-QString CStudioPreferences::GetVersionString()
+QString CStudioPreferences::versionString()
{
QString theVersionNumber = STRINGIFY(STUDIO_VERSION);
theVersionNumber.replace(QLatin1String(","), QLatin1String("."));
return theVersionNumber;
}
-
-bool CStudioPreferences::showEditModePreview()
-{
- return m_preferences->GetValue("showEditModePreview", false);
-}
-
-void CStudioPreferences::setShowEditModePreview(bool show)
-{
- m_preferences->SetValue("showEditModePreview", show);
-}
-
-bool CStudioPreferences::editModeLightingEnabled()
-{
- return m_preferences->GetValue("editModeLightingEnabled", true);
-}
-
-void CStudioPreferences::setEditModeLightingEnabled(bool enabled)
-{
- m_preferences->SetValue("editModeLightingEnabled", enabled);
-}
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h
index 99e2d02f..fb0b8fae 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h
+++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h
@@ -36,8 +36,8 @@
#include <QtGui/qbrush.h>
#include "CoreConst.h"
-#include "Preferences.h"
#include "Rct.h"
+#include "CColor.h"
QT_FORWARD_DECLARE_CLASS(QQmlContext)
@@ -47,124 +47,172 @@ class CStudioPreferences
virtual ~CStudioPreferences();
public:
- static void loadPreferences(const QString &filePath);
+ static void loadPreferences();
static void savePreferences();
- static bool IsTimelineSnappingGridActive();
- static void SetTimelineSnappingGridActive(bool inActive);
+ //
+ // Settings to save in QSettings
+ //
- static bool IsLegacyViewerActive();
- static void SetLegacyViewerActive(bool inActive);
+ // MainWindow settings
+ //
+ static QByteArray windowGeometry(int version);
+ static void setWindowGeometry(const QByteArray &geometry, int version);
+ static void resetWindowGeometry(int version);
- static ESnapGridResolution GetTimelineSnappingGridResolution();
- static void SetTimelineSnappingGridResolution(ESnapGridResolution inResolution);
+ static bool containsWindowState(int version);
+ static QByteArray windowState(int version);
+ static void setWindowState(const QByteArray &state, int version);
+ static void resetWindowState(int version);
- static bool GetEditViewFillMode();
- static void SetEditViewFillMode(bool inRenderAsSolid);
+ // Viewing settings
+ //
+ static bool isEditViewFillMode();
+ static void setEditViewFillMode(bool inRenderAsSolid);
- static long GetPreferredStartupView();
- static void SetPreferredStartupView(long inStartupView);
+ static int preferredStartupView();
+ static void setPreferredStartupView(int inStartupView);
- static bool IsAutosetKeyframesOn();
- static void SetAutosetKeyframesOn(bool inEnable);
+ static bool isDontShowGLVersionDialog();
+ static void setDontShowGLVersionDialog(bool inValue);
- static bool IsBoundingBoxesOn();
- static void SetBoundingBoxesOn(bool inEnable);
+ static QSize defaultClientSize();
+ static void setDefaultClientSize(int width, int height);
- static bool ShouldDisplayPivotPoint();
- static void SetDisplayPivotPoint(bool inEnable);
+ static bool isEditModeLightingEnabled();
+ static void setEditModeLightingEnabled(bool enabled);
- static bool IsWireframeModeOn();
- static void SetWireframeModeOn(bool inEnable);
+ static bool containsShowWelcomeScreen();
+ static bool isShowWelcomeScreen();
+ static void setShowWelcomeScreen(bool show);
- static bool ShouldShowTooltips();
- static void SetShowTooltips(bool inShowTooltips);
+ // Timeline settings
+ //
+ static bool isTimelineSnappingGridActive();
+ static void setTimelineSnappingGridActive(bool inActive);
- static long GetTimelineSplitterLocation();
- static void SetTimelineSplitterLocation(long inLocation);
+ static ESnapGridResolution timelineSnappingGridResolution();
+ static void setTimelineSnappingGridResolution(ESnapGridResolution inResolution);
- static bool GetInterpolation();
- static void SetInterpolation(bool inSmooth);
+ static bool isAutosetKeyframesOn();
+ static void setAutosetKeyframesOn(bool inEnable);
- static long GetSnapRange();
- static void SetSnapRange(long inSnapRange);
+ static double timelineSplitterLocation();
+ static void setTimelineSplitterLocation(double inLocation);
- static long GetAutoSaveDelay();
- static void SetAutoSaveDelay(long inAutoSaveDelay);
+ static bool isInterpolation();
+ static void setInterpolation(bool inSmooth);
- static bool GetAutoSavePreference();
- static void SetAutoSavePreference(bool inActive);
+ static double snapRange();
+ static void setSnapRange(double inSnapRange);
- static long GetDefaultObjectLifetime();
- static void SetDefaultObjectLifetime(long inLifetime);
+ static bool isTimebarDisplayTime();
+ static void setTimebarDisplayTime(bool inDisplayTime);
- static bool showEditModePreview();
- static void setShowEditModePreview(bool show);
+ static long timeAdvanceAmount();
+ static void setTimeAdvanceAmount(long inTime);
- static bool editModeLightingEnabled();
- static void setEditModeLightingEnabled(bool enabled);
+ static long bigTimeAdvanceAmount();
+ static void setBigTimeAdvanceAmount(long inTime);
- static bool GetTimebarDisplayTime();
- static void SetTimebarDisplayTime(bool inDisplayTime);
+ // VisualAids settings
+ //
+ static bool isBoundingBoxesOn();
+ static void setBoundingBoxesOn(bool inEnable);
- static QString GetVersionString();
+ static bool isPivotPointOn();
+ static void setPivotPointOn(bool inEnable);
- static bool GetDontShowGLVersionDialog();
- static void SetDontShowGLVersionDialog(bool inValue);
+ static bool isWireframeModeOn();
+ static void setWireframeModeOn(bool inEnable);
- static long GetTimeAdvanceAmount();
- static void SetTimeAdvanceAmount(long inTime);
- static long GetBigTimeAdvanceAmount();
- static void SetBigTimeAdvanceAmount(long inTime);
+ static bool isTooltipsOn();
+ static void setTooltipsOn(bool inShowTooltips);
- static QSize GetDefaultClientSize();
- static void SetDefaultClientSize(int width, int height);
+ static bool isHelperGridOn();
+ static void setHelperGridOn(bool showGrid);
- static int getNumRecentItems();
- static void setNumRecentItems(int n);
+ static int helperGridLines();
+ static void setHelperGridLines(int lines);
- static QString getRecentItem(int index);
- static void setRecentItem(int index, const QString &path);
+ static void setAxisHelperOn(bool showAxisHelper);
+ static bool isAxisHelperOn();
- static bool GetAdvancePropertyExpandedFlag();
- static void SetAdvancePropertyExpandedFlag(bool inAdvancePropertyFlag);
+ static int helperGridSpacing();
+ static void setHelperGridSpacing(int spacing);
- static QString GetPreviewConfig();
- static void SetPreviewConfig(const QString &inValue);
- static QString GetPreviewProperty(const QString &inName);
- static void SetPreviewProperty(const QString &inName, const QString &inValue);
+ static float selectorLineWidth();
+ static void setSelectorLineWidth(float width);
- static ::CColor GetNormalColor();
- static ::CColor GetMasterColor();
- static ::CColor GetInactiveColor();
+ static float selectorLineLength();
+ static void setSelectorLineLength(float length);
- static ::CColor GetMouseOverHighlightColor();
+ // Autosave settings
+ //
+ static int autoSaveDelay();
+ static void setAutoSaveDelay(int inAutoSaveDelay);
- static ::CColor GetObjectTimebarColor();
- static ::CColor GetLayerTimebarColor();
- static ::CColor GetDisabledTextColor();
+ static bool isAutoSavePreference();
+ static void setAutoSavePreference(bool inActive);
- static ::CColor GetSingleBoundingBoxColor();
- static ::CColor GetGroupBoundingBoxColor();
- static QColor GetXAxisColor();
- static QColor GetYAxisColor();
- static QColor GetZAxisColor();
+ // Preview settings
+ //
+ static QString previewConfig();
+ static void setPreviewConfig(const QString &inValue);
- static ::CColor GetRulerBackgroundColor();
- static ::CColor GetRulerTickColor();
- static ::CColor GetGuideColor();
- static ::CColor GetGuideSelectedColor();
- static ::CColor GetGuideFillColor();
- static ::CColor GetGuideFillSelectedColor();
+ static QString previewProperty(const QString &inName);
+ static void setPreviewProperty(const QString &inName, const QString &inValue);
- static QString GetFontFaceName();
+ static QString remoteDeploymentIP();
+ static void setRemoteDeploymentIP(const QString &ip);
- static float getSelectorLineWidth();
- static void setSelectorLineWidth(float width);
- static float getSelectorLineLength();
- static void setSelectorLineLength(float length);
+ static QString remoteDeploymentPort();
+ static void setRemoteDeploymentPort(const QString &port);
+ // Recent settings
+ //
+ static int numRecentItems();
+ static void setNumRecentItems(int numberOfItems);
+
+ static QString recentItem(int index);
+ static void setRecentItem(int index, const QString &path);
+
+ //
+ // Pop-up warnings
+ //
+ static bool doNotShowImportWarnings();
+ static void setDoNotShowImportWarnings(bool inDoNotShowImportWarnings);
+
+ //
+ // Other settings
+ //
static void setQmlContextProperties(QQmlContext *qml);
+
+ static QString fontFaceName();
+
+ static ::CColor mouseOverHighlightColor();
+ static ::CColor normalColor();
+ static ::CColor inactiveColor();
+ static ::CColor objectTimebarColor();
+ static ::CColor layerTimebarColor();
+ static ::CColor disabledTextColor();
+ static ::CColor singleBoundingBoxColor();
+ static ::CColor groupBoundingBoxColor();
+
+ static QColor xAxisColor();
+ static QColor yAxisColor();
+ static QColor zAxisColor();
+ static QColor wAxisColor();
+ static QColor helperGridColor();
+ static QColor bezierControlColor();
+
+ static ::CColor rulerBackgroundColor();
+ static ::CColor rulerTickColor();
+ static ::CColor guideNormalColor();
+ static ::CColor guideSelectedColor();
+ static ::CColor guideFillColor();
+ static ::CColor guideFillSelectedColor();
+
static QColor studioColor1();
static QColor studioColor2();
static QColor studioColor3();
@@ -203,30 +251,26 @@ public:
static QColor timelineRowSubpDescendantColor();
static QColor timelineRowCommentBgColor();
static QColor timelinePressedKeyframeColor();
+ static QColor timelineActionColor();
- static QColor invalidDataInputIndicatorColor();
+ static QColor invalidDataIndicatorColor();
static int fontSize();
static int controlBaseHeight();
static int idWidth();
static int valueWidth();
static QSize browserPopupSize();
+ static QString versionString();
// Default values that Studio will start out with or to restore
- static const long GUTTER_SIZE = 10;
- static const ::CColor EDITVIEW_DEFAULTBGCOLOR;
- static const long PREFERREDSTARTUP_DEFAULTINDEX = -1;
- static const long DEFAULT_SNAPRANGE = 10;
- static const long DEFAULT_LIFETIME = 10000;
- static const long DEFAULT_CLIENT_WIDTH = 1920;
- static const long DEFAULT_CLIENT_HEIGHT = 1080;
- static const long DEFAULT_TIME_ADVANCE = 100;
- static const long DEFAULT_BIG_TIME_ADVANCE = 500;
- static const long DEFAULT_SELECTOR_WIDTH = 30;
- static const long DEFAULT_SELECTOR_LENGTH = 50;
- static const long DEFAULT_AUTOSAVE_DELAY = 600;
-
-private:
- static std::unique_ptr<CPreferences> m_preferences;
+ static constexpr double DEFAULT_SNAPRANGE = 10.;
+ static constexpr float DEFAULT_SELECTOR_WIDTH = 30.f;
+ static constexpr float DEFAULT_SELECTOR_LENGTH = 50.f;
+ static const int PREFERREDSTARTUP_DEFAULTINDEX = -1;
+ static const int DEFAULT_CLIENT_WIDTH = 1920;
+ static const int DEFAULT_CLIENT_HEIGHT = 1080;
+ static const int DEFAULT_TIME_ADVANCE = 100;
+ static const int DEFAULT_BIG_TIME_ADVANCE = 500;
+ static const int DEFAULT_AUTOSAVE_DELAY = 600;
};
#endif // INCLUDED_STUDIO_PREFERENCES_H
diff --git a/src/Authoring/Client/Code/Core/Utility/cpuid.cpp b/src/Authoring/Client/Code/Core/Utility/cpuid.cpp
index 3e3ac13a..46149e87 100644
--- a/src/Authoring/Client/Code/Core/Utility/cpuid.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/cpuid.cpp
@@ -43,7 +43,7 @@ extern "C" {
// register set to 80000001h (only applicable to AMD)
#define _3DNOW_FEATURE_BIT 0x80000000
-#ifndef _WIN32
+#if !defined(_WIN32) || !defined(_MSC_VER)
void __cpuid(int cpuInfo[4], int function_id)
{
asm volatile
diff --git a/src/Authoring/Client/Code/Shared/CommonConstants.h b/src/Authoring/Client/Code/Shared/CommonConstants.h
deleted file mode 100644
index 26607db0..00000000
--- a/src/Authoring/Client/Code/Shared/CommonConstants.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 1999-2001 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef __CommonConstants_H__
-#define __CommonConstants_H__
-
-// The current version of the player
-const float CURRENT_PLAYER_VERSION = 1.0f;
-
-// Current User Registry Keys
-const char QT3DS_CLIENT_PREFERENCES_VALUE[] = "Preferences";
-const char QT3DS_CLIENT_REGISTRY_KEY_BASE[] = "Software\\Qt3DStudio\\Client";
-const char QT3DS_CLIENT_REGISTRY_KEY_ROOT[] = "Software\\Qt3DStudio\\Client\\1.0";
-const char QT3DS_CLIENT_REGISTRY_KEY[] = "Software\\Qt3DStudio\\Client\\1.0\\Preferences";
-const char QT3DS_CLIENT_MESSAGES_KEY[] = "Software\\Qt3DStudio\\Client\\1.0\\Preferences\\Messages";
-
-// Local Machine Registry Keys
-const char QT3DS_CLIENT_PLUGINS_VALUE[] = "Plugins";
-const char QT3DS_CLIENT_EXTENSIONS_VALUE[] = "Extensions";
-const char QT3DS_CLIENT_LATESTVERSION_VALUE[] = "LatestVersion";
-const char QT3DS_CLIENT_CURRENTVERSION_VALUE[] = "CurrentVersion";
-
-const char QT3DS_CLIENT_PLUGINS_KEY[] = "Software\\Qt3DStudio\\Client\\1.0\\Plugins";
-const char QT3DS_CLIENT_EXTENSIONS_KEY[] = "Software\\Qt3DStudio\\Client\\1.0\\Extensions";
-const char QT3DS_CLIENT_LATESTVERSION_KEY[] = "Software\\Qt3DStudio\\Client\\1.0\\LatestVersion";
-const char QT3DS_CLIENT_CURRENTVERSION_KEY[] = "Software\\Qt3DStudio\\Client\\1.0\\CurrentVersion";
-
-// Preference Registry Keys
-const char QT3DS_CLIENT_INITIALIZED_VALUE[] = "Initialized";
-const char QT3DS_CLIENT_AUTOMATICUPDATE_VALUE[] = "AutomaticallyUpdate";
-const char QT3DS_CLIENT_FORCENOINSTALL_VALUE[] = "ForceNoInstall";
-const char QT3DS_CLIENT_FORCEINSTALL_VALUE[] = "ForceInstall";
-const char QT3DS_CLIENT_NOREGISTER_VALUE[] = "NoRegister";
-const char QT3DS_CLIENT_LOGMODE_VALUE[] = "LogMode"; // REG_DWORD, 0, 1, 2, 3
-const char QT3DS_CLIENT_LOGLEVEL_VALUE[] = "LogLevel"; // REG_DWORD, 0, 1, 2, 3
-const char QT3DS_CLIENT_LOGTHRESHOLD_VALUE[] = "LogThreshold"; // REG_DWORD, # of entries
-const char QT3DS_CLIENT_CONTEXTMENU_VALUE[] = "ContextMenu";
-
-const char QT3DS_CLIENT_TRACKERRORTYPES_VALUE[] = "TrackErrorTypes";
-const char QT3DS_CLIENT_REPORTINGLEVEL_VALUE[] = "ReportingLevel";
-const char QT3DS_CLIENT_ERRORACTION_VALUE[] = "ErrorAction";
-const char QT3DS_CLIENT_FILENAMELINENO_VALUE[] = "FileNameLineNo";
-
-const char QT3DS_CLIENT_ENABLESCRIPTDEBUGGER_VALUE[] = "EnableScriptDebugger";
-const char QT3DS_CLIENT_DEBUGMODE_VALUE[] = "DebugMode";
-const char QT3DS_CLIENT_MINTIMEPERFRAME_VALUE[] = "MinTimePerFrame";
-const char QT3DS_CLIENT_UPDATEURL_VALUE[] = "DebugUpdateUrl";
-const char QT3DS_CLIENT_LASTUPDATECHECK_VALUE[] = "LastUpdateCheck";
-const char QT3DS_CLIENT_OVERRIDELASTUPDATE_VALUE[] = "LastUpdateCheckOverride";
-const char QT3DS_CLIENT_UPDATEINTERVAL_VALUE[] = "UpdateInterval";
-const char QT3DS_CLIENT_DEPRECATEDPRESENTATION_VALUE[] = "DeprecatedPresentationWarning";
-const char QT3DS_CLIENT_OPENGLDRIVER_VALUE[] = "OpenGLDriverWarning";
-const char QT3DS_CLIENT_GRAPHICSRENDERER_VALUE[] = "ClientRenderer";
-const char QT3DS_CLIENT_LICENSEKEY_VALUE[] = "LicenseKey";
-
-/*
-const char QT3DS_CLIENT_AGREEEULA_VALUE[] = "AgreeEULA";
-const char QT3DS_CLIENT_LASTNAME_VALUE[] = "LastName";
-const char QT3DS_CLIENT_FIRSTNAME_VALUE[] = "FirstName";
-const char QT3DS_CLIENT_USEREMAIL_VALUE[] = "UserEmail";
-const char QT3DS_CLIENT_OVER13_VALUE[] = "UserOver13";
-const char QT3DS_CLIENT_MAILINGLIST_VALUE[] = "MailingList";
-*/
-
-// Uninstall Registry Keys
-const char UNINSTALL_REGISTRY_KEY[] =
- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Qt3DStudioClient10";
-
-// Uninstall Registry Value Names
-const char UNINSTALL_DISPLAYNAME_VALUE[] = "DisplayName";
-const char UNINSTALL_COMMANDLINE_VALUE[] = "UninstallString";
-
-// File Names
-const char INSTALL_LOG_FILE_NAME[] = "Install.log";
-const char UNINSTALL_DATA_FILE_NAME[] = "Uninstal.dat";
-const char QT3DS_AUTO_UPDATER_EXE[] = "AMInstal.exe";
-const char QT3DS_CONTROL_PANEL[] = "AKCPanel.cpl";
-
-// Directory Names
-const char QT3DS_DIRECTORY[] = "\\The Qt Company\\";
-const char QT3DS_CLIENT_DIRECTORY[] = "Qt 3D Studio\\";
-const char QT3DS_TEMP_DIRECTORY[] = "Install\\";
-
-// Installer command line options
-const char REMOTE_COMMAND_LINE_OPTION[] = "remote";
-const char UNINSTALL_COMMAND_LINE_OPTION[] = "uninstall";
-const char SILENT_COMMAND_LINE_OPTION[] = "silent";
-const char INSTALLFROM_COMMAND_LINE_OPTION[] = "installfrom";
-
-// Uninstall file section names
-const char VERSION_SECTION_NAME[] = "Version";
-const char FILES_SECTION_NAME[] = "Files";
-const char DIR_SECTION_NAME[] = "Directories";
-const char REGKEY_SECTION_NAME[] = "RegKeys";
-const char REGVALUE_SECTION_NAME[] = "RegValues";
-
-// Uninstall file values
-const char FILEVERSION_VALUE[] = "FileVersion";
-const char REGISTRYROOT_HKLM[] = "HKLM";
-const char REGISTRYROOT_HKCU[] = "HKCU";
-
-// Misc
-const long CLIENT_UPDATE_INTERVAL = 7; ///< 7 days
-
-// OpenGL
-const char OPENGL_REQUIRED_EXTENSIONS[] =
- "GL_EXT_bgra GL_WIN_swap_hint GL_ARB_multitexture GL_EXT_texture_env_combine";
-
-// Unwelcome Video Vendor
-const char UNSUPPORT_VIDEO_VENDOR[] = "Microsoft Corporation";
-
-// Action mask ids
-const unsigned long ACTION_LOG_BITMASK = 0x00000001; ///< Write to log file
-const unsigned long ACTION_DISPLAYMESSAGEBOX_BITMASK = 0x00000002; ///< Display a message box
-const unsigned long ACTION_DEBUGGEROUTPUT_BITMASK = 0x00000004; ///< Output to debugger window
-const unsigned long ACTION_DEBUGBREAK_BITMASK = 0x00000008; ///< Break at the spot
-
-// 3D constants
-const float QT3DS_DEGREES_TO_RADIANS = (float)0.0174532925199;
-const float QT3DS_RADIANS_TO_DEGREES = (float)57.2957795131;
-
-// Fullscreen anti-aliasing modes
-const long FSAA_OFF = 0x00000000; ///< No fullscreen anti-aliasing
-const long FSAA_1X = 0x00000001; ///< 1x sample
-const long FSAA_2X = 0x00000002; ///< 2x sample
-const long FSAA_4X = 0x00000004; ///< 4x sample
-const long FSAA_6X = 0x00000006; ///< 6x sample
-const long FSAA_8X = 0x00000008; ///< 8x sample
-
-#endif // __CommonConstants_H__
diff --git a/src/Authoring/Common/Code/Preferences.h b/src/Authoring/Common/Code/Preferences.h
deleted file mode 100644
index d694de33..00000000
--- a/src/Authoring/Common/Code/Preferences.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef INCLUDED_PREFERENCES_H
-#define INCLUDED_PREFERENCES_H
-
-#include "CColor.h"
-#include <QtXml/qdom.h>
-
-class CPreferences
-{
-public:
- CPreferences();
- ~CPreferences();
-
- void SetStringValue(const QString &key, const QString &value, const QString &group = {});
- QString GetStringValue(const QString &key, const QString &defaultValue = {},
- const QString &group = {});
-
- void SetLongValue(const QString &inKey, long inValue, const QString &group = {});
- long GetLongValue(const QString &inKey, long inDefaultValue = 0, const QString &group = {});
-
- void SetValue(const QString &inKey, bool inValue, const QString &group = {});
- bool GetValue(const QString &inKey, bool inDefaultValue, const QString &group = {});
-
- void SetValue(const QString &inKey, double inValue, const QString &group = {});
- double GetValue(const QString &inKey, double inDefaultValue, const QString &group = {});
-
- void SetColorValue(const QString &inKey, ::CColor inValue, const QString &group = {});
- ::CColor GetColorValue(const QString &inKey, ::CColor inDefaultValue,
- const QString &group = {});
-
- void SetPreferencesFile(const QString &inFileName);
- void save();
-
-private:
- QString getValue(const QString &key, const QString &group = {});
- void setValue(const QString &key, const QString &value, const QString &group = {});
-
- QString m_PreferencesFile = {};
- QDomDocument m_domDoc = {};
-};
-#endif // INCLUDED_PREFERENCES_H
diff --git a/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h b/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h
index 93f06bf2..5e1bfe0c 100644
--- a/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h
+++ b/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h
@@ -90,7 +90,6 @@
#include "PlatformMacros.h"
#include "PlatformStrings.h"
#include "PlatformConversion.h"
-#include "CommonConstants.h"
#include "Mutex.h"
#include "Guard.h"
#include "Thread.h"
diff --git a/src/Authoring/Common/Code/Qt3DSMessageBox.cpp b/src/Authoring/Common/Code/Qt3DSMessageBox.cpp
index b802ab1c..0f761355 100644
--- a/src/Authoring/Common/Code/Qt3DSMessageBox.cpp
+++ b/src/Authoring/Common/Code/Qt3DSMessageBox.cpp
@@ -35,6 +35,7 @@ using namespace Q3DStudio;
#include "Qt3DSMessageBox.h"
#include <QtWidgets/qmessagebox.h>
+#include <QtWidgets/qcheckbox.h>
//==============================================================================
/**
@@ -58,12 +59,14 @@ Qt3DSMessageBox::~Qt3DSMessageBox()
* @param inTitle Title of the message box
* @param inText Text to be displayed on the message box
* @param inIcon Icon to be displayed on the message box
+ * @param inDoNotShowAgainChoice Should we show checkbox for hiding subsequent messages?
* @param inParentWindow window to attach this dialog to.
*/
Qt3DSMessageBox::EMessageBoxReturn
Qt3DSMessageBox::Show(const QString &inTitle, const QString &inText, EMessageBoxIcon inIcon,
- bool inShowCancel /*false*/,
- Qt3DSMessageBox::TPlatformWindow inParentWindow /*NULL*/)
+ bool &doNotShowAgain, bool inShowCancel /*false*/,
+ bool inDoNotShowAgainChoice /*false*/,
+ Qt3DSMessageBox::TPlatformWindow inParentWindow /*nullptr*/)
{
QMessageBox box(inParentWindow);
box.setWindowTitle(inTitle);
@@ -88,6 +91,31 @@ Qt3DSMessageBox::Show(const QString &inTitle, const QString &inText, EMessageBox
buttons |= QMessageBox::Cancel;
box.setStandardButtons(buttons);
+ if (inDoNotShowAgainChoice) {
+ QCheckBox *noShowAgain = new QCheckBox(QObject::tr("Do not show again."));
+ box.setCheckBox(noShowAgain);
+ QObject::connect(noShowAgain, &QCheckBox::stateChanged, [&doNotShowAgain](int state) {
+ doNotShowAgain = static_cast<Qt::CheckState>(state) == Qt::CheckState::Checked;
+ });
+ }
+
auto theButtonPressed = box.exec();
return theButtonPressed == QMessageBox::Ok ? MSGBX_OK : MSGBX_CANCEL;
}
+
+//==============================================================================
+/**
+ * Displays the modal message box to the user.
+ * @param inTitle Title of the message box
+ * @param inText Text to be displayed on the message box
+ * @param inIcon Icon to be displayed on the message box
+ * @param inParentWindow window to attach this dialog to.
+ */
+Qt3DSMessageBox::EMessageBoxReturn
+Qt3DSMessageBox::Show(const QString &inTitle, const QString &inText, EMessageBoxIcon inIcon,
+ bool inShowCancel /*false*/,
+ Qt3DSMessageBox::TPlatformWindow inParentWindow /*nullptr*/)
+{
+ bool dummy;
+ return Show(inTitle, inText, inIcon, dummy, inShowCancel, false, inParentWindow);
+}
diff --git a/src/Authoring/Common/Code/Qt3DSMessageBox.h b/src/Authoring/Common/Code/Qt3DSMessageBox.h
index ab8b7747..4d8a3b3d 100644
--- a/src/Authoring/Common/Code/Qt3DSMessageBox.h
+++ b/src/Authoring/Common/Code/Qt3DSMessageBox.h
@@ -79,7 +79,12 @@ public:
virtual ~Qt3DSMessageBox();
static EMessageBoxReturn Show(const QString &inTitle, const QString &inText,
EMessageBoxIcon inIcon, bool inShowCancel = false,
- TPlatformWindow inParentWindow = NULL);
+ TPlatformWindow inParentWindow = nullptr);
+ static EMessageBoxReturn Show(const QString &inTitle, const QString &inText,
+ EMessageBoxIcon inIcon, bool &doNotShowAgain,
+ bool inShowCancel = false, bool inDoNotShowAgainChoice = false,
+ TPlatformWindow inParentWindow = nullptr);
+
protected:
};
diff --git a/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h b/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h
index acfa4712..fd8f3f17 100644
--- a/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h
+++ b/src/Authoring/Common/Code/Serialize/ProjectSettingsSerializer.h
@@ -121,6 +121,9 @@ public:
bool thePreferKtx = theProjectSettings->getPreferCompressedTextures();
ar.Att("preferKtx", thePreferKtx);
+ bool theFlipCompressedTextures = theProjectSettings->getFlipCompressedTextures();
+ ar.Att("flipCompressedTextures", theFlipCompressedTextures);
+
if (QColorDialog::customCount() > 0) {
CustomColorSerializer ccs;
ar.Serialize(L"CustomColors", ccs);
@@ -161,6 +164,10 @@ public:
if (ar.Att("preferKtx", thePreferKtx))
theProjectSettings->setPreferCompressedTextures(thePreferKtx);
+ bool theFlipCompressedTextures;
+ if (ar.Att("flipCompressedTextures", theFlipCompressedTextures))
+ theProjectSettings->setFlipCompressedTextures(theFlipCompressedTextures);
+
{
CustomColorSerializer ccs;
ar.Serialize(L"CustomColors", ccs);
diff --git a/src/Authoring/Common/Code/_Win32/Preferences.cpp b/src/Authoring/Common/Code/_Win32/Preferences.cpp
deleted file mode 100644
index 0adb1268..00000000
--- a/src/Authoring/Common/Code/_Win32/Preferences.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Preferences.h"
-#include "StudioUtils.h"
-#include <QtCore/qdir.h>
-#include <QtCore/qsavefile.h>
-
-CPreferences::CPreferences()
-{
-}
-
-CPreferences::~CPreferences()
-{
-}
-
-void CPreferences::save()
-{
- if (!m_PreferencesFile.isEmpty() && !m_domDoc.isNull()) {
- QSaveFile file(m_PreferencesFile);
- if (StudioUtils::openTextSave(file))
- StudioUtils::commitDomDocumentSave(file, m_domDoc);
- }
-}
-
-/**
- * Sets the preferences file path
- * This sets the applications base path for all preferences that are to be
- * loaded. It also creates the preferences file if it doesn't exist. This
- * should be called before any CPreferences are created.
- * @param filePath preferences serialization file path.
- */
-void CPreferences::SetPreferencesFile(const QString &filePath)
-{
- if (m_PreferencesFile == filePath)
- return;
-
- m_PreferencesFile = filePath;
- QString preferencesFolder = QFileInfo(filePath).absolutePath();
-
- QDir dir(preferencesFolder);
- if (!dir.exists())
- dir.mkpath(preferencesFolder);
-
- QFile file(m_PreferencesFile);
- if (!file.exists()) {
- m_domDoc.setContent(QStringLiteral("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- "<Settings/>"));
-
- file.open(QIODevice::WriteOnly);
- file.write(m_domDoc.toByteArray(4));
- } else {
- file.open(QIODevice::ReadOnly);
- m_domDoc.setContent(&file);
- }
-}
-
-void CPreferences::SetStringValue(const QString &key, const QString &value,
- const QString &group)
-{
- setValue(key, value, group);
-}
-
-QString CPreferences::GetStringValue(const QString &key, const QString &defaultValue,
- const QString &group)
-{
- QString value = getValue(key, group);
-
- return value.isEmpty() ? defaultValue : value;
-}
-
-void CPreferences::SetLongValue(const QString &key, long value,
- const QString &group)
-{
- setValue(key, QString::number(value), group);
-}
-
-long CPreferences::GetLongValue(const QString &key, long defaultValue,
- const QString &group)
-{
- QString theStrValue = GetStringValue(key, {}, group);
-
- return theStrValue.isEmpty() ? defaultValue : theStrValue.toLong();
-}
-
-void CPreferences::SetValue(const QString &key, bool value, const QString &group)
-{
- long theRegValue = value ? 1 : 0;
-
- SetLongValue(key, theRegValue, group);
-}
-
-bool CPreferences::GetValue(const QString &key, bool defaultValue, const QString &group)
-{
- long theDefaultValue = defaultValue ? 1 : 0;
- long theRegValue = GetLongValue(key, theDefaultValue, group);
-
- return theRegValue ? true : false;
-}
-
-void CPreferences::SetValue(const QString &key, double value, const QString &group)
-{
- setValue(key, QString::number(value), group);
-}
-
-double CPreferences::GetValue(const QString &key, double defaultValue, const QString &group)
-{
- QString theStrValue = GetStringValue(key, {}, group);
-
- return theStrValue.isEmpty() ? defaultValue : theStrValue.toDouble();
-}
-
-CColor CPreferences::GetColorValue(const QString &key, CColor defaultColor, const QString &group)
-{
- QString theColorString = GetStringValue(key, {}, group);
- if (!theColorString.isEmpty()) {
- QStringList rgb = theColorString.split(QStringLiteral(" "));
- return ::CColor(rgb.at(0).toInt(), rgb.at(1).toInt(), rgb.at(2).toInt());
- }
-
- return defaultColor;
-}
-
-void CPreferences::SetColorValue(const QString &key, CColor value, const QString &group)
-{
- QString rgbStr = QString("%1 %2 %2").arg(value.red).arg(value.green).arg(value.blue);
- setValue(key, rgbStr, group);
-}
-
-QString CPreferences::getValue(const QString &key, const QString &group)
-{
- if (m_PreferencesFile.isEmpty())
- return {};
-
- QDomElement parentElem = group.isEmpty() ? m_domDoc.documentElement()
- : m_domDoc.documentElement().firstChildElement(group);
- if (!parentElem.isNull()) {
- QDomNodeList itemNodes = parentElem.elementsByTagName(QStringLiteral("Item"));
- if (!itemNodes.isEmpty()) {
- for (int i = 0; i < itemNodes.count(); ++i) {
- QDomElement itemElem = itemNodes.at(i).toElement();
- if (itemElem.attribute(QStringLiteral("Name")) == key)
- return itemElem.attribute(QStringLiteral("value"));
- }
- }
- }
-
- return {};
-}
-
-void CPreferences::setValue(const QString &key, const QString &value,
- const QString &group)
-{
- if (m_domDoc.isNull())
- return;
-
- QDomElement parentElem = group.isEmpty() ? m_domDoc.documentElement()
- : m_domDoc.documentElement().firstChildElement(group);
- if (!parentElem.isNull()) {
- QDomNodeList itemNodes = parentElem.elementsByTagName(QStringLiteral("Item"));
- if (!itemNodes.isEmpty()) {
- for (int i = 0; i < itemNodes.count(); ++i) {
- QDomElement itemElem = itemNodes.at(i).toElement();
- if (itemElem.attribute(QStringLiteral("Name")) == key) {
- // property exist, update it
- itemElem.setAttribute(QStringLiteral("value"), value);
- return;
- }
- }
- }
-
- // if property doesn't exist, create a new one
- QDomElement elem = m_domDoc.createElement("Item");
- elem.setAttribute(QStringLiteral("Name"), key);
- elem.setAttribute(QStringLiteral("value"), value);
- parentElem.appendChild(elem);
- }
-}
diff --git a/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp b/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp
index 933ad9a5..dfbcec22 100644
--- a/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp
+++ b/src/Authoring/Common/Code/_Win32/Qt3DSFile.cpp
@@ -173,7 +173,7 @@ Q3DStudio::CString Qt3DSFile::GetAbsolutePath() const
{
const QFileInfo fi(m_Path.toQString());
if (fi.isDir())
- return Q3DStudio::CString::fromQString(fi.absoluteFilePath() + QLatin1Char('/'));
+ return Q3DStudio::CString::fromQString(fi.absoluteFilePath());
return m_Path;
}
diff --git a/src/Authoring/Common/Common.pro b/src/Authoring/Common/Common.pro
index e53cd02b..444661a9 100644
--- a/src/Authoring/Common/Common.pro
+++ b/src/Authoring/Common/Common.pro
@@ -13,6 +13,17 @@ contains(QMAKE_TARGET.arch, x86_64) {
DEFINES += _AMD64_
}
+mingw {
+LIBS += \
+ -lqt3dsruntimestatic$$qtPlatformTargetSuffix() \
+ -lqt3dsqmlstreamer$$qtPlatformTargetSuffix() \
+ -lEASTL$$qtPlatformTargetSuffix() \
+ -lpcre$$qtPlatformTargetSuffix() \
+ -lTinyXML$$qtPlatformTargetSuffix() \
+ -lColladaDOM$$qtPlatformTargetSuffix() \
+ -lQT3DSDM$$qtPlatformTargetSuffix()
+}
+
INCLUDEPATH += \
Code/_Win32 \
Code/Thread \
@@ -55,7 +66,6 @@ SOURCES += \
Code/Thread/Mutex.cpp \
Code/Thread/Thread.cpp \
Code/Exceptions/XMLException.cpp \
- Code/_Win32/Preferences.cpp \
Code/_Win32/Qt3DSFile.cpp \
Code/Graph/Graph.cpp \
Code/InfoDump/CoutSink.cpp \
diff --git a/src/Authoring/CoreLib/CoreLib.pro b/src/Authoring/CoreLib/CoreLib.pro
index c9a4110a..c853c845 100644
--- a/src/Authoring/CoreLib/CoreLib.pro
+++ b/src/Authoring/CoreLib/CoreLib.pro
@@ -17,6 +17,18 @@ contains(QMAKE_TARGET.arch, x86_64) {
QT += widgets
+mingw {
+LIBS += \
+ -lqt3dsruntimestatic$$qtPlatformTargetSuffix() \
+ -lqt3dsqmlstreamer$$qtPlatformTargetSuffix() \
+ -lEASTL$$qtPlatformTargetSuffix() \
+ -lpcre$$qtPlatformTargetSuffix() \
+ -lTinyXML$$qtPlatformTargetSuffix() \
+ -lColladaDOM$$qtPlatformTargetSuffix() \
+ -lQT3DSDM$$qtPlatformTargetSuffix() \
+ -lCommonLib$$qtPlatformTargetSuffix()
+}
+
macos:DEFINES += WIDE_IS_DIFFERENT_TYPE_THAN_CHAR16_T QT3DS_LITTLE_ENDIAN
linux|qnx: DEFINES += WIDE_IS_DIFFERENT_TYPE_THAN_CHAR16_T
@@ -131,4 +143,6 @@ HEADERS += \
../Client/Code/Core/Utility/q3dsdirsystem.h \
../Client/Code/Core/Utility/q3dsdirwatcher.h \
../Client/Code/Core/Doc/Doc.h \
- ../Client/Code/Core/Core/Core.h
+ ../Client/Code/Core/Core/Core.h \
+ ../Client/Code/Core/Core/DispatchListeners.h \
+ ../Client/Code/Core/Core/Dispatch.h
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp
index 0364cb2b..661f0a03 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp
@@ -37,6 +37,7 @@
#include "Qt3DSImportComposerTypes.h"
#include "Qt3DSFileToolsSeekableMeshBufIOStream.h"
#include "foundation/StrConvertUTF.h"
+#include <QtCore/qurl.h>
using qt3dsdm::IStringTable;
@@ -342,14 +343,14 @@ public:
{
if (m_ValidInstances.contains(inst))
return fromHdl(inst);
- return NULL;
+ return nullptr;
}
Instance *GetInstance(TIMPHandle inst)
{
if (m_ValidInstances.contains(inst))
return fromHdl(inst);
- return NULL;
+ return nullptr;
}
Instance *GetInstance(TCharPtr id)
@@ -357,7 +358,7 @@ public:
ImportHashMap<TCharPtr, Instance *>::const_iterator entry = m_IdToInstMap.find(id);
if (entry != m_IdToInstMap.end())
return entry->second;
- return NULL;
+ return nullptr;
}
Instance *GetInstance(TCharPtr id) const
@@ -365,7 +366,7 @@ public:
ImportHashMap<TCharPtr, Instance *>::const_iterator entry = m_IdToInstMap.find(id);
if (entry != m_IdToInstMap.end())
return entry->second;
- return NULL;
+ return nullptr;
}
Option<InstanceDesc> GetInstanceByHandle(TIMPHandle inst) const override
@@ -434,7 +435,7 @@ public:
QT3DSU32 GetNumProperties(TIMPHandle instance) const override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
@@ -443,7 +444,7 @@ public:
QT3DSU32 GetProperties(TIMPHandle instance, NVDataRef<PropertyValue> outBuffer) const override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
@@ -460,7 +461,7 @@ public:
ComposerPropertyNames::Enum val) const override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return Empty();
}
@@ -475,7 +476,7 @@ public:
QT3DSU32 GetNumChildren(TIMPHandle instance) const override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
@@ -493,7 +494,7 @@ public:
QT3DSU32 GetChildren(TIMPHandle instance, NVDataRef<InstanceDesc> childBuffer) const override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
@@ -514,7 +515,7 @@ public:
void MarkInstanceInvalid(TIMPHandle instance) override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return;
}
@@ -579,7 +580,7 @@ public:
QT3DSIMP_FOREACH(idx, (QT3DSU32)inSource.m_Children.size())
{
Instance *oldChild = GetInstance(inSource.m_Children[idx]);
- if (oldChild == NULL) {
+ if (oldChild == nullptr) {
QT3DS_ASSERT(false);
return retval;
}
@@ -599,7 +600,7 @@ public:
return;
}
Instance *theCopy = GetInstance(theNewItemId->second);
- if (theCopy == NULL) {
+ if (theCopy == nullptr) {
QT3DS_ASSERT(false);
return;
}
@@ -632,7 +633,7 @@ public:
QT3DSIMP_FOREACH(idx, (QT3DSU32)inSource.m_Children.size())
{
Instance *oldChild = GetInstance(inSource.m_Children[idx]);
- if (oldChild == NULL) {
+ if (oldChild == nullptr) {
QT3DS_ASSERT(false);
return;
}
@@ -643,7 +644,7 @@ public:
TIMPHandle CopyInstance(TIMPHandle inSource) override
{
Instance *inst = GetInstance(inSource);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
@@ -654,7 +655,7 @@ public:
Instance *retval = CopyInstanceHierarchy(*inst, idMap);
Instance *parent = fromHdl(inst->m_Parent);
- if (parent != NULL)
+ if (parent != nullptr)
parent->AddChild(retval, inst);
// Copy properties and animations
@@ -666,7 +667,7 @@ public:
bool SetInstanceProperties(TIMPHandle instance, NVConstDataRef<PropertyValue> inBuffer) override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return false;
}
@@ -677,7 +678,7 @@ public:
const TImportModelValue &val) override
{
Instance *inst = GetInstance(instance);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return false;
}
@@ -694,11 +695,11 @@ public:
{
Instance *inst = GetInstance(instance);
Instance *child = GetInstance(childHdl);
- if (inst == NULL) {
+ if (inst == nullptr) {
QT3DS_ASSERT(false);
return false;
}
- if (child == NULL) {
+ if (child == nullptr) {
QT3DS_ASSERT(false);
return false;
}
@@ -757,25 +758,36 @@ public:
if (!m_ImageDir.IsDirectory())
m_ImageDir.CreateDir(true);
- if (!m_ImageDir.IsDirectory())
- return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_ImageDir.toCString());
+ if (!m_ImageDir.IsDirectory()) {
+ return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory,
+ m_ImageDir.toCString());
+ }
Q3DStudio::CString imgPath = CFilePath::GetAbsolutePath(CString(_imgPath));
- Q3DStudio::CString srcImgPath =
- CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath);
-
- Q3DStudio::SFileErrorCodeFileNameAndNumBytes copyResult =
- Q3DStudio::SFileTools::FindAndCopyDestFile(m_ImageDir, imgPath);
+ Q3DStudio::CString srcImgPath = CFilePath::GetRelativePathFromBase(m_FullSrcDirectory,
+ imgPath);
+
+ // Need to get rid of %20 and such in the path, or we won't find the image
+ Q3DStudio::CString cleanImgPath
+ = Q3DStudio::CString::fromQString(QUrl::fromPercentEncoding(
+ imgPath.toQString().toUtf8()));
+ Q3DStudio::CString cleanSrcImgPath
+ = Q3DStudio::CString::fromQString(QUrl::fromPercentEncoding(
+ srcImgPath.toQString().toUtf8()));
+
+ Q3DStudio::SFileErrorCodeFileNameAndNumBytes copyResult
+ = Q3DStudio::SFileTools::FindAndCopyDestFile(m_ImageDir, cleanImgPath);
// Get the actual return value relative do our destination directory
- Q3DStudio::CString _retval =
- CFilePath::GetRelativePathFromBase(m_DestDirectory, copyResult.m_DestFilename);
+ Q3DStudio::CString _retval = CFilePath::GetRelativePathFromBase(m_DestDirectory,
+ copyResult.m_DestFilename);
// Register the string, so we can hand retval back to clients
TCharPtr retval = m_StringTable.RegisterStr(_retval.c_str());
- m_Images.insert(eastl::make_pair(m_StringTable.RegisterStr(srcImgPath.c_str()), retval));
+ m_Images.insert(eastl::make_pair(m_StringTable.RegisterStr(cleanSrcImgPath.c_str()),
+ retval));
if (copyResult.m_Error != Q3DStudio::FileErrorCodes::NoError) {
- CharPtrOrError errorValue(
- ImportErrorData(FromFileErrorCode(copyResult.m_Error), RegisterStr(imgPath)));
+ CharPtrOrError errorValue(ImportErrorData(FromFileErrorCode(copyResult.m_Error),
+ RegisterStr(cleanImgPath)));
errorValue.m_Value = retval;
return errorValue;
}
@@ -786,23 +798,31 @@ public:
if (dstPath.hasValue()) {
if (!m_ImageDir.IsDirectory())
m_ImageDir.CreateDir(true);
- if (!m_ImageDir.IsDirectory())
- return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_ImageDir.toCString());
- CFilePath fullDestPath =
- CFilePath::CombineBaseAndRelative(m_DestDirectory, CString(dstPath.getValue()));
+ if (!m_ImageDir.IsDirectory()) {
+ return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory,
+ m_ImageDir.toCString());
+ }
+ CFilePath fullDestPath = CFilePath::CombineBaseAndRelative(m_DestDirectory,
+ CString(dstPath.getValue()));
Q3DStudio::SFileErrorCodeAndNumBytes copyResult = Q3DStudio::SFileTools::Copy(
fullDestPath, Q3DStudio::FileOpenFlags(Q3DStudio::FileOpenFlagValues::Truncate
| Q3DStudio::FileOpenFlagValues::Open
| Q3DStudio::FileOpenFlagValues::Create),
- CString(_imgPath));
+ CString(_imgPath));
// Regardless of if the copy operation succeeds or not, if the destination exists
- // already
- // Then we enter it into our dictionary
+ // already then we enter it into our dictionary.
if (fullDestPath.IsFile()) {
CFilePath imgPath = CFilePath::GetAbsolutePath(CString(_imgPath));
- CFilePath srcImgPath =
- CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath);
- m_Images.insert(eastl::make_pair(m_StringTable.RegisterStr(srcImgPath.toCString()),
+ CFilePath srcImgPath = CFilePath::GetRelativePathFromBase(m_FullSrcDirectory,
+ imgPath);
+ // Need to get rid of %20 and such in the path, or we won't find the image
+ Q3DStudio::CString cleanImgPath
+ = Q3DStudio::CString::fromQString(
+ QUrl::fromPercentEncoding(imgPath.toQString().toUtf8()));
+ Q3DStudio::CString cleanSrcImgPath
+ = Q3DStudio::CString::fromQString(
+ QUrl::fromPercentEncoding(srcImgPath.toQString().toUtf8()));
+ m_Images.insert(eastl::make_pair(m_StringTable.RegisterStr(cleanSrcImgPath),
m_StringTable.RegisterStr(dstPath.getValue())));
}
@@ -810,7 +830,7 @@ public:
if (copyResult.m_Error != Q3DStudio::FileErrorCodes::NoError) {
QT3DS_ASSERT(false);
- const wchar_t *extraData = NULL;
+ const wchar_t *extraData = nullptr;
ImportErrorCodes::Enum error = FromFileErrorCode(copyResult.m_Error);
if (error == ImportErrorCodes::ResourceNotWriteable)
extraData = dstPath.getValue();
@@ -827,9 +847,13 @@ public:
Option<TCharPtr> FindImageByPath(TCharPtr _imgPath) const override
{
Q3DStudio::CString imgPath = CFilePath::GetAbsolutePath(CString(_imgPath));
- Q3DStudio::CString srcImgPath =
- CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath);
- return FindImageByRelativePath(srcImgPath.c_str());
+ Q3DStudio::CString srcImgPath = CFilePath::GetRelativePathFromBase(m_FullSrcDirectory,
+ imgPath);
+ // Need to get rid of %20 and such in the path, or we won't find the image
+ Q3DStudio::CString cleanPath
+ = Q3DStudio::CString::fromQString(QUrl::fromPercentEncoding(
+ srcImgPath.toQString().toUtf8()));
+ return FindImageByRelativePath(cleanPath.c_str());
}
Option<TCharPtr> FindImageByRelativePath(TCharPtr imgPath) const override
@@ -1146,19 +1170,19 @@ public:
MemoryBuffer<RawAllocator> &inTempBuf)
{
Instance *theInstance = GetInstance(inAnimation.m_InstanceId);
- if (theInstance == NULL || theInstance->m_Valid == false)
+ if (theInstance == nullptr || theInstance->m_Valid == false)
return;
IDOMWriter::Scope __animScope(writer, L"AnimationTrack");
TCharStr thePropName(inAnimation.m_PropertyName);
SImportComposerTypes theTypes;
SImportAsset &theAsset(theTypes.GetImportAssetForType(inType));
DataModelDataType::Value theType(theAsset.GetPropertyDataType(thePropName.wide_str()));
- std::tuple<bool, size_t> animAndArity = GetDatatypeAnimatableAndArity(theType);
- if (std::get<0>(animAndArity) == false) {
+ size_t arity = getDatatypeAnimatableArity(theType);
+ if (arity == 0) {
QT3DS_ASSERT(false);
return;
};
- if (std::get<1>(animAndArity) > 1) {
+ if (arity > 1) {
thePropName.append(L".");
switch (inAnimation.m_SubPropertyIndex) {
case 0:
@@ -1395,7 +1419,7 @@ public:
std::shared_ptr<IDOMFactory> factory(IDOMFactory::CreateDOMFactory(m_StringTablePtr));
std::shared_ptr<IDOMWriter> theWriter;
- SDOMElement *theTopElement = NULL;
+ SDOMElement *theTopElement = nullptr;
bool exists = fullPath.Exists();
{
@@ -1413,7 +1437,7 @@ public:
theTopElement = CDOMSerializer::Read(*factory, stream);
- if (theTopElement == NULL) {
+ if (theTopElement == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
@@ -1460,8 +1484,8 @@ public:
CString src = theSrcFile.toCString();
writer.Att(L"SrcFile", src.c_str());
- writer.Att(L"ImageDir", L"Images");
- writer.Att(L"MeshDir", L"Meshes");
+ writer.Att(L"ImageDir", L"maps");
+ writer.Att(L"MeshDir", L"meshes");
Serialize(writer, L"Image", const_cast<TStrToStrMap &>(m_Images));
Serialize(writer, L"Mesh", const_cast<TPathToMeshMap &>(m_Meshes));
}
@@ -1480,7 +1504,7 @@ public:
{
using namespace Q3DStudio;
std::shared_ptr<IDOMFactory> factory(IDOMFactory::CreateDOMFactory(m_StringTablePtr));
- SDOMElement *topElement = NULL;
+ SDOMElement *topElement = nullptr;
{
Qt3DSFileToolsSeekableMeshBufIOStream stream(
SFile::Wrap(SFile::OpenForRead(fname), fname));
@@ -1492,7 +1516,7 @@ public:
topElement = CDOMSerializer::Read(*factory, stream);
}
- if (topElement == NULL) {
+ if (topElement == nullptr) {
QT3DS_ASSERT(false);
return false;
}
@@ -1945,7 +1969,7 @@ QT3DSU32 Import::GetHighestImportRevision(TCharPtr pathToFile)
std::shared_ptr<IDOMFactory> theFactory = IDOMFactory::CreateDOMFactory(theStringTable);
SDOMElement *theTopElement = CDOMSerializer::Read(*theFactory, stream);
- if (theTopElement == NULL) {
+ if (theTopElement == nullptr) {
QT3DS_ASSERT(false);
return 0;
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h
index dbebe4dd..02bbbe2e 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h
@@ -359,10 +359,9 @@ public:
void AddAnimation(TCharPtr instance, const SImportPropertyDefinition<TDataType> &inProperty,
QT3DSU32 subPropIndex, EAnimationType type, NVConstDataRef<QT3DSF32> values)
{
- std::tuple<bool, size_t> isAnimatableAndArity(
- GetDatatypeAnimatableAndArity(TypeToDataType<TDataType>()));
- if (std::get<0>(isAnimatableAndArity)) {
- if (subPropIndex >= std::get<1>(isAnimatableAndArity)) {
+ size_t arity = getDatatypeAnimatableArity(TypeToDataType<TDataType>());
+ if (arity) {
+ if (subPropIndex >= arity) {
QT3DS_ASSERT(false);
subPropIndex = 0;
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp
index d1d692fb..fdf332c5 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp
@@ -114,6 +114,8 @@ DataModelDataType::Value SImportControllableObject::GetPropertyDataType(
ITERATE_COMPOSER_MATERIAL_PROPERTIES
ITERATE_COMPOSER_NODE_PROPERTIES
ITERATE_COMPOSER_LIGHT_PROPERTIES
+ ITERATE_COMPOSER_CAMERA_PROPERTIES
+ ITERATE_COMPOSER_ASSET_PROPERTIES
// Cannot fall back to SImportAsset as we might receive custom material
// properties which are not known to property system and cause assert.
return DataModelDataType::None;
@@ -223,6 +225,8 @@ SImportAsset &SImportComposerTypes::GetImportAssetForType(ComposerObjectTypes::E
return m_Asset;
case ComposerObjectTypes::Group:
return m_Group;
+ case ComposerObjectTypes::Signal:
+ return m_Signal;
case ComposerObjectTypes::Light:
return m_Light;
case ComposerObjectTypes::Camera:
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h
index 78df2a9b..0f069270 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h
@@ -88,6 +88,11 @@ struct SImportGroup : public SImportNode
ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Group; }
};
+struct SImportSignal : public SImportNode
+{
+ ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Signal; }
+};
+
struct SImportLight : public SImportNode
{
ITERATE_COMPOSER_LIGHT_PROPERTIES
@@ -205,6 +210,7 @@ struct SImportComposerTypes
{
SImportAsset m_Asset;
SImportGroup m_Group;
+ SImportSignal m_Signal;
SImportLight m_Light;
SImportCamera m_Camera;
SImportModel m_Model;
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp
index 8072055f..6955a052 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp
@@ -58,17 +58,15 @@ void DoUpdateInstances(Import &import, IComposerEditor &composer,
QT3DSIMP_FOREACH(idx, instances.size())
{
// We have to re-lookup instances here because the instance data may have changed since it
- // was put
- // into the import report. For instance, you get an import report, then you add instances.
- // This adds
- // user ids. But the import report is already created so the instance descriptions in the
- // report's
- // add list won't reflect the new reality.
+ // was put into the import report. For instance, you get an import report, then you add
+ // instances. This adds user ids. But the import report is already created so the instance
+ // descriptions in the report's add list won't reflect the new reality.
const InstanceDesc &desc(instances[idx]);
QT3DSU32 numProps = import.GetNumProperties(desc.m_Handle);
properties.resize(numProps);
import.GetProperties(desc.m_Handle, properties);
- composer.UpdateInstanceProperties(desc.m_Id, properties.data(), (QT3DSU32)properties.size());
+ composer.UpdateInstanceProperties(desc.m_Id, properties.data(),
+ (QT3DSU32)properties.size());
}
}
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
index 2bf58a85..0cadee7b 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportColladaSGTranslation.cpp
@@ -40,8 +40,7 @@
#include "Qt3DSImportTranslationCommon.h"
#include "Qt3DSImportSceneGraphTranslation.h"
#include "Qt3DSImportTranslation.h"
-#include "Dialogs.h"
-#include "StudioApp.h"
+#include "Rotation3.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qfileinfo.h>
@@ -74,7 +73,7 @@ public:
public:
bool LoadDocument(const std::string &inFilePath);
- void ProcessScene();
+ bool ProcessScene();
void ProcessLibraryAnimations();
protected:
@@ -88,7 +87,8 @@ protected:
void ProcessGeometry(const domGeometry *inGeometry, TFaceIndicies &ioIndicies);
void ProcessTriangle(const domTrianglesRef inTrianglesRef, TFaceIndicies &ioFaceIndicies,
bool &outHasNormals, bool &outHasTexCoords, bool &outHasTexCoords2,
- bool &outHasTexTangents, bool &outHasTexBinormals, bool &outHasColors);
+ bool &outHasTexTangents, bool &outHasTexBinormals, bool &outHasColors,
+ const char *meshName);
void GenerateMeshTangents(const domTrianglesRef inTrianglesRef,
const SSourceArrayInfo &inVertexArrayInfo,
const SSourceArrayInfo &inNormalArrayInfo,
@@ -129,6 +129,7 @@ protected:
void TrackObjectIndex(const daeElement *inElement, long inIndex);
void GetIndicesFromElement(const daeElement *inElement, TLongsList &outIndicies);
bool ApplyAnimation(const daeElement *inContainerElement);
+ int CheckLightType(const domLight *light);
protected:
std::function<void(const char *)> PushGroup;
@@ -174,6 +175,7 @@ protected:
ISceneGraphTranslation *m_Translator;
const char *m_DAEFilename;
TElementToIndicesMap m_ElementToIndicies;
+ EAuthoringToolType m_authoringTool;
};
void FindTexturesViaNewParam(daeElement *inElementPtr, ColladaDOMWalker::TURIList &outTexturePaths)
@@ -361,10 +363,13 @@ bool ColladaDOMWalker::LoadDocument(const std::string &inFilePath)
* This begins by looking at the active visual_scene node and starting import
* from that node.
*/
-void ColladaDOMWalker::ProcessScene()
+bool ColladaDOMWalker::ProcessScene()
{
if (m_ColladaRoot != nullptr) {
const domCOLLADA::domSceneRef theScene = m_ColladaRoot->getScene();
+ if (!theScene)
+ return false;
+
// Retrieve the active visual_scene
const domInstanceWithExtraRef theInstanceVisualScene = theScene->getInstance_visual_scene();
const xsAnyURI &theVisualSceneURI = theInstanceVisualScene->getUrl();
@@ -411,6 +416,8 @@ void ColladaDOMWalker::ProcessScene()
// Disable wrapping the visual scene in it's own group, since m_TopMostParent exists
// PopGroup( );
}
+
+ return true;
}
void ColladaDOMWalker::SetFColladaAuthoringTool(const char *inName)
@@ -466,6 +473,9 @@ void ColladaDOMWalker::SetFColladaAuthoringTool(const char *inName)
} else if (theAuthoringToolLowerCase.find("opencollada") != std::string::npos
&& theAuthoringToolLowerCase.find("3ds max") != std::string::npos) {
theAuthoringToolType = EAuthoringToolType_FCollada_Max;
+ } else if (theAuthoringToolLowerCase.find("opencollada") != std::string::npos) {
+ // Assume Maya if no 3ds max was found
+ theAuthoringToolType = EAuthoringToolType_OpenCollada_Maya;
}
long theAuthoringToolVersion = 0;
@@ -473,6 +483,7 @@ void ColladaDOMWalker::SetFColladaAuthoringTool(const char *inName)
|| theAuthoringToolType == EAuthoringToolType_FCollada_Maya)
theAuthoringToolVersion = GetFColladaVersion(theAuthoringToolLowerCase);
+ m_authoringTool = theAuthoringToolType;
SetAuthoringTool(theAuthoringToolType, theAuthoringToolVersion);
}
@@ -516,9 +527,9 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
{
switch (inNode->getType()) {
case NODETYPE_NODE: {
- const domInstance_geometry_Array &theInstanceGeometryArray =
- inNode->getInstance_geometry_array();
- long theGeometryCount = (long)theInstanceGeometryArray.getCount();
+ const domInstance_geometry_Array &theInstanceGeometryArray
+ = inNode->getInstance_geometry_array();
+ size_t theGeometryCount = theInstanceGeometryArray.getCount();
bool thePushModelFlag = false;
bool lightFlag = false;
bool cameraFlag = false;
@@ -542,9 +553,9 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
PushGroup(GetNameOrIDOrSid(inNode));
ProcessTransform(inNode);
- for (long theIndex = 0; theIndex < theGeometryCount; ++theIndex) {
+ for (size_t theIndex = 0; theIndex < theGeometryCount; ++theIndex) {
const domInstance_geometryRef theInstanceGeometryRef =
- theInstanceGeometryArray[theIndex];
+ theInstanceGeometryArray[theIndex];
PushModel(GetNameOrIDOrSid(theInstanceGeometryRef));
ProcessInstanceGeometry(inNode, theInstanceGeometryRef);
PopModel();
@@ -569,20 +580,30 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
double clipstart = 0;
double clipend = 0;
bool ortho = false;
+ double aspectRatio = 0;
if (technique->getPerspective()) {
fov = technique->getPerspective()->getXfov() != nullptr
? technique->getPerspective()->getXfov()->getValue()
: technique->getPerspective()->getYfov()->getValue();
clipstart = technique->getPerspective()->getZnear()->getValue();
clipend = technique->getPerspective()->getZfar()->getValue();
+ aspectRatio = technique->getPerspective()->getAspect_ratio()->getValue();
} else if (technique->getOrthographic()) {
fov = technique->getOrthographic()->getXmag() != nullptr
? technique->getOrthographic()->getXmag()->getValue()
: technique->getOrthographic()->getYmag()->getValue();
clipstart = technique->getOrthographic()->getZnear()->getValue();
clipend = technique->getOrthographic()->getZfar()->getValue();
+ aspectRatio = technique->getOrthographic()->getAspect_ratio()->getValue();
ortho = true;
}
+ if (m_authoringTool == EAuthoringToolType_OpenCollada_Maya) {
+ // Calculate horizontal fov from vertical fov:
+ // hfov = 2 * tan-1(w/h * tan(vfov / 2))
+ fov = Q3DStudio::QT3DS_RADIANS_TO_DEGREES * 2
+ * std::atan(aspectRatio * std::tan(Q3DStudio::QT3DS_DEGREES_TO_RADIANS
+ * fov / 2.));
+ }
SetCameraProperties(clipstart, clipend, ortho, fov);
} else if (lights.getCount()) {
// Light
@@ -600,6 +621,11 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
double linearFade = 0;
double quadFade = 0;
if (technique->getPoint()) {
+ // Blender exports Area light as Point type, so we need to check if we are
+ // dealing with Blender, and dig the actual light type from inside extra
+ // elements
+ type = CheckLightType(light);
+ type = (type == -1) ? 0 : type;
domLight::domTechnique_common::domPointRef point = technique->getPoint();
color = point->getColor()->getValue();
linearFade = point->getLinear_attenuation()->getValue() * 1000;
@@ -610,7 +636,11 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
= technique->getDirectional();
color = directional->getColor()->getValue();
} else if (technique->getAmbient()) {
- type = 4;
+ // Blender exports Hemi light as Ambient type, so we need to check if we are
+ // dealing with Blender, and dig the actual light type from inside extra
+ // elements
+ type = CheckLightType(light);
+ type = (type == -1) ? 4 : type;
domLight::domTechnique_common::domAmbientRef ambient = technique->getAmbient();
color = ambient->getColor()->getValue();
} else {
@@ -621,11 +651,12 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
color = spot->getColor()->getValue();
linearFade = spot->getLinear_attenuation()->getValue() * 1000;
quadFade = spot->getQuadratic_attenuation()->getValue() * 1000;
+ LogWarning(ESceneGraphWarningCode_UnsupportedLight, GetNameOrIDOrSid(inNode));
}
// Collada does not seem to have info about casting shadows or light intensity.
// We'll use the defaults (intensity 100, no shadows)
- SetLightProperties(type,
- SFloat4(color.get(0), color.get(1), color.get(2), color.get(3)),
+ SetLightProperties(type, SFloat4(float(color.get(0)), float(color.get(1)),
+ float(color.get(2)), 1.0f),
100, linearFade, quadFade, false);
}
}
@@ -653,6 +684,29 @@ void ColladaDOMWalker::ProcessNode(const domNodeRef inNode)
}
}
+int ColladaDOMWalker::CheckLightType(const domLight *light)
+{
+ // In case of Blender, dig the actual light type from inside extra techniques
+ const domExtra_Array &lightExtraArray = light->getExtra_array();
+ size_t extrasCount = lightExtraArray.getCount();
+ for (size_t i = 0; i < extrasCount; ++i) {
+ domExtraRef lightExtra = lightExtraArray[i];
+ const domTechnique_Array &lightExtraTechniqueArray
+ = lightExtra->getTechnique_array();
+ size_t techniqueCount = lightExtraTechniqueArray.getCount();
+ for (size_t j = 0; j < techniqueCount; ++j) {
+ domTechniqueRef lightExtraTechnique = lightExtraTechniqueArray[i];
+ const char *profile = lightExtraTechnique->getProfile();
+ if (::strcmp(profile, "blender") == 0) {
+ if (daeElement *theElement = lightExtraTechnique->getChild("type"))
+ return GetIntFromElementChar(theElement);
+ break;
+ }
+ }
+ }
+ return -1; // Not found
+}
+
//==============================================================================
/**
* Processes transform elements on a <node>.
@@ -775,7 +829,15 @@ void ColladaDOMWalker::ProcessGeometry(const domGeometry *inGeometry, TFaceIndic
long theTriangleArrayCount = (long)theTriangles.getCount();
for (long theIndex = 0; theIndex < theTriangleArrayCount; ++theIndex) {
ProcessTriangle(theTriangles[theIndex], ioFaceIndicies, theHasNormals, theHasTexCoords,
- theHasTexCoords2, theHasTexTangents, theHasTexBinormals, theHasColors);
+ theHasTexCoords2, theHasTexTangents, theHasTexBinormals, theHasColors,
+ GetNameOrIDOrSid(inGeometry));
+ }
+
+ // Pop up warning message if model contains non-triangles geometry
+ if (theMesh->getPolylist_array().getCount() || theMesh->getPolygons_array().getCount()
+ || theMesh->getLines_array().getCount() || theMesh->getLinestrips_array().getCount()
+ || theMesh->getTrifans_array().getCount() || theMesh->getTristrips_array().getCount()) {
+ LogWarning(ESceneGraphWarningCode_OnlySupportTriangles, GetNameOrIDOrSid(inGeometry));
}
// Prepare arrays for population
@@ -832,13 +894,6 @@ void ColladaDOMWalker::ProcessGeometry(const domGeometry *inGeometry, TFaceIndic
m_Translator->SetGeometry(theVertices, theNormals, theTexCoords, theTexCoords2, theTexTangents,
theTexBinormals, theWeights, theBoneIndex, theColors,
theEntireFaceIndiciesList);
-
- // Pop up warning message if model contains non-triangles geometry
- if (theMesh->getPolylist_array().getCount() || theMesh->getPolygons_array().getCount()
- || theMesh->getLines_array().getCount() || theMesh->getLinestrips_array().getCount()
- || theMesh->getTrifans_array().getCount() || theMesh->getTristrips_array().getCount()) {
- LogWarning(ESceneGraphWarningCode_OnlySupportTriangles, GetNameOrIDOrSid(inGeometry));
- }
}
//==============================================================================
@@ -849,7 +904,7 @@ void ColladaDOMWalker::ProcessTriangle(const domTrianglesRef inTrianglesRef,
TFaceIndicies &ioFaceIndicies, bool &outHasNormals,
bool &outHasTexCoords, bool &outHasTexCoords2,
bool &outHasTexTangents, bool &outHasTexBinormals,
- bool &outHasColors)
+ bool &outHasColors, const char *meshName)
{
SSourceArrayInfo theVertexArrayInfo;
SSourceArrayInfo theNormalArrayInfo;
@@ -1014,13 +1069,10 @@ void ColladaDOMWalker::ProcessTriangle(const domTrianglesRef inTrianglesRef,
// Set the face indicies used by this particular material
const xsNCName theMaterialName =
inTrianglesRef->getMaterial(); // TODO: Handle the material settings for this face
- if (theMaterialName != nullptr) {
+ if (theMaterialName != nullptr)
ioFaceIndicies.second.push_back(std::make_pair(theMaterialName, theMaterialFaceIndicies));
- } else {
- g_StudioApp.GetDialogs()->DisplayKnownErrorDialog(
- QObject::tr("The mesh files could not be created.\n"
- "Materials are missing from the imported model."));
- }
+ else
+ LogWarning(ESceneGraphWarningCode_MissingMaterial, meshName);
}
/**
@@ -1769,8 +1821,7 @@ bool CImportTranslation::ParseColladaFile(const std::string &fileName, Import &i
ColladaDOMWalker theDOMWalker(&transHelper);
if (theDOMWalker.LoadDocument(fileName)) {
theDOMWalker.ProcessLibraryAnimations();
- theDOMWalker.ProcessScene();
- return true;
+ return theDOMWalker.ProcessScene();
}
return false;
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportFbxSGTranslation.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportFbxSGTranslation.cpp
index d68df5d7..8e0a0dc4 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportFbxSGTranslation.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportFbxSGTranslation.cpp
@@ -68,11 +68,9 @@ public:
typedef std::vector<_SVertexWeightInfo> TPerVertexWeightInfo;
typedef std::vector<_SJointInfo> TJointInfoList;
typedef std::tuple<SVector3, SVector3, SVector2, SVector3, SVector3, SVector4, SVector4,
- SVector2, SVector3>
- TVertexInfoTuple;
+ SVector2, SVector3> TVertexInfoTuple;
typedef std::pair<std::map<TVertexInfoTuple, long>,
- std::vector<std::pair<std::string, TLongsList>>>
- TFaceIndicies;
+ std::vector<std::pair<std::string, TLongsList>>> TFaceIndicies;
typedef std::vector<TPerVertexWeightInfo> TVertexWeigthList;
typedef std::vector<FbxAnimCurve *> TAnimCurveList;
@@ -83,8 +81,8 @@ public:
public:
bool LoadDocument(const std::string &inFilePath);
- void ProcessScene();
- void ProcessAnimationStacks();
+ void ProcessScene(bool animations = false);
+ bool ProcessAnimationStacks();
protected:
template <typename TNodeFilter>
@@ -118,7 +116,7 @@ protected:
void ReadWeight(const TPerVertexWeightInfo &inFbxWeights, int inFbxIndex, float *outValue);
void ReadBoneIndex(const TPerVertexWeightInfo &inFbxWeights, int inFbxIndex, float *outValue,
const TJointInfoList &inAbsoluteJoints);
- void ReadMaterial(const FbxSurfaceMaterial *inMaterial, const int startFace,
+ void ReadMaterial(FbxSurfaceMaterial *inMaterial, const int startFace,
const int faceCount);
void ReadDefaultMaterial(const FbxNode *pNode, const int startFace, const int faceCount);
void ProcessTextures(const FbxSurfaceMaterial *inMaterial, const char *fbxMatType,
@@ -160,6 +158,8 @@ protected:
TJointNodeHierarchyMap m_JointNodeHierarchyMap;
TNodeSet m_importNodes;
EAuthoringToolType m_AuthoringToolType;
+ bool m_reportedUnknownMaterials = false;
+ FbxAxisSystem::EUpVector m_originalUpVector;
};
FbxDomWalker::FbxDomWalker(ISceneGraphTranslation *inTranslation)
@@ -258,7 +258,9 @@ bool FbxDomWalker::LoadDocument(const std::string &inFilePath)
major * 1000 + minor * 100 + revision);
m_AuthoringToolType = EAuthoringToolType_FBX_Maya;
} else if (strstr(appName, "Blender")) {
- qWarning("Importing from Blender. Light and Camera rotations may be incorrect");
+ m_Translator->LogWarning(ESceneGraphWarningCode_Rotations,
+ "Imported from Blender. Light and Camera rotations may"
+ " be incorrect.");
m_Translator->SetAuthoringTool(EAuthoringToolType_FBX_Blender,
major * 1000 + minor * 100 + revision);
m_AuthoringToolType = EAuthoringToolType_FBX_Blender;
@@ -356,21 +358,36 @@ struct SNodeSetFilter
*
* @return no return
*/
-void FbxDomWalker::ProcessScene()
+void FbxDomWalker::ProcessScene(bool animations)
{
+ m_reportedUnknownMaterials = false;
if (m_FbxScene != nullptr) {
- // FbxAxisSystem::MayaYUp.ConvertScene( m_FbxScene );
- int sign;
FbxAxisSystem SceneAxisSystem = m_FbxScene->GetGlobalSettings().GetAxisSystem();
- if (SceneAxisSystem.GetUpVector(sign) == FbxAxisSystem::eZAxis) {
+ int sign;
+ m_originalUpVector = SceneAxisSystem.GetUpVector(sign);
+ if (m_originalUpVector == FbxAxisSystem::eZAxis
+ && m_AuthoringToolType != EAuthoringToolType_FBX_Maya) {
+ // Do automatic axis system conversion from Z-up to Y-up
+ FbxAxisSystem::OpenGL.ConvertScene(m_FbxScene);
+
+ m_Translator->LogWarning(ESceneGraphWarningCode_Rotations,
+ "Converted axis system from Z-up to Y-up.");
+ } else if (m_AuthoringToolType == EAuthoringToolType_FBX_Max && animations) {
+ // FBX is from 3ds Max and there are animations. As the exported FBX has forced Y-up
+ // axis system, some rotations had pre-rotations, which were removed in the
+ // animation stack handling step. This may cause incorrect rotations.
+ // Do manual x-rotation to fix it.
std::vector<INodeTransform *> theTransforms;
NodeTransform *theRotX = new NodeTransform(ETransformType_Rotation4);
(*theRotX)[0] = 1.0f;
(*theRotX)[1] = (*theRotX)[2] = 0.0f;
- (*theRotX)[3] =
- -90.0f; // Apply a -90 degree rotation on the X-axis to 'right' the model
+ (*theRotX)[3] = -90.0f; // Apply rotation on the X-axis to 'right' the model
theTransforms.push_back(theRotX);
+ m_Translator->LogWarning(ESceneGraphWarningCode_Rotations,
+ "Imported Y-up scene with animations from 3ds Max. "
+ "X axis was rotated to fix orientation. Some rotations "
+ "may still be incorrect.");
m_Translator->SetTransforms(theTransforms);
delete theRotX;
@@ -379,9 +396,8 @@ void FbxDomWalker::ProcessScene()
// triangulate just in case
FbxGeometryConverter theFbxGeometryConverter(m_FbxManager);
bool bOk = theFbxGeometryConverter.Triangulate(m_FbxScene, true, true);
- if (!bOk) {
+ if (!bOk)
QT3DS_ASSERT(false);
- }
m_importNodes.clear();
FilterNodeHierarchy(SMeshFilter(), m_importNodes);
@@ -405,8 +421,8 @@ long FbxDomWalker::GetJointNodeID(const FbxNode *inFbxNode)
if (theIter == m_JointNodeHierarchyMap.end())
theIter = m_JointNodeHierarchyMap
- .insert(std::make_pair(inFbxNode, (long)m_JointNodeHierarchyMap.size()))
- .first;
+ .insert(std::make_pair(inFbxNode, long(m_JointNodeHierarchyMap.size())))
+ .first;
return theIter->second;
}
@@ -420,7 +436,7 @@ long FbxDomWalker::GetJointNodeID(const FbxNode *inFbxNode)
*/
int FbxDomWalker::GetParentJointID(const FbxNode *inFbxNode)
{
- long nodeIndex = -1;
+ int nodeIndex = -1;
TJointNodeHierarchyMap::iterator theIter;
const FbxNode *parent = inFbxNode->GetParent();
@@ -428,7 +444,7 @@ int FbxDomWalker::GetParentJointID(const FbxNode *inFbxNode)
theIter = m_JointNodeHierarchyMap.find(parent);
if (theIter != m_JointNodeHierarchyMap.end()) {
- nodeIndex = theIter->second;
+ nodeIndex = int(theIter->second);
break;
}
@@ -484,9 +500,17 @@ void FbxDomWalker::ProcessLight(FbxNode *inFbxNode)
ProcessTransform(inFbxNode, true);
FbxLight *light = inFbxNode->GetLight();
FbxDouble3 color = light->Color.Get();
- m_Translator->SetLightProperties(light->LightType.Get(),
- SFloat4(color[0], color[1], color[2], 1.0f),
- light->Intensity.Get(), 0, 0, light->CastShadows.Get());
+ int lightType = light->LightType.Get();
+ if (lightType == FbxLight::eArea)
+ lightType = 4; // Area light type is 3 in FBX and 4 in DAE and internally
+ else if (lightType == FbxLight::eSpot)
+ m_Translator->LogWarning(ESceneGraphWarningCode_UnsupportedLight, lightName.c_str());
+ FbxLight::EDecayType decayType = light->DecayType.Get();
+ double linearDecay = (decayType == FbxLight::eLinear) ? light->DecayStart.Get() : 0.;
+ double quadDecay = (decayType == FbxLight::eQuadratic) ? light->DecayStart.Get() : 0.;
+ m_Translator->SetLightProperties(lightType, SFloat4(float(color[0]), float(color[1]),
+ float(color[2]), 1.0f), light->Intensity.Get(), linearDecay, quadDecay,
+ light->CastShadows.Get());
ProcessNodeChildren(inFbxNode);
m_Translator->PopLight();
}
@@ -507,7 +531,14 @@ void FbxDomWalker::ProcessCamera(FbxNode *inFbxNode)
// Maya does not export FOV, but focal length. We need to convert it to FOV.
FbxDouble fov = (m_AuthoringToolType == EAuthoringToolType_FBX_Maya)
? camera->ComputeFieldOfView(camera->FocalLength.Get()) : camera->FieldOfView.Get();
- m_Translator->SetCameraProperties(camera->GetNearPlane(), camera->GetFarPlane(),
+ FbxDouble nearPlane = camera->GetNearPlane();
+ FbxDouble farPlane = camera->GetFarPlane();
+ // Near and far planes are exported at 100-fold values from Blender.
+ nearPlane = (m_AuthoringToolType == EAuthoringToolType_FBX_Blender)
+ ? nearPlane / 100. : nearPlane;
+ farPlane = (m_AuthoringToolType == EAuthoringToolType_FBX_Blender)
+ ? farPlane / 100. : farPlane;
+ m_Translator->SetCameraProperties(nearPlane, farPlane,
camera->ProjectionType.Get() == FbxCamera::eOrthogonal,
fov);
ProcessNodeChildren(inFbxNode);
@@ -644,7 +675,27 @@ void FbxDomWalker::ProcessTransform(FbxNode *inFbxNode, bool ignoreScale)
// Lights and cameras should ignore scale
if (ignoreScale)
theTransformMatrix.SetS(FbxVector4(1.0, 1.0, 1.0, 1.0));
- // TODO: Do some rotation magic if m_AuthoringToolType == Blender?
+
+ // Do rotation corrections for cameras and lights if importing from Blender
+ // Note: Blender and 3ds max must have "Y Forward" and "Z Up" export settings defined for
+ // these to work. For 3ds Max it is the default setting, but for Blender it is not.
+ if (m_originalUpVector == FbxAxisSystem::eZAxis) {
+ if (m_AuthoringToolType == EAuthoringToolType_FBX_Blender) {
+ FbxDouble3 rot = inFbxNode->LclRotation.Get();
+ if (inFbxNode->GetLight())
+ theTransformMatrix.SetR(FbxVector4(rot[0] - 90., rot[1], rot[2], 1.0));
+ else if (inFbxNode->GetCamera())
+ theTransformMatrix.SetR(FbxVector4(rot[0], rot[1] - 90., rot[2], 1.0));
+ }
+ } else if (m_originalUpVector == FbxAxisSystem::eYAxis
+ && m_AuthoringToolType == EAuthoringToolType_FBX_Max) {
+ // 3ds Max messes up the positions if FBX is exported with y-up axis system.
+ // Fix that by switching the positions between z and y axes.
+ FbxDouble3 pos = inFbxNode->LclTranslation.Get();
+ // Override the converted rotations with correct ones
+ if (inFbxNode->GetLight())
+ theTransformMatrix.SetT(FbxVector4(pos[0], pos[1], pos[2], 1.0));
+ }
theTransforms.push_back(new NodeTransform(ETransformType_Matrix4x4));
@@ -685,7 +736,8 @@ FbxAMatrix GetPoseMatrix(FbxPose *pPose, int pNodeIndex)
FbxAMatrix lPoseMatrix;
FbxMatrix lMatrix = pPose->GetMatrix(pNodeIndex);
- memcpy((double *)lPoseMatrix, (double *)lMatrix, sizeof(lMatrix.mData));
+ memcpy(static_cast<double *>(lPoseMatrix), static_cast<double *>(lMatrix),
+ sizeof(lMatrix.mData));
return lPoseMatrix;
}
@@ -738,10 +790,11 @@ FbxAMatrix GetGlobalPosition(FbxNode *pNode, FbxPose *pPose)
// Compute the transform matrix that the cluster will transform the vertex at binding time.
void ComputeInitialBindPoseTransform(FbxAMatrix &pMeshGlobalPosition, FbxMesh *pMesh,
- FbxCluster *pCluster, FbxPose * /* pPose */,
+ FbxCluster *pCluster, FbxPose *pPose,
FbxAMatrix &pInverseBindMatrix,
FbxAMatrix &pJointToGlobalMatrix)
{
+ Q_UNUSED(pPose)
FbxCluster::ELinkMode lClusterMode = pCluster->GetLinkMode();
FbxAMatrix lReferenceGlobalInitPosition;
@@ -773,7 +826,7 @@ void ComputeInitialBindPoseTransform(FbxAMatrix &pMeshGlobalPosition, FbxMesh *p
// Compute the initial position of the link relative to the reference.
lClusterRelativeInitPosition =
- lClusterGlobalInitPosition.Inverse() * lReferenceGlobalInitPosition;
+ lClusterGlobalInitPosition.Inverse() * lReferenceGlobalInitPosition;
pInverseBindMatrix = lReferenceGlobalCurrentPosition.Inverse();
pJointToGlobalMatrix = lClusterRelativeInitPosition;
@@ -811,7 +864,7 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
FbxCluster::ELinkMode theClusterMode = FbxCluster::eNormalize;
// a weight entry for each vertex
- outWeights.resize(inFbxMesh->GetControlPointsCount());
+ outWeights.resize(size_t(inFbxMesh->GetControlPointsCount()));
// right now we do not handle multiple deformers per mesh
QT3DS_ASSERT(theDeformerCount <= 1);
@@ -820,8 +873,8 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
FbxSkin *theSkin = FbxCast<FbxSkin>(inFbxMesh->GetDeformer(i));
if (theSkin && theSkin->GetClusterCount() > 0) {
- std::vector<FbxVector4>
- theGlobaBindPose; // contains the transformed vertices to bone space
+ // contains the transformed vertices to bone space
+ std::vector<FbxVector4> theGlobaBindPose;
FbxDeformer::EDeformerType theDeformerType = theSkin->GetDeformerType();
// we only support skin deformer
@@ -832,7 +885,7 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
theClusterMode = theSkin->GetCluster(0)->GetLinkMode();
- theGlobaBindPose.resize(inFbxMesh->GetControlPointsCount());
+ theGlobaBindPose.resize(size_t(inFbxMesh->GetControlPointsCount()));
// same for all clusters
// GetTransformMatrix is the matrix to convert vertices of the mesh (skin) to world
@@ -844,8 +897,8 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
// convert all vertices from mesh space to world space
for (unsigned long vertexId = 0; vertexId < theGlobaBindPose.size(); vertexId++) {
- theGlobaBindPose[vertexId] =
- thelocalSkinToWorldSpace.MultT(inFbxMesh->GetControlPoints()[vertexId]);
+ theGlobaBindPose[vertexId] = thelocalSkinToWorldSpace.MultT(
+ inFbxMesh->GetControlPoints()[vertexId]);
}
for (int clusterId = 0; clusterId < theSkin->GetClusterCount(); clusterId++) {
@@ -855,17 +908,17 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
continue;
// this call adds the link node to our global list if not found
- int jointIdx = GetJointNodeID(theCluster->GetLink());
+ int jointIdx = int(GetJointNodeID(theCluster->GetLink()));
int parentJointIdx = GetParentJointID(theCluster->GetLink());
// should always be a skleton right now
QT3DS_ASSERT(theCluster->GetLink()->GetNodeAttribute()->GetAttributeType()
- == FbxNodeAttribute::eSkeleton);
+ == FbxNodeAttribute::eSkeleton);
// All the links must have the same link mode. and right now we don't support
// additive mode
if ((theCluster->GetLinkMode() != theClusterMode)
- || (theClusterMode == FbxCluster::eAdditive)) {
+ || (theClusterMode == FbxCluster::eAdditive)) {
QT3DS_ASSERT(false);
return;
}
@@ -883,8 +936,8 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
// The inverse converts from world space to cluster (bone) sapce
invBoneBindposeMatrix = BoneBindposeMatrix.Inverse();
// This Matrix convertes from local bone space to world space
- FbxAMatrix boneLocalToSkinWorldSpace =
- invBoneBindposeMatrix * thelocalSkinToWorldSpace;
+ FbxAMatrix boneLocalToSkinWorldSpace = invBoneBindposeMatrix
+ * thelocalSkinToWorldSpace;
FbxAMatrix worldSpaceToSkinSpace = thelocalSkinToWorldSpace.Inverse();
// add a joint node to our internal list
@@ -894,7 +947,7 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
// get the actual weights
for (int j = 0; j < theCluster->GetControlPointIndicesCount(); j++) {
const int vertexID = vertexIDs[j];
- const float w = (float)weights[j];
+ const float w = float(weights[j]);
// this can happen with smooting groups
if (vertexID >= inFbxMesh->GetControlPointsCount())
@@ -903,8 +956,10 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
continue;
// store away values and convert vertices to local bone space
- outWeights[vertexID].push_back(_SVertexWeightInfo(
- jointIdx, w, invBoneBindposeMatrix.MultT(theGlobaBindPose[vertexID])));
+ outWeights[size_t(vertexID)].push_back(
+ _SVertexWeightInfo(jointIdx, w,
+ invBoneBindposeMatrix.MultT(
+ theGlobaBindPose[size_t(vertexID)])));
}
}
}
@@ -918,24 +973,23 @@ void FbxDomWalker::GetVertexWeights(FbxMesh *inFbxMesh, TVertexWeigthList &outWe
QT3DS_ASSERT(outWeights[vertexID].size() < 4);
// get total sum of the weigths for each vertex
- for (unsigned long i = 0; i < outWeights[vertexID].size(); i++) {
+ for (unsigned long i = 0; i < outWeights[vertexID].size(); i++)
weightSum += outWeights[vertexID][i].m_Weight;
- }
if (weightSum != 0.0f) {
switch (theClusterMode) {
case FbxCluster::eNormalize: {
float oneOverWeightSum = 1.0f / weightSum;
// in this mode we need to normalize the weights
- for (unsigned long i = 0; i < outWeights[vertexID].size(); i++) {
+ for (unsigned long i = 0; i < outWeights[vertexID].size(); i++)
outWeights[vertexID][i].m_Weight *= oneOverWeightSum;
- }
} break;
case FbxCluster::eTotalOne: {
// in this mode we must sum up to one
if (weightSum < 1.0f) {
- outWeights[vertexID].push_back(_SVertexWeightInfo(
- 0, 1.0f - weightSum, inFbxMesh->GetControlPoints()[vertexID]));
+ outWeights[vertexID].push_back(
+ _SVertexWeightInfo(0, 1.0f - weightSum,
+ inFbxMesh->GetControlPoints()[vertexID]));
}
} break;
case FbxCluster::eAdditive:
@@ -988,10 +1042,10 @@ void FbxDomWalker::GenerateMeshTangents(const FbxMesh *inFbxMesh,
// normal data
const FbxGeometryElementNormal *theFbxNormals = inFbxMesh->GetElementNormal();
- int theFbxNormalCount = 0;
+ size_t theFbxNormalCount = 0;
FbxGeometryElement::EMappingMode theFbxNormalsMappingMode = FbxGeometryElement::eNone;
if (theFbxNormals) {
- theFbxNormalCount = theFbxNormals->GetDirectArray().GetCount();
+ theFbxNormalCount = size_t(theFbxNormals->GetDirectArray().GetCount());
theFbxNormalsMappingMode = theFbxNormals->GetMappingMode();
}
// uv data
@@ -1004,9 +1058,8 @@ void FbxDomWalker::GenerateMeshTangents(const FbxMesh *inFbxMesh,
}
// we need normals and uv's
- if (theFbxNormalCount == 0 || theFbxUVsCount == 0) {
+ if (theFbxNormalCount == 0 || theFbxUVsCount == 0)
return;
- }
// allocate arrays
SVector3 *tan1 = new SVector3[theFbxNormalCount * 2];
@@ -1038,53 +1091,41 @@ void FbxDomWalker::GenerateMeshTangents(const FbxMesh *inFbxMesh,
// read vertex 1 data
int theFbxCtrlPointIndex1 = inFbxMesh->GetPolygonVertex(i, 0);
- ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex1, (float *)vx1, identidy);
+ ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex1, static_cast<float *>(vx1), identidy);
ReadNormal(theFbxNormals, (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex1,
- (float *)n1);
+ ? theVertexID : theFbxCtrlPointIndex1, static_cast<float *>(n1));
ReadTexCoord(theFbxUVs, (theFbxUVsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex1,
- (float *)uv1);
+ ? theVertexID : theFbxCtrlPointIndex1, static_cast<float *>(uv1));
theFbxCtrlPointIndex1 = GetNormalIndex(
- theFbxNormals, (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex1);
+ theFbxNormals,
+ (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
+ ? theVertexID : theFbxCtrlPointIndex1);
++theVertexID;
// read vertex 2 data
int theFbxCtrlPointIndex2 = inFbxMesh->GetPolygonVertex(i, 1);
- ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex2, (float *)vx2, identidy);
+ ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex2, static_cast<float *>(vx2), identidy);
ReadNormal(theFbxNormals, (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex2,
- (float *)n2);
+ ? theVertexID : theFbxCtrlPointIndex2, static_cast<float *>(n2));
ReadTexCoord(theFbxUVs, (theFbxUVsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex2,
- (float *)uv2);
+ ? theVertexID : theFbxCtrlPointIndex2, static_cast<float *>(uv2));
theFbxCtrlPointIndex2 = GetNormalIndex(
- theFbxNormals, (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex2);
+ theFbxNormals,
+ (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
+ ? theVertexID : theFbxCtrlPointIndex2);
++theVertexID;
// read vertex 3 data
int theFbxCtrlPointIndex3 = inFbxMesh->GetPolygonVertex(i, 2);
- ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex3, (float *)vx3, identidy);
+ ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex3, static_cast<float *>(vx3), identidy);
ReadNormal(theFbxNormals, (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex3,
- (float *)n3);
+ ? theVertexID : theFbxCtrlPointIndex3, static_cast<float *>(n3));
ReadTexCoord(theFbxUVs, (theFbxUVsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex3,
- (float *)uv3);
+ ? theVertexID : theFbxCtrlPointIndex3, static_cast<float *>(uv3));
theFbxCtrlPointIndex3 = GetNormalIndex(
- theFbxNormals, (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex3);
+ theFbxNormals,
+ (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
+ ? theVertexID : theFbxCtrlPointIndex3);
++theVertexID;
// compute triangle vectors
@@ -1101,8 +1142,8 @@ void FbxDomWalker::GenerateMeshTangents(const FbxMesh *inFbxMesh,
float t2 = uv3[1] - uv1[1];
float area = (s1 * t2 - s2 * t1);
- if (area == 0.0)
- area = 1.0;
+ if (area == 0.0f)
+ area = 1.0f;
float r = 1.0f / area;
@@ -1152,7 +1193,7 @@ void FbxDomWalker::GenerateMeshTangents(const FbxMesh *inFbxMesh,
outTangents.resize(theFbxNormalCount);
outBinormals.resize(theFbxNormalCount);
// compute actual tangents
- for (int i = 0; i < theFbxNormalCount; i++) {
+ for (size_t i = 0; i < theFbxNormalCount; i++) {
QT3DSVec3 n(normals[i][0], normals[i][1], normals[i][2]);
const qt3ds::QT3DSVec3 t(tan1[i][0], tan1[i][1], tan1[i][2]);
const qt3ds::QT3DSVec3 t2(tan2[i][0], tan2[i][1], tan2[i][2]);
@@ -1200,7 +1241,7 @@ long RetrieveFaceIndex(FbxDomWalker::TFaceIndicies &ioFaceIndicies,
std::pair<FbxDomWalker::TFaceIndicies::first_type::iterator, bool> theTupleEntry;
theTupleEntry = ioFaceIndicies.first.insert(
- std::make_pair(inFaceValues, (long)(ioFaceIndicies.first.size())));
+ std::make_pair(inFaceValues, long(ioFaceIndicies.first.size())));
return theTupleEntry.first->second;
}
@@ -1253,8 +1294,8 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
if (theFbxNormals) {
theFbxNormalCount = theFbxNormals->GetDirectArray().GetCount();
theFbxNormalsMappingMode = theFbxNormals->GetMappingMode();
- canUseDirectMode &=
- (theFbxNormalsMappingMode == FbxGeometryElement::eByControlPoint) ? true : false;
+ canUseDirectMode &= (theFbxNormalsMappingMode == FbxGeometryElement::eByControlPoint)
+ ? true : false;
}
// uv data
int theFbxUVsSetCount = theFbxMesh->GetElementUVCount(); // overall uv set count
@@ -1265,8 +1306,8 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
if (theFbxUVs) {
theFbxUVsCount = theFbxUVs->GetDirectArray().GetCount();
theFbxUVsMappingMode = theFbxUVs->GetMappingMode();
- canUseDirectMode &=
- (theFbxUVsMappingMode == FbxGeometryElement::eByControlPoint) ? true : false;
+ canUseDirectMode &= (theFbxUVsMappingMode == FbxGeometryElement::eByControlPoint)
+ ? true : false;
}
// uv data second set
const FbxGeometryElementUV *theFbxUV2s = theFbxMesh->GetElementUV(1);
@@ -1275,8 +1316,8 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
if (theFbxUV2s && theFbxUVsSetCount > 1) {
theFbxUV2sCount = theFbxUV2s->GetDirectArray().GetCount();
theFbxUV2sMappingMode = theFbxUV2s->GetMappingMode();
- canUseDirectMode &=
- (theFbxUV2sMappingMode == FbxGeometryElement::eByControlPoint) ? true : false;
+ canUseDirectMode &= (theFbxUV2sMappingMode == FbxGeometryElement::eByControlPoint)
+ ? true : false;
}
// tangent data
@@ -1286,8 +1327,8 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
if (theFbxTangents) {
theFbxTangentsCount = theFbxTangents->GetDirectArray().GetCount();
theFbxTangentsMappingMode = theFbxTangents->GetMappingMode();
- canUseDirectMode &=
- (theFbxTangentsMappingMode == FbxGeometryElement::eByControlPoint) ? true : false;
+ canUseDirectMode &= (theFbxTangentsMappingMode == FbxGeometryElement::eByControlPoint)
+ ? true : false;
}
// binormal data
FbxGeometryElementBinormal *theFbxBinormals = theFbxMesh->GetElementBinormal();
@@ -1296,8 +1337,8 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
if (theFbxBinormals) {
theFbxBinormalsCount = theFbxBinormals->GetDirectArray().GetCount();
theFbxBinormalsMappingMode = theFbxBinormals->GetMappingMode();
- canUseDirectMode &=
- (theFbxBinormalsMappingMode == FbxGeometryElement::eByControlPoint) ? true : false;
+ canUseDirectMode &= (theFbxBinormalsMappingMode == FbxGeometryElement::eByControlPoint)
+ ? true : false;
}
// material data
FbxGeometryElementMaterial *theFbxMaterials = theFbxMesh->GetElementMaterial();
@@ -1320,9 +1361,8 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
// check if we need to generate tangents and binormals
std::vector<SVector3> newTangents;
std::vector<SVector3> newBinormals;
- if (!theFbxTangents && !theFbxBinormals) {
+ if (!theFbxTangents && !theFbxBinormals)
GenerateMeshTangents(theFbxMesh, newTangents, newBinormals);
- }
// polygon data
int theFbxTriangleCount = theFbxMesh->GetPolygonCount();
@@ -1332,7 +1372,7 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
QueryMaterialInfo(theFbxMesh, &thePerFaceMaterialnfo);
TLongsList theMaterialFaceIndicies;
- theMaterialFaceIndicies.reserve(theFbxTriangleCount);
+ theMaterialFaceIndicies.reserve(size_t(theFbxTriangleCount));
// When we build a transform history we build everything into one matrix
// but the geometric transform is not inherited therefore
@@ -1343,12 +1383,12 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
canUseDirectMode = false; // currently disabled
if (canUseDirectMode) {
QT3DS_ASSERT(!theFbxNormals
- || theFbxNormalsMappingMode == FbxGeometryElement::eByControlPoint);
+ || theFbxNormalsMappingMode == FbxGeometryElement::eByControlPoint);
QT3DS_ASSERT(!theFbxUVs || theFbxUVsMappingMode == FbxGeometryElement::eByControlPoint);
QT3DS_ASSERT(!theFbxTangents
- || theFbxTangentsMappingMode == FbxGeometryElement::eByControlPoint);
+ || theFbxTangentsMappingMode == FbxGeometryElement::eByControlPoint);
QT3DS_ASSERT(!theFbxBinormals
- || theFbxBinormalsMappingMode == FbxGeometryElement::eByControlPoint);
+ || theFbxBinormalsMappingMode == FbxGeometryElement::eByControlPoint);
for (int i = 0; i < theFbxCtrlPointCount; ++i) {
TVertexInfoTuple theFaceTupleValues;
@@ -1398,7 +1438,7 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
int theFbxCtrlPointIndex = theFbxMesh->GetPolygonVertex(i, j);
QT3DS_ASSERT(theFbxMesh->GetPolygonSize(i) == 3);
QT3DS_ASSERT(theFbxCtrlPointIndex < theFbxCtrlPointCount
- && theFbxCtrlPointIndex != -1);
+ && theFbxCtrlPointIndex != -1);
ReadVertex(theFbxCtrlPoints, theFbxCtrlPointIndex, get<0>(theFaceTupleValues),
geomTransform);
@@ -1406,68 +1446,54 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
if (theFbxNormals) {
ReadNormal(theFbxNormals,
(theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
- get<1>(theFaceTupleValues));
+ ? theVertexID : theFbxCtrlPointIndex, get<1>(theFaceTupleValues));
}
if (theFbxUVs) {
ReadTexCoord(theFbxUVs,
(theFbxUVsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
- get<2>(theFaceTupleValues));
+ ? theVertexID : theFbxCtrlPointIndex, get<2>(theFaceTupleValues));
}
if (theFbxTangents) {
ReadTexTangent(theFbxTangents, (theFbxTangentsMappingMode
== FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
+ ? theVertexID : theFbxCtrlPointIndex,
get<3>(theFaceTupleValues));
} else if (newTangents.size() > 0) {
// we use the mapping as the normals
ReadTexTangent(
- newTangents, theFbxNormals,
- (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
- get<3>(theFaceTupleValues));
+ newTangents, theFbxNormals,
+ (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
+ ? theVertexID : theFbxCtrlPointIndex, get<3>(theFaceTupleValues));
}
if (theFbxBinormals) {
ReadTexBinormal(theFbxBinormals, (theFbxBinormalsMappingMode
== FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
+ ? theVertexID : theFbxCtrlPointIndex,
get<4>(theFaceTupleValues));
} else if (newBinormals.size() > 0) {
ReadTexBinormal(
- newBinormals, theFbxNormals,
- (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
- get<4>(theFaceTupleValues));
+ newBinormals, theFbxNormals,
+ (theFbxNormalsMappingMode == FbxGeometryElement::eByPolygonVertex)
+ ? theVertexID : theFbxCtrlPointIndex, get<4>(theFaceTupleValues));
}
if (theVertexWeights.size() > 0) {
- ReadWeight(theVertexWeights[theFbxCtrlPointIndex], theFbxCtrlPointIndex,
+ ReadWeight(theVertexWeights[size_t(theFbxCtrlPointIndex)], theFbxCtrlPointIndex,
get<5>(theFaceTupleValues));
- ReadBoneIndex(theVertexWeights[theFbxCtrlPointIndex], theFbxCtrlPointIndex,
- get<6>(theFaceTupleValues), theJointInfoList);
+ ReadBoneIndex(theVertexWeights[size_t(theFbxCtrlPointIndex)],
+ theFbxCtrlPointIndex, get<6>(theFaceTupleValues), theJointInfoList);
}
if (theFbxUV2s) {
ReadTexCoord(theFbxUV2s,
(theFbxUV2sMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
- get<7>(theFaceTupleValues));
+ ? theVertexID : theFbxCtrlPointIndex, get<7>(theFaceTupleValues));
}
if (theFbxColors) {
ReadColor(theFbxColors,
(theFbxColorsMappingMode == FbxGeometryElement::eByPolygonVertex)
- ? theVertexID
- : theFbxCtrlPointIndex,
- get<8>(theFaceTupleValues));
+ ? theVertexID : theFbxCtrlPointIndex, get<8>(theFaceTupleValues));
}
long theFaceIndex = RetrieveFaceIndex(theFaceIndices, theFaceTupleValues);
@@ -1503,30 +1529,25 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
TFloatsList theColors;
// Prepare arrays for population
- long theNumberOfUniqueFacePoints = (long)theFaceIndices.first.size();
+ size_t theNumberOfUniqueFacePoints = theFaceIndices.first.size();
if (theNumberOfUniqueFacePoints == 0)
return;
theVertices.resize(theNumberOfUniqueFacePoints * 3);
- if (theFbxNormals) {
+ if (theFbxNormals)
theNormals.resize(theNumberOfUniqueFacePoints * 3);
- }
- if (theFbxUVs) {
+ if (theFbxUVs)
theTexCoords.resize(theNumberOfUniqueFacePoints * 2);
- }
- if (theFbxTangents || newTangents.size() > 0) {
+ if (theFbxTangents || newTangents.size() > 0)
theTexTangents.resize(theNumberOfUniqueFacePoints * 3);
- }
- if (theFbxBinormals || newBinormals.size() > 0) {
+ if (theFbxBinormals || newBinormals.size() > 0)
theTexBinormals.resize(theNumberOfUniqueFacePoints * 3);
- }
if (theVertexWeights.size() > 0) {
theWeights.resize(theNumberOfUniqueFacePoints * 4);
theBoneIndex.resize(theNumberOfUniqueFacePoints * 4);
}
- if (theFbxUV2s) {
+ if (theFbxUV2s)
theTexCoords2.resize(theNumberOfUniqueFacePoints * 2);
- }
if (theFbxColors)
theColors.resize(theNumberOfUniqueFacePoints * 3);
@@ -1534,7 +1555,7 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
TFaceIndicies::first_type::const_iterator theIter = theFaceIndices.first.begin();
TFaceIndicies::first_type::const_iterator theEnd = theFaceIndices.first.end();
for (; theIter != theEnd; ++theIter) {
- long theFaceIndex = theIter->second;
+ size_t theFaceIndex = size_t(theIter->second);
const TVertexInfoTuple &thePointTuple = theIter->first;
WriteFloat3(theVertices, theFaceIndex, get<0>(thePointTuple));
@@ -1575,12 +1596,14 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
for (size_t elCount = 0; elCount < thePerFaceMaterialnfo.m_MatElementsIDs.size();
elCount++) {
FbxGeometryElementMaterial *theMaterialElement = theFbxMesh->GetElementMaterial(
- thePerFaceMaterialnfo.m_MatElementsIDs.at(elCount));
+ thePerFaceMaterialnfo.m_MatElementsIDs.at(elCount));
FbxSurfaceMaterial *theMaterial = inFbxNode->GetMaterial(
- theMaterialElement->GetIndexArray().GetAt(thePerFaceMaterialnfo.m_StartFace));
- if (theMaterial)
- ReadMaterial(theMaterial, thePerFaceMaterialnfo.m_StartFace,
- thePerFaceMaterialnfo.m_FaceCount);
+ theMaterialElement->GetIndexArray().GetAt(
+ int(thePerFaceMaterialnfo.m_StartFace)));
+ if (theMaterial) {
+ ReadMaterial(theMaterial, int(thePerFaceMaterialnfo.m_StartFace),
+ int(thePerFaceMaterialnfo.m_FaceCount));
+ }
}
}
} else if (theFbxNormals) {
@@ -1589,17 +1612,16 @@ void FbxDomWalker::ProcessMesh(FbxNode *inFbxNode)
thePerFaceMaterialnfo.m_FaceCount = theFbxTriangleCount - thePerFaceMaterialnfo.m_StartFace;
theFaceMaterialIndices.push_back(thePerFaceMaterialnfo);
- ReadDefaultMaterial(inFbxNode, thePerFaceMaterialnfo.m_StartFace,
- thePerFaceMaterialnfo.m_FaceCount);
+ ReadDefaultMaterial(inFbxNode, int(thePerFaceMaterialnfo.m_StartFace),
+ int(thePerFaceMaterialnfo.m_FaceCount));
}
// stream out joint info if any
if (theJointInfoList.size()) {
TJointInfoList::iterator theIter;
- for (theIter = theJointInfoList.begin(); theIter != theJointInfoList.end(); theIter++) {
+ for (theIter = theJointInfoList.begin(); theIter != theJointInfoList.end(); theIter++)
m_Translator->SetJointNode(*theIter);
- }
}
// Here we process a skeleton hierarchy which belongs to a mesh.
@@ -1642,9 +1664,9 @@ void FbxDomWalker::ReadVertex(const FbxVector4 *inFbxCtrlPoints, int inFbxCtrlPo
const FbxVector4 &inCtrlPoint = inFbxCtrlPoints[inFbxCtrlPointIndex];
FbxVector4 transformedCtrlPoint = geometricTransformation.MultT(inCtrlPoint);
- outValue[0] = (float)transformedCtrlPoint[0];
- outValue[1] = (float)transformedCtrlPoint[1];
- outValue[2] = (float)transformedCtrlPoint[2];
+ outValue[0] = float(transformedCtrlPoint[0]);
+ outValue[1] = float(transformedCtrlPoint[1]);
+ outValue[2] = float(transformedCtrlPoint[2]);
}
/**
@@ -1659,8 +1681,9 @@ void FbxDomWalker::ReadVertex(const FbxVector4 *inFbxCtrlPoints, int inFbxCtrlPo
* @return no return.
*/
void FbxDomWalker::ReadVertex(const TPerVertexWeightInfo &inFbxWeights,
- int /* inFbxCtrlPointIndex */, float *outValue)
+ int inFbxCtrlPointIndex, float *outValue)
{
+ Q_UNUSED(inFbxCtrlPointIndex)
outValue[0] = inFbxWeights[0].m_Position[0];
outValue[1] = inFbxWeights[0].m_Position[1];
outValue[2] = inFbxWeights[0].m_Position[2];
@@ -1693,9 +1716,9 @@ void FbxDomWalker::ReadNormal(const FbxGeometryElementNormal *inFbxNormals, int
FbxVector4 theNormal = inFbxNormals->GetDirectArray().GetAt(theFbxNormalIndex);
- outValue[0] = (float)theNormal[0];
- outValue[1] = (float)theNormal[1];
- outValue[2] = (float)theNormal[2];
+ outValue[0] = float(theNormal[0]);
+ outValue[1] = float(theNormal[1]);
+ outValue[2] = float(theNormal[2]);
}
void FbxDomWalker::ReadColor(const FbxGeometryElementVertexColor *inFbxColors, int inFbxIndex,
@@ -1716,9 +1739,9 @@ void FbxDomWalker::ReadColor(const FbxGeometryElementVertexColor *inFbxColors, i
FbxColor theColor = inFbxColors->GetDirectArray().GetAt(theFbxColorIndex);
- outValue[0] = (float)theColor.mRed;
- outValue[1] = (float)theColor.mGreen;
- outValue[2] = (float)theColor.mBlue;
+ outValue[0] = float(theColor.mRed);
+ outValue[1] = float(theColor.mGreen);
+ outValue[2] = float(theColor.mBlue);
}
/**
@@ -1747,8 +1770,8 @@ void FbxDomWalker::ReadTexCoord(const FbxGeometryElementUV *inFbxUVs, int inFbxI
}
const FbxVector2 uv(inFbxUVs->GetDirectArray().GetAt(theFbxUVIndex));
- outValue[0] = (float) uv[0];
- outValue[1] = (float) uv[1];
+ outValue[0] = float(uv[0]);
+ outValue[1] = float(uv[1]);
}
/**
@@ -1778,9 +1801,9 @@ void FbxDomWalker::ReadTexTangent(const FbxGeometryElementTangent *inFbxTangents
FbxVector4 theTexTangent = inFbxTangents->GetDirectArray().GetAt(theFbxTangentIndex);
- outValue[0] = (float)theTexTangent[0];
- outValue[1] = (float)theTexTangent[1];
- outValue[2] = (float)theTexTangent[2];
+ outValue[0] = float(theTexTangent[0]);
+ outValue[1] = float(theTexTangent[1]);
+ outValue[2] = float(theTexTangent[2]);
}
/**
@@ -1796,13 +1819,13 @@ void FbxDomWalker::ReadTexTangent(std::vector<SVector3> &inTangentPoints,
const FbxGeometryElementNormal *inFbxNormals, int inFbxIndex,
float *outValue)
{
- int theFbxTangentIndex = 0;
+ size_t theFbxTangentIndex = 0;
switch (inFbxNormals->GetReferenceMode()) {
case FbxGeometryElement::eDirect:
- theFbxTangentIndex = inFbxIndex;
+ theFbxTangentIndex = size_t(inFbxIndex);
break;
case FbxGeometryElement::eIndexToDirect:
- theFbxTangentIndex = inFbxNormals->GetIndexArray().GetAt(inFbxIndex);
+ theFbxTangentIndex = size_t(inFbxNormals->GetIndexArray().GetAt(inFbxIndex));
break;
default:
QT3DS_ASSERT(false);
@@ -1841,9 +1864,9 @@ void FbxDomWalker::ReadTexBinormal(const FbxGeometryElementBinormal *inFbxBinorm
FbxVector4 theTexBinormal = inFbxBinormals->GetDirectArray().GetAt(theFbxBinormalIndex);
- outValue[0] = (float)theTexBinormal[0];
- outValue[1] = (float)theTexBinormal[1];
- outValue[2] = (float)theTexBinormal[2];
+ outValue[0] = float(theTexBinormal[0]);
+ outValue[1] = float(theTexBinormal[1]);
+ outValue[2] = float(theTexBinormal[2]);
}
/**
@@ -1859,13 +1882,13 @@ void FbxDomWalker::ReadTexBinormal(std::vector<SVector3> &inBinormalPoints,
const FbxGeometryElementNormal *inFbxNormals, int inFbxIndex,
float *outValue)
{
- int theFbxBinormalIndex = 0;
+ size_t theFbxBinormalIndex = 0;
switch (inFbxNormals->GetReferenceMode()) {
case FbxGeometryElement::eDirect:
- theFbxBinormalIndex = inFbxIndex;
+ theFbxBinormalIndex = size_t(inFbxIndex);
break;
case FbxGeometryElement::eIndexToDirect:
- theFbxBinormalIndex = inFbxNormals->GetIndexArray().GetAt(inFbxIndex);
+ theFbxBinormalIndex = size_t(inFbxNormals->GetIndexArray().GetAt(inFbxIndex));
break;
default:
QT3DS_ASSERT(false);
@@ -1887,13 +1910,13 @@ void FbxDomWalker::ReadTexBinormal(std::vector<SVector3> &inBinormalPoints,
* @return no return.
*/
void FbxDomWalker::ReadWeight(const FbxDomWalker::TPerVertexWeightInfo &inFbxWeights,
- int /* inFbxIndex */, float *outValue)
+ int inFbxIndex, float *outValue)
{
+ Q_UNUSED(inFbxIndex)
// clear since we might not use all values
outValue[0] = outValue[1] = outValue[2] = outValue[3] = 0;
- for (unsigned long i = 0; i < inFbxWeights.size() && i < 4; i++) {
+ for (unsigned long i = 0; i < inFbxWeights.size() && i < 4; i++)
outValue[i] = inFbxWeights[i].m_Weight;
- }
}
/**
@@ -1907,9 +1930,10 @@ void FbxDomWalker::ReadWeight(const FbxDomWalker::TPerVertexWeightInfo &inFbxWei
* @return no return.
*/
void FbxDomWalker::ReadBoneIndex(const FbxDomWalker::TPerVertexWeightInfo &inFbxWeights,
- int /* inFbxIndex */, float *outValue,
+ int inFbxIndex, float *outValue,
const TJointInfoList &inAbsoluteJoints)
{
+ Q_UNUSED(inFbxIndex)
// clear since we might not use all values
outValue[0] = outValue[1] = outValue[2] = outValue[3] = 0;
@@ -1924,7 +1948,7 @@ void FbxDomWalker::ReadBoneIndex(const FbxDomWalker::TPerVertexWeightInfo &inFbx
break;
}
}
- outValue[i] = (float)relativeIndex;
+ outValue[i] = float(relativeIndex);
}
}
@@ -1941,15 +1965,15 @@ void FbxDomWalker::ProcessTextureParameter(FbxTexture *inTexture,
{
if (inTexture) {
outTextureParameters.m_Flag = true;
- outTextureParameters.m_offsetU.SetValue(inTexture->GetTranslationU());
- outTextureParameters.m_offsetV.SetValue(inTexture->GetTranslationV());
- outTextureParameters.m_repeatU.SetValue(inTexture->GetScaleU());
- outTextureParameters.m_repeatV.SetValue(inTexture->GetScaleV());
+ outTextureParameters.m_offsetU.SetValue(float(inTexture->GetTranslationU()));
+ outTextureParameters.m_offsetV.SetValue(float(inTexture->GetTranslationV()));
+ outTextureParameters.m_repeatU.SetValue(float(inTexture->GetScaleU()));
+ outTextureParameters.m_repeatV.SetValue(float(inTexture->GetScaleV()));
#if 0
// TODO: These parameters do not work correctly with current math in SetTexture, so they are
// ignored for now. Created a task (QT3DS-2255) to implement support later, if deemed
// necessary.
- outTextureParameters.m_rotateUV.SetValue(inTexture->GetRotationW());
+ outTextureParameters.m_rotateUV.SetValue(float(inTexture->GetRotationW()));
outTextureParameters.m_mirrorU.SetValue(inTexture->GetSwapUV());
outTextureParameters.m_mirrorV.SetValue(inTexture->GetSwapUV());
#endif
@@ -2035,8 +2059,8 @@ void FbxDomWalker::QueryMaterialInfo(FbxMesh *fbxMesh, SFaceMaterialInfo *info)
FbxSurfaceMaterial *theMaterial = nullptr;
int theMatId = -1;
theMaterial = fbxMesh->GetNode()->GetMaterial(
- theMaterialElement->GetIndexArray().GetAt(info->m_StartFace));
- theMatId = theMaterialElement->GetIndexArray().GetAt(info->m_StartFace);
+ theMaterialElement->GetIndexArray().GetAt(int(info->m_StartFace)));
+ theMatId = theMaterialElement->GetIndexArray().GetAt(int(info->m_StartFace));
if (theMatId >= 0) {
info->m_MatElementsIDs.push_back(l);
@@ -2054,7 +2078,7 @@ void FbxDomWalker::QueryMaterialInfo(FbxMesh *fbxMesh, SFaceMaterialInfo *info)
*
* @return no return.
*/
-void FbxDomWalker::ReadMaterial(const FbxSurfaceMaterial *inMaterial, const int startFace,
+void FbxDomWalker::ReadMaterial(FbxSurfaceMaterial *inMaterial, const int startFace,
const int faceCount)
{
SMaterialParameters theNewMaterial;
@@ -2071,48 +2095,102 @@ void FbxDomWalker::ReadMaterial(const FbxSurfaceMaterial *inMaterial, const int
// init some base values
theNewMaterial.m_Ambient.SetColor(0, 0, 0, 1);
theNewMaterial.m_Diffuse.SetColor(1, 1, 1, 1);
+ theNewMaterial.m_TechniqueType = EMatCommonProfileTechnique_Constant;
+
+ if (m_AuthoringToolType == EAuthoringToolType_FBX_Max
+ && !inMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId)
+ && !inMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) {
+ // For 3ds Max FBX try getting initial values from FbxSurfaceMaterial, as it may not
+ // have defined surface material type correctly. Ignore attenuations for colors.
+ FbxProperty theProperty = inMaterial->FindProperty(FbxSurfaceMaterial::sAmbient);
+ if (theProperty.IsValid()) {
+ fbxColor = theProperty.Get<FbxDouble3>();
+ theNewMaterial.m_Ambient.SetColor(float(fbxColor.mData[0]), float(fbxColor.mData[1]),
+ float(fbxColor.mData[2]), 1);
+ }
+ theProperty = inMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
+ if (theProperty.IsValid()) {
+ fbxColor = theProperty.Get<FbxDouble3>();
+ theNewMaterial.m_Diffuse.SetColor(float(fbxColor.mData[0]), float(fbxColor.mData[1]),
+ float(fbxColor.mData[2]), 1);
+ }
+ theProperty = inMaterial->FindProperty(FbxSurfaceMaterial::sEmissive);
+ if (theProperty.IsValid()) {
+ fbxColor = theProperty.Get<FbxDouble3>();
+ theNewMaterial.m_Emission.SetColor(float(fbxColor.mData[0]), float(fbxColor.mData[1]),
+ float(fbxColor.mData[2]), 1);
+ }
+ theProperty = inMaterial->FindProperty(FbxSurfaceMaterial::sTransparentColor);
+ if (theProperty.IsValid()) {
+ fbxColor = theProperty.Get<FbxDouble3>();
+ theNewMaterial.m_Transparent.SetColor(float(fbxColor.mData[0]),
+ float(fbxColor.mData[1]), float(fbxColor.mData[2]), 1);
+ }
+ theProperty = inMaterial->FindProperty(FbxSurfaceMaterial::sSpecular);
+ if (theProperty.IsValid()) {
+ fbxColor = theProperty.Get<FbxDouble3>();
+ // Based on tests with an FBX with "unknown" surface material type we might only have
+ // specular color. If that is the case, replace fully black diffuse color with it
+ // instead of applying it to specular.
+ if (theNewMaterial.m_Diffuse.m_Color[0] == 0.0f
+ && theNewMaterial.m_Diffuse.m_Color[1] == 0.0f
+ && theNewMaterial.m_Diffuse.m_Color[2] == 0.0f) {
+ theNewMaterial.m_Diffuse.SetColor(float(fbxColor.mData[0]),
+ float(fbxColor.mData[1]), float(fbxColor.mData[2]), 1);
+ } else {
+ theNewMaterial.m_Specular.SetColor(float(fbxColor.mData[0]),
+ float(fbxColor.mData[1]), float(fbxColor.mData[2]), 1);
+ }
+ }
+ }
if (inMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId)) {
// lambert is base for all materials
// for phong we override the type and read the additional values later below
- FbxSurfaceLambert *lambertMaterial = (FbxSurfaceLambert *)inMaterial;
+ FbxSurfaceLambert *lambertMaterial = static_cast<FbxSurfaceLambert *>(inMaterial);
theNewMaterial.m_TechniqueType = EMatCommonProfileTechnique_Lambert;
fbxColor = lambertMaterial->Ambient;
- attenuationFactor = (float)lambertMaterial->AmbientFactor;
- theNewMaterial.m_Ambient.SetColor((float)fbxColor.mData[0] * attenuationFactor,
- (float)fbxColor.mData[1] * attenuationFactor,
- (float)fbxColor.mData[2] * attenuationFactor, 1);
+ attenuationFactor = float(lambertMaterial->AmbientFactor);
+ theNewMaterial.m_Ambient.SetColor(float(fbxColor.mData[0]) * attenuationFactor,
+ float(fbxColor.mData[1]) * attenuationFactor,
+ float(fbxColor.mData[2]) * attenuationFactor, 1);
fbxColor = lambertMaterial->Diffuse;
- attenuationFactor = (float)lambertMaterial->DiffuseFactor;
- theNewMaterial.m_Diffuse.SetColor((float)fbxColor.mData[0] * attenuationFactor,
- (float)fbxColor.mData[1] * attenuationFactor,
- (float)fbxColor.mData[2] * attenuationFactor, 1);
+ attenuationFactor = float(lambertMaterial->DiffuseFactor);
+ theNewMaterial.m_Diffuse.SetColor(float(fbxColor.mData[0]) * attenuationFactor,
+ float(fbxColor.mData[1]) * attenuationFactor,
+ float(fbxColor.mData[2]) * attenuationFactor, 1);
fbxColor = lambertMaterial->Emissive;
- attenuationFactor = (float)lambertMaterial->EmissiveFactor;
- theNewMaterial.m_Emission.SetColor((float)fbxColor.mData[0] * attenuationFactor,
- (float)fbxColor.mData[1] * attenuationFactor,
- (float)fbxColor.mData[2] * attenuationFactor, 1);
+ attenuationFactor = float(lambertMaterial->EmissiveFactor);
+ theNewMaterial.m_Emission.SetColor(float(fbxColor.mData[0]) * attenuationFactor,
+ float(fbxColor.mData[1]) * attenuationFactor,
+ float(fbxColor.mData[2]) * attenuationFactor, 1);
fbxColor = lambertMaterial->TransparentColor;
- theNewMaterial.m_Transparent.SetColor((float)fbxColor.mData[0], (float)fbxColor.mData[1],
- (float)fbxColor.mData[2], 1);
- theNewMaterial.m_Transparency.SetValue((float)lambertMaterial->TransparencyFactor);
+ theNewMaterial.m_Transparent.SetColor(float(fbxColor.mData[0]), float(fbxColor.mData[1]),
+ float(fbxColor.mData[2]), 1);
+ theNewMaterial.m_Transparency.SetValue(float(lambertMaterial->TransparencyFactor));
}
if (inMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) {
- FbxSurfacePhong *phongMaterial = (FbxSurfacePhong *)inMaterial;
+ FbxSurfacePhong *phongMaterial = static_cast<FbxSurfacePhong *>(inMaterial);
theNewMaterial.m_TechniqueType = EMatCommonProfileTechnique_Phong;
fbxColor = phongMaterial->Specular;
- attenuationFactor = (float)phongMaterial->SpecularFactor;
- theNewMaterial.m_Specular.SetColor((float)fbxColor.mData[0] * attenuationFactor,
- (float)fbxColor.mData[1] * attenuationFactor,
- (float)fbxColor.mData[2] * attenuationFactor, 1);
+ attenuationFactor = float(phongMaterial->SpecularFactor);
+ theNewMaterial.m_Specular.SetColor(float(fbxColor.mData[0]) * attenuationFactor,
+ float(fbxColor.mData[1]) * attenuationFactor,
+ float(fbxColor.mData[2]) * attenuationFactor, 1);
fbxColor = phongMaterial->Reflection;
- theNewMaterial.m_Reflective.SetColor((float)fbxColor.mData[0], (float)fbxColor.mData[1],
- (float)fbxColor.mData[2], 1);
- theNewMaterial.m_Reflectivity.SetValue((float)phongMaterial->ReflectionFactor);
- theNewMaterial.m_Shininess.SetValue((float)phongMaterial->Shininess);
+ theNewMaterial.m_Reflective.SetColor(float(fbxColor.mData[0]), float(fbxColor.mData[1]),
+ float(fbxColor.mData[2]), 1);
+ theNewMaterial.m_Reflectivity.SetValue(float(phongMaterial->ReflectionFactor));
+ theNewMaterial.m_Shininess.SetValue(float(phongMaterial->Shininess));
+ }
+
+ if (!m_reportedUnknownMaterials
+ && theNewMaterial.m_TechniqueType == EMatCommonProfileTechnique_Constant) {
+ m_Translator->LogWarning(ESceneGraphWarningCode_UnknownMaterial, {});
+ m_reportedUnknownMaterials = true;
}
m_Translator->PushMaterial(inMaterial->GetName());
@@ -2158,14 +2236,14 @@ void FbxDomWalker::ReadDefaultMaterial(const FbxNode *inFbxNode, const int start
if (FbxColor3DT == theFbxType) {
FbxDouble3 theDouble3 = theProperty.Get<FbxDouble3>();
- theNewMaterial.m_Diffuse.SetColor((float)theDouble3[0], (float)theDouble3[1],
- (float)theDouble3[2], 1);
+ theNewMaterial.m_Diffuse.SetColor(float(theDouble3[0]), float(theDouble3[1]),
+ float(theDouble3[2]), 1);
break;
} else if (FbxColor4DT == theFbxType) {
FbxDouble4 theDouble4 = theProperty.Get<FbxDouble4>();
- theNewMaterial.m_Diffuse.SetColor((float)theDouble4[0], (float)theDouble4[1],
- (float)theDouble4[2], (float)theDouble4[3]);
+ theNewMaterial.m_Diffuse.SetColor(float(theDouble4[0]), float(theDouble4[1]),
+ float(theDouble4[2]), float(theDouble4[3]));
break;
}
@@ -2342,7 +2420,7 @@ inline void WriteKeyframe(const FbxAnimCurveKey &inKey, const char *transformTyp
const char *channelName, qt3dsimp::ISceneGraphTranslation *inTranslator)
{
// Create a key
- SKeyframeParameters theKeyframeInfo((float)inKey.GetTime().GetSecondDouble(), inKey.GetValue(),
+ SKeyframeParameters theKeyframeInfo(float(inKey.GetTime().GetSecondDouble()), inKey.GetValue(),
0, 0, 0, 0);
// Set information about the key
@@ -2396,8 +2474,8 @@ void FbxDomWalker::ProcessAnimLayer(FbxNode *inNode, FbxAnimLayer *inAnimLayer)
FbxNodeAttribute *nodeAttribute = inNode->GetNodeAttribute();
if (nodeAttribute) {
redAnimCurve = nodeAttribute->Color.GetCurve(inAnimLayer, FBXSDK_CURVENODE_COLOR_RED);
- greenAnimCurve =
- nodeAttribute->Color.GetCurve(inAnimLayer, FBXSDK_CURVENODE_COLOR_GREEN);
+ greenAnimCurve = nodeAttribute->Color.GetCurve(inAnimLayer,
+ FBXSDK_CURVENODE_COLOR_GREEN);
blueAnimCurve = nodeAttribute->Color.GetCurve(inAnimLayer, FBXSDK_CURVENODE_COLOR_BLUE);
}
@@ -2410,10 +2488,10 @@ void FbxDomWalker::ProcessAnimLayer(FbxNode *inNode, FbxAnimLayer *inAnimLayer)
m_Translator->CacheAnimationTrack();
m_Translator->SetAnimationTrack(FBXSDK_CURVENODE_TRANSLATION,
- theTranslateCurveNode->GetChannelName(i));
+ theTranslateCurveNode->GetChannelName(int(i)));
ProcessAnimCurve(theTranslateCurveNode->GetCurve(i), FBXSDK_CURVENODE_TRANSLATION,
- theTranslateCurveNode->GetChannelName(i));
+ theTranslateCurveNode->GetChannelName(int(i)));
}
}
@@ -2426,10 +2504,10 @@ void FbxDomWalker::ProcessAnimLayer(FbxNode *inNode, FbxAnimLayer *inAnimLayer)
m_Translator->CacheAnimationTrack();
m_Translator->SetAnimationTrack(FBXSDK_CURVENODE_ROTATION,
- theRotateCurveNode->GetChannelName(i));
+ theRotateCurveNode->GetChannelName(int(i)));
ProcessAnimCurve(theRotateCurveNode->GetCurve(i), FBXSDK_CURVENODE_ROTATION,
- theRotateCurveNode->GetChannelName(i));
+ theRotateCurveNode->GetChannelName(int(i)));
}
}
@@ -2442,10 +2520,10 @@ void FbxDomWalker::ProcessAnimLayer(FbxNode *inNode, FbxAnimLayer *inAnimLayer)
m_Translator->CacheAnimationTrack();
m_Translator->SetAnimationTrack(FBXSDK_CURVENODE_SCALING,
- theScaleCurveNode->GetChannelName(i));
+ theScaleCurveNode->GetChannelName(int(i)));
ProcessAnimCurve(theScaleCurveNode->GetCurve(i), FBXSDK_CURVENODE_SCALING,
- theScaleCurveNode->GetChannelName(i));
+ theScaleCurveNode->GetChannelName(int(i)));
}
}
@@ -2485,9 +2563,8 @@ void FbxDomWalker::ProcessAnimLayer(FbxNode *inNode, FbxAnimLayer *inAnimLayer)
m_NodeIsAnimatedMap.insert(std::make_pair(inNode, true));
// process node children
- for (int i = 0; i < inNode->GetChildCount(); ++i) {
+ for (int i = 0; i < inNode->GetChildCount(); ++i)
ProcessAnimLayer(inNode->GetChild(i), inAnimLayer);
- }
}
}
@@ -2497,19 +2574,26 @@ void FbxDomWalker::ProcessAnimLayer(FbxNode *inNode, FbxAnimLayer *inAnimLayer)
*
* @return no return.
*/
-void FbxDomWalker::ProcessAnimationStacks()
+bool FbxDomWalker::ProcessAnimationStacks()
{
if (m_FbxScene != nullptr) {
- // get animation stack count
+ int numAnimations = m_FbxScene->GetSrcObjectCount<FbxAnimCurve>()
+ + m_FbxScene->GetSrcObjectCount<FbxAnimCurveNode>();
+
+ if (numAnimations == 0) {
+ // No actual animations, bail out
+ return false;
+ }
+
+ // Get animation stack count
int numAnimStacks = m_FbxScene->GetSrcObjectCount<FbxAnimStack>();
- // iterate throug all animations stacks
+ // Iterate throug all animations stacks
for (int i = 0; i < numAnimStacks; i++) {
FbxAnimStack *theAnimStack = m_FbxScene->GetSrcObject<FbxAnimStack>(i);
-
if (theAnimStack) {
FbxNode *theRootNode = m_FbxScene->GetRootNode();
- // our internal animation system cannot handle pivots.
+ // Our internal animation system cannot handle pivots.
// This means fbx can contain "pre-rotations" which must be applied
// to the object before the aniamtion is applied. In addition this rotation
// is inherited to children. This messes up our converion entirely.
@@ -2517,16 +2601,16 @@ void FbxDomWalker::ProcessAnimationStacks()
theRootNode->ResetPivotSetAndConvertAnimation();
int numAnimLayers = theAnimStack->GetMemberCount<FbxAnimLayer>();
- // iterate throug all animations layers
+ // Iterate throug all animations layers
for (int n = 0; n < numAnimLayers; n++) {
FbxAnimLayer *theAnimLayer = theAnimStack->GetMember<FbxAnimLayer>(n);
- for (int nodeCount = 0; nodeCount < theRootNode->GetChildCount(); nodeCount++) {
+ for (int nodeCount = 0; nodeCount < theRootNode->GetChildCount(); nodeCount++)
ProcessAnimLayer(theRootNode->GetChild(nodeCount), theAnimLayer);
- }
}
}
}
}
+ return true;
}
} // End anonymous namespace
@@ -2541,14 +2625,15 @@ struct ScopedHelper
~ScopedHelper() { m_Helper.Release(); }
};
-bool CImportTranslation::ParseFbxFile(const std::string &fileName, Import &import, ISGTranslationLog &log)
+bool CImportTranslation::ParseFbxFile(const std::string &fileName, Import &import,
+ ISGTranslationLog &log)
{
ISceneGraphTranslation &transHelper = ISceneGraphTranslation::CreateTranslation(import, log);
ScopedHelper __scope(transHelper);
FbxDomWalker theDomWalker(&transHelper);
if (theDomWalker.LoadDocument(fileName)) {
- theDomWalker.ProcessAnimationStacks();
- theDomWalker.ProcessScene();
+ bool animated = theDomWalker.ProcessAnimationStacks();
+ theDomWalker.ProcessScene(animated);
return true;
}
return false;
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp
index 55d23c67..a098a301 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp
@@ -38,7 +38,6 @@
#include "foundation/Qt3DSVec3.h"
#include "foundation/Qt3DSMemoryBuffer.h"
#include "Qt3DSImportComposerTypes.h"
-#include "CommonConstants.h"
#include <QtCore/qstring.h>
@@ -247,7 +246,7 @@ void matrixFromAxisAngle(float inDegreeAngle, float inXAxis, float inYAxis, floa
return;
}
- inDegreeAngle *= (float)QT3DS_DEGREES_TO_RADIANS;
+ inDegreeAngle *= float(Q3DStudio::QT3DS_DEGREES_TO_RADIANS);
Q3DStudio::CVector3 theAxis(inXAxis, inYAxis, inZAxis);
if (theAxis.LengthSquared() != 1.0f)
@@ -406,7 +405,7 @@ public:
TCharPtr ToImport(const char *data)
{
- if (data == NULL || *data == 0)
+ if (data == nullptr || *data == 0)
return L"";
// Convert from multi byte to wide character string
@@ -428,7 +427,7 @@ public:
}
TCharPtr name(ToImport(inName));
- if (name == NULL || *name == 0)
+ if (name == nullptr || *name == 0)
name = ComposerObjectTypes::Convert(inType);
Q3DStudio::CFilePath objectName = Q3DStudio::CFilePath(name);
@@ -491,8 +490,6 @@ public:
void SetLightProperties(int type, const SFloat4 &color, double intensity, double linearfade,
double quadfade, bool shadows) override
{
- Q_UNUSED(linearfade)
- Q_UNUSED(quadfade)
TIMPHandle light = m_InstanceStack.back();
switch (type) {
case 0:
@@ -511,10 +508,8 @@ public:
}
m_Import.SetInstancePropertyValue(light, m_Light.m_LightColor, color);
m_Import.SetInstancePropertyValue(light, m_Light.m_Brightness, intensity);
- // TODO: These do not seem to be incuded in FbxLight. Kept here in case Collada has support
- // for them (QT3DS-2857)
- //m_Import.SetInstancePropertyValue(light, m_Light.m_LinearFade, linearfade);
- //m_Import.SetInstancePropertyValue(light, m_Light.m_ExpFade, quadfade);
+ m_Import.SetInstancePropertyValue(light, m_Light.m_LinearFade, linearfade);
+ m_Import.SetInstancePropertyValue(light, m_Light.m_ExpFade, quadfade);
m_Import.SetInstancePropertyValue(light, m_Light.m_CastShadow, shadows);
}
void PopLight() override { PopObject(); }
@@ -530,8 +525,10 @@ public:
m_Import.SetInstancePropertyValue(camera, m_Camera.m_ClipFar, clipend);
m_Import.SetInstancePropertyValue(camera, m_Camera.m_Orthographic, ortho);
m_Import.SetInstancePropertyValue(camera, m_Camera.m_Fov, fov);
- if (m_AuthoringToolType == EAuthoringToolType_FBX_Maya)
+ if (m_AuthoringToolType == EAuthoringToolType_FBX_Maya
+ || m_AuthoringToolType == EAuthoringToolType_OpenCollada_Maya) {
m_Import.SetInstancePropertyValue(camera, m_Camera.m_FovHorizontal, true);
+ }
}
void PopCamera() override { PopObject(); }
@@ -635,7 +632,7 @@ public:
}
CharPtrOrError result = m_Import.AddImage(source);
TCharPtr dest = result.m_Value;
- TCharPtr imgPath = NULL;
+ TCharPtr imgPath = nullptr;
wchar_t pathBuf[1024];
if (result.m_Error) {
ESceneGraphWarningCode code = ESceneGraphWarningCode_Generic;
@@ -648,7 +645,7 @@ public:
}
m_Log.OnWarning(code, errorStr);
}
- if (result.m_Value != NULL && *result.m_Value)
+ if (result.m_Value != nullptr && *result.m_Value)
imgPath = result.m_Value;
else {
swprintf(pathBuf, 1024, L"%hs/missing.png",
@@ -1007,7 +1004,7 @@ public:
template <typename TDataType>
static NVConstDataRef<QT3DSU8> toRef(const std::vector<TDataType> &data)
{
- const TDataType *dataPtr = data.size() ? &data[0] : NULL;
+ const TDataType *dataPtr = data.size() ? &data[0] : nullptr;
return toU8ConstDataRef(dataPtr, (QT3DSU32)data.size());
}
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.h b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.h
index 8935f28b..4a9c1e48 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.h
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.h
@@ -334,6 +334,7 @@ typedef enum _EAuthoringToolType {
EAuthoringToolType_NextGen_Maya,
EAuthoringToolType_FCollada_Max,
EAuthoringToolType_FCollada_Maya,
+ EAuthoringToolType_OpenCollada_Maya,
EAuthoringToolType_SketchUp,
EAuthoringToolType_Cinema4D,
EAuthoringToolType_StudioCORE,
diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
index 5ecd9d64..188b3a2c 100644
--- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
+++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h
@@ -39,19 +39,28 @@ namespace qt3dsimp {
class Import;
typedef enum _ESceneGraphWarningCode {
- ESceneGraphWarningCode_OnlySupportTriangles, ///< Model contains geometric elements other than
- ///triangles (note that this won't throw exception,
- ///just pop up warning)
- ESceneGraphWarningCode_TrianglesDuplicateSemantic, ///< Triangle contains duplicate semantics,
- ///ex: 1 triangle has multiple TEXCOORD
- ///(multiple UV maps)
- ESceneGraphWarningCode_VertexBufferTooLarge, ///< Triangle contains duplicate semantics, ex: 1
- ///triangle has multiple TEXCOORD (multiple UV
- ///maps)
- ESceneGraphWarningCode_MissingSourceFile, ///< Couldn't find a source image file
- ESceneGraphWarningCode_LockedDestFile, ///< An image or mesh file we need to write to is not
- ///writeable.
- ESceneGraphWarningCode_Generic, ///< For generic warnings
+ // Model contains geometric elements other than triangles (note that this won't throw exception,
+ // just pop up warning).
+ ESceneGraphWarningCode_OnlySupportTriangles,
+ // Triangle contains duplicate semantics, ex: 1 triangle has multiple TEXCOORD (multiple UV
+ // maps).
+ ESceneGraphWarningCode_TrianglesDuplicateSemantic,
+ // A single mesh exceeds the maximum vertex count of 65535.
+ ESceneGraphWarningCode_VertexBufferTooLarge,
+ // Couldn't find a source image file
+ ESceneGraphWarningCode_MissingSourceFile,
+ // An image or mesh file we need to write to is not writeable.
+ ESceneGraphWarningCode_LockedDestFile,
+ // Mesh is missing a material.
+ ESceneGraphWarningCode_MissingMaterial,
+ // Unsupported light type.
+ ESceneGraphWarningCode_UnsupportedLight,
+ // For rotation warnings.
+ ESceneGraphWarningCode_Rotations,
+ // For "unknown" material surface type
+ ESceneGraphWarningCode_UnknownMaterial,
+ // For generic warnings.
+ ESceneGraphWarningCode_Generic
} ESceneGraphWarningCode;
class ISGTranslationLog
@@ -89,7 +98,7 @@ struct STranslationLog : public qt3dsimp::ISGTranslationLog
{
vector<pair<qt3dsimp::ESceneGraphWarningCode, Q3DStudio::CString>> m_Warnings;
void OnWarning(qt3dsimp::ESceneGraphWarningCode inWarningCode,
- const wchar_t *inAssociatedName) override
+ const wchar_t *inAssociatedName) override
{
m_Warnings.push_back(std::make_pair(inWarningCode, inAssociatedName));
}
diff --git a/src/Authoring/Qt3DStudio/Application/AboutDlg.cpp b/src/Authoring/Qt3DStudio/Application/AboutDlg.cpp
index 818c3556..e037dc0d 100644
--- a/src/Authoring/Qt3DStudio/Application/AboutDlg.cpp
+++ b/src/Authoring/Qt3DStudio/Application/AboutDlg.cpp
@@ -109,7 +109,7 @@ static QString compilerString()
void CAboutDlg::OnInitDialog()
{
// Set the Studio version
- m_ProductVersionStr = QStringLiteral("Qt 3D Studio v") + CStudioPreferences::GetVersionString();
+ m_ProductVersionStr = QStringLiteral("Qt 3D Studio v") + CStudioPreferences::versionString();
// Set the copyright string
m_CopyrightStr = QObject::tr("Copyright (C) %1 The Qt Company. All rights reserved.").arg(
@@ -136,9 +136,9 @@ void CAboutDlg::OnInitDialog()
// Add link to Web site
QString theURL(QStringLiteral("https://www.qt.io/3d-studio"));
- m_ui->m_WebSite->setText(QString("<a href=\"%1\"><font color=\"#%2\">%3</font></a>").arg(
+ m_ui->m_WebSite->setText(QString("<a href=\"%1\"><font color=\"%2\">%3</font></a>").arg(
theURL,
- CStudioPreferences::GetMasterColor().GetString().toQString(),
+ CStudioPreferences::masterColor().name(),
theURL));
m_ui->m_WebSite->setToolTip(tr("Click to visit Qt web site"));
m_ui->m_WebSite->setOpenExternalLinks(true);
@@ -146,9 +146,9 @@ void CAboutDlg::OnInitDialog()
// Add link to support address
const QString theSupport = QStringLiteral("https://account.qt.io/support");
- m_ui->m_Email->setText(QString("<a href=\"%1\"><font color=\"#%2\">%3</font></a>").arg(
+ m_ui->m_Email->setText(QString("<a href=\"%1\"><font color=\"%2\">%3</font></a>").arg(
theSupport,
- CStudioPreferences::GetMasterColor().GetString().toQString(),
+ CStudioPreferences::masterColor().name(),
theSupport));
m_ui->m_Email->setToolTip(tr("Send a Studio support request to the Qt Company"));
m_ui->m_Email->setOpenExternalLinks(true);
diff --git a/src/Authoring/Qt3DStudio/Application/DataInputDlg.cpp b/src/Authoring/Qt3DStudio/Application/DataInputDlg.cpp
index f6255395..127f6547 100644
--- a/src/Authoring/Qt3DStudio/Application/DataInputDlg.cpp
+++ b/src/Authoring/Qt3DStudio/Application/DataInputDlg.cpp
@@ -56,9 +56,6 @@ CDataInputDlg::CDataInputDlg(CDataInputDialogItem **datainput, QStandardItemMode
m_ui->comboBoxTypeList->setItemDelegate(itemDelegate);
m_ui->comboBoxTypeList->addItem(tr("Boolean"), QVariant(DataTypeBoolean));
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- m_ui->comboBoxTypeList->addItem(tr("Evaluator"), QVariant(DataTypeEvaluator));
-#endif
m_ui->comboBoxTypeList->addItem(tr("Float"), QVariant(DataTypeFloat));
m_ui->comboBoxTypeList->addItem(tr("Ranged Number"), QVariant(DataTypeRangedNumber));
m_ui->comboBoxTypeList->addItem(tr("String"), QVariant(DataTypeString));
@@ -127,11 +124,6 @@ void CDataInputDlg::initDialog()
m_min = m_dataInput->minValue;
m_max = m_dataInput->maxValue;
}
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- else if (m_type == DataTypeEvaluator) {
- m_ui->lineEditEvaluation->setText(m_dataInput->valueString);
- }
-#endif
} else {
m_name = getUniqueId(tr("newDataInput"));
if (m_dataInput->type == DataTypeRangedNumber) {
@@ -190,11 +182,6 @@ void CDataInputDlg::accept()
m_dataInput->minValue = m_min;
m_dataInput->maxValue = m_max;
}
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- else if (m_type == DataTypeEvaluator) {
- m_dataInput->valueString = m_text;
- }
-#endif
m_dataInput->metadata.clear();
for (auto const &it : qAsConst(m_orderedMetadata))
@@ -255,15 +242,7 @@ void CDataInputDlg::updateVisibility(int type)
m_ui->doubleSpinBoxMin->setVisible(false);
m_ui->doubleSpinBoxMax->setVisible(false);
}
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- if (type == DataTypeEvaluator) {
- m_ui->lineEditEvaluation->setVisible(true);
- m_ui->labelEvaluation->setVisible(true);
- } else {
- m_ui->lineEditEvaluation->setVisible(false);
- m_ui->labelEvaluation->setVisible(false);
- }
-#endif
+
// Adjust text label positioning according to the
// visibility of info text warning about allowed datatypes.
if (m_dataInput->ctrldElems.size()) {
@@ -293,11 +272,7 @@ bool CDataInputDlg::isEquivalentDataType(int dlgType, qt3dsdm::DataModelDataType
// Variant can be bound to any property type except timeline controller because only
// datainput of type Ranged Number has additional min/max information. For slide control,
// we can allow variant type in addition to String type.
- || (dlgType == EDataType::DataTypeVariant && dmType != DataModelDataType::RangedNumber)
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- || dlgType == EDataType::DataTypeEvaluator
-#endif
- ) {
+ || (dlgType == EDataType::DataTypeVariant && dmType != DataModelDataType::RangedNumber)) {
return true;
}
diff --git a/src/Authoring/Qt3DStudio/Application/DataInputDlg.h b/src/Authoring/Qt3DStudio/Application/DataInputDlg.h
index 9ae6bc6f..c859ccf6 100644
--- a/src/Authoring/Qt3DStudio/Application/DataInputDlg.h
+++ b/src/Authoring/Qt3DStudio/Application/DataInputDlg.h
@@ -52,9 +52,6 @@ QT_FORWARD_DECLARE_CLASS(QStandardItemModel)
enum EDataType {
DataTypeBoolean = 0,
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- DataTypeEvaluator,
-#endif
DataTypeFloat,
DataTypeRangedNumber,
DataTypeString,
@@ -73,9 +70,6 @@ static const QVector<EDataType> allDataTypes {
EDataType::DataTypeVector2,
EDataType::DataTypeRangedNumber,
EDataType::DataTypeBoolean,
- #ifdef DATAINPUT_EVALUATOR_ENABLED
- EDataType::DataTypeEvaluator,
- #endif
EDataType::DataTypeVariant
};
diff --git a/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp b/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp
index 2f8bc29b..a6d9e932 100644
--- a/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp
+++ b/src/Authoring/Qt3DStudio/Application/DataInputListDlg.cpp
@@ -60,6 +60,7 @@ CDataInputListDlg::CDataInputListDlg(QMap<QString, CDataInputDialogItem *> *data
, m_sortColumn(-1)
, m_defaultType(defaultType)
, m_acceptedTypes(acceptedTypes)
+
{
m_ui->setupUi(this);
@@ -215,12 +216,6 @@ void CDataInputListDlg::updateContents()
} else if (dataInputType == DataTypeFloat
&& (m_typeFilter == (int)DataTypeFloat || m_typeFilter == -1)) {
dataInput.append(new QStandardItem(tr("Float")));
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- } else if (dataInputType == DataTypeEvaluator
- && (m_typeFilter == (int)DataTypeEvaluator || m_typeFilter == -1)) {
- dataInput.append(new QStandardItem(tr("Evaluator")));
- dataInput.append(new QStandardItem(m_dataInputs.at(i)->valueString));
-#endif
} else if (dataInputType == DataTypeBoolean
&& (m_typeFilter == (int)DataTypeBoolean || m_typeFilter == -1)) {
dataInput.append(new QStandardItem(tr("Boolean")));
@@ -296,6 +291,10 @@ void CDataInputListDlg::updateInfo()
auto path = refHelper->GetObjectReferenceString(
doc->GetSceneInstance(), CRelativePathTools::EPATHTYPE_GUID,
allCtrldElemsIt->instHandle).toQString();
+ // Differentiate between paths such as Scene.Layer and Scene.Layer.Light by adding
+ // whitespace, and simultaneously create separation between element path and
+ // count of controlled properties which is shown in UI.
+ path.append(QLatin1Char(' '));
// One element can have several properties controlled by this datainput,
// do not show element several times. Show the number of properties after
// the elementpath and the list of property names in a separate column.
@@ -350,7 +349,7 @@ void CDataInputListDlg::updateInfo()
// Highlight the entire property name item if a non-match was found.
if (typeNotMatching) {
item3->setForeground(
- QBrush(CStudioPreferences::invalidDataInputIndicatorColor()));
+ QBrush(CStudioPreferences::invalidDataIndicatorColor()));
static QString warning(tr("\n\nData Input type is not matching with one or "
"several bound properties"));
item3->setToolTip(propNames + warning);
@@ -409,15 +408,9 @@ void CDataInputListDlg::accept()
for (auto name : keys)
m_actualDataInputs->insert(name, m_dataInputs.value(name));
- // Only show automatic binding removal choice if user has deleted
- // in-use datainput during this activation of the dialog, to avoid constant
- // nagging at closing of this dialog in case we have invalid datainputs.
- if (m_deletedDiInUse)
- QTimer::singleShot(0, &g_StudioApp, &CStudioApp::checkDeletedDatainputs);
-
if (g_StudioApp.GetCore()->GetDoc()->isTransactionOpened()) {
g_StudioApp.GetCore()->GetDoc()->closeTransaction();
- // If a datainput has been edited (and datainput controller names
+ // If a datainput has been edited (and datainput controller info has been
// updated in element "controlledproperty" properties), we need to make all changes
// non-undoable. This is because datainput definitions in UIA file (and in global
// datainput map) are not participating in the command stack. Changes there cannot be
@@ -426,6 +419,21 @@ void CDataInputListDlg::accept()
g_StudioApp.GetCore()->GetCmdStack()->RemoveLastUndo();
}
+ // Change element controlledproperties directly right now without undo just as we warned
+ // the user earlier about.
+ // Otherwise it is possible to add a similarly named datainput, and fool the control
+ // binding check that is triggered after this dialog, causing the old bindings to be
+ // "inherited" to the new datainput. This makes all bindings go away for the removed
+ // datainputs, even if we have new similarly named DI in the global map (which will have
+ // no bindings as expected).
+ if (!m_toRemove.isEmpty()) {
+ // Opens a transaction.
+ g_StudioApp.GetCore()->GetDoc()->RemoveDatainputBindings(&m_toRemove);
+ g_StudioApp.GetCore()->GetCmdStack()->RemoveLastUndo();
+ }
+
+ QTimer::singleShot(0, &g_StudioApp, [&]{ g_StudioApp.checkDeletedDatainputs(false); });
+
QDialog::accept();
}
@@ -484,18 +492,23 @@ void CDataInputListDlg::onRemoveDataInput()
if (m_dataInputs[diName]->ctrldElems.size()
|| m_dataInputs[diName]->externalPresBoundTypes.size() ) {
anyDiInUse = true;
+ for (const auto &remove : qAsConst(m_dataInputs[diName]->ctrldElems))
+ m_toRemove.insert(diName, {remove.instHandle, remove.propHandle});
}
}
}
}
-
QString title(QObject::tr("Warning"));
QString text;
- if (anyDiInUse)
- text.append(QObject::tr("One or more datainputs are currently in use. "));
- text.append(QObject::tr("This operation cannot be undone.\n\nAre you sure?"));
+ if (anyDiInUse) {
+ text.append(QObject::tr("One or more datainputs are currently in use.\n\n"
+ "Any control bindings in this presentation will be removed.\n"
+ "Bindings in other presentations will be left intact "
+ "but will not function anymore.\n\n"));
+ }
+ text.append(QObject::tr("This operation cannot be undone. Are you sure?"));
auto ret = g_StudioApp.GetDialogs()->DisplayMessageBox(title, text,
Qt3DSMessageBox::ICON_WARNING, true,
@@ -503,8 +516,6 @@ void CDataInputListDlg::onRemoveDataInput()
if (ret != Qt3DSMessageBox::MSGBX_OK)
return;
- m_deletedDiInUse = anyDiInUse;
-
if (removedRows.size() > 0) {
std::sort(removedRows.begin(), removedRows.end());
for (int i = removedRows.size() - 1; i >= 0; --i) {
diff --git a/src/Authoring/Qt3DStudio/Application/DataInputListDlg.h b/src/Authoring/Qt3DStudio/Application/DataInputListDlg.h
index ff59c5b4..acee72de 100644
--- a/src/Authoring/Qt3DStudio/Application/DataInputListDlg.h
+++ b/src/Authoring/Qt3DStudio/Application/DataInputListDlg.h
@@ -110,8 +110,10 @@ private:
// -1 all types, 0... matches EDataType enum
int m_typeFilter = -1;
QString m_searchString;
- bool m_deletedDiInUse = false;
bool m_diHasBeenEdited = false;
+ // To be deleted datainput entries that have control bindings
+ QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle,
+ qt3dsdm::Qt3DSDMPropertyHandle>> m_toRemove;
QAction *m_replaceSelectedAction;
QAction *m_replaceAllAction;
diff --git a/src/Authoring/Qt3DStudio/Application/DataInputSelectView.cpp b/src/Authoring/Qt3DStudio/Application/DataInputSelectView.cpp
index 5d37b0af..878f779b 100644
--- a/src/Authoring/Qt3DStudio/Application/DataInputSelectView.cpp
+++ b/src/Authoring/Qt3DStudio/Application/DataInputSelectView.cpp
@@ -118,11 +118,6 @@ QString DataInputSelectView::getDiTypeStr(int type)
case EDataType::DataTypeBoolean:
return tr("Boolean");
break;
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- case EDataType::DataTypeEvaluator:
- return tr("Evaluator");
- break;
-#endif
case EDataType::DataTypeFloat:
return tr("Float");
break;
@@ -141,6 +136,9 @@ QString DataInputSelectView::getDiTypeStr(int type)
case EDataType::DataTypeVector3:
return tr("Vector3");
break;
+ case EDataType::DataTypeVector4:
+ return tr("Vector4");
+ break;
default:
return {};
Q_ASSERT(false);
@@ -216,7 +214,7 @@ void DataInputSelectView::focusOutEvent(QFocusEvent *event)
bool DataInputSelectView::toolTipsEnabled() const
{
- return CStudioPreferences::ShouldShowTooltips();
+ return CStudioPreferences::isTooltipsOn();
}
void DataInputSelectView::setCurrentController(const QString &currentController)
diff --git a/src/Authoring/Qt3DStudio/Application/DurationEditDlg.cpp b/src/Authoring/Qt3DStudio/Application/DurationEditDlg.cpp
index f0707a56..82221860 100644
--- a/src/Authoring/Qt3DStudio/Application/DurationEditDlg.cpp
+++ b/src/Authoring/Qt3DStudio/Application/DurationEditDlg.cpp
@@ -40,7 +40,7 @@ CDurationEditDlg::CDurationEditDlg(QWidget *parent)
setWindowFlag(Qt::WindowContextHelpButtonHint, false); // remove '?' from the dialog title bar
QIntValidator *minValidator = new QIntValidator(this);
- minValidator->setRange(0, 9999);
+ minValidator->setRange(0, 59);
m_ui->lineEditMinutes->setValidator(minValidator);
m_ui->lineEditEndMinutes->setValidator(minValidator);
QIntValidator *secValidator = new QIntValidator(this);
@@ -157,13 +157,23 @@ void CDurationEditDlg::onStartTimeChanged()
long sec = m_ui->lineEditSeconds->text().toInt();
long msec = m_ui->lineEditMilliseconds->text().toInt();
+ // Keep min & sec values under 60
+ if (min > 59) {
+ min = 59;
+ m_ui->lineEditMinutes->setText(QString::number(min));
+ }
+ if (sec > 59) {
+ sec = 59;
+ m_ui->lineEditSeconds->setText(QString::number(sec));
+ }
+
long theGoToTime = min * 60000 + sec * 1000 + msec;
// Go to the time specified in the start time edit display
updateObjectTime(theGoToTime, true);
// If max number of digits reached in a number field, select the next
- if (m_ui->lineEditMinutes->hasFocus() && min > 999) {
+ if (m_ui->lineEditMinutes->hasFocus() && min > 9) {
m_ui->lineEditSeconds->setFocus();
m_ui->lineEditSeconds->selectAll();
} else if (m_ui->lineEditSeconds->hasFocus() && sec > 9) {
@@ -178,13 +188,23 @@ void CDurationEditDlg::onEndTimeChanged()
long sec = m_ui->lineEditEndSeconds->text().toInt();
long msec = m_ui->lineEditEndMilliseconds->text().toInt();
+ // Keep min & sec values under 60
+ if (min > 59) {
+ min = 59;
+ m_ui->lineEditEndMinutes->setText(QString::number(min));
+ }
+ if (sec > 59) {
+ sec = 59;
+ m_ui->lineEditEndSeconds->setText(QString::number(sec));
+ }
+
long theGoToTime = min * 60000 + sec * 1000 + msec;
// Go to the time specified in the end time edit display
updateObjectTime(theGoToTime, false);
// If max number of digits reached in a number field, select the next
- if (m_ui->lineEditEndMinutes->hasFocus() && min > 999) {
+ if (m_ui->lineEditEndMinutes->hasFocus() && min > 9) {
m_ui->lineEditEndSeconds->setFocus();
m_ui->lineEditEndSeconds->selectAll();
} else if (m_ui->lineEditEndSeconds->hasFocus() && sec > 9) {
diff --git a/src/Authoring/Qt3DStudio/Application/PresentationFile.cpp b/src/Authoring/Qt3DStudio/Application/PresentationFile.cpp
index cbc7f417..d9bf60cb 100644
--- a/src/Authoring/Qt3DStudio/Application/PresentationFile.cpp
+++ b/src/Authoring/Qt3DStudio/Application/PresentationFile.cpp
@@ -534,10 +534,30 @@ void PresentationFile::getSourcePaths(const QFileInfo &uipSrc, const QFileInfo &
* @param outmap returned list of datainput - property name pairs
*/
// static
-bool PresentationFile::getDataInputBindings(const SubPresentationRecord &subpresentation,
- QMultiMap<QString, QPair<QString, QString>> &outmap)
+bool PresentationFile::getDataInputBindings(
+ const SubPresentationRecord &subpresentation,
+ QMultiHash<QString, ProjectFile::DataInputOutputBinding> &outmap)
{
- QList<QString> ctrldPropList;
+ return getDataInputOutputBindings(subpresentation, outmap,
+ QStringLiteral("controlledproperty"));
+}
+
+bool PresentationFile::getDataOutputBindings(
+ const SubPresentationRecord &subpresentation,
+ QMultiHash<QString, ProjectFile::DataInputOutputBinding> &outmap)
+{
+ return getDataInputOutputBindings(subpresentation, outmap,
+ QStringLiteral("observedproperty"));
+}
+
+bool PresentationFile::getDataInputOutputBindings(
+ const SubPresentationRecord &subpresentation,
+ QMultiHash<QString, ProjectFile::DataInputOutputBinding> &outmap,
+ const QString &dioProperty)
+{
+ QVector<QPair<QString, QString>> ctrldPropList;
+ QHash<QString, QString> sourceClasses; // class id, sourcepath
+ QHash<QString, QString> idToSourceMap; // material/effect/behavior id, sourcepath
QString spPath(g_StudioApp.getRenderableAbsolutePath(subpresentation.m_id));
@@ -545,71 +565,45 @@ bool PresentationFile::getDataInputBindings(const SubPresentationRecord &subpres
if (!StudioUtils::readFileToDomDocument(spPath, domDoc))
return false;
- // search <Graph>
- QDomElement graphElem = domDoc.documentElement().firstChild()
- .firstChildElement(QStringLiteral("Graph"));
- for (QDomElement p = graphElem.firstChild().toElement(); !p.isNull();
- p = p.nextSibling().toElement()) {
- QString ctrldPropStr = p.attribute(QStringLiteral("controlledproperty"));
- if (!ctrldPropStr.isEmpty())
- ctrldPropList.append(ctrldPropStr);
- }
- // Search Logic - State - Add
- QDomNodeList addElems = domDoc.documentElement().firstChild()
- .firstChildElement(QStringLiteral("Logic"))
- .elementsByTagName(QStringLiteral("Add"));
+ spPath = QFileInfo(spPath).absolutePath() + QLatin1Char('/');
- for (int i = 0; i < addElems.count(); ++i) {
- QDomElement elem = addElems.at(i).toElement();
- QString ctrldPropStr = elem.attribute(QStringLiteral("controlledproperty"));
- if (!ctrldPropStr.isEmpty())
- ctrldPropList.append(ctrldPropStr);
+ // Search <Classes> for custom materials
+ QDomElement classesElem = domDoc.documentElement().firstChild()
+ .firstChildElement(QStringLiteral("Classes"));
+ for (QDomElement p = classesElem.firstChild().toElement(); !p.isNull();
+ p = p.nextSibling().toElement()) {
+ if (p.tagName() == QLatin1String("CustomMaterial")
+ || p.tagName() == QLatin1String("Effect")
+ || p.tagName() == QLatin1String("Behavior")) {
+ const QString id = p.attribute(QStringLiteral("id"));
+ QString sourcePath = spPath + p.attribute(QStringLiteral("sourcepath"));
+ sourceClasses.insert(id, sourcePath);
+ }
}
- for (auto di : qAsConst(ctrldPropList)) {
- QStringList split = di.split(QLatin1String(" "));
- for (int i = 0; i < split.size(); i += 2) {
- QString diName = split[i];
- // Datainput names indicated with prefix "$", remove
- // if found.
- if (diName.startsWith(QLatin1String("$")))
- diName = diName.mid(1, diName.size() - 1);
- QString propName = split[i + 1];
- // We should find the datainput from the global datainput list
- // parsed out from UIA file, but check just in case and do not insert
- // if not found.
- if (g_StudioApp.m_dataInputDialogItems.contains(diName)) {
- outmap.insert(subpresentation.m_id, QPair<QString, QString>(diName, propName));
- } else {
- qWarning() << "Subpresentation" << subpresentation.m_id
- << "is using datainput" << diName << "that is "
- "not found from the current UIA file";
+ std::function<void(const QDomElement &parentElem)> searchGraph;
+ searchGraph = [&](const QDomElement &parentElem) {
+ for (QDomElement p = parentElem.firstChild().toElement(); !p.isNull();
+ p = p.nextSibling().toElement()) {
+ searchGraph(p);
+ QString ctrldPropStr = p.attribute(dioProperty);
+ QString sourcePath;
+ if (p.tagName() == QLatin1String("CustomMaterial")
+ || p.tagName() == QLatin1String("Effect")
+ || p.tagName() == QLatin1String("Behavior")) {
+ const QString id = p.attribute(QStringLiteral("id"));
+ const QString classId = p.attribute(QStringLiteral("class")).mid(1);
+ sourcePath = sourceClasses.value(classId);
+ idToSourceMap.insert(id, sourcePath);
}
+ if (!ctrldPropStr.isEmpty())
+ ctrldPropList.append({ctrldPropStr, sourcePath});
}
- }
- return true;
-}
-
-bool PresentationFile::getDataOutputBindings(const SubPresentationRecord &subpresentation,
- QMultiMap<QString, QPair<QString, QString>> &outmap)
-{
- QList<QString> ctrldPropList;
-
- QString spPath(g_StudioApp.getRenderableAbsolutePath(subpresentation.m_id));
+ };
- QDomDocument domDoc;
- if (!StudioUtils::readFileToDomDocument(spPath, domDoc))
- return false;
+ // Search <Graph> recursively for controlled properties
+ searchGraph(domDoc.documentElement().firstChild().firstChildElement(QStringLiteral("Graph")));
- // search <Graph>
- QDomElement graphElem = domDoc.documentElement().firstChild()
- .firstChildElement(QStringLiteral("Graph"));
- for (QDomElement p = graphElem.firstChild().toElement(); !p.isNull();
- p = p.nextSibling().toElement()) {
- QString ctrldPropStr = p.attribute(QStringLiteral("observedproperty"));
- if (!ctrldPropStr.isEmpty())
- ctrldPropList.append(ctrldPropStr);
- }
// Search Logic - State - Add
QDomNodeList addElems = domDoc.documentElement().firstChild()
.firstChildElement(QStringLiteral("Logic"))
@@ -617,27 +611,35 @@ bool PresentationFile::getDataOutputBindings(const SubPresentationRecord &subpre
for (int i = 0; i < addElems.count(); ++i) {
QDomElement elem = addElems.at(i).toElement();
- QString ctrldPropStr = elem.attribute(QStringLiteral("observedproperty"));
- if (!ctrldPropStr.isEmpty())
- ctrldPropList.append(ctrldPropStr);
+ QString ctrldPropStr = elem.attribute(dioProperty);
+ if (!ctrldPropStr.isEmpty()) {
+ const QString ref = elem.attribute(QStringLiteral("ref")).mid(1);
+ QString sourcePath;
+ if (idToSourceMap.contains(ref))
+ sourcePath = idToSourceMap.value(ref);
+ ctrldPropList.append({ctrldPropStr, sourcePath});
+ }
}
- for (auto dout : qAsConst(ctrldPropList)) {
- QStringList split = dout.split(QLatin1Char(' '));
+ for (const auto &dio : qAsConst(ctrldPropList)) {
+ const QString dioStr = dio.first;
+ const QString sourcePath = dio.second;
+ QStringList split = dioStr.split(QLatin1Char(' '));
for (int i = 0; i < split.size(); i += 2) {
- QString doName = split[i];
- // Dataoutput names indicated with prefix "$", remove if found.
- if (doName.startsWith(QLatin1Char('$')))
- doName = doName.mid(1, doName.size() - 1);
+ QString dioName = split[i];
+ // Datainput/output names indicated with prefix "$", remove
+ // if found.
+ if (dioName.startsWith(QLatin1Char('$')))
+ dioName = dioName.mid(1, dioName.size() - 1);
QString propName = split[i + 1];
- // We should find the dataoutputs from the global dataoutput list
+ // We should find the datainput/output from the global datainput list
// parsed out from UIA file, but check just in case and do not insert
// if not found.
- if (g_StudioApp.m_dataInputDialogItems.contains(doName)) {
- outmap.insert(subpresentation.m_id, QPair<QString, QString>(doName, propName));
+ if (g_StudioApp.m_dataInputDialogItems.contains(dioName)) {
+ outmap.insert(subpresentation.m_id, {dioName, propName, sourcePath});
} else {
qWarning() << "Subpresentation" << subpresentation.m_id
- << "is using dataoutput" << doName << "that is "
+ << "is using datainput/output" << dioName << "that is "
"not found from the current UIA file";
}
}
diff --git a/src/Authoring/Qt3DStudio/Application/PresentationFile.h b/src/Authoring/Qt3DStudio/Application/PresentationFile.h
index 1d8aba85..865b8aec 100644
--- a/src/Authoring/Qt3DStudio/Application/PresentationFile.h
+++ b/src/Authoring/Qt3DStudio/Application/PresentationFile.h
@@ -52,12 +52,18 @@ public:
const QString &newName);
static QSize readSize(const QString &uipPath);
static QString findProjectFile(const QString &uipPath);
- static bool getDataInputBindings(const SubPresentationRecord &subpresentation,
- QMultiMap<QString, QPair<QString, QString>> &outmap);
- static bool getDataOutputBindings(const SubPresentationRecord &subpresentation,
- QMultiMap<QString, QPair<QString, QString>> &outmap);
+ static bool getDataInputBindings(
+ const SubPresentationRecord &subpresentation,
+ QMultiHash<QString, ProjectFile::DataInputOutputBinding> &outmap);
+ static bool getDataOutputBindings(
+ const SubPresentationRecord &subpresentation,
+ QMultiHash<QString, ProjectFile::DataInputOutputBinding> &outmap);
private:
+ static bool getDataInputOutputBindings(
+ const SubPresentationRecord &subpresentation,
+ QMultiHash<QString, ProjectFile::DataInputOutputBinding> &outmap,
+ const QString &dioProperty);
PresentationFile();
};
diff --git a/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp b/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp
index b4c18c50..1ad0b5c0 100644
--- a/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp
+++ b/src/Authoring/Qt3DStudio/Application/ProjectFile.cpp
@@ -486,12 +486,6 @@ void ProjectFile::parseDataInputElem(const QDomElement &elem,
} else if (type == QLatin1String("Variant")) {
item->type = EDataType::DataTypeVariant;
}
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- else if (type == QLatin1String("Evaluator")) {
- item->type = EDataType::DataTypeEvaluator;
- item->valueString = elem.attribute(QStringLiteral("evaluator"));
- }
-#endif
auto metadata = elem.attribute(QStringLiteral("metadata"));
if (!metadata.isEmpty()) {
@@ -546,9 +540,11 @@ void ProjectFile::loadSubpresentationsAndDatainputs(
m_initialPresentation = g_StudioApp.GetCore()->GetDoc()->getPresentationId();
QDomDocument doc;
- if (!StudioUtils::readFileToDomDocument(getProjectFilePath(), doc))
+ QSaveFile projectFile(getProjectFilePath());
+ if (!StudioUtils::openDomDocumentSave(projectFile, doc))
return;
+ QVector<QDomElement> removedElements;
QDomElement assetsElem = doc.documentElement().firstChildElement(QStringLiteral("assets"));
if (!assetsElem.isNull()) {
QString initial = assetsElem.attribute(QStringLiteral("initial"));
@@ -563,13 +559,24 @@ void ProjectFile::loadSubpresentationsAndDatainputs(
QString argsOrSrc = p.attribute(QStringLiteral("src"));
if (argsOrSrc.isNull())
argsOrSrc = p.attribute(QStringLiteral("args"));
- subpresentations.push_back(
- SubPresentationRecord(p.nodeName(), p.attribute("id"), argsOrSrc));
+ // Skip non-existent presentations (they have been manually deleted)
+ if (QFileInfo().exists(getAbsoluteFilePathTo(argsOrSrc))) {
+ subpresentations.push_back(
+ SubPresentationRecord(p.nodeName(), p.attribute("id"), argsOrSrc));
+ } else {
+ removedElements.append(p);
+ }
} else {
parseDataInputElem(p, datainputs);
}
}
}
+ if (removedElements.size()) {
+ for (auto &elem : qAsConst(removedElements))
+ assetsElem.removeChild(elem);
+ StudioUtils::commitDomDocumentSave(projectFile, doc);
+ }
+
g_StudioApp.GetCore()->GetDoc()->UpdateDatainputMap();
}
@@ -934,11 +941,11 @@ QString ProjectFile::getRelativeFilePathTo(const QString &absFilePath) const
return QDir(getProjectPath()).relativeFilePath(absFilePath);
}
-// Return multimap of type subpresentationid - QPair<datainput, propertyname>
-QMultiMap<QString, QPair<QString, QString>>
+// Return multimap of type subpresentationid - DataInputOutputBinding
+QMultiHash<QString, ProjectFile::DataInputOutputBinding>
ProjectFile::getDiBindingtypesFromSubpresentations() const
{
- QMultiMap<QString, QPair<QString, QString>> map;
+ QMultiHash<QString, DataInputOutputBinding> map;
for (auto sp : qAsConst(g_StudioApp.m_subpresentations))
PresentationFile::getDataInputBindings(sp, map);
diff --git a/src/Authoring/Qt3DStudio/Application/ProjectFile.h b/src/Authoring/Qt3DStudio/Application/ProjectFile.h
index b53f559c..8b2717b2 100644
--- a/src/Authoring/Qt3DStudio/Application/ProjectFile.h
+++ b/src/Authoring/Qt3DStudio/Application/ProjectFile.h
@@ -51,6 +51,12 @@ public:
QStringList m_tags;
};
+ struct DataInputOutputBinding {
+ QString dioName;
+ QString propertyName;
+ QString propertyDefinitionFile; // E.g. for CustomMaterials, this is the .shader file
+ };
+
void create(const QString &uiaPath);
void ensureProjectFile();
void initProjectFile(const QString &presPath);
@@ -74,7 +80,8 @@ public:
QString getAbsoluteFilePathTo(const QString &relFilePath) const;
QString getRelativeFilePathTo(const QString &absFilePath) const;
QString createPreview();
- QMultiMap<QString, QPair<QString, QString>> getDiBindingtypesFromSubpresentations() const;
+
+ QMultiHash<QString, DataInputOutputBinding> getDiBindingtypesFromSubpresentations() const;
static QString getInitialPresentationSrc(const QString &uiaPath);
static void getPresentations(const QString &inUiaPath,
diff --git a/src/Authoring/Qt3DStudio/Application/StudioApp.cpp b/src/Authoring/Qt3DStudio/Application/StudioApp.cpp
index f3594c94..ac9efb10 100644
--- a/src/Authoring/Qt3DStudio/Application/StudioApp.cpp
+++ b/src/Authoring/Qt3DStudio/Application/StudioApp.cpp
@@ -39,9 +39,9 @@
#include "qtlocalpeer.h"
#include "TimelineWidget.h"
#include "SlideView.h"
-#include "IKeyframesManager.h"
#include "PresentationFile.h"
#include "EditPresentationIdDlg.h"
+#include "Qt3DSDMWStrOps.h"
#include <QtGui/qsurfaceformat.h>
#include <QtCore/qfileinfo.h>
@@ -160,9 +160,6 @@ int main(int argc, char *argv[])
return g_StudioApp.run(parser);
}
-//==============================================================================
-// Includes
-//==============================================================================
#include "Exceptions.h"
#include "IOLibraryException.h"
#include "MainFrm.h"
@@ -184,7 +181,6 @@ int main(int argc, char *argv[])
#include "StudioUtils.h"
#include "ClientDataModelBridge.h"
-#include "CommonConstants.h"
#include "IOLibraryException.h"
#include "Qt3DSDMErrors.h"
@@ -196,7 +192,6 @@ int main(int argc, char *argv[])
#include <string.h>
#include <QtWidgets/qapplication.h>
-#include <QtCore/qsettings.h>
#include "Core.h"
#include "HotKeys.h"
@@ -204,7 +199,6 @@ int main(int argc, char *argv[])
#include "Qt3DSDMStudioSystem.h"
#include "Qt3DSDMInspectable.h"
#include "Qt3DSDMSlides.h"
-#include "Qt3DSDMMaterialInspectable.h"
#include "Qt3DSDMAnimation.h"
#include "Qt3DSDMDataCore.h"
#include "IDirectoryWatchingSystem.h"
@@ -215,21 +209,6 @@ CStudioApp g_StudioApp;
using namespace Q3DStudio;
-namespace qt3ds
-{
-void Qt3DSAssert(const char *exp, const char *file, int line, bool *ignore)
-{
- Q_UNUSED(ignore)
- g_StudioApp.GetDialogs()->DestroyProgressScreen();
- g_StudioApp.GetDialogs()->DisplayKnownErrorDialog(exp);
- qFatal("Assertion thrown %s(%d): %s", file, line, exp);
-}
-}
-
-//=============================================================================
-/**
- * Constructor
- */
CStudioApp::CStudioApp()
: m_core(nullptr)
, m_isSilent(false)
@@ -248,10 +227,6 @@ CStudioApp::CStudioApp()
connect(m_autosaveTimer, &QTimer::timeout, this, [=](){ OnSave(true); });
}
-//=============================================================================
-/**
- * Destructor
- */
CStudioApp::~CStudioApp()
{
delete m_views;
@@ -300,7 +275,6 @@ void CStudioApp::performShutdown()
qApp->exit();
}
-//=============================================================================
/**
* Entry location for the creation of this application.
* This creates the all the views, then returns if everything
@@ -311,10 +285,10 @@ bool CStudioApp::initInstance(const QCommandLineParser &parser, bool isOpenGLES)
QApplication::setOrganizationName("The Qt Company");
QApplication::setOrganizationDomain("qt.io");
QApplication::setApplicationName("Qt 3D Studio");
- QApplication::setApplicationVersion(CStudioPreferences::GetVersionString());
+ QApplication::setApplicationVersion(CStudioPreferences::versionString());
qCInfo(qt3ds::TRACE_INFO) << "Studio: " << QApplication::applicationFilePath();
- qCInfo(qt3ds::TRACE_INFO) << "Version: " << CStudioPreferences::GetVersionString();
+ qCInfo(qt3ds::TRACE_INFO) << "Version: " << CStudioPreferences::versionString();
// Silent is ignored for everything but create
m_isSilent = parser.isSet("silent") && parser.isSet("create");
@@ -325,9 +299,7 @@ bool CStudioApp::initInstance(const QCommandLineParser &parser, bool isOpenGLES)
m_gettingStartedFilePath = Qt3DSFile::GetApplicationDirectory()
+ QStringLiteral("/../doc/qt3dstudio/getting-started.html");
- QString thePreferencesPath = CFilePath::GetUserApplicationDirectory()
- + QStringLiteral("/Qt3DStudio/Preferences.setting");
- CStudioPreferences::loadPreferences(thePreferencesPath);
+ CStudioPreferences::loadPreferences();
m_dialogs = new CDialogs(!m_isSilent);
@@ -352,14 +324,13 @@ bool CStudioApp::initInstance(const QCommandLineParser &parser, bool isOpenGLES)
m_core->GetDispatch()->AddFailListener(this);
// Initialize autosave
- m_autosaveTimer->setInterval(CStudioPreferences::GetAutoSaveDelay() * 1000);
- if (CStudioPreferences::GetAutoSavePreference())
+ m_autosaveTimer->setInterval(CStudioPreferences::autoSaveDelay() * 1000);
+ if (CStudioPreferences::isAutoSavePreference())
m_autosaveTimer->start();
return true;
}
-//=============================================================================
/**
* Command handler to display the about dialog.
*/
@@ -369,7 +340,6 @@ void CStudioApp::onAppAbout()
aboutDlg.exec();
}
-//=============================================================================
/**
* Main application execution loop.
* The application's main thread stays in this until the app exits.
@@ -403,7 +373,7 @@ bool CStudioApp::run(const QCommandLineParser &parser)
performShutdown();
} catch (qt3dsdm::Qt3DSDMError &uicdmError) {
- Q_UNUSED(uicdmError);
+ Q_UNUSED(uicdmError)
exit(1);
} catch (...) {
throw;
@@ -521,7 +491,6 @@ QString CStudioApp::resolvePresentationFile(const QString &inFile)
return {};
}
-//=============================================================================
/**
* Show startup dialog and perform necessary action such as create new doc or load doc.
* Return false if user requests to exit
@@ -540,17 +509,15 @@ bool CStudioApp::showStartupDialog()
m_welcomeShownThisSession = true;
bool show = false;
- QSettings settings;
- if (!settings.contains("showWelcomeScreen")) {
- settings.setValue("showWelcomeScreen", 1);
+ if (!CStudioPreferences::containsShowWelcomeScreen()) {
+ CStudioPreferences::setShowWelcomeScreen(true);
show = true;
} else {
// if we are returning to welcome dialog page after canceling
// file dialog, do not care about settings but always show
// welcome
- show = settings.value("showWelcomeScreen").toBool()
- || m_goStraightToWelcomeFileDialog;
+ show = CStudioPreferences::isShowWelcomeScreen() || m_goStraightToWelcomeFileDialog;
}
if (show) {
@@ -635,7 +602,6 @@ void CStudioApp::openApplication(const QString &inFilename)
}
#endif
-//=============================================================================
/**
* Start the app.
*/
@@ -653,7 +619,6 @@ bool CStudioApp::blankRunApplication()
return runApplication();
}
-//=============================================================================
/**
* Open the specified file and run the application.
* This will load the file then go into the standard app loop.
@@ -711,7 +676,6 @@ bool CStudioApp::createAndRunApplication(const QString &filename, const QString
return theSuccess;
}
-//=============================================================================
/**
* This is the app execution loop, the main thread loops here until the app exits.
* @return true on success; false on failure
@@ -721,7 +685,6 @@ bool CStudioApp::runApplication()
return qApp->exec() == 0;
}
-//=============================================================================
/**
* Initialize the core and all the views.
*/
@@ -737,7 +700,13 @@ void CStudioApp::initCore()
if (m_views) {
m_views->createViews(m_isSilent);
m_pMainWnd = m_views->getMainFrame();
- m_pMainWnd->initializeGeometryAndState();
+ if (!CStudioPreferences::containsWindowState(STUDIO_VERSION_NUM)) {
+ // On first run, save and restore geometry and state. For some reason they are both
+ // needed to avoid a bug with palettes resizing to their original size when window is
+ // resized or something in a palette is edited.
+ m_pMainWnd->handleGeometryAndState(true);
+ }
+ m_pMainWnd->handleGeometryAndState(false);
}
RegisterGlobalKeyboardShortcuts(m_core->GetHotKeys(), m_pMainWnd);
@@ -880,7 +849,6 @@ CCore *CStudioApp::GetCore()
return m_core;
}
-//=============================================================================
/**
* Get the view manager for this core to communicate to the views.
*/
@@ -889,7 +857,6 @@ CViews *CStudioApp::GetViews()
return m_views;
}
-//=============================================================================
/**
* Get the dialog manager for this core for displaying dialogs.
*/
@@ -936,20 +903,12 @@ void CStudioApp::SetManipulationMode(StudioManipulationModes::Enum inManipulatio
}
}
-//=============================================================================
-/**
- * return true if undo is possible
- */
bool CStudioApp::CanUndo()
{
return m_core->GetCmdStack()->CanUndo()
&& !m_views->getMainFrame()->getTimelineWidget()->dndActive();
}
-//=============================================================================
-/**
- * return true if redo is possible
- */
bool CStudioApp::CanRedo()
{
return m_core->GetCmdStack()->CanRedo();
@@ -965,7 +924,6 @@ bool CStudioApp::CanCopy()
return m_core->GetDoc()->canCopy();
}
-//=============================================================================
/**
* Get a string describing the type of the copy operation that can be done.
* Precedence of copying is 1) Actions; 2) Keyframes; 3) Objects
@@ -1025,7 +983,7 @@ QString CStudioApp::getDeleteType() const
if (bridge->CanDelete(selected[idx]))
deletableCount++;
}
- if (deletableCount && deletableCount == selected.size())
+ if (deletableCount && deletableCount == int(selected.size()))
return tr("Object");
}
return {};
@@ -1103,7 +1061,6 @@ bool CStudioApp::ungroupSelectedObjects() const
return false;
}
-//=============================================================================
/**
* Cuts the selected object or keys
*/
@@ -1117,7 +1074,6 @@ bool CStudioApp::CanCut()
return m_core->GetDoc()->canCut();
}
-//=============================================================================
/**
* Paste keys from the copied list yo
*/
@@ -1131,7 +1087,6 @@ bool CStudioApp::CanPaste()
return m_core->GetDoc()->canPaste();
}
-//=============================================================================
/**
* Get a string describing the type of the paste operation that can be done.
* Precedence of paste is 1) Actions; 2) Object ; 3) Keyframes
@@ -1153,18 +1108,14 @@ QString CStudioApp::GetPasteType()
bool CStudioApp::CanChangeTimebarColor()
{
- bool theRetVal = true;
- qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = m_core->GetDoc()->GetSelectedInstance();
- if (!theSelectedInstance.Valid()
- || m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge()->IsSceneInstance(
- theSelectedInstance)) {
- theRetVal = false;
+ auto theSelectedInstance = m_core->GetDoc()->GetSelectedInstance();
+ if (theSelectedInstance.Valid()) {
+ auto bridge = m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
+ return !bridge->IsActiveComponent(theSelectedInstance);
}
-
- return theRetVal;
+ return false;
}
-//=============================================================================
/**
* Sets any changed keyframes on the selected object
*/
@@ -1173,7 +1124,6 @@ void CStudioApp::HandleSetChangedKeys()
m_core->GetDoc()->SetChangedKeyframes();
}
-//=============================================================================
/**
* Deletes all selected keys
*/
@@ -1182,7 +1132,6 @@ void CStudioApp::DeleteSelectedKeys()
m_core->GetDoc()->deleteSelectedKeyframes();
}
-//=============================================================================
/**
* Deletes selected object or keyframes
*/
@@ -1206,23 +1155,21 @@ void CStudioApp::HandleDuplicateCommand()
*/
void CStudioApp::OnToggleAutosetKeyframes()
{
- SetAutosetKeyframes(!CStudioPreferences::IsAutosetKeyframesOn());
+ SetAutosetKeyframes(!CStudioPreferences::isAutosetKeyframesOn());
m_core->GetDispatch()->FireOnToolbarChange();
}
-//==============================================================================
/**
* Updates the preferences, and AnimationSystem.
*/
void CStudioApp::SetAutosetKeyframes(bool inFlag)
{
- CStudioPreferences::SetAutosetKeyframesOn(inFlag);
+ CStudioPreferences::setAutosetKeyframesOn(inFlag);
m_core->GetDoc()->GetStudioSystem()->GetAnimationSystem()->SetAutoKeyframe(inFlag);
}
-//==============================================================================
/**
* If the presentation is not currently playing, this function will make it
* start playing from the current position. The starting point of the playhead
@@ -1230,19 +1177,20 @@ void CStudioApp::SetAutosetKeyframes(bool inFlag)
*/
void CStudioApp::PlaybackPlay()
{
- // Do not start playback if user is currently interacting with scene
- if (getRenderer().isMouseDown())
- return;
+ if (!m_core->GetDoc()->getPresentationId().isEmpty()) {
+ // Do not start playback if user is currently interacting with scene
+ if (getRenderer().isMouseDown())
+ return;
- CDoc *theDoc = m_core->GetDoc();
- if (!theDoc->IsPlaying()) {
- m_playbackTime = theDoc->GetCurrentViewTime();
- m_playbackOriginalSlide = theDoc->GetActiveSlide();
- theDoc->SetPlayMode(PLAYMODE_PLAY);
+ CDoc *theDoc = m_core->GetDoc();
+ if (!theDoc->IsPlaying()) {
+ m_playbackTime = theDoc->GetCurrentViewTime();
+ m_playbackOriginalSlide = theDoc->GetActiveSlide();
+ theDoc->SetPlayMode(PLAYMODE_PLAY);
+ }
}
}
-//==============================================================================
/**
* If the presentation is currently playing, it is stopped. The playhead is
* left wherever it was stopped at (hence it's not restored).
@@ -1252,7 +1200,6 @@ void CStudioApp::PlaybackStopNoRestore()
m_core->GetDoc()->SetPlayMode(PLAYMODE_STOP);
}
-//==============================================================================
/**
* Moves the playhead back to time zero.
*/
@@ -1272,7 +1219,6 @@ bool CStudioApp::IsPlaying()
return m_core->GetDoc()->IsPlaying();
}
-//=============================================================================
/**
* Performs a file revert.
* This will revert the doc to the last saved version.
@@ -1285,7 +1231,6 @@ void CStudioApp::OnRevert()
}
}
-//=============================================================================
/**
* Check to see if it is possible to perform a revert.
*/
@@ -1294,7 +1239,6 @@ bool CStudioApp::CanRevert() const
return m_core->GetDoc()->isModified() && m_core->GetDoc()->isValid();
}
-//==============================================================================
/**
* Handles the recent list.
*/
@@ -1304,7 +1248,6 @@ void CStudioApp::OnFileOpenRecent(const QString &inDocument)
OnLoadDocument(inDocument);
}
-//==============================================================================
/**
* Called when closing the current doc, this prompts the user to save the doc.
* This will only prompt if the doc is modified, and if the user selects save
@@ -1328,7 +1271,6 @@ bool CStudioApp::PerformSavePrompt()
return true;
}
-//==============================================================================
/**
* If the presentation is currently playing, it is stopped. The playhead is
* restored to the position found in m_PlaybackTime.
@@ -1346,53 +1288,54 @@ void CStudioApp::PlaybackStop()
m_playbackOriginalSlide = 0;
}
-//=============================================================================
/**
- * Used for track wheel to do smooth tracking on mac, just scrolls the playhead.
+ * advance time by a small amount
*/
-void CStudioApp::AdvanceTime()
+void CStudioApp::advanceTime()
{
- long theDeltaTime = CStudioPreferences::GetTimeAdvanceAmount();
- long theTime =
- (m_core->GetDoc()->GetCurrentViewTime() + theDeltaTime) / theDeltaTime * theDeltaTime;
- m_core->GetDoc()->NotifyTimeChanged(theTime);
+ if (!m_core->GetDoc()->getPresentationId().isEmpty()) {
+ long dt = CStudioPreferences::timeAdvanceAmount();
+ long time = (m_core->GetDoc()->GetCurrentViewTime() + dt) / dt * dt;
+ m_core->GetDoc()->NotifyTimeChanged(time);
+ }
}
-//=============================================================================
/**
- * Used for track wheel to do smooth tracking on mac, just scrolls the playhead.
+ * move back time by a small amount
*/
-void CStudioApp::ReduceTime()
+void CStudioApp::reduceTime()
{
- long theDeltaTime = CStudioPreferences::GetTimeAdvanceAmount();
- long theTime = (m_core->GetDoc()->GetCurrentViewTime() - 1) / theDeltaTime * theDeltaTime;
- m_core->GetDoc()->NotifyTimeChanged(theTime);
+ if (!m_core->GetDoc()->getPresentationId().isEmpty()) {
+ long dt = CStudioPreferences::timeAdvanceAmount();
+ long time = (m_core->GetDoc()->GetCurrentViewTime() - 1) / dt * dt;
+ m_core->GetDoc()->NotifyTimeChanged(time);
+ }
}
-//=============================================================================
/**
- * Used for track wheel to do smooth tracking on mac, just scrolls the playhead.
+ * advance time by a big amount
*/
-void CStudioApp::AdvanceUltraBigTime()
+void CStudioApp::advanceTimeBig()
{
- long theDeltaTime = CStudioPreferences::GetBigTimeAdvanceAmount();
- long theTime =
- (m_core->GetDoc()->GetCurrentViewTime() + theDeltaTime) / theDeltaTime * theDeltaTime;
- m_core->GetDoc()->NotifyTimeChanged(theTime);
+ if (!m_core->GetDoc()->getPresentationId().isEmpty()) {
+ long dt = CStudioPreferences::bigTimeAdvanceAmount();
+ long time = (m_core->GetDoc()->GetCurrentViewTime() + dt) / dt * dt;
+ m_core->GetDoc()->NotifyTimeChanged(time);
+ }
}
-//=============================================================================
/**
- * Used for track wheel to do smooth tracking on mac, just scrolls the playhead.
+ * move back time by a big amount
*/
-void CStudioApp::ReduceUltraBigTime()
+void CStudioApp::reduceTimeBig()
{
- long theDeltaTime = CStudioPreferences::GetBigTimeAdvanceAmount();
- long theTime = (m_core->GetDoc()->GetCurrentViewTime() - 1) / theDeltaTime * theDeltaTime;
- m_core->GetDoc()->NotifyTimeChanged(theTime);
+ if (!m_core->GetDoc()->getPresentationId().isEmpty()) {
+ long dt = CStudioPreferences::bigTimeAdvanceAmount();
+ long time = (m_core->GetDoc()->GetCurrentViewTime() - 1) / dt * dt;
+ m_core->GetDoc()->NotifyTimeChanged(time);
+ }
}
-//==============================================================================
/**
* If the presentation is currently playing, it is stopped. Otherwise, the
* presetation starts playing from its current position. Called when the user
@@ -1400,69 +1343,34 @@ void CStudioApp::ReduceUltraBigTime()
*/
void CStudioApp::PlaybackToggle()
{
- // If the presentation is playing, stop it and leave the playhead where it is
- if (m_core->GetDoc()->IsPlaying())
- PlaybackStopNoRestore();
- // Otherwise, the presentation is stopped, so start it playing
- else
- PlaybackPlay();
-}
-
-// TODO: move to more appropriate place (InspectorControlModel.cpp)
-CInspectableBase *CStudioApp::getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
-{
- CInspectableBase *inspectableBase = nullptr;
- CDoc *doc = m_core->GetDoc();
-
- if (doc->GetDocumentReader().IsInstance(inInstance)) {
- CClientDataModelBridge *theBridge = doc->GetStudioSystem()->GetClientDataModelBridge();
- qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide();
-
- // Slide, scene or component
- if (inInstance == theBridge->GetOwningComponentInstance(activeSlide)) {
- Qt3DSDMInstanceHandle activeSlideInstance = doc->GetStudioSystem()->GetSlideSystem()
- ->GetSlideInstance(activeSlide);
-
- inspectableBase = new Qt3DSDMInspectable(inInstance, activeSlideInstance);
- }
- if (!inspectableBase) {
- if (theBridge->IsMaterialBaseInstance(inInstance))
- inspectableBase = new Qt3DSDMMaterialInspectable(inInstance);
- else
- inspectableBase = new Qt3DSDMInspectable(inInstance);
- }
+ if (!m_core->GetDoc()->getPresentationId().isEmpty()) {
+ // If the presentation is playing, stop it and leave the playhead where it is
+ if (m_core->GetDoc()->IsPlaying())
+ PlaybackStopNoRestore();
+ // Otherwise, the presentation is stopped, so start it playing
+ else
+ PlaybackPlay();
}
-
- return inspectableBase;
}
-void CStudioApp::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler,
- QWidget *actionParent)
+void CStudioApp::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent)
{
m_core->RegisterGlobalKeyboardShortcuts(inShortcutHandler, actionParent);
- ADD_GLOBAL_SHORTCUT(actionParent,
- QKeySequence(Qt::Key_Period),
- CStudioApp::AdvanceTime);
- ADD_GLOBAL_SHORTCUT(actionParent,
- QKeySequence(Qt::Key_Comma),
- CStudioApp::ReduceTime);
- ADD_GLOBAL_SHORTCUT(actionParent,
- QKeySequence(Qt::ShiftModifier | Qt::Key_Period),
- CStudioApp::AdvanceUltraBigTime);
- ADD_GLOBAL_SHORTCUT(actionParent,
- QKeySequence(Qt::ShiftModifier | Qt::Key_Comma),
- CStudioApp::ReduceUltraBigTime);
- ADD_GLOBAL_SHORTCUT(actionParent,
- QKeySequence(Qt::Key_Return),
- CStudioApp::PlaybackToggle);
+ ADD_GLOBAL_SHORTCUT(actionParent, QKeySequence(Qt::Key_Period), CStudioApp::advanceTime)
+ ADD_GLOBAL_SHORTCUT(actionParent, QKeySequence(Qt::Key_Comma), CStudioApp::reduceTime)
+ ADD_GLOBAL_SHORTCUT(actionParent, QKeySequence(Qt::ShiftModifier | Qt::Key_Period),
+ CStudioApp::advanceTimeBig)
+ ADD_GLOBAL_SHORTCUT(actionParent, QKeySequence(Qt::ShiftModifier | Qt::Key_Comma),
+ CStudioApp::reduceTimeBig)
+ ADD_GLOBAL_SHORTCUT(actionParent, QKeySequence(Qt::Key_Return), CStudioApp::PlaybackToggle)
inShortcutHandler->RegisterKeyUpEvent(
- new CDynHotKeyConsumer<CStudioApp>(this, &CStudioApp::playbackPreviewEnd), 0,
+ new CDynHotKeyConsumer<CStudioApp>(this, &CStudioApp::playbackPreviewEnd), nullptr,
Qt::Key_Space);
inShortcutHandler->RegisterKeyDownEvent(
- new CDynHotKeyConsumer<CStudioApp>(this, &CStudioApp::playbackPreviewStart), 0,
- Qt::Key_Space);
+ new CDynHotKeyConsumer<CStudioApp>(this, &CStudioApp::playbackPreviewStart),
+ nullptr, Qt::Key_Space);
if (m_views)
m_views->registerGlobalKeyboardShortcuts(inShortcutHandler, actionParent);
@@ -1576,7 +1484,6 @@ void CStudioApp::SetAutosaveInterval(int interval)
m_autosaveTimer->setInterval(interval * 1000);
}
-//=============================================================================
/**
* Call to load a new document.
* There should not be a currently active document when this is called.
@@ -1661,6 +1568,13 @@ bool CStudioApp::OnLoadDocument(const QString &inDocument, bool inShowStartupDia
}
} else {
m_dialogs->ResetSettings(loadFile);
+ if (m_core->GetDoc()->ensureActiveCamera())
+ m_dialogs->DisplayMessageBox(
+ tr("More than one camera active"),
+ tr("Layer can only have one active camera. "
+ "Additional cameras were set to inactive."),
+ Qt3DSMessageBox::ICON_WARNING, false);
+
m_core->getProjectFile().updateDocPresentationId();
m_core->getProjectFile().loadSubpresentationsAndDatainputs(m_subpresentations,
m_dataInputDialogItems);
@@ -1672,7 +1586,7 @@ bool CStudioApp::OnLoadDocument(const QString &inDocument, bool inShowStartupDia
m_core->GetDispatch()->FireAuthorZoomChanged();
verifyDatainputBindings();
- checkDeletedDatainputs();
+ checkDeletedDatainputs(true);
}
return theLoadResult;
@@ -1721,12 +1635,6 @@ void CStudioApp::saveDataInputsToProjectFile()
} else if (item->type == EDataType::DataTypeVariant) {
diNode.setAttribute(QStringLiteral("type"), QStringLiteral("Variant"));
}
-#ifdef DATAINPUT_EVALUATOR_ENABLED
- else if (item->type == EDataType::DataTypeEvaluator) {
- diNode.setAttribute(QStringLiteral("type"), QStringLiteral("Evaluator"));
- diNode.setAttribute(QStringLiteral("evaluator"), item->valueString);
- }
-#endif
QHashIterator<QString, QString> it(item->metadata);
QString metadataStr;
@@ -1850,6 +1758,23 @@ QString CStudioApp::OnProjectNew()
}
/**
+ * Closes current project
+ */
+void CStudioApp::OnProjectClose()
+{
+ if (PerformSavePrompt()) {
+ // CloseDocument() clears all the OpenGL buffers so it needs the correct context
+ getRenderer().MakeContextCurrent();
+ m_core->GetDoc()->CloseDocument();
+ getRenderer().ReleaseContext();
+ m_pMainWnd->setActionsEnabledStatus(false);
+ m_pMainWnd->setWindowTitle(QObject::tr("Qt 3D Studio"));
+ showStartupDialog();
+ }
+}
+
+
+/**
* Create a new presentation
* this creates a .uip file
*/
@@ -1890,6 +1815,7 @@ void CStudioApp::OnAsynchronousCommand(CCmd *inCmd)
void CStudioApp::OnDisplayAppStatus(const QString &inStatusMsg)
{
+ Q_UNUSED(inStatusMsg)
// Do nothing, it was used to show this in the status bar
}
@@ -1951,7 +1877,7 @@ void CStudioApp::OnRefreshResourceFail(const QString &inResourceName, const QStr
void CStudioApp::OnNewPresentation()
{
m_core->GetDoc()->GetStudioSystem()->GetAnimationSystem()->SetAutoKeyframe(
- CStudioPreferences::IsAutosetKeyframesOn());
+ CStudioPreferences::isAutosetKeyframesOn());
qCInfo(qt3ds::TRACE_INFO) << "New Presentation: "
<< m_core->GetDoc()->GetDocumentPath();
}
@@ -2069,11 +1995,12 @@ QSize CStudioApp::getRenderableSize(const QString &renderableId)
void CStudioApp::OnUndefinedDatainputsFail(
const QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle,
- qt3dsdm::Qt3DSDMPropertyHandle>> *map)
+ qt3dsdm::Qt3DSDMPropertyHandle>> *map,
+ bool askFromUser)
{
- bool res = m_dialogs->DisplayUndefinedDatainputDlg(map);
+ bool res = askFromUser ? m_dialogs->DisplayUndefinedDatainputDlg(map) : true;
- // Delete invalid datainput bindings if user prompted so.
+ // Delete invalid datainput bindings if user prompted so, or silently if not asked.
if (res) {
m_core->GetDoc()->RemoveDatainputBindings(map);
// clear commands as we do not want to create undo point
@@ -2133,6 +2060,13 @@ void CStudioApp::showPresentationIdEmptyWarning()
Qt3DSMessageBox::ICON_WARNING, false);
}
+void CStudioApp::showShaderCompileError(const QString &error)
+{
+ m_dialogs->DisplayMessageBox(tr("Warning"),
+ tr("Shader compile error.\n") + error,
+ Qt3DSMessageBox::ICON_WARNING, false);
+}
+
void CStudioApp::showInvalidFilenameWarning()
{
m_dialogs->DisplayMessageBox(tr("Invalid filename"),
@@ -2140,7 +2074,7 @@ void CStudioApp::showInvalidFilenameWarning()
Qt3DSMessageBox::ICON_WARNING, false);
}
-void CStudioApp::checkDeletedDatainputs()
+void CStudioApp::checkDeletedDatainputs(bool askFromUser)
{
QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle>> *map;
map = new QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle,
@@ -2150,7 +2084,7 @@ void CStudioApp::checkDeletedDatainputs()
doc->UpdateDatainputMap(map);
if (!map->empty())
- m_core->GetDispatch()->FireOnUndefinedDatainputsFail(map);
+ m_core->GetDispatch()->FireOnUndefinedDatainputsFail(map, askFromUser);
// Update allowed property types for datainput-controlled properties
// in subpresentations. It is ok to do this once
@@ -2161,15 +2095,16 @@ void CStudioApp::checkDeletedDatainputs()
for (auto it : qAsConst(m_dataInputDialogItems))
it->externalPresBoundTypes.clear();
- const QMultiMap<QString, QPair<QString, QString>> spDatainputs
+ const QMultiHash<QString, ProjectFile::DataInputOutputBinding> spDatainputs
= GetCore()->getProjectFile().getDiBindingtypesFromSubpresentations();
-
+ QHash<QString, QHash<QString, qt3dsdm::DataModelDataType::Value>>
+ customPropertyTypes; // sourcepath, <propname, proptype>
// For datainput bindings in subpresentations we do not have specific
// instance and/or property handles. Get the datatype for property using
// the generic name string and leave instance/property handle empty.
for (auto sp = spDatainputs.cbegin(); sp != spDatainputs.cend(); ++sp) {
- const QString propName = sp->second;
- CDataInputDialogItem *item = m_dataInputDialogItems.find(sp->first).value();
+ const QString propName = sp->propertyName;
+ CDataInputDialogItem *item = m_dataInputDialogItems.find(sp->dioName).value();
QPair<qt3dsdm::DataModelDataType::Value, bool> spEntry;
if (propName == QLatin1String("@timeline")) {
spEntry.first = qt3dsdm::DataModelDataType::Value::RangedNumber;
@@ -2178,15 +2113,70 @@ void CStudioApp::checkDeletedDatainputs()
spEntry.first = qt3dsdm::DataModelDataType::Value::String;
spEntry.second = true;
} else {
- qt3dsimp::SImportComposerTypes theTypes;
- qt3dsimp::SImportAsset &theAsset(theTypes.GetImportAssetForType(
- qt3dsdm::ComposerObjectTypes::ControllableObject));
- qt3dsdm::DataModelDataType::Value theType(
- theAsset.GetPropertyDataType(propName.toStdWString().c_str()));
+ qt3dsdm::DataModelDataType::Value theType = qt3dsdm::DataModelDataType::Value::None;
+ if (!sp->propertyDefinitionFile.isEmpty()) {
+ // Check property type from custom property definition file
+ if (!customPropertyTypes.contains(sp->propertyDefinitionFile)) {
+ QHash<QString, qt3dsdm::DataModelDataType::Value> propTypes;
+ QFile file(sp->propertyDefinitionFile);
+ file.open(QFile::Text | QFile::ReadOnly);
+ if (!file.isOpen()) {
+ qWarning() << file.errorString();
+ } else {
+ QString xmlContent = file.readAll();
+ if (sp->propertyDefinitionFile.endsWith(QLatin1String("qml"),
+ Qt::CaseInsensitive)) {
+ // Property defs are in comments in behavior scripts, and not in well
+ // formed XML format, so skip until start of the property definitions
+ // and extract properties under a fake root tag to avoid parsing issues
+ int start = xmlContent.indexOf(QLatin1String("/*[["));
+ if (start != -1) {
+ int end = xmlContent.indexOf(QLatin1String("]]*/"), start);
+ QString tagged = QStringLiteral("<Behavior>\n");
+ tagged.append(xmlContent.mid(start, end - start).trimmed());
+ tagged.append(QLatin1String("</Behavior>\n"));
+ tagged.replace(QLatin1String("\r\n"), QLatin1String("\n"));
+ xmlContent = tagged;
+ }
+ }
+ QDomDocument domDoc;
+ domDoc.setContent(xmlContent);
+ QDomNodeList propElems
+ = domDoc.elementsByTagName(QStringLiteral("Property"));
+ for (int i = 0; i < propElems.count(); ++i) {
+ QDomElement elem = propElems.at(i).toElement();
+ const QString metaName = elem.attribute(QStringLiteral("name"));
+ const QString metaType = elem.attribute(QStringLiteral("type"));
+ qt3dsdm::DataModelDataType::Value dataType;
+ if (metaType.isEmpty()) {
+ dataType = qt3dsdm::DataModelDataType::Value::Float;
+ } else {
+ QByteArray buf((metaType.size() + 1) * int(sizeof(wchar_t)),'\0');
+ metaType.toWCharArray(reinterpret_cast<wchar_t *>(buf.data()));
+ qt3dsdm::CompleteMetaDataType::Enum typeValue;
+ WStrOps<qt3dsdm::CompleteMetaDataType::Enum> converter;
+ converter.StrTo(reinterpret_cast<const wchar_t *>(
+ buf.constData()), typeValue);
+ dataType = qt3dsdm::CompleteMetaDataType::ToDataType(typeValue);
+ }
+ propTypes.insert(metaName, dataType);
+ }
+ customPropertyTypes.insert(sp->propertyDefinitionFile, propTypes);
+ }
+ }
+ theType = customPropertyTypes[sp->propertyDefinitionFile].value(
+ propName, qt3dsdm::DataModelDataType::Value::None);
+ }
+ if (theType == qt3dsdm::DataModelDataType::Value::None) {
+ qt3dsimp::SImportComposerTypes theTypes;
+ qt3dsimp::SImportAsset &theAsset(
+ theTypes.GetImportAssetForType(
+ qt3dsdm::ComposerObjectTypes::ControllableObject));
+ theType = theAsset.GetPropertyDataType(propName.toStdWString().c_str());
+ }
spEntry.first = theType;
spEntry.second = false;
}
-
item->externalPresBoundTypes.insert(sp.key(), spEntry);
}
}
diff --git a/src/Authoring/Qt3DStudio/Application/StudioApp.h b/src/Authoring/Qt3DStudio/Application/StudioApp.h
index 86603af0..11e50138 100644
--- a/src/Authoring/Qt3DStudio/Application/StudioApp.h
+++ b/src/Authoring/Qt3DStudio/Application/StudioApp.h
@@ -194,12 +194,11 @@ public:
bool PerformSavePrompt();
void PlaybackStop();
bool isPlaybackPreviewOn() const;
- void AdvanceTime();
- void ReduceTime();
- void AdvanceUltraBigTime();
- void ReduceUltraBigTime();
+ void advanceTime();
+ void reduceTime();
+ void advanceTimeBig();
+ void reduceTimeBig();
void PlaybackToggle();
- CInspectableBase *getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent);
bool OnSave(bool autosave = false);
void onProjectSaveAs();
@@ -207,6 +206,7 @@ public:
void OnLoadDocumentCatcher(const QString &inLocation);
void OnFileOpen();
QString OnProjectNew();
+ void OnProjectClose();
void OnFileNew();
bool IsAuthorZoom() const;
bool isOnProgress() const;
@@ -219,7 +219,8 @@ public:
void showPresentationIdUniqueWarning();
void showPresentationIdEmptyWarning();
void showInvalidFilenameWarning();
- void checkDeletedDatainputs();
+ void showShaderCompileError(const QString &error);
+ void checkDeletedDatainputs(bool askFromUser);
void saveDataInputsToProjectFile();
void verifyDatainputBindings();
void duplicatePresentation(const QString &presFile = {});
@@ -241,17 +242,40 @@ public:
void OnErrorFail(const QString &inText) override;
void OnRefreshResourceFail(const QString &inResourceName,
const QString &inDescription) override;
- void OnUndefinedDatainputsFail(
- const QMultiMap<QString,
- QPair<qt3dsdm::Qt3DSDMInstanceHandle,
- qt3dsdm::Qt3DSDMPropertyHandle>> *map) override;
+ void OnUndefinedDatainputsFail(const QMultiMap<QString,
+ QPair<qt3dsdm::Qt3DSDMInstanceHandle,
+ qt3dsdm::Qt3DSDMPropertyHandle>> *map,
+ bool askFromUser) override;
// CPresentationChangeListener
void OnNewPresentation() override;
void OnPresentationModifiedExternally() override;
+ void SetConvertingPresentationOn()
+ {
+ m_convertPresentation = true;
+ }
+ void SetConvertingPresentationOff()
+ {
+ m_convertPresentation = false;
+ }
+ bool IsConvertingPresentationOn()
+ {
+ return m_convertPresentation;
+ }
+ int getDocumentVersion() const
+ {
+ return m_docVersion;
+ }
+ void setDocumentVersion(int version)
+ {
+ m_docVersion = version;
+ }
+
QString m_helpFilePath;
QString m_gettingStartedFilePath;
+ bool m_convertPresentation = false;
+ int m_docVersion = 0;
QVector<SubPresentationRecord> m_subpresentations;
QMap<QString, CDataInputDialogItem *> m_dataInputDialogItems;
diff --git a/src/Authoring/Qt3DStudio/Application/StudioTutorialWidget.cpp b/src/Authoring/Qt3DStudio/Application/StudioTutorialWidget.cpp
index bb80e7bf..4cd9797c 100644
--- a/src/Authoring/Qt3DStudio/Application/StudioTutorialWidget.cpp
+++ b/src/Authoring/Qt3DStudio/Application/StudioTutorialWidget.cpp
@@ -75,8 +75,7 @@ void StudioTutorialWidget::OnInitDialog()
setFixedSize(backgroundSize);
- QSettings settings;
- m_ui->studioTutorialShowAgain->setChecked(!settings.value("showWelcomeScreen").toBool());
+ m_ui->studioTutorialShowAgain->setChecked(!CStudioPreferences::isShowWelcomeScreen());
m_backgroundPalette = new QPalette(palette());
QPixmap background(size());
QPainter backgroundPainter(&background);
@@ -94,9 +93,7 @@ void StudioTutorialWidget::OnInitDialog()
void StudioTutorialWidget::handleDoNotShowAgainChange(int state)
{
- QSettings settings;
- const bool show = !(state == Qt::Checked);
- settings.setValue("showWelcomeScreen", show);
+ CStudioPreferences::setShowWelcomeScreen(!(state == Qt::Checked));
}
void StudioTutorialWidget::handleOpenSample()
diff --git a/src/Authoring/Qt3DStudio/Controls/AppFonts.cpp b/src/Authoring/Qt3DStudio/Controls/AppFonts.cpp
index 6b491cf1..13209cc1 100644
--- a/src/Authoring/Qt3DStudio/Controls/AppFonts.cpp
+++ b/src/Authoring/Qt3DStudio/Controls/AppFonts.cpp
@@ -38,7 +38,7 @@
CAppFonts::CAppFonts()
{
// Normal font
- const QString theFontFace = CStudioPreferences::GetFontFaceName();
+ const QString theFontFace = CStudioPreferences::fontFaceName();
m_NormalFont.setFamily(theFontFace);
m_NormalFont.setPointSize(13);
diff --git a/src/Authoring/Qt3DStudio/DragAndDrop/BasicObjectDropSource.cpp b/src/Authoring/Qt3DStudio/DragAndDrop/BasicObjectDropSource.cpp
index 3ad659d2..ecaae33a 100644
--- a/src/Authoring/Qt3DStudio/DragAndDrop/BasicObjectDropSource.cpp
+++ b/src/Authoring/Qt3DStudio/DragAndDrop/BasicObjectDropSource.cpp
@@ -163,6 +163,9 @@ CCmd *CBasicObjectDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandl
case OBJTYPE_GROUP:
theComposerType = ComposerObjectTypes::Group;
break;
+ case OBJTYPE_SIGNAL:
+ theComposerType = ComposerObjectTypes::Signal;
+ break;
case OBJTYPE_IMAGE:
theComposerType = ComposerObjectTypes::Image;
break;
@@ -239,8 +242,11 @@ CCmd *CBasicObjectDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandl
Q3DStudio::FileOpenFlags(Q3DStudio::FileOpenFlagValues::Create),
theResFontFile);
// Force the text renderer to refresh
- if (theDoc->GetSceneGraph() && theDoc->GetSceneGraph()->GetTextRenderer())
+ if (theDoc->GetSceneGraph() && theDoc->GetSceneGraph()->GetTextRenderer()) {
theDoc->GetSceneGraph()->GetTextRenderer()->ReloadFonts();
+ if (theDoc->GetSceneGraph()->GetDistanceFieldRenderer())
+ theDoc->GetSceneGraph()->GetDistanceFieldRenderer()->ReloadFonts();
+ }
}
// Lastly, we use the font file to create the Text object. This is similar to drag-drop
@@ -251,10 +257,17 @@ CCmd *CBasicObjectDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandl
Q3DStudio::ImportUtils::GetInsertTypeForDropType(inDestType), thePoint,
theStartTime);
} else {
- SCOPED_DOCUMENT_EDITOR(*theDoc, QObject::tr("Add Instance"))
- ->CreateSceneGraphInstance(theComposerType, inTarget, inSlide, theInsertType,
+ ScopedDocumentEditor editor(
+ SCOPED_DOCUMENT_EDITOR(*theDoc, QObject::tr("Add Instance")));
+ Qt3DSDMInstanceHandle newHandle =
+ editor->CreateSceneGraphInstance(theComposerType, inTarget, inSlide, theInsertType,
thePoint, (EPrimitiveType)m_PrimitiveType, theStartTime,
false);
+
+ if (theComposerType == ComposerObjectTypes::Signal) {
+ // When creating a signal, automatically create also onActivate action
+ editor->AddAction(inSlide, newHandle, L"onActivate", L"Emit Signal");
+ }
}
}
return nullptr;
diff --git a/src/Authoring/Qt3DStudio/Info.plist b/src/Authoring/Qt3DStudio/Info.plist
index 5dcc69d1..de9a9cac 100644
--- a/src/Authoring/Qt3DStudio/Info.plist
+++ b/src/Authoring/Qt3DStudio/Info.plist
@@ -2,78 +2,78 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>UTImportedTypeDeclarations</key>
- <array>
- <dict>
- <key>UTTypeDescription</key>
- <string>Qt 3D Studio Application File</string>
- <key>UTTypeConformsTo</key>
- <array>
- <string>public.source-code</string>
- </array>
- <key>UTTypeIdentifier</key>
- <string>org.qt-project.uia</string>
- <key>UTTypeTagSpecification</key>
- <dict>
- <key>public.filename-extension</key>
- <array>
- <string>uia</string>
- </array>
- </dict>
- </dict>
- <dict>
- <key>UTTypeDescription</key>
- <string>Qt 3D Studio Presentation File</string>
- <key>UTTypeConformsTo</key>
- <array>
- <string>public.source-code</string>
- </array>
- <key>UTTypeIdentifier</key>
- <string>org.qt-project.uip</string>
- <key>UTTypeTagSpecification</key>
- <dict>
- <key>public.filename-extension</key>
- <array>
- <string>uip</string>
- </array>
- </dict>
- </dict>
- </array>
- <key>CFBundleDocumentTypes</key>
- <array>
- <dict>
- <key>LSItemContentTypes</key>
- <array>
- <string>org.qt-project.uip</string>
- <string>org.qt-project.uia</string>
- </array>
- <key>CFBundleTypeRole</key>
- <string>Editor</string>
- <key>LSHandlerRank</key>
- <string>Default</string>
- </dict>
- </array>
- <key>NSHumanReadableCopyright</key>
- <string>(C) 2019 The Qt Company Ltd</string>
- <key>CFBundleExecutable</key>
- <string>Qt3DStudio</string>
- <key>CFBundleIconFile</key>
- <string>studio.icns</string>
- <key>CFBundleIdentifier</key>
- <string>org.qt-project.qt3dstudio</string>
- <key>CFBundleVersion</key>
- <string>2.4.0</string>
- <key>CFBundleShortVersionString</key>
- <string>2.4</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>LSMinimumSystemVersion</key>
- <string>10.10</string>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>NSSupportsAutomaticGraphicsSwitching</key>
- <true/>
+ <key>UTImportedTypeDeclarations</key>
+ <array>
+ <dict>
+ <key>UTTypeDescription</key>
+ <string>Qt 3D Studio Application File</string>
+ <key>UTTypeConformsTo</key>
+ <array>
+ <string>public.source-code</string>
+ </array>
+ <key>UTTypeIdentifier</key>
+ <string>org.qt-project.uia</string>
+ <key>UTTypeTagSpecification</key>
+ <dict>
+ <key>public.filename-extension</key>
+ <array>
+ <string>uia</string>
+ </array>
+ </dict>
+ </dict>
+ <dict>
+ <key>UTTypeDescription</key>
+ <string>Qt 3D Studio Presentation File</string>
+ <key>UTTypeConformsTo</key>
+ <array>
+ <string>public.source-code</string>
+ </array>
+ <key>UTTypeIdentifier</key>
+ <string>org.qt-project.uip</string>
+ <key>UTTypeTagSpecification</key>
+ <dict>
+ <key>public.filename-extension</key>
+ <array>
+ <string>uip</string>
+ </array>
+ </dict>
+ </dict>
+ </array>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>LSItemContentTypes</key>
+ <array>
+ <string>org.qt-project.uip</string>
+ <string>org.qt-project.uia</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>LSHandlerRank</key>
+ <string>Default</string>
+ </dict>
+ </array>
+ <key>NSHumanReadableCopyright</key>
+ <string>(C) 2020 The Qt Company Ltd</string>
+ <key>CFBundleExecutable</key>
+ <string>Qt3DStudio</string>
+ <key>CFBundleIconFile</key>
+ <string>studio.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.qt-project.qt3dstudio</string>
+ <key>CFBundleVersion</key>
+ <string>2.8.0</string>
+ <key>CFBundleShortVersionString</key>
+ <string>2.8</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.10</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
</dict>
</plist>
diff --git a/src/Authoring/Qt3DStudio/MainFrm.cpp b/src/Authoring/Qt3DStudio/MainFrm.cpp
index 3f2f946f..8a868d23 100644
--- a/src/Authoring/Qt3DStudio/MainFrm.cpp
+++ b/src/Authoring/Qt3DStudio/MainFrm.cpp
@@ -32,7 +32,6 @@
#include "StudioConst.h"
#include "SceneView.h"
#include "StudioApp.h"
-#include "IKeyframesManager.h"
#include "Dialogs.h"
#include "StudioPreferencesPropSheet.h"
#include "StudioPreferences.h"
@@ -57,7 +56,6 @@
#include <QtGui/qevent.h>
#include <QtGui/qdesktopservices.h>
-#include <QtCore/qsettings.h>
#include <QtCore/qurl.h>
#include <QtCore/qprocess.h>
#include <QtGui/qfontdatabase.h>
@@ -97,6 +95,7 @@ CMainFrame::CMainFrame()
connect(m_ui->action_Duplicate_Presentation, &QAction::triggered,
this, &CMainFrame::onDuplicatePresentation);
connect(m_ui->action_Revert, &QAction::triggered, this, &CMainFrame::OnFileRevert);
+ connect(m_ui->action_Close, &QAction::triggered, this, &CMainFrame::OnProjectClose);
connect(m_ui->actionImportAssets, &QAction::triggered, this, &CMainFrame::OnFileImportAssets);
connect(m_ui->actionData_Inputs, &QAction::triggered, this, &CMainFrame::OnFileDataInputs);
connect(m_ui->actionData_InputsGenerate, &QAction::triggered, this,
@@ -176,7 +175,13 @@ CMainFrame::CMainFrame()
connect(m_ui->actionPivot_Point, &QAction::triggered, this, &CMainFrame::OnViewPivotPoint);
connect(m_ui->actionWireframe, &QAction::triggered, this, &CMainFrame::OnViewWireframe);
connect(m_ui->actionTooltips, &QAction::triggered, this, &CMainFrame::OnViewTooltips);
- connect(m_ui->actionCamera_Preview, &QAction::triggered, this, &CMainFrame::OnShowEditPreview);
+
+ connect(m_ui->actionHelper_Grid, &QAction::triggered, this, &CMainFrame::onHelperGrid);
+ connect(m_ui->actionAxis_Helper, &QAction::triggered, this, &CMainFrame::onAxisHelper);
+ m_ui->actionHelper_Grid->setToolTip(
+ m_ui->actionHelper_Grid->toolTip().arg(
+ m_ui->actionHelper_Grid->shortcut().toString(QKeySequence::NativeText)));
+
connect(m_ui->actionEdit_Lighting, &QAction::triggered, this,
&CMainFrame::OnEditViewLightingEnabled);
// connect(m_ui->actionFind, &QAction::triggered, this, &CMainFrame::onViewFind); // TODO: Implement
@@ -214,16 +219,6 @@ CMainFrame::CMainFrame()
connect(m_ui->actionRemote_Preview, &QAction::triggered,
this, &CMainFrame::OnPlaybackPreviewRemote);
- // Only show Qt3D runtime preview if we have appropriate viewer and it's enabled
- if (CStudioPreferences::IsLegacyViewerActive()
- && QFileInfo(CPreviewHelper::getViewerFilePath(QStringLiteral("q3dsviewer"))).exists()) {
- connect(m_ui->actionPreviewQt3DRuntime, &QAction::triggered,
- this, &CMainFrame::OnPlaybackPreviewQt3DRuntime);
- m_ui->actionPreviewQt3DRuntime->setVisible(true);
- } else {
- m_ui->actionPreviewQt3DRuntime->setVisible(false);
- }
-
// Tool mode toolbar
connect(m_ui->actionPosition_Tool, &QAction::triggered, this,
std::bind(&CMainFrame::onTransformToolChanged, this, STUDIO_TOOLMODE_MOVE));
@@ -277,6 +272,8 @@ CMainFrame::CMainFrame()
OnUpdateViewPivotPoint();
OnUpdateViewWireframe();
OnUpdateViewTooltips();
+ onUpdateHelperGrid();
+ onUpdateAxisHelper();
OnUpdateViewTimeline();
onUpdateViewSceneCamera();
OnUpdateViewInspector();
@@ -298,7 +295,6 @@ CMainFrame::CMainFrame()
OnUpdateViewGuidesRulers();
OnUpdateClearGuides();
OnUpdateLockGuides();
- OnUpdateCameraPreview();
OnUpdateEditViewLightingEnabled();
});
@@ -314,6 +310,35 @@ CMainFrame::~CMainFrame()
m_updateUITimer->stop();
}
+/**
+ * Enable/disable menu and toolbar actions which require project availability.
+ */
+void CMainFrame::setActionsEnabledStatus(bool enabled)
+{
+ m_ui->m_ClientToolsBar->setEnabled(enabled);
+ m_ui->m_EditCamerasBar->setEnabled(enabled);
+ m_ui->m_PlaybackToolbar->setEnabled(enabled);
+ m_ui->menu_Edit->setEnabled(enabled);
+ m_ui->menu_Timeline->setEnabled(enabled);
+ m_ui->menu_View->setEnabled(enabled);
+ m_ui->action_Save_Project_As->setEnabled(enabled);
+ m_ui->action_Duplicate_Presentation->setEnabled(enabled);
+ m_ui->action_Connect_to_Device->setEnabled(enabled);
+ m_ui->action_Revert->setEnabled(enabled);
+ m_ui->action_Close->setEnabled(enabled);
+ m_ui->actionImportAssets->setEnabled(enabled);
+ m_ui->action_New_Presentation->setEnabled(enabled);
+ m_ui->actionData_Inputs->setEnabled(enabled);
+ m_ui->actionData_InputsGenerate->setEnabled(enabled);
+ m_ui->actionAutoset_Keyframes->setEnabled(enabled);
+ m_ui->action_Duplicate_Object->setEnabled(enabled);
+ m_ui->actionStudio_Preferences->setEnabled(enabled);
+ m_ui->actionPresentation_Settings->setEnabled(enabled);
+ // Note: actionRemote_Preview is a special case. isChecked changes based on OnConnectionChanged.
+ if (!enabled)
+ m_ui->actionRemote_Preview->setEnabled(m_ui->action_Connect_to_Device->isChecked());
+}
+
// Timer callback
void CMainFrame::onPlaybackTimeout()
{
@@ -367,21 +392,8 @@ void CMainFrame::OnCreate()
delete m_ui->toolBar;
// Disable toolbars and menus until we have a presentation
- m_ui->m_ClientToolsBar->setEnabled(false);
- m_ui->m_EditCamerasBar->setEnabled(false);
- m_ui->m_PlaybackToolbar->setEnabled(false);
- m_ui->menu_Edit->setEnabled(false);
- m_ui->menu_Timeline->setEnabled(false);
- m_ui->menu_View->setEnabled(false);
- m_ui->action_Save_Project_As->setEnabled(false);
- m_ui->action_Duplicate_Presentation->setEnabled(false);
- m_ui->action_Connect_to_Device->setEnabled(false);
- m_ui->action_Revert->setEnabled(false);
- m_ui->actionImportAssets->setEnabled(false);
- m_ui->actionRemote_Preview->setEnabled(false);
- m_ui->action_New_Presentation->setEnabled(false);
- m_ui->actionData_Inputs->setEnabled(false);
- m_ui->actionData_InputsGenerate->setEnabled(false);
+ setActionsEnabledStatus(false);
+
#if 1 // TODO: Hidden until UX decision is made if these buttons are needed at all or not
m_ui->actionPan_Tool->setVisible(false);
m_ui->actionOrbit_Tool->setVisible(false);
@@ -407,20 +419,7 @@ void CMainFrame::OnNewPresentation()
m_ui->m_EditCamerasBar->setupCameras();
// Enable dockables, toolbars, and menus
m_paletteManager->EnablePalettes();
- m_ui->m_ClientToolsBar->setEnabled(true);
- m_ui->m_EditCamerasBar->setEnabled(true);
- m_ui->m_PlaybackToolbar->setEnabled(true);
- m_ui->menu_Edit->setEnabled(true);
- m_ui->menu_Timeline->setEnabled(true);
- m_ui->menu_View->setEnabled(true);
- m_ui->action_Save_Project_As->setEnabled(true);
- m_ui->action_Duplicate_Presentation->setEnabled(true);
- m_ui->action_Connect_to_Device->setEnabled(true);
- m_ui->action_Revert->setEnabled(true);
- m_ui->actionImportAssets->setEnabled(true);
- m_ui->action_New_Presentation->setEnabled(true);
- m_ui->actionData_Inputs->setEnabled(true);
- m_ui->actionData_InputsGenerate->setEnabled(true);
+ setActionsEnabledStatus(true);
// Clear data input list and sub-presentation list
g_StudioApp.m_subpresentations.clear();
@@ -437,6 +436,9 @@ void CMainFrame::OnNewPresentation()
*/
void CMainFrame::OnClosingPresentation()
{
+ g_StudioApp.GetCore()->GetDoc()->setPresentationId({});
+ m_paletteManager->EnablePalettes(false);
+ setActionsEnabledStatus(false);
}
/**
@@ -676,7 +678,8 @@ void CMainFrame::OnUpdateTimelineDeleteSelectedKeyframes()
*/
void CMainFrame::OnUpdateTimelineSetInterpolation()
{
- m_ui->actionSet_Interpolation->setEnabled(getTimelineWidget()->hasSelectedKeyframes());
+ bool enabled = g_StudioApp.GetCore()->GetDoc()->canSetKeyframeInterpolation();
+ m_ui->actionSet_Interpolation->setEnabled(enabled);
}
/**
@@ -750,6 +753,15 @@ void CMainFrame::OnProjectNew()
g_StudioApp.OnProjectNew();
}
+/**
+ * Command handler for the Close Project menu option.
+ * This will close the currently open project.
+ */
+void CMainFrame::OnProjectClose()
+{
+ g_StudioApp.OnProjectClose();
+}
+
void CMainFrame::OnFileNew()
{
g_StudioApp.OnFileNew();
@@ -861,35 +873,50 @@ void CMainFrame::EditPreferences(short inPageIndex)
if (thePrefsReturn == PREFS_RESET_DEFAULTS) {
// Restore default values
+ // Timeline
g_StudioApp.SetAutosetKeyframes(true); // Sets the preference as well
- CStudioPreferences::SetBoundingBoxesOn(true);
- CStudioPreferences::SetDisplayPivotPoint(true);
- CStudioPreferences::SetWireframeModeOn(true);
- CStudioPreferences::SetShowTooltips(true);
- CStudioPreferences::SetTimebarDisplayTime(false);
g_StudioApp.GetCore()->GetDoc()->SetDefaultKeyframeInterpolation(true);
- CStudioPreferences::SetSnapRange(CStudioPreferences::DEFAULT_SNAPRANGE);
- CStudioPreferences::SetDefaultObjectLifetime(CStudioPreferences::DEFAULT_LIFETIME);
- CStudioPreferences::SetAdvancePropertyExpandedFlag(false);
- CStudioPreferences::SetPreviewConfig("");
- CStudioPreferences::SetPreviewProperty("", "");
- CStudioPreferences::SetDontShowGLVersionDialog(false);
- CStudioPreferences::SetDefaultClientSize(CStudioPreferences::DEFAULT_CLIENT_WIDTH,
+ CStudioPreferences::setTimebarDisplayTime(false);
+ CStudioPreferences::setTimeAdvanceAmount(CStudioPreferences::DEFAULT_TIME_ADVANCE);
+ CStudioPreferences::setBigTimeAdvanceAmount(CStudioPreferences::DEFAULT_BIG_TIME_ADVANCE);
+ CStudioPreferences::setTimelineSnappingGridActive(true);
+ CStudioPreferences::setTimelineSnappingGridResolution(SNAPGRID_SECONDS);
+ CStudioPreferences::setSnapRange(CStudioPreferences::DEFAULT_SNAPRANGE);
+ CStudioPreferences::setTimelineSplitterLocation(250.);
+
+ // Viewing
+ CStudioPreferences::setDontShowGLVersionDialog(false);
+ CStudioPreferences::setDefaultClientSize(CStudioPreferences::DEFAULT_CLIENT_WIDTH,
CStudioPreferences::DEFAULT_CLIENT_HEIGHT);
- CStudioPreferences::SetTimeAdvanceAmount(CStudioPreferences::DEFAULT_TIME_ADVANCE);
- CStudioPreferences::SetBigTimeAdvanceAmount(CStudioPreferences::DEFAULT_BIG_TIME_ADVANCE);
- CStudioPreferences::SetTimelineSnappingGridActive(true);
- CStudioPreferences::SetTimelineSnappingGridResolution(SNAPGRID_SECONDS);
- CStudioPreferences::SetLegacyViewerActive(true);
- CStudioPreferences::SetEditViewFillMode(true);
- CStudioPreferences::SetPreferredStartupView(
+ CStudioPreferences::setEditViewFillMode(true);
+ CStudioPreferences::setPreferredStartupView(
CStudioPreferences::PREFERREDSTARTUP_DEFAULTINDEX);
- CStudioPreferences::SetAutoSaveDelay(CStudioPreferences::DEFAULT_AUTOSAVE_DELAY);
- CStudioPreferences::SetAutoSavePreference(true);
+ CStudioPreferences::setEditModeLightingEnabled(false);
+
+ // VisualAids
+ CStudioPreferences::setBoundingBoxesOn(true);
+ CStudioPreferences::setPivotPointOn(true);
+ CStudioPreferences::setWireframeModeOn(true);
+ CStudioPreferences::setTooltipsOn(true);
+ CStudioPreferences::setHelperGridOn(true);
+ CStudioPreferences::setAxisHelperOn(true);
+ CStudioPreferences::setHelperGridLines(10);
+ CStudioPreferences::setHelperGridSpacing(100);
CStudioPreferences::setSelectorLineWidth(
- (float)CStudioPreferences::DEFAULT_SELECTOR_WIDTH / 10.0f);
+ float(CStudioPreferences::DEFAULT_SELECTOR_WIDTH / 10.0f));
CStudioPreferences::setSelectorLineLength(
- (float)CStudioPreferences::DEFAULT_SELECTOR_LENGTH);
+ float(CStudioPreferences::DEFAULT_SELECTOR_LENGTH));
+
+ // Autosave
+ CStudioPreferences::setAutoSaveDelay(CStudioPreferences::DEFAULT_AUTOSAVE_DELAY);
+ CStudioPreferences::setAutoSavePreference(true);
+
+ // Preview
+ CStudioPreferences::setPreviewConfig({});
+ CStudioPreferences::setPreviewProperty({}, {});
+
+ // Pop-ups
+ CStudioPreferences::setDoNotShowImportWarnings(false);
RecheckSizingMode();
@@ -912,10 +939,10 @@ void CMainFrame::EditPreferences(short inPageIndex)
void CMainFrame::OnToolAutosetkeys()
{
// Toggle autoset keyframes to the opposite of what it's currently set as
- g_StudioApp.SetAutosetKeyframes(!CStudioPreferences::IsAutosetKeyframesOn());
+ g_StudioApp.SetAutosetKeyframes(!CStudioPreferences::isAutosetKeyframesOn());
// Don't wait for regular update cycle to update the corresponding toolbar/menu checked status
- m_ui->actionAutoset_Keyframes->setChecked(CStudioPreferences::IsAutosetKeyframesOn());
+ m_ui->actionAutoset_Keyframes->setChecked(CStudioPreferences::isAutosetKeyframesOn());
}
/**
@@ -927,7 +954,7 @@ void CMainFrame::OnToolAutosetkeys()
void CMainFrame::OnUpdateToolAutosetkeys()
{
// If autoset keyframes is on
- m_ui->actionAutoset_Keyframes->setChecked(CStudioPreferences::IsAutosetKeyframesOn());
+ m_ui->actionAutoset_Keyframes->setChecked(CStudioPreferences::isAutosetKeyframesOn());
}
/**
@@ -966,6 +993,7 @@ void CMainFrame::OnPlayStop()
*/
void CMainFrame::OnTimeChanged(long inTime)
{
+ Q_UNUSED(inTime)
}
/**
@@ -999,11 +1027,6 @@ void CMainFrame::OnPlaybackPreview(const QString &viewerExeName, bool remote)
}
}
-void CMainFrame::OnPlaybackPreviewQt3DRuntime()
-{
- OnPlaybackPreview(QStringLiteral("q3dsviewer"));
-}
-
void CMainFrame::OnPlaybackPreviewOpenGLRuntime()
{
OnPlaybackPreview(QStringLiteral("Qt3DViewer"));
@@ -1100,6 +1123,7 @@ void CMainFrame::OnPlaybackRewind()
*/
void CMainFrame::RegisterGlobalKeyboardShortcuts(CHotKeys *inHotKeys, QWidget *actionParent)
{
+ Q_UNUSED(inHotKeys)
// Default undo shortcut is Ctrl-Y, which is specified in main form. Let's add the common
// alternate shortcut for redo, CTRL-SHIFT-Z
ADD_GLOBAL_SHORTCUT(actionParent,
@@ -1436,15 +1460,9 @@ void CMainFrame::OnUpdateLockGuides()
m_ui->actionLock_Guides->setChecked(!g_StudioApp.getRenderer().AreGuidesEditable());
}
-void CMainFrame::OnUpdateCameraPreview()
-{
- m_ui->actionCamera_Preview->setChecked(CStudioPreferences::showEditModePreview());
- g_StudioApp.getRenderer().RequestRender();
-}
-
void CMainFrame::OnUpdateEditViewLightingEnabled()
{
- m_ui->actionEdit_Lighting->setChecked(CStudioPreferences::editModeLightingEnabled());
+ m_ui->actionEdit_Lighting->setChecked(CStudioPreferences::isEditModeLightingEnabled());
g_StudioApp.getRenderer().RequestRender();
}
@@ -1464,13 +1482,10 @@ void CMainFrame::onViewResetLayout()
"layout? \nYour current layout will be lost, and "
"Studio will restart."));
- // If "Yes" is clicked, delete window geometry and window state keys from QSettings
+ // If "Yes" is clicked, delete window geometry and window state keys
if (theChoice == QMessageBox::Yes) {
- QSettings settings;
- QString geoKey = QStringLiteral("mainWindowGeometry") + QString::number(STUDIO_VERSION_NUM);
- QString stateKey = QStringLiteral("mainWindowState") + QString::number(STUDIO_VERSION_NUM);
- settings.remove(geoKey);
- settings.remove(stateKey);
+ CStudioPreferences::resetWindowGeometry(STUDIO_VERSION_NUM);
+ CStudioPreferences::resetWindowState(STUDIO_VERSION_NUM);
// Prevent saving geometry and state, and exit
m_resettingLayout = true;
QTimer::singleShot(0, this, &CMainFrame::handleRestart);
@@ -1574,7 +1589,7 @@ void CMainFrame::onUpdateViewSceneCamera()
*/
void CMainFrame::OnViewBoundingBoxes()
{
- CStudioPreferences::SetBoundingBoxesOn(!CStudioPreferences::IsBoundingBoxesOn());
+ CStudioPreferences::setBoundingBoxesOn(!CStudioPreferences::isBoundingBoxesOn());
g_StudioApp.getRenderer().RequestRender();
}
@@ -1585,7 +1600,7 @@ void CMainFrame::OnViewBoundingBoxes()
*/
void CMainFrame::OnUpdateViewBoundingBoxes()
{
- m_ui->actionBounding_Boxes->setChecked(CStudioPreferences::IsBoundingBoxesOn());
+ m_ui->actionBounding_Boxes->setChecked(CStudioPreferences::isBoundingBoxesOn());
}
//==============================================================================
@@ -1594,7 +1609,7 @@ void CMainFrame::OnUpdateViewBoundingBoxes()
*/
void CMainFrame::OnViewPivotPoint()
{
- CStudioPreferences::SetDisplayPivotPoint(!CStudioPreferences::ShouldDisplayPivotPoint());
+ CStudioPreferences::setPivotPointOn(!CStudioPreferences::isPivotPointOn());
g_StudioApp.getRenderer().RequestRender();
}
@@ -1605,7 +1620,7 @@ void CMainFrame::OnViewPivotPoint()
*/
void CMainFrame::OnUpdateViewPivotPoint()
{
- m_ui->actionPivot_Point->setChecked(CStudioPreferences::ShouldDisplayPivotPoint());
+ m_ui->actionPivot_Point->setChecked(CStudioPreferences::isPivotPointOn());
}
//==============================================================================
@@ -1614,10 +1629,10 @@ void CMainFrame::OnUpdateViewPivotPoint()
*/
void CMainFrame::OnViewWireframe()
{
- CStudioPreferences::SetWireframeModeOn(!CStudioPreferences::IsWireframeModeOn());
+ CStudioPreferences::setWireframeModeOn(!CStudioPreferences::isWireframeModeOn());
// Don't wait for regular update cycle to update the corresponding toolbar/menu checked status
- m_ui->actionWireframe->setChecked(CStudioPreferences::IsWireframeModeOn());
+ m_ui->actionWireframe->setChecked(CStudioPreferences::isWireframeModeOn());
g_StudioApp.getRenderer().RequestRender();
}
@@ -1629,7 +1644,7 @@ void CMainFrame::OnViewWireframe()
*/
void CMainFrame::OnUpdateViewWireframe()
{
- m_ui->actionWireframe->setChecked(CStudioPreferences::IsWireframeModeOn());
+ m_ui->actionWireframe->setChecked(CStudioPreferences::isWireframeModeOn());
}
//==============================================================================
@@ -1640,7 +1655,7 @@ void CMainFrame::OnUpdateViewWireframe()
*/
void CMainFrame::OnUpdateViewTooltips()
{
- m_ui->actionTooltips->setChecked(CStudioPreferences::ShouldShowTooltips());
+ m_ui->actionTooltips->setChecked(CStudioPreferences::isTooltipsOn());
}
//==============================================================================
@@ -1650,7 +1665,33 @@ void CMainFrame::OnUpdateViewTooltips()
*/
void CMainFrame::OnViewTooltips()
{
- CStudioPreferences::SetShowTooltips(!CStudioPreferences::ShouldShowTooltips());
+ CStudioPreferences::setTooltipsOn(!CStudioPreferences::isTooltipsOn());
+}
+
+void CMainFrame::onUpdateHelperGrid()
+{
+ if (m_sceneView.data() == GetActiveView() && !m_sceneView->isDeploymentView()) {
+ m_ui->actionHelper_Grid->setEnabled(true);
+ m_ui->actionHelper_Grid->setChecked(CStudioPreferences::isHelperGridOn());
+ } else {
+ m_ui->actionHelper_Grid->setEnabled(false);
+ m_ui->actionHelper_Grid->setChecked(false);
+ }
+}
+
+void CMainFrame::onUpdateAxisHelper()
+{
+ m_ui->actionAxis_Helper->setChecked(CStudioPreferences::isAxisHelperOn());
+}
+
+void CMainFrame::onHelperGrid()
+{
+ CStudioPreferences::setHelperGridOn(!CStudioPreferences::isHelperGridOn());
+}
+
+void CMainFrame::onAxisHelper()
+{
+ CStudioPreferences::setAxisHelperOn(!CStudioPreferences::isAxisHelperOn());
}
//==============================================================================
@@ -1828,15 +1869,9 @@ void CMainFrame::OnShowInspector()
m_paletteManager->ShowControl(CPaletteManager::CONTROLTYPE_INSPECTOR);
}
-void CMainFrame::OnShowEditPreview()
-{
- bool show = CStudioPreferences::showEditModePreview();
- CStudioPreferences::setShowEditModePreview(!show);
-}
-
void CMainFrame::OnEditViewLightingEnabled()
{
- bool enabled = CStudioPreferences::editModeLightingEnabled();
+ bool enabled = CStudioPreferences::isEditModeLightingEnabled();
CStudioPreferences::setEditModeLightingEnabled(!enabled);
}
@@ -1886,7 +1921,7 @@ bool CMainFrame::eventFilter(QObject *obj, QEvent *event)
{
switch (event->type()) {
case QEvent::ToolTip: {
- if (CStudioPreferences::ShouldShowTooltips())
+ if (CStudioPreferences::isTooltipsOn())
event->ignore();
else
return true;
@@ -1914,19 +1949,15 @@ void CMainFrame::handleGeometryAndState(bool save)
if (m_resettingLayout)
return;
- QSettings settings;
- QString geoKey = QStringLiteral("mainWindowGeometry") + QString::number(STUDIO_VERSION_NUM);
- QString stateKey = QStringLiteral("mainWindowState") + QString::number(STUDIO_VERSION_NUM);
if (save) {
- settings.setValue(geoKey, saveGeometry());
- settings.setValue(stateKey, saveState(STUDIO_VERSION_NUM));
+ CStudioPreferences::setWindowGeometry(saveGeometry(), STUDIO_VERSION_NUM);
+ CStudioPreferences::setWindowState(saveState(STUDIO_VERSION_NUM), STUDIO_VERSION_NUM);
} else {
// Restoring geometry and state back to back results in errors in state restoration, so
// let's restore state asynchronously
- restoreGeometry(settings.value(geoKey).toByteArray());
- QTimer::singleShot(0, this, [this, stateKey]() {
- QSettings settings;
- restoreState(settings.value(stateKey).toByteArray(), STUDIO_VERSION_NUM);
+ restoreGeometry(CStudioPreferences::windowGeometry(STUDIO_VERSION_NUM));
+ QTimer::singleShot(0, this, [this]() {
+ restoreState(CStudioPreferences::windowState(STUDIO_VERSION_NUM), STUDIO_VERSION_NUM);
});
}
}
@@ -1938,19 +1969,6 @@ void CMainFrame::handleRestart()
QProcess::startDetached(qApp->arguments()[0], presentationFile);
}
-void CMainFrame::initializeGeometryAndState()
-{
- QSettings settings;
- QString stateKey = QStringLiteral("mainWindowState") + QString::number(STUDIO_VERSION_NUM);
- if (!settings.contains(stateKey)) {
- // On first run, save and restore geometry and state. For some reason they are both needed
- // to avoid a bug with palettes resizing to their original size when window is resized or
- // something in a palette is edited.
- handleGeometryAndState(true);
- }
- handleGeometryAndState(false);
-}
-
void CMainFrame::toggleSelectMode()
{
if (m_ui->actionItem_Select_Tool->isChecked())
diff --git a/src/Authoring/Qt3DStudio/MainFrm.h b/src/Authoring/Qt3DStudio/MainFrm.h
index cf5d4768..f1d2fdeb 100644
--- a/src/Authoring/Qt3DStudio/MainFrm.h
+++ b/src/Authoring/Qt3DStudio/MainFrm.h
@@ -100,6 +100,7 @@ public:
void onProjectSaveAs();
void onDuplicatePresentation();
void OnProjectNew();
+ void OnProjectClose();
void OnFileNew();
void OnFileRevert();
void OnFileImportAssets();
@@ -143,7 +144,6 @@ public:
void OnPlaybackRewind();
void OnPlaybackStop();
void OnPlaybackPreview(const QString &viewerExeName, bool remote = false);
- void OnPlaybackPreviewQt3DRuntime();
void OnPlaybackPreviewOpenGLRuntime();
void OnPlaybackPreviewRemote();
void onFilterVariants();
@@ -168,10 +168,14 @@ public:
void OnUpdateViewHelpPalette();
void OnUpdateViewTooltips();
void OnViewTooltips();
+ void onUpdateHelperGrid();
+ void onHelperGrid();
void OnUpdateHelpIndex();
void OnHelpIndex();
void OnHelpVisitQt();
void OnHelpOpenTutorial();
+ void onUpdateAxisHelper();
+ void onAxisHelper();
void onViewResetLayout();
void OnViewAction();
@@ -215,8 +219,6 @@ public:
void OnShowProject();
void OnShowAction();
void OnShowInspector();
- void OnShowEditPreview();
- void OnUpdateCameraPreview();
void OnConnectionChanged(bool);
@@ -234,20 +236,20 @@ public:
QWidget *GetActiveView() const;
CPlayerWnd *GetPlayerWnd() const;
- void initializeGeometryAndState();
-
void toggleSelectMode();
void showScene();
QString getVariantsFilterStr() const;
void updateActionFilterEnableState();
void updateToolbarVariantsIcons(bool isFiltered);
+ void setActionsEnabledStatus(bool enabled);
+
+ void handleGeometryAndState(bool save);
Q_SIGNALS:
void playStateChanged(bool started);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
- void handleGeometryAndState(bool save);
void handleRestart();
QScopedPointer<QT_PREPEND_NAMESPACE(Ui::MainFrame)> m_ui;
diff --git a/src/Authoring/Qt3DStudio/MainFrm.ui b/src/Authoring/Qt3DStudio/MainFrm.ui
index 0a94407d..9473052f 100644
--- a/src/Authoring/Qt3DStudio/MainFrm.ui
+++ b/src/Authoring/Qt3DStudio/MainFrm.ui
@@ -45,7 +45,7 @@ Project palette using Import functionality.</string>
<x>0</x>
<y>0</y>
<width>1800</width>
- <height>17</height>
+ <height>21</height>
</rect>
</property>
<property name="focusPolicy">
@@ -74,6 +74,8 @@ Project palette using Import functionality.</string>
<addaction name="menuRecent_Projects"/>
<addaction name="action_Revert"/>
<addaction name="separator"/>
+ <addaction name="action_Close"/>
+ <addaction name="separator"/>
<addaction name="action_Save"/>
<addaction name="action_Save_Project_As"/>
<addaction name="separator"/>
@@ -129,10 +131,11 @@ Project palette using Import functionality.</string>
<addaction name="actionWireframe"/>
<addaction name="actionTooltips"/>
<addaction name="actionFind"/>
+ <addaction name="actionHelper_Grid"/>
+ <addaction name="actionAxis_Helper"/>
<addaction name="actionRulers_Guides"/>
<addaction name="actionLock_Guides"/>
<addaction name="actionClear_Guides"/>
- <addaction name="actionCamera_Preview"/>
<addaction name="actionEdit_Lighting"/>
</widget>
<widget class="QMenu" name="menu_Timeline">
@@ -244,6 +247,7 @@ Project palette using Import functionality.</string>
<addaction name="actionZoom_Tool"/>
<addaction name="actionOrbit_Tool"/>
<addaction name="separator"/>
+ <addaction name="actionHelper_Grid"/>
<addaction name="actionShading_Mode"/>
<addaction name="actionWireframe"/>
</widget>
@@ -272,7 +276,6 @@ Project palette using Import functionality.</string>
<addaction name="actionFilterVariants"/>
<addaction name="actionPreview"/>
<addaction name="actionRemote_Preview"/>
- <addaction name="actionPreviewQt3DRuntime"/>
</widget>
<action name="action_Reference_Manual">
<property name="text">
@@ -565,6 +568,11 @@ Project palette using Import functionality.</string>
<string>&amp;Revert to Last Save</string>
</property>
</action>
+ <action name="action_Close">
+ <property name="text">
+ <string>Close Project</string>
+ </property>
+ </action>
<action name="action_Connect_to_Device">
<property name="checkable">
<bool>true</bool>
@@ -867,21 +875,6 @@ Project palette using Import functionality.</string>
<bool>false</bool>
</property>
</action>
- <action name="actionPreviewQt3DRuntime">
- <property name="icon">
- <iconset resource="images.qrc">
- <normaloff>:/images/playback_tools_play.png</normaloff>:/images/playback_tools_play.png</iconset>
- </property>
- <property name="text">
- <string>Preview with Qt3D Runtime Viewer</string>
- </property>
- <property name="iconText">
- <string>Preview with Qt3D Runtime Viewer</string>
- </property>
- <property name="toolTip">
- <string>Preview with Qt3D Runtime Viewer</string>
- </property>
- </action>
<action name="actionImportAssets">
<property name="text">
<string>Import...</string>
@@ -1056,17 +1049,6 @@ Project palette using Import functionality.</string>
<string>Ctrl+Shift+N</string>
</property>
</action>
- <action name="actionCamera_Preview">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Scene Preview</string>
- </property>
- <property name="toolTip">
- <string>Show Scene Camera Preview in Edit Mode</string>
- </property>
- </action>
<action name="actionEdit_Lighting">
<property name="checkable">
<bool>true</bool>
@@ -1100,6 +1082,43 @@ Project palette using Import functionality.</string>
<string>Copy QML code for DataInput and DataOutput elements to clipboard</string>
</property>
</action>
+ <action name="actionHelper_Grid">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="images.qrc">
+ <normaloff>:/images/helper_grid.png</normaloff>
+ <disabledoff>:/images/helper_grid_disabled.png</disabledoff>
+ <disabledon>:/images/helper_grid_disabled.png</disabledon>:/images/helper_grid.png</iconset>
+ </property>
+ <property name="text">
+ <string>Helper Grid</string>
+ </property>
+ <property name="toolTip">
+ <string>Toggle Helper Grid (%1)</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+H</string>
+ </property>
+ <property name="iconVisibleInMenu">
+ <bool>false</bool>
+ </property>
+ </action>
+ <action name="actionAxis_Helper">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Axis Helper</string>
+ </property>
+ <property name="toolTip">
+ <string>Show world axis helper</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.cpp b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.cpp
index 41d67789..1c4fe0f2 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.cpp
@@ -183,6 +183,11 @@ bool ActionView::event(QEvent *event)
return QQuickWidget::event(event);
}
+void ActionView::setControlView(InspectorControlView *controlView)
+{
+ m_inspectorControlView = controlView;
+}
+
void ActionView::setItem(const qt3dsdm::Qt3DSDMInstanceHandle &handle)
{
if (!m_activeBrowser.isNull() && m_activeBrowser->isVisible()) {
@@ -324,6 +329,11 @@ bool ActionView::isPropertyValueInvalid() const
return m_propertyValueInvalid;
}
+QColor ActionView::showColorDialog(const QColor &color, int instance, int handle)
+{
+ return ActionView::m_inspectorControlView->showColorDialog(color, instance, handle);
+}
+
void ActionView::setCurrentActionIndex(int index)
{
if (index == m_currentActionIndex)
@@ -384,8 +394,17 @@ void ActionView::addAction()
// Query data model bridge to see the applicable events and actions for this instance.
CClientDataModelBridge *theBridge = GetBridge();
- std::wstring theEventName = theBridge->GetDefaultEvent(m_itemHandle);
- std::wstring theHandlerName = theBridge->GetDefaultHandler(m_itemHandle);
+ // For signals, default to onActivate and emitting signal
+ std::wstring preferredEvent = L"";
+ std::wstring preferredHandler = L"";
+ auto info = m_objRefHelper->GetInfo(m_itemHandle);
+ if (info.m_Type == OBJTYPE_SIGNAL) {
+ preferredEvent = L"onActivate";
+ preferredHandler = L"Emit Signal";
+ }
+
+ std::wstring theEventName = theBridge->GetDefaultEvent(m_itemHandle, preferredEvent);
+ std::wstring theHandlerName = theBridge->GetDefaultHandler(m_itemHandle, preferredHandler);
Q3DStudio::SCOPED_DOCUMENT_EDITOR(*GetDoc(), QObject::tr("Add Action"))
->AddAction(GetDoc()->GetActiveSlide(), m_itemHandle, theEventName,
@@ -514,6 +533,22 @@ QObject *ActionView::showEventBrowser(const QPoint &point)
qt3dsdm::TEventHandleList eventList;
bridge->GetEvents(instanceHandle, eventList);
+
+ // Only show time events if the selected object is a signal
+ auto info = m_objRefHelper->GetInfo(m_itemHandle);
+ if (info.m_Type == OBJTYPE_SIGNAL) {
+ qt3dsdm::TEventHandleList filteredEventList;
+ auto thePos = eventList.begin();
+ for (; thePos != eventList.end(); ++thePos) {
+ qt3dsdm::SEventInfo theEvent = bridge->GetEventInfo(*thePos);
+ QString name = QString::fromWCharArray(theEvent.m_Category.wide_str());
+
+ if (name == QString("Time"))
+ filteredEventList.emplace_back(*thePos);
+ }
+ eventList = filteredEventList;
+ }
+
m_eventsModel->setEventList(eventList);
if (!m_eventsBrowser)
@@ -1034,6 +1069,8 @@ void ActionView::updateHandlerArguments()
m_currentPropertyValueHandle = 0;
m_currentPropertyNameHandle = 0;
m_handlerArguments.clear();
+ // Emit empty list, to force update even when arguments amount remain the same
+ Q_EMIT handlerArgumentsChanged();
const auto doc = GetDoc();
if (!doc->isValid() || !m_itemHandle.Valid())
return;
@@ -1059,6 +1096,7 @@ void ActionView::updateHandlerArguments()
argument.m_completeType = argMetaData->m_CompleteType;
m_handlerArguments.append(QVariant::fromValue(argument));
}
+ Q_EMIT handlerArgumentsChanged();
}
}
@@ -1106,6 +1144,8 @@ void ActionView::initialize()
{
CStudioPreferences::setQmlContextProperties(rootContext());
rootContext()->setContextProperty(QStringLiteral("_parentView"), this);
+ rootContext()->setContextProperty(QStringLiteral("_inspectorModel"),
+ m_inspectorControlView->inspectorControlModel());
rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
rootContext()->setContextProperty(QStringLiteral("_tabOrderHandler"), tabOrderHandler());
rootContext()->setContextProperty(QStringLiteral("_mouseHelper"), &m_mouseHelper);
@@ -1161,7 +1201,7 @@ int ActionView::slideNameToIndex(const QString &name)
bool ActionView::toolTipsEnabled()
{
- return CStudioPreferences::ShouldShowTooltips();
+ return CStudioPreferences::isTooltipsOn();
}
void ActionView::updateActionStates()
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.h b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.h
index ab2976f3..6e826448 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.h
@@ -48,6 +48,8 @@
#include "Qt3DSDMMetaDataTypes.h"
#include "TabOrderHandler.h"
#include "MouseHelper.h"
+#include "InspectorControlView.h"
+#include "InspectorControlModel.h"
class ActionModel;
class CClientDataModelBridge;
@@ -91,7 +93,7 @@ class ActionView : public QQuickWidget,
Q_PROPERTY(QString targetObjectName READ targetObjectName NOTIFY actionChanged FINAL)
Q_PROPERTY(QString eventName READ eventName NOTIFY actionChanged FINAL)
Q_PROPERTY(QString handlerName READ handlerName NOTIFY actionChanged FINAL)
- Q_PROPERTY(QVariantList handlerArguments READ handlerArguments NOTIFY actionChanged FINAL)
+ Q_PROPERTY(QVariantList handlerArguments READ handlerArguments NOTIFY handlerArgumentsChanged FINAL)
Q_PROPERTY(PropertyInfo property READ property NOTIFY propertyChanged FINAL)
Q_PROPERTY(QString firedEvent MEMBER m_firedEvent NOTIFY firedEventChanged FINAL)
Q_PROPERTY(bool propertyValueInvalid READ isPropertyValueInvalid NOTIFY propertyValueInvalidChanged FINAL)
@@ -103,6 +105,7 @@ public:
QSize sizeHint() const override;
void setItem(const qt3dsdm::Qt3DSDMInstanceHandle &handle);
+ void setControlView(InspectorControlView *controlView);
QString itemIcon() const;
QString itemText() const;
QColor itemColor() const;
@@ -116,6 +119,8 @@ public:
PropertyInfo property() const;
bool isPropertyValueInvalid() const;
+
+ Q_INVOKABLE QColor showColorDialog(const QColor &color, int instance = 0, int handle = 0);
Q_INVOKABLE void setCurrentActionIndex(int index);
Q_INVOKABLE void setCurrentPropertyIndex(int handle, int index);
Q_INVOKABLE void addAction();
@@ -166,6 +171,7 @@ Q_SIGNALS:
void hasItemChanged();
void propertyValueInvalidChanged();
void dialogCurrentColorChanged(const QColor &newColor);
+ void handlerArgumentsChanged();
private Q_SLOTS:
void copyAction();
@@ -226,6 +232,7 @@ private:
bool m_propertyValueInvalid = true;
QColor m_currentColor;
QPointer<QWidget> m_activeBrowser = nullptr;
+ QPointer<InspectorControlView> m_inspectorControlView;
};
#endif // ACTIONVIEW_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml
index a5b905b3..f06143f0 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/ActionView.qml
@@ -421,8 +421,11 @@ Rectangle {
_tabOrderHandler.addItem(0, item.tabItem1)
if (item.tabItem2 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem2)
- if (item.tabItem3 !== undefined)
+ if (item.tabItem3 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem3)
+ if (item.tabItem4 !== undefined)
+ _tabOrderHandler.addItem(0, item.tabItem4)
+ }
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml
index 8c184409..5b77dbdf 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericBaseColor.qml
@@ -69,7 +69,7 @@ RowLayout {
onClicked: {
root.listenToColorChanges = true;
_inspectorModel.suspendMaterialRename(true);
- root.selectedColor = _parentView.showColorDialog(rect.color, instance, handle);
+ root.selectedColor = _parentView.showColorDialog(rect.color);
root.listenToColorChanges = false;
_inspectorModel.suspendMaterialRename(false);
root.colorSelected();
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericFloat.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericFloat.qml
index 11ac38a5..edc66c14 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericFloat.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerGenericFloat.qml
@@ -42,6 +42,8 @@ RowLayout {
signal editingFinished
signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
onValueChanged: {
// FloatTextField can set its text internally, thus breaking the binding, so
@@ -59,5 +61,7 @@ RowLayout {
decimalValue: numberOfDecimal
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml
index a101488e..39aea92e 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerProperty.qml
@@ -119,6 +119,38 @@ ColumnLayout {
}
Component {
+ id: xyzwPropertyComponent
+
+ HandlerPropertyXYZW {
+ readonly property var propValue: propertyModel && !_parentView.propertyValueInvalid
+ && propertyModel.value !== undefined
+ ? propertyModel.value : undefined
+ label: parent ? parent.label : ""
+ valueX: propValue !== undefined ? Number(propValue.x).toFixed(numberOfDecimal) : "0.000"
+ valueY: propValue !== undefined ? Number(propValue.y).toFixed(numberOfDecimal) : "0.000"
+ valueZ: propValue !== undefined ? Number(propValue.z).toFixed(numberOfDecimal) : "0.000"
+ valueW: propValue !== undefined ? Number(propValue.w).toFixed(numberOfDecimal) : "0.000"
+
+ onPropValueChanged: {
+ // FloatTextField can set its text internally, thus breaking the binding, so
+ // let's set the text value explicitly each time value changes
+ if (propValue !== undefined) {
+ valueX = Number(propValue.x).toFixed(numberOfDecimal);
+ valueY = Number(propValue.y).toFixed(numberOfDecimal);
+ valueZ = Number(propValue.z).toFixed(numberOfDecimal);
+ valueW = Number(propValue.w).toFixed(numberOfDecimal);
+ }
+ }
+
+ onEditingFinished: {
+ _parentView.setArgumentValue(propertyModel.valueHandle,
+ Qt.vector4d(valueX, valueY, valueZ, valueW), true);
+ }
+ }
+ }
+
+
+ Component {
id: sliderPropertyComponent
HandlerPropertySlider {
@@ -224,8 +256,11 @@ ColumnLayout {
_tabOrderHandler.addItem(0, item.tabItem1)
if (item.tabItem2 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem2)
- if (item.tabItem3 !== undefined)
+ if (item.tabItem3 !== undefined) {
_tabOrderHandler.addItem(0, item.tabItem3)
+ if (item.tabItem4 !== undefined)
+ _tabOrderHandler.addItem(0, item.tabItem4)
+ }
}
}
}
@@ -257,6 +292,8 @@ ColumnLayout {
case DataModelDataType.Float4:
if (actionProperty.additionalType === AdditionalMetaDataType.Color)
return colorBox;
+ if (actionProperty.additionalType === AdditionalMetaDataType.None)
+ return xyzwPropertyComponent;
break;
case DataModelDataType.String:
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXY.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXY.qml
index 4406703f..e22bda8c 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXY.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXY.qml
@@ -44,6 +44,8 @@ RowLayout {
signal editingFinished
signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
spacing: 0
@@ -59,6 +61,8 @@ RowLayout {
decimalValue: numberOfDecimal
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
Item { width: 20 }
@@ -75,6 +79,8 @@ RowLayout {
decimalValue: numberOfDecimal
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZ.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZ.qml
index 50440dba..2ffa84bb 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZ.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZ.qml
@@ -46,6 +46,9 @@ RowLayout {
signal editingFinished
signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
+
transformOrigin: Item.Center
spacing: 0
@@ -61,6 +64,8 @@ RowLayout {
decimalValue: numberOfDecimal
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
Item { width: 10 }
@@ -77,6 +82,8 @@ RowLayout {
decimalValue: numberOfDecimal
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
Item { width: 10 }
@@ -93,6 +100,8 @@ RowLayout {
decimalValue: numberOfDecimal
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml
new file mode 100644
index 00000000..d5d2b483
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyBaseXYZW.qml
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import "../controls"
+
+/* Use for: Float4 */
+
+ColumnLayout {
+ id: root
+
+ property alias valueX: textFieldX.text
+ property alias valueY: textFieldY.text
+ property alias valueZ: textFieldZ.text
+ property alias valueW: textFieldW.text
+ property int numberOfDecimal: 3
+ property Item tabItem1: textFieldX
+ property Item tabItem2: textFieldY
+ property Item tabItem3: textFieldZ
+ property Item tabItem4: textFieldW
+
+ signal editingFinished
+ signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
+
+ transformOrigin: Item.Center
+ spacing: 0
+
+ RowLayout {
+ transformOrigin: Item.Center
+ spacing: 0
+
+ StyledLabel {
+ Layout.preferredWidth: 10
+ text: qsTr("X")
+ color: _xAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldX
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
+ }
+
+ Item { width: 10 }
+
+ StyledLabel {
+ Layout.preferredWidth: 10
+ text: qsTr("Y")
+ color: _yAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldY
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
+ }
+
+ Item { width: 10 }
+
+ StyledLabel {
+ Layout.preferredWidth: 10
+ text: qsTr("Z")
+ color: _zAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldZ
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
+ }
+ }
+
+ Item { height: 4 }
+
+ RowLayout {
+ transformOrigin: Item.Center
+ spacing: 0
+ Layout.leftMargin: -3
+
+ StyledLabel {
+ Layout.preferredWidth: 13
+ text: qsTr("W")
+ color: _wAxisColor
+ }
+
+ FloatTextField {
+ id: textFieldW
+ Layout.preferredWidth: (_valueWidth - 50) / 3
+ decimalValue: numberOfDecimal
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
+ }
+ }
+}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZ.qml b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZ.qml
index 6571f1d0..a123d7ad 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZ.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZ.qml
@@ -47,6 +47,8 @@ RowLayout {
signal editingFinished
signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
StyledLabel {
id: labelItem
@@ -60,5 +62,7 @@ RowLayout {
onEditingFinished: root.editingFinished()
onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.h b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml
index 0e57773e..82adb6aa 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Action/HandlerPropertyXYZW.qml
@@ -1,7 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
@@ -27,39 +26,45 @@
**
****************************************************************************/
-//==============================================================================
-// Prefix
-//==============================================================================
-#ifndef INCLUDED_OFFSET_KEYFRAMES_COMMAND_HELPER_H
-#define INCLUDED_OFFSET_KEYFRAMES_COMMAND_HELPER_H 1
+import QtQuick 2.6
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import "../controls"
-#pragma once
+/* Use for: Float4 */
-// Data model
-#include "Qt3DSDMHandles.h"
-#include "IDocumentEditor.h"
+RowLayout {
+ id: root
-namespace Q3DStudio {
-class IDocumentEditor;
-}
-
-//==============================================================================
-// Classes
-//==============================================================================
-class CCmdDataModelSetKeyframeTime;
+ property alias valueX: propertyXYZW.valueX
+ property alias valueY: propertyXYZW.valueY
+ property alias valueZ: propertyXYZW.valueZ
+ property alias valueW: propertyXYZW.valueW
+ property alias label: labelItem.text
+ property alias tabItem1: propertyXYZW.tabItem1
+ property alias tabItem2: propertyXYZW.tabItem2
+ property alias tabItem3: propertyXYZW.tabItem3
+ property alias tabItem4: propertyXYZW.tabItem4
+ property alias numberOfDecimal: propertyXYZW.numberOfDecimal
-class COffsetKeyframesCommandHelper : public Q3DStudio::CUpdateableDocumentEditor
-{
-protected:
- CDoc &m_Doc;
+ signal editingFinished
+ signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
-public:
- COffsetKeyframesCommandHelper(CDoc &inDoc);
- ~COffsetKeyframesCommandHelper();
+ StyledLabel {
+ id: labelItem
+ Layout.alignment: Qt.AlignTop | Qt.AlignLeft
+ text: qsTr("New Value")
+ }
- void SetCommandTime(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, long inTime);
- void Finalize();
- void Rollback() { RollbackEditor(); }
-};
+ HandlerPropertyBaseXYZW {
+ id: propertyXYZW
+ Layout.alignment: Qt.AlignRight
-#endif \ No newline at end of file
+ onEditingFinished: root.editingFinished()
+ onPreviewValueChanged: root.previewValueChanged()
+ onTriggerUndo: root.triggerUndo()
+ onTriggerRedo: root.triggerRedo()
+ }
+}
diff --git a/src/Authoring/Qt3DStudio/Palettes/BasicObjects/BasicObjectsModel.cpp b/src/Authoring/Qt3DStudio/Palettes/BasicObjects/BasicObjectsModel.cpp
index 8694fda7..65274d7b 100644
--- a/src/Authoring/Qt3DStudio/Palettes/BasicObjects/BasicObjectsModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/BasicObjects/BasicObjectsModel.cpp
@@ -55,6 +55,7 @@ const QVector<BasicObjectItem> BasicObjectsModel::InitializeObjectModel()
{tr("Cone"), "Asset-Cone-Normal.png"_L1, OBJTYPE_MODEL, PRIMITIVETYPE_CONE},
{tr("Component"), "Asset-Component-Normal.png"_L1, OBJTYPE_COMPONENT, PRIMITIVETYPE_UNKNOWN},
{tr("Group"), "Asset-Group-Normal.png"_L1, OBJTYPE_GROUP, PRIMITIVETYPE_UNKNOWN},
+ {tr("Signal"), "Asset-Signal-Normal.png"_L1, OBJTYPE_SIGNAL, PRIMITIVETYPE_UNKNOWN},
{tr("Text"), "Asset-Text-Normal.png"_L1, OBJTYPE_TEXT, PRIMITIVETYPE_UNKNOWN},
{tr("Camera"), "Asset-Camera-Normal.png"_L1, OBJTYPE_CAMERA, PRIMITIVETYPE_UNKNOWN},
{tr("Light"), "Asset-Light-Normal.png"_L1, OBJTYPE_LIGHT, PRIMITIVETYPE_UNKNOWN},
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/DataInputChooser.qml b/src/Authoring/Qt3DStudio/Palettes/Inspector/DataInputChooser.qml
index 3681a102..8b522e91 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/DataInputChooser.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/DataInputChooser.qml
@@ -70,7 +70,7 @@ Rectangle {
// index directly without going through string -> int table lookup
model: [qsTr("[Compatible types]"), qsTr("[All types]"), qsTr("Boolean"),
qsTr("Float"), qsTr("Ranged Number"), qsTr("String"), qsTr("Variant"),
- qsTr("Vector2"), qsTr("Vector3")]
+ qsTr("Vector2"), qsTr("Vector3"), qsTr("Vector4")]
onCurrentIndexChanged: _parentView.setTypeFilter(currentIndex - numOfFixedChoices);
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml b/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml
index b1514d03..25d40173 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/HandlerFilesChooser.qml
@@ -37,12 +37,28 @@ RowLayout {
signal showBrowser
property string value: ""
property alias activeBrowser: browser.activeBrowser
+ property var validData: parent.modelData.validData
BrowserCombo {
id: browser
Layout.preferredWidth: _valueWidth
+ validData: root.validData
Layout.fillWidth: true
value: root.value === "" ? qsTr("Select...") : root.value
onShowBrowser: root.showBrowser()
+ StyledTooltip {
+ text: qsTr("Invalid path")
+ enabled: browserMouseArea.containsMouse && !root.validData
+ }
+
+ MouseArea {
+ id: browserMouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ // pass through mouse click to Combobox
+ onPressed: {
+ mouse.accepted = false;
+ }
+ }
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.cpp
index e8180f94..28819dc3 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.cpp
@@ -46,7 +46,6 @@ ImageChooserView::ImageChooserView(QWidget *parent)
: QQuickWidget(parent)
, m_model(new ImageChooserModel(true, this))
{
- setWindowTitle(tr("Images"));
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
setResizeMode(QQuickWidget::SizeRootObjectToView);
QTimer::singleShot(0, this, &ImageChooserView::initialize);
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.h
index bbf8eff5..308356cc 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/ImageChooserView.h
@@ -36,6 +36,7 @@ class ImageChooserModel;
class ImageChooserView : public QQuickWidget
{
Q_OBJECT
+
Q_PROPERTY(bool focused READ isFocused NOTIFY focusChanged)
Q_PROPERTY(int instance READ instance)
Q_PROPERTY(int handle READ handle)
@@ -59,17 +60,17 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
+ void showEvent(QShowEvent *event) override;
Q_SIGNALS:
void focusChanged();
private:
- void showEvent(QShowEvent *event) override;
void initialize();
bool isFocused() const;
- int m_handle = -1;
- int m_instance = -1;
+ int m_handle = 0;
+ int m_instance = 0;
ImageChooserModel *m_model = nullptr;
};
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
index 53519573..4542f72d 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
@@ -28,6 +28,7 @@
#include "InspectorControlModel.h"
#include "StudioApp.h"
+#include "MainFrm.h"
#include "Core.h"
#include "Doc.h"
#include "InspectorGroup.h"
@@ -44,7 +45,6 @@
#include "Qt3DSDMDataTypes.h"
#include "IObjectReferenceHelper.h"
#include "SlideSystem.h"
-#include "Qt3DSDMMaterialInspectable.h"
#include "ClientDataModelBridge.h"
#include "IDocumentReader.h"
#include "IStudioRenderer.h"
@@ -129,7 +129,7 @@ CInspectableBase *InspectorControlModel::inspectable() const
}
qt3dsdm::Qt3DSDMInstanceHandle InspectorControlModel::getReferenceMaterial(
- CInspectableBase *inspectable) const
+ CInspectableBase *inspectable) const
{
if (inspectable)
return getBridge()->getMaterialReference(inspectable->getInstance());
@@ -137,6 +137,23 @@ qt3dsdm::Qt3DSDMInstanceHandle InspectorControlModel::getReferenceMaterial(
return 0;
}
+qt3dsdm::Qt3DSDMInstanceHandle InspectorControlModel::getReferenceMaterialRecursively(
+ CInspectableBase *inspectable) const
+{
+ if (inspectable) {
+ auto bridge = getBridge();
+ auto refMaterial = bridge->getMaterialReference(inspectable->getInstance());
+ auto type = bridge->GetObjectType(refMaterial);
+ while (type == OBJTYPE_REFERENCEDMATERIAL) {
+ refMaterial = bridge->getMaterialReference(refMaterial);
+ type = bridge->GetObjectType(refMaterial);
+ }
+ return refMaterial;
+ }
+
+ return 0;
+}
+
void InspectorControlModel::notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3dsdm::Qt3DSDMPropertyHandle inProperty)
{
@@ -165,6 +182,7 @@ void InspectorControlModel::notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle
if (property->m_property == inProperty || imageInstance == inInstance) {
updatePropertyValue(property);
changed = true;
+ updateValidState(property);
}
}
}
@@ -172,17 +190,19 @@ void InspectorControlModel::notifyPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle
Q_EMIT dataChanged(index(0), index(rowCount() - 1));
}
-bool InspectorControlModel::hasInstanceProperty(long instance, int handle)
+bool InspectorControlModel::hasInstanceProperty(qt3dsdm::Qt3DSDMInstanceHandle instance,
+ qt3dsdm::Qt3DSDMPropertyHandle handle) const
{
for (const auto &group : qAsConst(m_groupElements)) {
for (const auto &element : qAsConst(group.controlElements)) {
InspectorControlBase *property = element.value<InspectorControlBase *>();
- if (property->m_property == qt3dsdm::CDataModelHandle(handle)
- && property->m_instance == qt3dsdm::CDataModelHandle(instance)) {
- return true;
+ if (property->m_property == handle) {
+ auto refInstance = getBridge()->getMaterialReference(property->m_instance);
+ return property->m_instance == instance || refInstance == instance;
}
}
}
+
return false;
}
@@ -230,17 +250,7 @@ bool InspectorControlModel::isBasicMaterial(CInspectableBase *inspectable) const
if (!inspectable)
return false;
- if (inspectable->getObjectType() == OBJTYPE_REFERENCEDMATERIAL) {
- const auto instance = inspectable->getInstance();
- if (!instance.Valid())
- return false;
-
- const auto refMaterial = getBridge()->getMaterialReference(instance);
- if (refMaterial.Valid() && getBridge()->isInsideMaterialContainer(refMaterial))
- return true;
- }
-
- return false;
+ return getBridge()->isBasicMaterial(inspectable->getInstance());
}
bool InspectorControlModel::isMaterial() const
@@ -267,6 +277,7 @@ void InspectorControlModel::addMaterial()
i++;
absPath = path + QString::number(i) + extension;
}
+ const auto relPath = doc->GetRelativePathToDoc(absPath);
qt3dsdm::Qt3DSDMInstanceHandle newMaterial;
{
@@ -287,15 +298,13 @@ void InspectorControlModel::addMaterial()
doc->SelectDataModelObject(newMaterial);
const auto type = getBridge()->GetObjectType(instance);
- if (type == OBJTYPE_REFERENCEDMATERIAL) {
- sceneEditor->setMaterialReferenceByPath(instance, absPath);
- const auto relPath = doc->GetRelativePathToDoc(absPath);
- sceneEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath));
- sceneEditor->SetName(instance, getBridge()->GetName(newMaterial, true));
-
- doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
- instance, getBridge()->GetNameProperty());
- }
+ if (type != OBJTYPE_REFERENCEDMATERIAL)
+ sceneEditor->SetMaterialType(instance, QStringLiteral("Referenced Material"));
+ sceneEditor->setMaterialReferenceByPath(instance, absPath);
+ sceneEditor->SetName(instance, getBridge()->GetName(newMaterial, true));
+ sceneEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath));
+ doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
+ instance, getBridge()->GetNameProperty());
}
void InspectorControlModel::duplicateMaterial()
@@ -312,7 +321,7 @@ void InspectorControlModel::duplicateMaterial()
auto material = instance;
if (type == OBJTYPE_REFERENCEDMATERIAL)
- material = getReferenceMaterial(m_inspectableBase);
+ material = getReferenceMaterialRecursively(m_inspectableBase);
if (material.Valid()) {
const auto sceneEditor = doc->getSceneEditor();
@@ -329,6 +338,7 @@ void InspectorControlModel::duplicateMaterial()
materialName = originalMaterialName + QString::number(i);
absPath = sceneEditor->getMaterialFilePath(materialName);
}
+ const auto relPath = doc->GetRelativePathToDoc(absPath);
qt3dsdm::Qt3DSDMInstanceHandle duplicate;
{
@@ -350,14 +360,29 @@ void InspectorControlModel::duplicateMaterial()
Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Material Type")));
doc->SelectDataModelObject(duplicate);
- if (type == OBJTYPE_REFERENCEDMATERIAL) {
- scopedEditor->setMaterialReferenceByPath(instance, absPath);
- const auto relPath = doc->GetRelativePathToDoc(absPath);
- scopedEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath));
- scopedEditor->SetName(instance, getBridge()->GetName(duplicate, true));
- doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
- instance, getBridge()->GetNameProperty());
+ // Change all material that reference this material to basic materials too
+ Q3DStudio::CString relPathCString = Q3DStudio::CString::fromQString(relPath);
+ Q3DStudio::CString duplicateName = getBridge()->GetName(duplicate, true);
+ auto nameProperty = getBridge()->GetNameProperty();
+ QVector<qt3dsdm::Qt3DSDMInstanceHandle> refMats;
+ doc->getSceneReferencedMaterials(doc->GetSceneInstance(), refMats);
+ for (auto &refMat : qAsConst(refMats)) {
+ if (getBridge()->getMaterialReference(refMat) == instance) {
+ scopedEditor->setMaterialReferenceByPath(refMat, absPath);
+ scopedEditor->setMaterialSourcePath(refMat, relPathCString);
+ scopedEditor->SetName(refMat, duplicateName);
+ doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
+ refMat, nameProperty);
+ }
}
+
+ if (type != OBJTYPE_REFERENCEDMATERIAL)
+ sceneEditor->SetMaterialType(instance, QStringLiteral("Referenced Material"));
+ scopedEditor->setMaterialReferenceByPath(instance, absPath);
+ scopedEditor->setMaterialSourcePath(instance, relPathCString);
+ scopedEditor->SetName(instance, duplicateName);
+ doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue(
+ instance, nameProperty);
}
}
@@ -371,9 +396,8 @@ void InspectorControlModel::updateMaterialValues(const QStringList &values, int
startIndex = m_groupElements.count() - 1; // Update the last group for referenced materials
for (int row = startIndex; row < m_groupElements.count(); ++row) {
const CInspectorGroup *inspectorGroup = m_inspectableBase->getGroup(row);
- const auto group = dynamic_cast<const Qt3DSDMInspectorGroup *>(inspectorGroup);
- const auto materialGroup = dynamic_cast<const Qt3DSDMMaterialInspectorGroup *>(group);
- if (materialGroup && (materialGroup->isMaterialGroup() || isReferenced)) {
+ const auto group = static_cast<const Qt3DSDMInspectorGroup *>(inspectorGroup);
+ if (group->isMaterial() || isReferenced) {
if (m_groupElements[row].controlElements.size()) {
auto item = m_groupElements[row].controlElements[elementIndex]
.value<InspectorControlBase *>();
@@ -381,6 +405,7 @@ void InspectorControlModel::updateMaterialValues(const QStringList &values, int
Q_EMIT item->valuesChanged();
// Changing values resets the selected index, so pretend the value has also changed
Q_EMIT item->valueChanged();
+ updateValidState(item);
}
}
}
@@ -389,7 +414,7 @@ void InspectorControlModel::updateMaterialValues(const QStringList &values, int
void InspectorControlModel::updateShaderValues()
{
int index = 0;
- if (isAnimatableMaterial() && !isInsideMaterialContainer())
+ if (!isInsideMaterialContainer())
index = 1;
updateMaterialValues(shaderValues(), index, true);
}
@@ -413,7 +438,7 @@ void InspectorControlModel::setMaterials(std::vector<Q3DStudio::CFilePath> &mate
m_materials.push_back({name, path.toQString()});
}
- if (!isDefaultMaterial())
+ if (isAnimatableMaterial() && !isDefaultMaterial())
updateShaderValues();
}
@@ -422,6 +447,7 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
m_matDatas.clear();
const auto doc = g_StudioApp.GetCore()->GetDoc();
+ bool forceModified = false;
bool isDocModified = doc->isModified();
const auto sceneEditor = doc->getSceneEditor();
if (!sceneEditor)
@@ -440,6 +466,8 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
const QString relativePath = path.toQString();
const Q3DStudio::CFilePath absolutePath
= Q3DStudio::CFilePath::CombineBaseAndRelative(doc->GetDocumentDirectory(), path);
+ const QDir projDir = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath());
+ const QString projRelativePath = projDir.relativeFilePath(absolutePath.toQString());
QString name;
QMap<QString, QString> values;
@@ -452,19 +480,21 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
bool needRewrite = false;
if (values.contains(QStringLiteral("path"))) {
const QString oldPath = values[QStringLiteral("path")];
- needRewrite = oldPath != absolutePath.toQString();
- if (!QFileInfo(oldPath).exists()) {
+ needRewrite = oldPath != projRelativePath;
+ const QString oldAbsolutePath = projDir.absoluteFilePath(oldPath);
+ if (!QFileInfo(oldAbsolutePath).exists()) {
const auto instance = sceneEditor->getMaterial(oldPath);
if (instance.Valid()) {
const QString oldName = sceneEditor->GetName(instance).toQString();
const QString newName = sceneEditor
- ->getMaterialNameFromFilePath(relativePath);
+ ->getMaterialNameFromFilePath(projRelativePath);
const QString actualPath = sceneEditor
->getFilePathFromMaterialName(oldName);
- if (actualPath == oldPath) {
+ if (projDir.relativeFilePath(actualPath) == oldPath) {
doc->queueMaterialRename(oldName, newName);
Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Name"))
- ->setMaterialNameByPath(instance, relativePath);
+ ->setMaterialNameByPath(instance, projRelativePath);
+ forceModified = true;
}
}
}
@@ -501,7 +531,10 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
sceneEditor->removeDeletedFromMaterialContainer();
// Modified flag has to be restored because of the hidden transaction
- doc->SetModifiedFlag(isDocModified);
+ if (!forceModified)
+ doc->SetModifiedFlag(isDocModified);
+ else
+ doc->SetModifiedFlag(true);
m_cachedMatDatas = matDatas;
}
@@ -640,11 +673,7 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem(
item->m_propertyType = qt3dsdm::AdditionalMetaDataType::None;
item->m_tooltip = tr("Type of material being used");
item->m_animatable = false;
-
- const QStringList values = materialTypeValues();
- item->m_values = values;
-
- QString sourcePath = getBridge()->GetSourcePath(item->m_instance);
+ item->m_values = materialTypeValues();
switch (inspectable->getObjectType()) {
case OBJTYPE_MATERIAL:
@@ -652,17 +681,19 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem(
item->m_value = getAnimatableMaterialString();
break;
- case OBJTYPE_REFERENCEDMATERIAL:
- item->m_value = getReferencedMaterialString();
- if (sourcePath == getBridge()->getDefaultMaterialName())
- item->m_value = getBasicMaterialString();
- for (int matIdx = 0, end = int(m_matDatas.size()); matIdx < end; ++matIdx) {
- if (QString::compare(m_matDatas[matIdx].m_relativePath,
- sourcePath, Qt::CaseInsensitive) == 0) {
+ case OBJTYPE_REFERENCEDMATERIAL: {
+ QString sourcePath = getBridge()->GetSourcePath(item->m_instance);
+ item->m_value = sourcePath == getBridge()->getDefaultMaterialName()
+ ? getBasicMaterialString()
+ : getReferencedMaterialString();
+
+ for (auto &mData : m_matDatas) {
+ if (QString::compare(mData.m_relativePath, sourcePath, Qt::CaseInsensitive) == 0) {
item->m_value = getBasicMaterialString();
+ break;
}
}
- break;
+ } break;
default:
break;
@@ -689,11 +720,13 @@ InspectorControlBase *InspectorControlModel::createShaderItem(
QString sourcePath = getBridge()->GetSourcePath(item->m_instance);
item->m_value = values[0];
- for (int matIdx = 0, end = int(m_materials.size()); matIdx < end; ++matIdx) {
- if (m_materials[matIdx].m_relativePath == sourcePath)
- item->m_value = values[matIdx + 1];
+ for (int i = 0, end = int(m_materials.size()); i < end; ++i) {
+ if (m_materials[i].m_relativePath == sourcePath) {
+ item->m_value = values[i + 1]; // + 1 for Standard shader
+ break;
+ }
}
-
+ updateValidState(item);
return item;
}
@@ -715,10 +748,10 @@ InspectorControlBase *InspectorControlModel::createMatDataItem(
QString sourcePath = getBridge()->GetSourcePath(item->m_instance);
item->m_value = getDefaultMaterialString();
- for (int matIdx = 0, end = int(m_matDatas.size()); matIdx < end; ++matIdx) {
- if (QString::compare(m_matDatas[matIdx].m_relativePath,
- sourcePath, Qt::CaseInsensitive) == 0) {
- item->m_value = values[matIdx + 1]; // + 1 for Default basic material
+ for (int i = 0, end = int(m_matDatas.size()); i < end; ++i) {
+ if (QString::compare(m_matDatas[i].m_relativePath, sourcePath, Qt::CaseInsensitive) == 0) {
+ item->m_value = values[i + 1]; // + 1 for Default basic material
+ break;
}
}
@@ -749,6 +782,10 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp
if (title == "Name" && isBasicMaterial())
return nullptr;
+ // Hide everything else than name for signals
+ if (title != "Name" && getBridge()->IsSignalInstance(inspectable->getInstance()))
+ return nullptr;
+
InspectorControlBase *item = new InspectorControlBase;
item->m_property = metaProperty.m_Property;
item->m_instance = inspectable->GetGroupInstance(groupIndex);
@@ -772,9 +809,10 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp
// properties explicitly set as controllable in metadata
item->m_controllable = item->m_animatable || metaProperty.m_Controllable;
- // disable IBL Override for reference materials
+ // disable IBL Override for reference and 'default basic' materials
if (item->m_title == QLatin1String("IBL Override")
- && getBridge()->GetObjectType(item->m_instance) == OBJTYPE_REFERENCEDMATERIAL) {
+ && getBridge()->GetObjectType(item->m_instance) == OBJTYPE_REFERENCEDMATERIAL
+ && (!isBasicMaterial() || getBridge()->isDefaultMaterial(item->m_instance))) {
item->m_enabled = false;
}
auto signalProvider = studio->GetFullSystemSignalProvider();
@@ -798,12 +836,12 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp
// Update UI icon state and tooltip
updateControlledToggleState(item);
item->m_connections.push_back(signalProvider->ConnectControlledToggled(
- std::bind(&InspectorControlModel::updateControlledToggleState,
- this, item)));
+ std::bind(&InspectorControlModel::updateControlledToggleState, this, item)));
}
// synchronize the value itself
updatePropertyValue(item);
+ updateValidState(item);
return item;
}
@@ -884,6 +922,37 @@ void InspectorControlModel::updateAnimateToggleState(InspectorControlBase* inIte
}
}
+void InspectorControlModel::updateValidState(InspectorControlBase *inItem) const
+{
+ const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
+ ->GetClientDataModelBridge();
+ if (bridge->GetSourcePathProperty() == inItem->m_property) {
+ QFileInfo fileinfo(g_StudioApp.GetCore()->GetDoc()->GetResolvedPathToDoc(
+ bridge->GetSourcePath(inItem->m_instance)));
+ if (fileinfo.exists() != inItem->m_valid) {
+ inItem->m_valid = !inItem->m_valid;
+ Q_EMIT inItem->validDataChanged();
+ }
+ }
+
+ // Check the validity of shader.
+ if (inItem->m_title == tr("Shader")) {
+ QString err;
+ g_StudioApp.getRenderer().getObjectError(inItem->m_instance, err);
+ if (!err.isEmpty()) {
+ inItem->m_tooltip = err;
+ inItem->m_valid = false;
+ Q_EMIT inItem->validDataChanged();
+ Q_EMIT inItem->tooltipChanged();
+ } else {
+ inItem->m_tooltip = tr("Shader being used");
+ inItem->m_valid = true;
+ Q_EMIT inItem->validDataChanged();
+ Q_EMIT inItem->tooltipChanged();
+ }
+ }
+}
+
bool InspectorControlModel::isTreeRebuildRequired(CInspectableBase* inspectBase)
{
if (inspectBase != m_inspectableBase || !inspectBase)
@@ -918,29 +987,31 @@ bool InspectorControlModel::isGroupRebuildRequired(CInspectableBase *inspectable
if (existingGroup.groupTitle != theInspectorGroup->GetName())
return true;
- if (const auto cdmInspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectable)) {
+ if (inspectable->getObjectType() != OBJTYPE_GUIDE) {
+ const auto dmInspectable = static_cast<Qt3DSDMInspectable *>(inspectable);
+ const auto group = static_cast<const Qt3DSDMInspectorGroup *>(theInspectorGroup);
int existingIndex = 0;
- if (const auto group = dynamic_cast<const Qt3DSDMInspectorGroup *>(theInspectorGroup)) {
- const auto materialGroup = dynamic_cast<const Qt3DSDMMaterialInspectorGroup *>(group);
- if (materialGroup && materialGroup->isMaterialGroup()) {
- auto i = existingGroup.controlElements.at(existingIndex++).value<InspectorControlBase*>();
- if (i->m_instance != cdmInspectable->GetGroupInstance(theIndex))
- return true;
- if (!isInsideMaterialContainer())
- existingIndex++; // Add material type dropdown to existing elements
- }
-
- if ((existingGroup.controlElements.size() - existingIndex) != group->GetRows().size())
+ if (group && group->isMaterial()) {
+ auto i = existingGroup.controlElements.at(existingIndex++)
+ .value<InspectorControlBase *>();
+ if (i->m_instance != dmInspectable->GetGroupInstance(theIndex))
return true;
- for (const auto row : group->GetRows()) {
- auto i = existingGroup.controlElements.at(existingIndex++).value<InspectorControlBase*>();
- if (i->m_instance != cdmInspectable->GetGroupInstance(theIndex))
- return true;
+ if (!isInsideMaterialContainer())
+ existingIndex++; // Add material type dropdown to existing elements
+ }
- if (i->m_property != row->GetMetaDataPropertyInfo().m_Property)
- return true;
- }
+ if ((existingGroup.controlElements.size() - existingIndex) != group->GetRows().size())
+ return true;
+
+ for (const auto row : group->GetRows()) {
+ auto i = existingGroup.controlElements.at(existingIndex++)
+ .value<InspectorControlBase *>();
+ if (i->m_instance != dmInspectable->GetGroupInstance(theIndex))
+ return true;
+
+ if (i->m_property != row->GetMetaDataPropertyInfo().m_Property)
+ return true;
}
}
@@ -952,27 +1023,54 @@ CClientDataModelBridge *InspectorControlModel::getBridge() const
return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
}
-auto InspectorControlModel::computeTree(CInspectableBase *inspectBase)
+CInspectableBase *InspectorControlModel::getInspectableFromInstance(
+ qt3dsdm::Qt3DSDMInstanceHandle inInstance)
+{
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ qt3dsdm::ISlideSystem *slideSystem = doc->GetStudioSystem()->GetSlideSystem();
+
+ if (doc->GetDocumentReader().IsInstance(inInstance)) {
+ qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide();
+ qt3dsdm::Qt3DSDMInstanceHandle activeSlideInstance = 0;
+
+ // Slide, scene or component
+ if (inInstance == getBridge()->GetOwningComponentInstance(activeSlide))
+ activeSlideInstance = slideSystem->GetSlideInstance(activeSlide);
+
+ return new Qt3DSDMInspectable(inInstance, activeSlideInstance);
+ }
+
+ return nullptr;
+}
+
+auto InspectorControlModel::computeTree(CInspectableBase *inspectableBase)
-> QVector<GroupInspectorControl>
{
QVector<GroupInspectorControl> result;
- if (inspectBase) {
- qt3dsdm::Qt3DSDMInstanceHandle instance = inspectBase->getInstance();
- bool isMatFromFile = instance.Valid() && getBridge()->isInsideMaterialContainer(instance);
- long groupCount = inspectBase->getGroupCount();
- for (long idx = 0; idx < groupCount; ++idx)
- result.append(computeGroup(inspectBase, idx, isMatFromFile, false));
+ if (inspectableBase) {
+ qt3dsdm::Qt3DSDMInstanceHandle instance = inspectableBase->getInstance();
- if (isDefaultMaterial() && result.size() > 0) {
- result[result.size() - 1].groupInfo = tr("\nDefault material cannot be edited.\n\n"
- "Create new or import material, then apply.");
+ if (isDefaultMaterial()) {
+ // for default materials skip the first 2 groups (Basic Properties, Lighting) and only
+ // show the Material group
+ result.append(computeGroup(inspectableBase, 2));
+ result[0].groupInfo = tr("\nDefault material cannot be edited. Create new or import "
+ "material, then apply.");
+ } else {
+ // disable animation for basic materials, this applies only when editing the basic
+ // material from the project palette.
+ bool disableAnim = instance.Valid()
+ && getBridge()->isInsideMaterialContainer(instance);
+ long groupCount = inspectableBase->getGroupCount();
+ for (long idx = 0; idx < groupCount; ++idx)
+ result.append(computeGroup(inspectableBase, idx, disableAnim));
}
- //Show original material properties for referenced materials
- auto refMaterial = getReferenceMaterial(inspectBase);
+ // show original material properties for referenced materials
+ auto refMaterial = getReferenceMaterial(inspectableBase);
if (refMaterial.Valid()) {
- auto refMaterialInspectable = g_StudioApp.getInspectableFromInstance(refMaterial);
+ auto refMaterialInspectable = getInspectableFromInstance(refMaterial);
if (refMaterialInspectable) {
QString materialSrcPath;
if (instance.Valid())
@@ -992,11 +1090,11 @@ auto InspectorControlModel::computeTree(CInspectableBase *inspectBase)
return result;
}
-auto InspectorControlModel::computeGroup(CInspectableBase *inspectable, int theIndex,
+auto InspectorControlModel::computeGroup(CInspectableBase *inspectable, int index,
bool disableAnimation, bool isReference)
-> GroupInspectorControl
{
- CInspectorGroup *theInspectorGroup = inspectable->getGroup(theIndex);
+ CInspectorGroup *theInspectorGroup = inspectable->getGroup(index);
GroupInspectorControl result;
result.groupTitle = theInspectorGroup->GetName();
result.groupInfo.clear();
@@ -1004,43 +1102,44 @@ auto InspectorControlModel::computeGroup(CInspectableBase *inspectable, int theI
if (isReference)
result.groupTitle += tr(" (Reference)");
- if (const auto cdmInspectable = dynamic_cast<Qt3DSDMInspectable *>(inspectable)) {
- if (const auto group = dynamic_cast<Qt3DSDMInspectorGroup *>(theInspectorGroup)) {
- const auto materialGroup = dynamic_cast<Qt3DSDMMaterialInspectorGroup *>(group);
- bool isMatData = isBasicMaterial(cdmInspectable);
- if (materialGroup && materialGroup->isMaterialGroup()) {
- InspectorControlBase *item = nullptr;
-
- if (!isInsideMaterialContainer(cdmInspectable) && !isReference) {
- item = createMaterialTypeItem(cdmInspectable, theIndex);
- if (item)
- result.controlElements.push_back(QVariant::fromValue(item));
- }
-
- if (isAnimatableMaterial(cdmInspectable)) {
- item = createShaderItem(cdmInspectable, theIndex);
- if (item)
- result.controlElements.push_back(QVariant::fromValue(item));
- } else if (isMatData) {
- item = createMatDataItem(cdmInspectable, theIndex);
- if (item)
- result.controlElements.push_back(QVariant::fromValue(item));
- }
- }
+ if (inspectable->getObjectType() != OBJTYPE_GUIDE) {
+ const auto dmInspectable = static_cast<Qt3DSDMInspectable *>(inspectable);
+ const auto group = static_cast<Qt3DSDMInspectorGroup *>(theInspectorGroup);
- for (const auto row : group->GetRows()) {
- InspectorControlBase *item = createItem(cdmInspectable, row, theIndex);
- if (!item)
- continue;
+ bool isBasicMat = isBasicMaterial(dmInspectable);
+ if (group->isMaterial()) {
+ InspectorControlBase *item = nullptr;
- if (disableAnimation)
- item->m_animatable = false;
+ if (!isInsideMaterialContainer(dmInspectable) && !isReference) {
+ item = createMaterialTypeItem(dmInspectable, index);
+ if (item)
+ result.controlElements.push_back(QVariant::fromValue(item));
+ }
- if (!isMatData || item->m_title != getReferencedMaterialString())
+ if (isAnimatableMaterial(dmInspectable)) {
+ item = createShaderItem(dmInspectable, index);
+ if (item)
+ result.controlElements.push_back(QVariant::fromValue(item));
+ } else if (isBasicMat) {
+ item = createMatDataItem(dmInspectable, index);
+ if (item)
result.controlElements.push_back(QVariant::fromValue(item));
}
}
- } else if (const auto guideInspectable = dynamic_cast<GuideInspectable *>(inspectable)) {
+
+ for (const auto row : group->GetRows()) {
+ InspectorControlBase *item = createItem(dmInspectable, row, index);
+ if (!item)
+ continue;
+
+ if (disableAnimation)
+ item->m_animatable = false;
+
+ if (!isBasicMat || item->m_title != getReferencedMaterialString())
+ result.controlElements.push_back(QVariant::fromValue(item));
+ }
+ } else { // Guide
+ const auto guideInspectable = static_cast<GuideInspectable *>(inspectable);
// Guide properties don't come from metadata as they are not actual objects
m_guideInspectable = guideInspectable;
const auto &properties = m_guideInspectable->properties();
@@ -1096,8 +1195,18 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c
auto studioSystem = doc->GetStudioSystem();
const auto propertySystem = studioSystem->GetPropertySystem();
qt3dsdm::SValue value;
- const auto instance = element->m_instance;
+ auto instance = element->m_instance;
qt3dsdm::Option<qt3dsdm::SMetaDataPropertyInfo> info;
+
+ // For ref materials update IBL Override from the referenced material. This applies only for
+ // basic materials as IBL Override is disabled for referenced (and default basic) materials.
+ if (element->m_property
+ == getBridge()->GetObjectDefinitions().m_MaterialBase.m_IblProbe.m_Property) {
+ int refInstance = getBridge()->getMaterialReference(instance);
+ if (refInstance)
+ instance = refInstance;
+ }
+
if (m_guideInspectable) {
value = m_guideInspectable->properties()
[handleToGuidePropIndex(element->m_property)]->GetInspectableData();
@@ -1106,25 +1215,44 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c
return;
propertySystem->GetInstancePropertyValue(instance, element->m_property, value);
- if (value.getType() == qt3dsdm::DataModelDataType::None)
+ if (value.getType() == qt3dsdm::DataModelDataType::None) {
+ updateValidState(element); // Shader property has type none, still need to update valid
return;
+ }
const auto metaDataProvider = doc->GetStudioSystem()->GetActionMetaData();
info = metaDataProvider->GetMetaDataPropertyInfo(
metaDataProvider->GetMetaDataProperty(instance, element->m_property));
}
-
+ bool isTexture = info.hasValue()
+ && info->GetAdditionalType() == qt3dsdm::AdditionalMetaDataType::Texture;
bool skipEmits = false;
switch (element->m_dataType) {
case qt3dsdm::DataModelDataType::String: {
- QString stringValue = qt3dsdm::get<QString>(value);
- if (getBridge()->isInsideMaterialContainer(element->m_instance)) {
- int index = stringValue.lastIndexOf(QLatin1Char('/'));
- if (index != -1)
- stringValue = stringValue.mid(index + 1);
- }
+ if (value.getType() == qt3dsdm::DataModelDataType::Long4) {
+ qt3dsdm::Option<qt3dsdm::SLong4> guid = qt3dsdm::get<qt3dsdm::SLong4>(value);
+ qt3dsdm::Qt3DSDMInstanceHandle imageInstance = doc->GetDocumentReader()
+ .GetInstanceForGuid(guid);
+ if (imageInstance.Valid()) {
+ Q3DStudio::CString path = doc->GetDocumentReader().GetSourcePath(imageInstance);
+ Q3DStudio::CFilePath relPath(path);
+ element->m_value = QVariant(relPath.GetFileName().toQString());
+ } else {
+ element->m_value = QVariant(QString());
+ }
+ } else {
+ QString stringValue = qt3dsdm::get<QString>(value);
+ if (getBridge()->isInsideMaterialContainer(element->m_instance)) {
+ int index = stringValue.lastIndexOf(QLatin1Char('/'));
+ if (index != -1)
+ stringValue = stringValue.mid(index + 1);
+ }
- element->m_value = stringValue;
+ if (!isTexture)
+ element->m_value = stringValue;
+ else
+ element->m_value = {};
+ }
}
Q_FALLTHROUGH(); // fall-through for other String-derived datatypes
@@ -1213,8 +1341,20 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c
QString meshValue = QFileInfo(qt3dsdm::get<QString>(value)).fileName();
element->m_value = meshValue.startsWith('#'_L1) ? meshValue.mid(1) : meshValue;
} else if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::Texture) {
- QFileInfo fileInfo(qt3dsdm::get<QString>(value));
- element->m_value = fileInfo.fileName();
+ if (value.getType() == qt3dsdm::DataModelDataType::Long4) {
+ qt3dsdm::Option<qt3dsdm::SLong4> guid = qt3dsdm::get<qt3dsdm::SLong4>(value);
+ qt3dsdm::Qt3DSDMInstanceHandle imageInstance = doc->GetDocumentReader()
+ .GetInstanceForGuid(guid);
+ if (imageInstance.Valid()) {
+ Q3DStudio::CString path = doc->GetDocumentReader().GetSourcePath(imageInstance);
+ Q3DStudio::CFilePath relPath(path);
+ element->m_value = QVariant(relPath.GetFileName().toQString());
+ } else {
+ element->m_value = QVariant(QString());
+ }
+ } else {
+ element->m_value = {};
+ }
} else if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::PathBuffer) {
element->m_value = qt3dsdm::get<QString>(value);
} else if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::String) {
@@ -1295,6 +1435,11 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c
case qt3dsdm::DataModelDataType::Float4:
if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::Color) {
element->m_value = qt3dsdm::get<QColor>(value);
+ } else if (element->m_propertyType == qt3dsdm::AdditionalMetaDataType::None) {
+ const QVector4D theFloat4 = qt3dsdm::get<QVector4D>(value);
+ const QList<double> float4Values{theFloat4.x(), theFloat4.y(), theFloat4.z(),
+ theFloat4.w()};
+ element->m_values = QVariant::fromValue<QList<double> >(float4Values);
}
break;
@@ -1358,6 +1503,8 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c
// not the controlled flag nor the tooltip
if (element->m_controllable)
updateControlledToggleState(element);
+
+ updateValidState(element);
}
void InspectorControlModel::refreshRenderables()
@@ -1405,7 +1552,7 @@ void InspectorControlModel::refresh()
for (int p = 0; p < group.controlElements.count(); ++p) {
QVariant& element = group.controlElements[p];
InspectorControlBase *property = element.value<InspectorControlBase *>();
- if (property->m_property.Valid()) {
+ if (property->m_property.Valid() || property->m_title == tr("Shader")) {
updatePropertyValue(property);
updateControlledToggleState(property);
}
@@ -1426,7 +1573,7 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan
EStudioObjectType type = getBridge()->GetObjectType(instance);
auto material = instance;
- if (type == EStudioObjectType::OBJTYPE_IMAGE)
+ if (type == OBJTYPE_IMAGE)
material = sceneEditor->GetParent(instance);
if (!material.Valid())
@@ -1441,8 +1588,7 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan
type = getBridge()->GetObjectType(material);
- if (type == EStudioObjectType::OBJTYPE_MATERIAL
- || type == EStudioObjectType::OBJTYPE_CUSTOMMATERIAL) {
+ if (type & (OBJTYPE_MATERIAL | OBJTYPE_CUSTOMMATERIAL)) {
qt3dsdm::SValue value;
studio->GetPropertySystem()->GetInstancePropertyValue(
material, getBridge()->GetObjectDefinitions().m_Named.m_NameProp, value);
@@ -1554,6 +1700,10 @@ void InspectorControlModel::setShaderValue(long instance, int handle, const QVar
}
saveIfMaterial(instance);
+
+ // Make sure that inspector panel is up-to-date with regards to result of shader compilation
+ // errors.
+ rebuildTree();
}
void InspectorControlModel::setMatDataValue(long instance, int handle, const QVariant &value)
@@ -1563,7 +1713,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa
const QString typeValue = value.toString();
QString v;
QString name;
- Q3DStudio::CString srcPath;
+ QString srcPath;
QMap<QString, QString> values;
QMap<QString, QMap<QString, QString>> textureValues;
@@ -1573,7 +1723,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa
if (typeValue == getDefaultMaterialString()) {
v = QStringLiteral("Referenced Material");
name = getBridge()->getDefaultMaterialName();
- srcPath = Q3DStudio::CString::fromQString(name);
+ srcPath = name;
changeMaterialFile = true;
} else {
const auto sceneEditor = doc->getSceneEditor();
@@ -1589,15 +1739,15 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa
v = QStringLiteral("Referenced Material");
changeMaterialFile = true;
name = m_matDatas[matIdx].m_name;
- srcPath = Q3DStudio::CString::fromQString(m_matDatas[matIdx].m_relativePath);
- const auto material = sceneEditor->getMaterial(srcPath.toQString());
+ srcPath = m_matDatas[matIdx].m_relativePath;
+ const auto material = sceneEditor->getMaterial(srcPath);
if (material.Valid()) {
// Get the correct case source path
const auto absPath = sceneEditor->getFilePathFromMaterialName(
sceneEditor->GetName(material).toQString());
const auto relPath = QDir(doc->GetDocumentDirectory())
.relativeFilePath(absPath);
- srcPath = Q3DStudio::CString::fromQString(relPath);
+ srcPath = relPath;
}
values = m_matDatas[matIdx].m_values;
textureValues = m_matDatas[matIdx].m_textureValues;
@@ -1609,7 +1759,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa
if (changeMaterialFile) {
{
Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QString())
- ->setMaterialValues(srcPath.toQString(), values, textureValues);
+ ->setMaterialValues(srcPath, values, textureValues);
}
// Several aspects of the editor are not updated correctly
// if the data core is changed without a transaction
@@ -1624,8 +1774,8 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa
scopedEditor->SetMaterialType(instance, v);
if (changeMaterialFile) {
- scopedEditor->setMaterialSourcePath(instance, srcPath);
- scopedEditor->setMaterialReferenceByPath(instance, srcPath.toQString());
+ scopedEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(srcPath));
+ scopedEditor->setMaterialReferenceByPath(instance, srcPath);
// Select original instance again since potentially
// creating a material selects the created one
@@ -1675,7 +1825,8 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV
&& ((newName.Find('/') != Q3DStudio::CString::ENDOFSTRING
|| newName.Find('#') != Q3DStudio::CString::ENDOFSTRING
|| newName.Find(':') != Q3DStudio::CString::ENDOFSTRING)
- || m_suspendMaterialRename)) {
+ || m_suspendMaterialRename)
+ || newName.toQString().contains(QChar('.'))) {
return;
}
qt3dsdm::Qt3DSDMInstanceHandle parentInstance = getBridge()
@@ -1968,6 +2119,16 @@ QHash<int, QByteArray> InspectorControlModel::roleNames() const
return names;
}
+void InspectorControlModel::undo()
+{
+ g_StudioApp.m_pMainWnd->OnEditUndo();
+}
+
+void InspectorControlModel::redo()
+{
+ g_StudioApp.m_pMainWnd->OnEditRedo();
+}
+
InspectorControlBase::~InspectorControlBase()
{
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h
index 3063f047..bcd4ce22 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.h
@@ -70,6 +70,7 @@ class InspectorControlBase : public QObject
Q_PROPERTY(bool animated MEMBER m_animated NOTIFY animatedChanged)
Q_PROPERTY(bool controlled MEMBER m_controlled NOTIFY controlledChanged)
Q_PROPERTY(bool controllable MEMBER m_controllable CONSTANT)
+ Q_PROPERTY(bool validData MEMBER m_valid NOTIFY validDataChanged)
Q_PROPERTY(QString controller MEMBER m_controller NOTIFY controlledChanged)
public:
@@ -81,6 +82,7 @@ Q_SIGNALS:
void animatedChanged();
void controlledChanged();
void tooltipChanged();
+ void validDataChanged();
public:
qt3dsdm::DataModelDataType::Value m_dataType;
@@ -99,6 +101,7 @@ public:
bool m_animated = false;
bool m_controlled = false;
bool m_controllable = false;
+ bool m_valid = true;
QString m_controller;
std::vector<qt3dsdm::TSignalConnectionPtr> m_connections;
};
@@ -130,7 +133,8 @@ public:
void refresh();
void saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance);
- bool hasInstanceProperty(long instance, int handle);
+ bool hasInstanceProperty(qt3dsdm::Qt3DSDMInstanceHandle instance,
+ qt3dsdm::Qt3DSDMPropertyHandle handle) const;
qt3dsdm::SValue currentPropertyValue(long instance, int handle) const;
QString currentControllerValue(long instance, int handle) const;
@@ -158,25 +162,17 @@ public:
Q_INVOKABLE void duplicateMaterial();
Q_INVOKABLE bool isGroupCollapsed(int groupIdx) const;
Q_INVOKABLE void updateGroupCollapseState(int groupIdx, bool state);
+ Q_INVOKABLE void undo();
+ Q_INVOKABLE void redo();
private:
- void onSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inOldIndex,
- int inNewIndex);
-
-
- struct GroupInspectorControl {
+ struct GroupInspectorControl
+ {
QString groupTitle;
QVariantList controlElements;
QString groupInfo;
-
- ~GroupInspectorControl() {
- }
};
- QVector<GroupInspectorControl> m_groupElements;
- CInspectableBase *m_inspectableBase = nullptr;
- GuideInspectable *m_guideInspectable = nullptr;
-
struct MaterialEntry
{
QString m_name;
@@ -191,20 +187,9 @@ private:
QMap<QString, QMap<QString, QString>> m_textureValues;
};
- std::vector<MaterialEntry> m_materials;
- std::vector<MaterialDataEntry> m_matDatas;
- std::vector<Q3DStudio::CFilePath> m_cachedMatDatas;
- qt3dsdm::Qt3DSDMInstanceHandle m_refMaterial;
-
- Q3DStudio::CUpdateableDocumentEditor m_UpdatableEditor;
-
- bool m_suspendMaterialRename = false;
-
- QPair<long, int> m_modifiedProperty;
-
- qt3dsdm::SValue m_previouslyCommittedValue;
+ void onSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inOldIndex,
+ int inNewIndex);
- QHash<int, QHash<int, bool> > m_collapseMap;
QString getBasicMaterialString() const;
QString getAnimatableMaterialString() const;
@@ -220,6 +205,8 @@ private:
void updateMaterialValues(const QStringList &values, int elementIndex,
bool updatingShaders = false);
qt3dsdm::Qt3DSDMInstanceHandle getReferenceMaterial(CInspectableBase *inspectable) const;
+ qt3dsdm::Qt3DSDMInstanceHandle getReferenceMaterialRecursively(
+ CInspectableBase *inspectable) const;
void updateShaderValues();
void updateMatDataValues();
void updatePropertyValue(InspectorControlBase *element) const;
@@ -227,6 +214,7 @@ private:
void refreshTree();
void updateAnimateToggleState(InspectorControlBase *inItem);
void updateControlledToggleState(InspectorControlBase *inItem) const;
+ void updateValidState(InspectorControlBase *inItem) const;
QStringList materialTypeValues() const;
QStringList shaderValues() const;
@@ -247,11 +235,30 @@ private:
int theIndex, bool disableAnimation = false,
bool isReference = false);
bool isGroupRebuildRequired(CInspectableBase *inspectable, int theIndex) const;
-
+ CInspectableBase *getInspectableFromInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
CClientDataModelBridge *getBridge() const;
static int handleToGuidePropIndex(int handle) { return handle - 1; }
+ QVector<GroupInspectorControl> m_groupElements;
+ CInspectableBase *m_inspectableBase = nullptr;
+ GuideInspectable *m_guideInspectable = nullptr;
+
+ std::vector<MaterialEntry> m_materials;
+ std::vector<MaterialDataEntry> m_matDatas;
+ std::vector<Q3DStudio::CFilePath> m_cachedMatDatas;
+ qt3dsdm::Qt3DSDMInstanceHandle m_refMaterial;
+
+ Q3DStudio::CUpdateableDocumentEditor m_UpdatableEditor;
+
+ bool m_suspendMaterialRename = false;
+
+ QPair<long, int> m_modifiedProperty;
+
+ qt3dsdm::SValue m_previouslyCommittedValue;
+
+ QHash<int, QHash<int, bool> > m_collapseMap;
+
VariantsGroupModel *m_variantsModel = nullptr;
};
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp
index e4e0379f..f991f467 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.cpp
@@ -65,7 +65,6 @@
#include "SelectedValue.h"
#include "Qt3DSDMInspectable.h"
#include "Qt3DSDMSlides.h"
-#include "Qt3DSDMMaterialInspectable.h"
#include "GuideInspectable.h"
#include <QtCore/qtimer.h>
@@ -89,6 +88,13 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget *
dispatch->AddPresentationChangeListener(this);
dispatch->AddDataModelListener(this);
+ m_shaderStatusUpdateTimer.setSingleShot(true);
+ m_shaderStatusUpdateTimer.setInterval(3000);
+
+ connect(&m_shaderStatusUpdateTimer, &QTimer::timeout, [&](){
+ m_inspectorControlModel->refresh();
+ });
+
connect(m_meshChooserView, &MeshChooserView::meshSelected, this,
[this] (int handle, int instance, const QString &name) {
if (name.startsWith(QLatin1Char('#'))) {
@@ -171,6 +177,9 @@ void InspectorControlView::onFilesChanged(
L"material", L"shader", L"materialdef",
nullptr
};
+ static const wchar_t *effectExtensions[] = {
+ L"effect", nullptr
+ };
static const wchar_t *fontExtensions[] = {
L"ttf", L"otf",
nullptr
@@ -190,6 +199,8 @@ void InspectorControlView::onFilesChanged(
qt3dsdm::binary_sort_insert_unique(m_fileList, relativePath);
else if (record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed)
qt3dsdm::binary_sort_erase(m_fileList, relativePath);
+ else
+ m_shaderStatusUpdateTimer.start();
} else if (isInList(fontExtensions, record.m_File.GetExtension())) {
if (record.m_ModificationType == Q3DStudio::FileModificationType::Created
|| record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) {
@@ -201,6 +212,8 @@ void InspectorControlView::onFilesChanged(
g_StudioApp.GetCore()->getProjectFile().loadSubpresentationsAndDatainputs(
g_StudioApp.m_subpresentations, g_StudioApp.m_dataInputDialogItems);
m_inspectorControlModel->refreshRenderables();
+ } else if (isInList(effectExtensions, record.m_File.GetExtension())) {
+ m_shaderStatusUpdateTimer.start();
}
}
}
@@ -278,8 +291,7 @@ QString InspectorControlView::titleText() const
bool InspectorControlView::isRefMaterial(int instance) const
{
- auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
- return bridge->IsReferencedMaterialInstance(instance);
+ return getBridge()->IsReferencedMaterialInstance(instance);
}
QString InspectorControlView::noneString() const
@@ -289,16 +301,21 @@ QString InspectorControlView::noneString() const
bool InspectorControlView::canLinkProperty(int instance, int handle) const
{
- CDoc *doc = g_StudioApp.GetCore()->GetDoc();
- const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ if (!instance || !handle)
+ return false;
- if (bridge->isInsideMaterialContainer(instance))
+ if (getBridge()->isInsideMaterialContainer(instance))
return false;
- if (bridge->IsMaterialBaseInstance(instance)) // all material types are unlinkable
+ if (handle == getBridge()->GetSceneAsset().m_Eyeball.m_Property) // eyeball is unlinkable
return false;
- if (handle == bridge->GetSceneAsset().m_Eyeball.m_Property) // eyeball is unlinkable
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+
+ // Disallow linking of properties that refer to images as unlinking them is not trivial at all.
+ qt3dsdm::AdditionalMetaDataType::Value thePropertyMetaData =
+ doc->GetStudioSystem()->GetPropertySystem()->GetAdditionalMetaDataType(instance, handle);
+ if (thePropertyMetaData == qt3dsdm::AdditionalMetaDataType::Image)
return false;
return doc->GetDocumentReader().CanPropertyBeLinked(instance, handle);
@@ -307,6 +324,7 @@ bool InspectorControlView::canLinkProperty(int instance, int handle) const
bool InspectorControlView::canOpenInInspector(int instance, int handle) const
{
const auto doc = g_StudioApp.GetCore()->GetDoc();
+
qt3dsdm::SValue value;
doc->GetPropertySystem()->GetInstancePropertyValue(instance, handle, value);
if (!value.empty() && value.getType() == qt3dsdm::DataModelDataType::Long4) {
@@ -319,12 +337,12 @@ bool InspectorControlView::canOpenInInspector(int instance, int handle) const
void InspectorControlView::openInInspector()
{
const auto doc = g_StudioApp.GetCore()->GetDoc();
- const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+
qt3dsdm::SValue value;
doc->GetPropertySystem()->GetInstancePropertyValue(m_contextMenuInstance, m_contextMenuHandle,
value);
qt3dsdm::SLong4 guid = qt3dsdm::get<qt3dsdm::SLong4>(value);
- const auto instance = bridge->GetInstanceByGUID(guid);
+ const auto instance = getBridge()->GetInstanceByGUID(guid);
doc->SelectDataModelObject(instance);
}
@@ -333,11 +351,10 @@ void InspectorControlView::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inIn
{
m_inspectorControlModel->notifyPropertyChanged(inInstance, inProperty);
- auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
// titleChanged implies icon change too, but that will only occur if inspectable type changes,
// which will invalidate the inspectable anyway, so in reality we are only interested in name
// property here
- if (inProperty == bridge->GetNameProperty() && m_inspectableBase
+ if (inProperty == getBridge()->GetNameProperty() && m_inspectableBase
&& m_inspectableBase->isValid()) {
Q_EMIT titleChanged();
}
@@ -349,13 +366,12 @@ void InspectorControlView::onChildAdded(int inChild)
if (m_activeBrowser.isActive() && m_activeBrowser.m_browser == m_objectReferenceView)
m_activeBrowser.clear();
- const auto doc = g_StudioApp.GetCore()->GetDoc();
- const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
- if (bridge->IsCustomMaterialInstance(inChild)) {
+ if (getBridge()->IsCustomMaterialInstance(inChild)) {
QVector<qt3dsdm::Qt3DSDMInstanceHandle> refMats;
+ auto doc = g_StudioApp.GetCore()->GetDoc();
doc->getSceneReferencedMaterials(doc->GetSceneInstance(), refMats);
for (auto &refMat : qAsConst(refMats)) {
- if ((int)bridge->getMaterialReference(refMat) == inChild)
+ if (int(getBridge()->getMaterialReference(refMat)) == inChild)
g_StudioApp.GetCore()->GetDispatch()->FireImmediateRefreshInstance(refMat);
}
}
@@ -401,8 +417,10 @@ void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue selectable)
{
CInspectableBase *inspectable = createInspectableFromSelectable(selectable);
- if (inspectable && !inspectable->isValid())
+ if (inspectable && !inspectable->isValid()) {
+ delete inspectable;
inspectable = nullptr;
+ }
setInspectable(inspectable);
}
@@ -429,17 +447,14 @@ CInspectableBase *InspectorControlView::createInspectableFromSelectable(
if (selectedsInstances.size() == 1) {
Qt3DSDMInstanceHandle selectedInstance = selectedsInstances[0];
if (doc->GetDocumentReader().IsInstance(selectedInstance)) {
- auto *bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
qt3dsdm::Qt3DSDMSlideHandle activeSlide = doc->GetActiveSlide();
// Scene or Component (when being edited)
- if (selectedInstance == bridge->GetOwningComponentInstance(activeSlide)) {
+ if (selectedInstance == getBridge()->GetOwningComponentInstance(activeSlide)) {
Qt3DSDMInstanceHandle activeSlideInstance = doc->GetStudioSystem()
->GetSlideSystem()->GetSlideInstance(activeSlide);
inspectableBase = new Qt3DSDMInspectable(selectedInstance,
activeSlideInstance);
- } else if (bridge->IsMaterialBaseInstance(selectedInstance)) {
- inspectableBase = new Qt3DSDMMaterialInspectable(selectedInstance);
} else {
inspectableBase = new Qt3DSDMInspectable(selectedInstance);
}
@@ -464,9 +479,16 @@ void InspectorControlView::setInspectable(CInspectableBase *inInspectable)
{
if (m_inspectableBase != inInspectable) {
m_activeBrowser.clear();
+
+ CInspectableBase *oldInspectableBase = m_inspectableBase;
+
m_inspectableBase = inInspectable;
m_inspectorControlModel->setInspectable(inInspectable);
+ // Delete old inspectable base only after setting the new inspectable is completed,
+ // as model may still need it to commit pending transaction
+ delete oldInspectableBase;
+
Q_EMIT titleChanged();
m_variantsGroupModel->refresh();
@@ -480,7 +502,6 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc
QMenu theContextMenu;
- auto doc = g_StudioApp.GetCore()->GetDoc();
if (canOpenInInspector(instance, handle)) {
auto action = theContextMenu.addAction(tr("Open in Inspector"));
@@ -488,6 +509,7 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc
}
if (canLinkProperty(instance, handle)) {
+ auto doc = g_StudioApp.GetCore()->GetDoc();
bool isLinked = doc->GetDocumentReader().IsPropertyLinked(instance, handle);
auto action = theContextMenu.addAction(isLinked ? tr("Unlink Property from Master Slide")
: tr("Link Property from Master Slide"));
@@ -634,6 +656,14 @@ QObject *InspectorControlView::showImageChooser(int handle, int instance, const
});
}
+ // For basic materials edit IBL Override of the referenced material. This applies only for basic
+ // materials as IBL Override is disabled for referenced (and default basic) materials.
+ if (handle == getBridge()->GetObjectDefinitions().m_MaterialBase.m_IblProbe.m_Property) {
+ int refInstance = getBridge()->getMaterialReference(instance);
+ if (refInstance)
+ instance = refInstance;
+ }
+
m_imageChooserView->setHandle(handle);
m_imageChooserView->setInstance(instance);
@@ -838,10 +868,9 @@ QColor InspectorControlView::showColorDialog(const QColor &color, int instance,
{
bool showAlpha = false;
if (instance && handle) {
- auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
- ->GetClientDataModelBridge();
- showAlpha = bridge->getBGColorProperty(instance).GetHandleValue() == handle
- || bridge->getTextColorProperty(instance).GetHandleValue() == handle;
+ showAlpha = getBridge()->getBGColorProperty(instance).GetHandleValue() == handle
+ || getBridge()->getTextColorProperty(instance).GetHandleValue() == handle
+ || getBridge()->IsCustomMaterialInstance(instance);
}
m_currentColor = color;
@@ -854,9 +883,9 @@ QColor InspectorControlView::showColorDialog(const QColor &color, int instance,
return currentColor;
}
-bool InspectorControlView::toolTipsEnabled()
+bool InspectorControlView::toolTipsEnabled() const
{
- return CStudioPreferences::ShouldShowTooltips();
+ return CStudioPreferences::isTooltipsOn();
}
// Converts a path that is relative to the current presentation to be relative to
@@ -919,6 +948,11 @@ void InspectorControlView::OnEndDataModelNotifications()
}
}
+CClientDataModelBridge *InspectorControlView::getBridge() const
+{
+ return g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
+}
+
void InspectorControlView::OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
m_inspectorControlModel->refresh();
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h
index 75d07d73..6bc7d6fb 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.h
@@ -51,6 +51,7 @@ class ObjectListModel;
class FileChooserView;
class TextureChooserView;
class MaterialRefView;
+class CClientDataModelBridge;
QT_FORWARD_DECLARE_CLASS(QAbstractItemModel)
@@ -86,7 +87,7 @@ public:
Q_INVOKABLE QObject *showObjectReference(int handle, int instance, const QPoint &point);
Q_INVOKABLE QObject *showMaterialReference(int handle, int instance, const QPoint &point);
Q_INVOKABLE QObject *showTextureChooser(int handle, int instance, const QPoint &point);
- Q_INVOKABLE bool toolTipsEnabled();
+ Q_INVOKABLE bool toolTipsEnabled() const;
Q_INVOKABLE bool isRefMaterial(int instance) const;
Q_INVOKABLE bool isEditable(int handle) const;
Q_INVOKABLE QString convertPathToProjectRoot(const QString &presentationPath);
@@ -132,6 +133,7 @@ private:
std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>> m_connections;
QColor m_backgroundColor;
+ QTimer m_shaderStatusUpdateTimer;
VariantsGroupModel *m_variantsGroupModel = nullptr;
InspectorControlModel *m_inspectorControlModel = nullptr;
CInspectableBase *m_inspectableBase = nullptr;
@@ -143,6 +145,8 @@ private:
QPointer<MaterialRefView> m_matRefListWidget;
QPointer<ObjectListModel> m_objectReferenceModel;
QPointer<DataInputSelectView> m_dataInputChooserView;
+ CClientDataModelBridge *getBridge() const;
+
std::vector<Q3DStudio::CFilePath> m_fileList;
MouseHelper m_mouseHelper;
QmlUtils m_qmlUtils;
@@ -167,8 +171,8 @@ private:
if (isActive())
m_browser->close();
m_browser.clear();
- m_handle = -1;
- m_instance = -1;
+ m_handle = 0;
+ m_instance = 0;
}
bool isActive() const
{
@@ -176,8 +180,8 @@ private:
}
QPointer<QWidget> m_browser = nullptr;
- int m_handle = -1;
- int m_instance = -1;
+ int m_handle = 0;
+ int m_instance = 0;
};
ActiveBrowserData m_activeBrowser;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml
index c291de7b..d5570fc7 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlView.qml
@@ -192,7 +192,7 @@ Rectangle {
property int indexOfThisDelegate: index
- width: parent.width
+ width: groupElements.width
height: items.height
color: "transparent";
ListView.delayRemove: true
@@ -263,6 +263,11 @@ Rectangle {
_tabOrderHandler.addItem(
indexOfThisDelegate,
item.loadedItem.tabItem3)
+ if (item.loadedItem.tabItem4 !== undefined) {
+ _tabOrderHandler.addItem(
+ indexOfThisDelegate,
+ item.loadedItem.tabItem4)
+ }
}
}
}
@@ -280,9 +285,6 @@ Rectangle {
coords.x, coords.y,
model.modelData.handle,
model.modelData.instance);
- // Refresh text; title color is wrong after this
- propertyRow.color = _parentView.titleColor(
- modelData.instance, modelData.handle);
}
ColumnLayout { // Property row and datainput control
@@ -332,7 +334,9 @@ Rectangle {
}
}
StyledTooltip {
- text: qsTr("Enable animation")
+ text: model.modelData.animated
+ ? qsTr("Disable animation")
+ : qsTr("Enable animation")
enabled: animateButtonMouseArea.containsMouse
}
}
@@ -372,7 +376,6 @@ Rectangle {
+ ctrldPropButton.width,
ctrldPropButton.y
+ ctrldPropButton.height));
-
}
}
@@ -391,11 +394,13 @@ Rectangle {
readonly property var modelData: model.modelData
text: model.modelData.title
- // Color picked from DataInput icon
- color: model.modelData.controlled?
- _dataInputColor
- : _parentView.titleColor(modelData.instance,
- modelData.handle)
+ // Label is showing "controlled", "invalid data" or
+ // ordinary text color.
+ color: model.modelData.controlled
+ ? _dataInputColor : model.modelData.validData
+ ? _parentView.titleColor(modelData.instance,
+ modelData.handle)
+ : _invalidDataIndicatorColor
Layout.alignment: Qt.AlignTop
@@ -476,7 +481,7 @@ Rectangle {
if (modelData.propertyType === AdditionalMetaDataType.Font)
return fontDropDown;
if (modelData.propertyType === AdditionalMetaDataType.Texture)
- return textureChooser;
+ return imageChooser;
if (modelData.propertyType === AdditionalMetaDataType.String)
return editLine;
if (modelData.propertyType === AdditionalMetaDataType.None)
@@ -515,6 +520,8 @@ Rectangle {
case DataModelDataType.Float4:
if (modelData.propertyType === AdditionalMetaDataType.Color)
return colorBox;
+ if (modelData.propertyType === AdditionalMetaDataType.None)
+ return xyzwPropertyComponent;
return null;
case DataModelDataType.StringRef:
if (modelData.propertyType === AdditionalMetaDataType.None)
@@ -539,13 +546,12 @@ Rectangle {
}
}
- Column {
+ StyledLabel {
visible: model.info.length > 0
- StyledLabel {
- width: groupElements.width
- horizontalAlignment: Text.AlignHCenter
- text: model.info;
- }
+ x: 42
+ width: items.width - x - 10
+ wrapMode: Text.WordWrap
+ text: model.info;
}
}
}
@@ -660,6 +666,54 @@ Rectangle {
}
Component {
+ id: xyzwPropertyComponent
+
+ RowLayout {
+ property int instance: parent.modelData.instance
+ property int handle: parent.modelData.handle
+ property variant values: parent.modelData.values
+ property alias tabItem1: xyzwHandler.tabItem1
+ property alias tabItem2: xyzwHandler.tabItem2
+ property alias tabItem3: xyzwHandler.tabItem3
+ property alias tabItem4: xyzwHandler.tabItem4
+ spacing: 0
+
+ onValuesChanged: {
+ // FloatTextField can set its text internally, thus breaking the binding, so
+ // let's set the text value explicitly each time value changes
+ xyzwHandler.valueX = Number(values[0]).toFixed(xyzwHandler.numberOfDecimal);
+ xyzwHandler.valueY = Number(values[1]).toFixed(xyzwHandler.numberOfDecimal);
+ xyzwHandler.valueZ = Number(values[2]).toFixed(xyzwHandler.numberOfDecimal);
+ xyzwHandler.valueW = Number(values[3]).toFixed(xyzwHandler.numberOfDecimal);
+ }
+
+ HandlerPropertyBaseXYZW {
+ id: xyzwHandler
+ valueX: Number(values[0]).toFixed(numberOfDecimal)
+ valueY: Number(values[1]).toFixed(numberOfDecimal)
+ valueZ: Number(values[2]).toFixed(numberOfDecimal)
+ valueW: Number(values[3]).toFixed(numberOfDecimal)
+ onEditingFinished: {
+ _inspectorModel.setPropertyValue(parent.instance, parent.handle,
+ Qt.vector4d(valueX, valueY, valueZ, valueW),
+ true);
+ }
+ onPreviewValueChanged: {
+ _inspectorModel.setPropertyValue(parent.instance, parent.handle,
+ Qt.vector4d(valueX, valueY, valueZ, valueW),
+ false);
+ }
+ onTriggerUndo: {
+ _inspectorModel.undo();
+ }
+ onTriggerRedo: {
+ _inspectorModel.redo();
+ }
+ }
+ }
+ }
+
+ Component {
id: xyzPropertyComponent
RowLayout {
@@ -692,6 +746,12 @@ Rectangle {
_inspectorModel.setPropertyValue(parent.instance, parent.handle,
Qt.vector3d(valueX, valueY, valueZ), false);
}
+ onTriggerUndo: {
+ _inspectorModel.undo();
+ }
+ onTriggerRedo: {
+ _inspectorModel.redo();
+ }
}
}
}
@@ -726,6 +786,12 @@ Rectangle {
_inspectorModel.setPropertyValue(parent.instance, parent.handle,
Qt.vector2d(valueX, valueY), false);
}
+ onTriggerUndo: {
+ _inspectorModel.undo();
+ }
+ onTriggerRedo: {
+ _inspectorModel.redo();
+ }
}
}
}
@@ -762,6 +828,12 @@ Rectangle {
_inspectorModel.setPropertyValue(parent.instance, parent.handle,
Number(text), true);
}
+ onTriggerUndo: {
+ _inspectorModel.undo();
+ }
+ onTriggerRedo: {
+ _inspectorModel.redo();
+ }
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.cpp
index 24c67fbe..a6b53552 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.cpp
@@ -118,23 +118,31 @@ QPoint MouseHelper::delta()
QPoint delta(0, 0);
if (m_dragState == StateDragging) {
QPoint currentPoint = QCursor::pos();
- delta = currentPoint - m_previousPoint;
+ // In macOS we come here after QCursor::setPos has been called from resetCursor(), but
+ // before the actual position has changed. This results in hude delta values, which makes
+ // mouse drag adjustment on macOS unusable (QT3DS-3763).
+ // This also breaks the cursor position resetting on macOS, but that's due to a bug in
+ // Qt (QTBUG-33959)
+ if (m_previousPoint != m_referencePoint) {
+ delta = currentPoint - m_previousPoint;
+
+ // Limit delta to even out the maximum possible change rate regardless of widget position
+ if (delta.x() > m_maxDelta.x())
+ delta.setX(m_maxDelta.x());
+ else if (delta.x() < -m_maxDelta.x())
+ delta.setX(-m_maxDelta.x());
+
+ if (delta.y() > m_maxDelta.y())
+ delta.setY(m_maxDelta.y());
+ else if (delta.y() < -m_maxDelta.y())
+ delta.setY(-m_maxDelta.y());
+
+ if (!m_cursorResetTimer.isActive())
+ m_cursorResetTimer.start();
+ }
m_previousPoint = currentPoint;
-
- // Limit delta to even out the maximum possible change rate regardless of widget position
- if (delta.x() > m_maxDelta.x())
- delta.setX(m_maxDelta.x());
- else if (delta.x() < -m_maxDelta.x())
- delta.setX(-m_maxDelta.x());
-
- if (delta.y() > m_maxDelta.y())
- delta.setY(m_maxDelta.y());
- else if (delta.y() < -m_maxDelta.y())
- delta.setY(-m_maxDelta.y());
-
- if (!m_cursorResetTimer.isActive())
- m_cursorResetTimer.start();
}
+
return delta;
}
@@ -168,7 +176,6 @@ void MouseHelper::resetCursor()
m_dragState = StateNotDragging;
break;
case StateNotDragging:
- default:
break;
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.h
index 8f343bc4..13cc070d 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/MouseHelper.h
@@ -41,7 +41,7 @@ class MouseHelper : public QObject
public:
explicit MouseHelper(QObject *parent = nullptr);
- ~MouseHelper() {};
+ ~MouseHelper() override {}
Q_INVOKABLE void startUnboundedDrag();
Q_INVOKABLE void endUnboundedDrag();
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp
index a82df79c..eb6803b4 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.cpp
@@ -29,6 +29,7 @@
#include "Qt3DSDMInspectable.h"
#include "Qt3DSDMInspectorGroup.h"
+#include "Qt3DSDMInspectorRow.h"
#include "StudioApp.h"
#include "Core.h"
#include "Doc.h"
@@ -54,6 +55,13 @@ Qt3DSDMInspectable::Qt3DSDMInspectable(qt3dsdm::Qt3DSDMInstanceHandle instance,
}
}
+Qt3DSDMInspectable::~Qt3DSDMInspectable()
+{
+ for (auto g : qAsConst(m_groups))
+ delete g;
+ m_groups.clear();
+}
+
// Returns the name of this inspectable
Q3DStudio::CString Qt3DSDMInspectable::getName()
{
@@ -87,11 +95,31 @@ long Qt3DSDMInspectable::getGroupCount() const
}
// Return the property group for display
-CInspectorGroup *Qt3DSDMInspectable::getGroup(long inIndex)
+CInspectorGroup *Qt3DSDMInspectable::getGroup(long index)
{
- Qt3DSDMInspectorGroup *group = new Qt3DSDMInspectorGroup(GetGroupName(inIndex));
+ TMetaDataPropertyHandleList properties = GetGroupProperties(index);
+ if (m_groups.contains(index)) {
+ // Check if the group properties have changed. This can f.ex happen if property
+ // filter status changed and it became visible.
+ std::vector<Q3DStudio::Qt3DSDMInspectorRow *> rows
+ = static_cast<const Qt3DSDMInspectorGroup *>(m_groups[index])->GetRows();
+ TMetaDataPropertyHandleList rowProps;
+
+ for (uint i = 0; i < rows.size(); ++i)
+ rowProps.push_back(rows[i]->GetMetaDataProperty());
+
+ // No need to sort; if ordering has changed for some reason, group also needs to be
+ // reconstructed. (Assume that the default case is that row ordering is derived from
+ // property ordering, so we can use direct == operator to see if properties match the
+ // inspector rows.)
+ if (properties == rowProps)
+ return m_groups[index];
+
+ delete m_groups[index];
+ }
- TMetaDataPropertyHandleList properties = GetGroupProperties(inIndex);
+ Qt3DSDMInspectorGroup *group = new Qt3DSDMInspectorGroup(GetGroupName(index));
+ m_groups[index] = group;
for (auto &prop : properties)
group->CreateRow(getDoc(), prop);
@@ -100,16 +128,16 @@ CInspectorGroup *Qt3DSDMInspectable::getGroup(long inIndex)
}
// Return the property handles for display, given the group index
-TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex)
+TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long index)
{
- long activeGroupIdx = activeGroupIndex(inIndex);
+ long activeGroupIdx = activeGroupIndex(index);
TMetaDataPropertyHandleList retval;
IMetaData &theMetaData = *getDoc()->GetStudioSystem()->GetActionMetaData();
- theMetaData.GetMetaDataProperties(GetGroupInstance(inIndex), retval);
+ theMetaData.GetMetaDataProperties(GetGroupInstance(index), retval);
qt3dsdm::IPropertySystem &thePropertySystem(*getDoc()->GetStudioSystem()->GetPropertySystem());
// get name of the current group for filtering
Option<qt3dsdm::TCharStr> theGroupFilterName =
- theMetaData.GetGroupFilterNameForInstance(GetGroupInstance(inIndex), activeGroupIdx);
+ theMetaData.GetGroupFilterNameForInstance(GetGroupInstance(index), activeGroupIdx);
long theGroupCount = getGroupCount();
// end is explicitly required
@@ -140,7 +168,7 @@ TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex)
SValue theValue;
thePropertySystem.GetInstancePropertyValue(
- GetGroupInstance(inIndex), theFilter.m_FilterProperty, theValue);
+ GetGroupInstance(index), theFilter.m_FilterProperty, theValue);
bool resultIfTrue = theFilter.m_FilterType == PropertyFilterTypes::ShowIfEqual;
if (Equals(theValue.toOldSkool(), theFilter.m_Value.toOldSkool())) {
keepProperty = resultIfTrue;
@@ -168,7 +196,7 @@ QString Qt3DSDMInspectable::GetGroupName(long groupIndex)
long activeGroupIdx = activeGroupIndex(groupIndex);
if (activeGroupIdx < theGroupNames.size())
- return Q3DStudio::CString(theGroupNames[activeGroupIdx].wide_str()).toQString();
+ return QString::fromWCharArray(theGroupNames[activeGroupIdx].wide_str());
return QObject::tr("Basic Properties");
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.h
index 0da2916d..56529c5d 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectable.h
@@ -41,6 +41,7 @@ class Qt3DSDMInspectable : public CInspectableBase
public:
Qt3DSDMInspectable(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3dsdm::Qt3DSDMInstanceHandle activeSlideInstance = 0);
+ ~Qt3DSDMInspectable();
Q3DStudio::CString getName() override;
long getGroupCount() const override;
@@ -59,6 +60,8 @@ protected:
virtual QString GetGroupName(long inGroupIndex);
CDoc *getDoc() const;
long activeGroupIndex(long groupIndex) const;
+
+ QHash<int, CInspectorGroup *> m_groups;
};
#endif
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp
index f62812ac..c3f435f1 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.cpp
@@ -29,7 +29,6 @@
#include "Qt3DSDMInspectorGroup.h"
#include "Qt3DSDMInspectorRow.h"
-#include "Qt3DSDMInspectable.h"
#include "Qt3DSDMMetaData.h"
Qt3DSDMInspectorGroup::Qt3DSDMInspectorGroup(const QString &inName)
@@ -39,11 +38,12 @@ Qt3DSDMInspectorGroup::Qt3DSDMInspectorGroup(const QString &inName)
Qt3DSDMInspectorGroup::~Qt3DSDMInspectorGroup()
{
- for (auto it = m_inspectorRows.begin(); it != m_inspectorRows.end(); ++it)
- delete (*it);
+ for (auto row : m_inspectorRows)
+ delete row;
+
+ m_inspectorRows.clear();
}
-// Create a new InspectorRowBase.
void Qt3DSDMInspectorGroup::CreateRow(CDoc *inDoc,
qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty)
{
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.h b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.h
index c2bbc9fc..146d6363 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/Qt3DSDMInspectorGroup.h
@@ -49,8 +49,9 @@ public:
void CreateRow(CDoc *inDoc, qt3dsdm::Qt3DSDMMetaDataPropertyHandle inProperty);
const std::vector<Q3DStudio::Qt3DSDMInspectorRow *> &GetRows() const { return m_inspectorRows; }
+ bool isMaterial() const { return m_name == QLatin1String("Material"); }
-protected:
+private:
std::vector<Q3DStudio::Qt3DSDMInspectorRow *> m_inspectorRows;
};
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/TextureChooserView.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/TextureChooserView.cpp
index 8804e675..8b20b950 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/TextureChooserView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/TextureChooserView.cpp
@@ -91,8 +91,20 @@ QString TextureChooserView::currentDataModelPath() const
qt3dsdm::SValue value;
propertySystem->GetInstancePropertyValue(m_instance, m_handle, value);
-
- const QString path = qt3dsdm::get<QString>(value);
+ QString path;
+ if (value.getType() == qt3dsdm::DataModelDataType::Long4) {
+ qt3dsdm::Option<qt3dsdm::SLong4> guid = qt3dsdm::get<qt3dsdm::SLong4>(value);
+ qt3dsdm::Qt3DSDMInstanceHandle imageInstance = doc->GetDocumentReader()
+ .GetInstanceForGuid(guid);
+ if (imageInstance.Valid()) {
+ Q3DStudio::CFilePath relPath(doc->GetDocumentReader().GetSourcePath(imageInstance));
+ path = relPath.GetFileName().toQString();
+ } else {
+ path = QString();
+ }
+ } else {
+ path = qt3dsdm::get<QString>(value);
+ }
// An empty value can sometimes be represented by a relative path either to project root or the
// presentation file, such as"./" or "../", so let's just consider all directory paths as empty
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/VariantsGroupModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/VariantsGroupModel.cpp
index 066f912a..0142b668 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/VariantsGroupModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/VariantsGroupModel.cpp
@@ -152,7 +152,7 @@ void VariantsGroupModel::setTagState(const QString &group, const QString &tag, b
}
}
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), QObject::tr("Set Property"))
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), tr("Set Tag State"))
->SetInstancePropertyValue(m_instance, m_property, QVariant(val));
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/PaletteManager.cpp b/src/Authoring/Qt3DStudio/Palettes/PaletteManager.cpp
index f83a5df6..e30512e9 100644
--- a/src/Authoring/Qt3DStudio/Palettes/PaletteManager.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/PaletteManager.cpp
@@ -158,6 +158,7 @@ CPaletteManager::CPaletteManager(CMainFrame *inMainFrame, QObject *parent)
QSize(defaultRightDockWidth, inMainFrame->height() - defaultProjectHeight),
m_inspectorDock);
inspectorView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ actionView->setControlView(inspectorView);
m_inspectorDock->setWidget(inspectorView);
inMainFrame->addDockWidget(Qt::RightDockWidgetArea, m_inspectorDock);
inMainFrame->tabifyDockWidget(m_inspectorDock, m_actionDock);
@@ -165,13 +166,7 @@ CPaletteManager::CPaletteManager(CMainFrame *inMainFrame, QObject *parent)
m_inspectorDock->raise();
- m_basicObjectsDock->setEnabled(false);
- m_projectDock->setEnabled(false);
- m_slideDock->setEnabled(false);
- m_actionDock->setEnabled(false);
- m_inspectorDock->setEnabled(false);
- m_timelineDock->setEnabled(false);
- m_cameraDock->setEnabled(false);
+ EnablePalettes(false);
}
//==============================================================================
@@ -281,14 +276,14 @@ ProjectView *CPaletteManager::projectView() const
return m_projectView;
}
-void CPaletteManager::EnablePalettes()
+void CPaletteManager::EnablePalettes(bool enable)
{
- m_basicObjectsDock->setEnabled(true);
- m_projectDock->setEnabled(true);
- m_slideDock->setEnabled(true);
- m_timelineDock->setEnabled(true);
- m_actionDock->setEnabled(true);
- m_inspectorDock->setEnabled(true);
- m_cameraDock->setEnabled(true);
+ m_basicObjectsDock->setEnabled(enable);
+ m_projectDock->setEnabled(enable);
+ m_slideDock->setEnabled(enable);
+ m_timelineDock->setEnabled(enable);
+ m_actionDock->setEnabled(enable);
+ m_inspectorDock->setEnabled(enable);
+ m_cameraDock->setEnabled(enable);
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/PaletteManager.h b/src/Authoring/Qt3DStudio/Palettes/PaletteManager.h
index 0b672216..871af3db 100644
--- a/src/Authoring/Qt3DStudio/Palettes/PaletteManager.h
+++ b/src/Authoring/Qt3DStudio/Palettes/PaletteManager.h
@@ -107,7 +107,7 @@ public:
ProjectView *projectView() const;
// Commands
- void EnablePalettes();
+ void EnablePalettes(bool enable = true);
};
#endif // INCLUDED_VIEW_MANAGER_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.cpp b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.cpp
index 5c985359..4d61f886 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.cpp
@@ -103,7 +103,7 @@ ProjectContextMenu::ProjectContextMenu(ProjectView *parent, int index)
openFileAction->setText(tr("Edit"));
action = new QAction(tr("Duplicate"));
- connect(action, &QAction::triggered, this, &ProjectContextMenu::handleDuplicate);
+ connect(action, &QAction::triggered, this, &ProjectContextMenu::handleDuplicateMaterial);
addAction(action);
}
@@ -200,9 +200,9 @@ void ProjectContextMenu::handleAddMaterial()
m_view->addMaterial(m_index);
}
-void ProjectContextMenu::handleDuplicate()
+void ProjectContextMenu::handleDuplicateMaterial()
{
- m_view->duplicate(m_index);
+ m_view->duplicateMaterial(m_index);
}
void ProjectContextMenu::handleDuplicatePresentation()
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.h b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.h
index 12cd2367..a89206fe 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectContextMenu.h
@@ -50,7 +50,7 @@ private Q_SLOTS:
void handleRefreshImport();
void handleImportAssets();
void handleAddMaterial();
- void handleDuplicate();
+ void handleDuplicateMaterial();
void handleDuplicatePresentation();
void handleInitialPresentation();
void handleRenamePresentation();
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp
index 4f62cd59..9d608276 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.cpp
@@ -34,6 +34,9 @@
#include "ProjectFileSystemModel.h"
#include "StudioUtils.h"
#include "StudioApp.h"
+#include "MainFrm.h"
+#include "InspectorControlView.h"
+#include "VariantsGroupModel.h"
#include "ClientDataModelBridge.h"
#include "Core.h"
#include "Doc.h"
@@ -47,6 +50,7 @@
#include "IDragable.h"
#include "IObjectReferenceHelper.h"
#include "IDirectoryWatchingSystem.h"
+#include "IStudioRenderer.h"
ProjectFileSystemModel::ProjectFileSystemModel(QObject *parent) : QAbstractListModel(parent)
, m_model(new QFileSystemModel(this))
@@ -62,8 +66,15 @@ ProjectFileSystemModel::ProjectFileSystemModel(QObject *parent) : QAbstractListM
m_projectReferencesUpdateTimer.setSingleShot(true);
m_projectReferencesUpdateTimer.setInterval(0);
+ m_shaderCheckTimer.setSingleShot(true);
+ m_shaderCheckTimer.setInterval(3000);
+
connect(&m_projectReferencesUpdateTimer, &QTimer::timeout,
this, &ProjectFileSystemModel::updateProjectReferences);
+ connect(&m_shaderCheckTimer, &QTimer::timeout, [&](){
+ checkShaders();
+ updateRoles({IsProjectReferencedRole, HasWarningRole, ExtraIconRole});
+ });
}
QHash<int, QByteArray> ProjectFileSystemModel::roleNames() const
@@ -77,6 +88,7 @@ QHash<int, QByteArray> ProjectFileSystemModel::roleNames() const
modelRoleNames.insert(ExpandedRole, "_expanded");
modelRoleNames.insert(FileIdRole, "_fileId");
modelRoleNames.insert(ExtraIconRole, "_extraIcon");
+ modelRoleNames.insert(HasWarningRole, "_hasWarning");
return modelRoleNames;
}
@@ -96,11 +108,10 @@ QVariant ProjectFileSystemModel::data(const QModelIndex &index, int role) const
}
case IsExpandableRole: {
- if (item.index == m_rootIndex) {
+ if (item.index == m_rootIndex)
return false;
- } else {
- return hasVisibleChildren(item.index);
- }
+
+ return hasVisibleChildren(item.index);
}
case IsDraggableRole:
@@ -124,24 +135,25 @@ QVariant ProjectFileSystemModel::data(const QModelIndex &index, int role) const
case FileIdRole: {
const QString path = item.index.data(QFileSystemModel::FilePathRole).toString();
- EStudioObjectType iconType = getIconType(path);
- if (iconType == OBJTYPE_PRESENTATION || iconType == OBJTYPE_QML_STREAM)
+ if (getIconType(path) & (OBJTYPE_PRESENTATION | OBJTYPE_QML_STREAM))
return presentationId(path);
- else
- return {};
+
+ return {};
}
case ExtraIconRole: {
const QString path = item.index.data(QFileSystemModel::FilePathRole).toString();
- EStudioObjectType iconType = getIconType(path);
- if (iconType == OBJTYPE_PRESENTATION || iconType == OBJTYPE_QML_STREAM) {
+ if (getIconType(path) & (OBJTYPE_PRESENTATION | OBJTYPE_QML_STREAM)) {
if (presentationId(path).isEmpty())
return QStringLiteral("warning.png");
- else
- return {};
- } else {
- return {};
+ } else if (!item.error.isEmpty()) {
+ return QStringLiteral("warning.png");
}
+ return {};
+ }
+
+ case HasWarningRole: {
+ return !item.error.isEmpty();
}
default:
@@ -171,10 +183,18 @@ bool ProjectFileSystemModel::isRefreshable(int row) const
return path.endsWith(QLatin1String(".import"));
}
+bool ProjectFileSystemModel::isCollapsable(int row) const
+{
+ auto &item = m_items[row];
+ return item.expanded;
+}
+
void ProjectFileSystemModel::updateReferences()
{
m_references.clear();
const auto doc = g_StudioApp.GetCore()->GetDoc();
+ if (!doc->isValid())
+ return;
const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
const auto sourcePathList = bridge->GetSourcePathList();
const auto fontFileList = bridge->GetFontFileList();
@@ -209,8 +229,38 @@ void ProjectFileSystemModel::updateReferences()
std::for_each(renderableList.begin(), renderableList.end(), addReferencesRenderable);
m_references.insert(projectPath);
+ updateRoles({IsReferencedRole, Qt::DecorationRole, HasWarningRole, ExtraIconRole});
+}
+
+void ProjectFileSystemModel::showItemError(const QModelIndex index)
+{
+ const auto &item = m_items.at(index.row());
+ // Currently we only show shader compilation errors.
+ g_StudioApp.showShaderCompileError(item.error);
+}
- updateRoles({IsReferencedRole, Qt::DecorationRole});
+void ProjectFileSystemModel::checkShaders(const int startRow, const int endRow)
+{
+ auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
+ qt3dsdm::TInstanceHandleList theShaderInstances(bridge->GetShaderInstances());
+
+ for (const auto &instance : theShaderInstances) {
+ auto sourcepath = bridge->GetSourcePath(instance);
+ const QString relativePath = g_StudioApp.GetCore()->GetDoc()
+ ->GetResolvedPathToDoc(sourcepath);
+ auto currRow = rowForPath(relativePath);
+
+ if (currRow >= startRow && startRow == -1 && currRow <= endRow)
+ continue;
+
+ QString err;
+ auto res = g_StudioApp.getRenderer().getObjectError(instance, err);
+
+ if (!err.isEmpty() && currRow != -1)
+ m_items[currRow].error = bridge->GetSourcePath(instance) + QStringLiteral("\n\n") + err;
+ else if (currRow != -1 && res)
+ m_items[currRow].error = QString();
+ }
}
/**
@@ -371,7 +421,7 @@ void ProjectFileSystemModel::updateProjectReferences()
}
m_projectReferencesUpdateMap.clear();
- updateRoles({IsProjectReferencedRole});
+ updateRoles({IsProjectReferencedRole, HasWarningRole, ExtraIconRole});
}
void ProjectFileSystemModel::getQmlAssets(const QObject *qmlNode,
@@ -495,6 +545,12 @@ void ProjectFileSystemModel::setRootPath(const QString &path)
});
}
+// set a file to be selected upon next layout change (used to auto select newly created files)
+void ProjectFileSystemModel::selectFile(const QString &path)
+{
+ m_selectFile = path;
+}
+
void ProjectFileSystemModel::setRootIndex(const QModelIndex &rootIndex)
{
if (rootIndex == m_rootIndex)
@@ -505,7 +561,7 @@ void ProjectFileSystemModel::setRootIndex(const QModelIndex &rootIndex)
m_rootIndex = rootIndex;
beginInsertRows({}, 0, 0);
- m_items.append({ m_rootIndex, 0, true, nullptr, 0 });
+ m_items.append({m_rootIndex, 0, true, nullptr, 0});
endInsertRows();
showModelTopLevelItems();
@@ -558,13 +614,16 @@ void ProjectFileSystemModel::showModelChildItems(const QModelIndex &parentIndex,
beginInsertRows({}, startRow, startRow + insertCount - 1);
for (auto it = rowsToInsert.rbegin(); it != rowsToInsert.rend(); ++it)
- m_items.insert(startRow, { *it, depth, false, parent, 0 });
+ m_items.insert(startRow, {*it, depth, false, parent, 0});
for (; parent != nullptr; parent = parent->parent)
parent->childCount += insertCount;
endInsertRows();
+ checkShaders(startRow, startRow + insertCount - 1);
+ updateRoles({HasWarningRole, ExtraIconRole});
+
// also fetch children so we're notified when files are added or removed in immediate subdirs
for (const auto &childIndex : rowsToInsert) {
if (m_model->hasChildren(childIndex) && m_model->canFetchMore(childIndex))
@@ -614,65 +673,6 @@ bool ProjectFileSystemModel::hasValidUrlsForDropping(const QList<QUrl> &urls) co
return false;
}
-void ProjectFileSystemModel::showInfo(int row)
-{
- if (row < 0 || row >= m_items.size())
- row = 0;
-
- const TreeItem &item = m_items.at(row);
- QString path = item.index.data(QFileSystemModel::FilePathRole).toString();
-
- QFileInfo fi(path);
-
- if (fi.suffix() == QLatin1String("materialdef")) {
- const auto doc = g_StudioApp.GetCore()->GetDoc();
- bool isDocModified = doc->isModified();
- { // Scope for the ScopedDocumentEditor
- Q3DStudio::ScopedDocumentEditor sceneEditor(
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QString()));
- const auto material = sceneEditor->getOrCreateMaterial(path);
- QString name;
- QMap<QString, QString> values;
- QMap<QString, QMap<QString, QString>> textureValues;
- sceneEditor->getMaterialInfo(fi.absoluteFilePath(), name, values, textureValues);
- sceneEditor->setMaterialValues(fi.absoluteFilePath(), values, textureValues);
- if (material.Valid())
- doc->SelectDataModelObject(material);
- }
- // Several aspects of the editor are not updated correctly
- // if the data core is changed without a transaction
- // The above scope completes the transaction for creating a new material
- // Next the added undo has to be popped from the stack
- // and the modified flag has to be restored
- // TODO: Find a way to update the editor fully without a transaction
- doc->SetModifiedFlag(isDocModified);
- g_StudioApp.GetCore()->GetCmdStack()->RemoveLastUndo();
- }
-}
-
-void ProjectFileSystemModel::duplicate(int row)
-{
- if (row < 0 || row >= m_items.size())
- row = 0;
-
- const TreeItem &item = m_items.at(row);
- QString path = item.index.data(QFileSystemModel::FilePathRole).toString();
-
- QFileInfo srcFile(path);
- const QString destPathStart = srcFile.dir().absolutePath() + QLatin1Char('/')
- + srcFile.completeBaseName() + QStringLiteral(" Copy");
- const QString destPathEnd = QStringLiteral(".") + srcFile.suffix();
- QString destPath = destPathStart + destPathEnd;
-
- int i = 1;
- while (QFile::exists(destPath)) {
- i++;
- destPath = destPathStart + QString::number(i) + destPathEnd;
- }
-
- QFile::copy(path, destPath);
-}
-
void ProjectFileSystemModel::importUrls(const QList<QUrl> &urls, int row, bool autoSort)
{
if (row < 0 || row >= m_items.size())
@@ -723,6 +723,9 @@ void ProjectFileSystemModel::importUrls(const QList<QUrl> &urls, int row, bool a
// Batch update all imported presentation nodes
g_StudioApp.GetCore()->getProjectFile().addPresentationNodes(presentationNodes);
+ checkShaders(row, row);
+ updateRoles({HasWarningRole, ExtraIconRole});
+
// Add new data inputs that are missing from project's data inputs. Duplicates are ignored,
// even if they are different type.
QMapIterator<QString, CDataInputDialogItem *> diIt(importedDataInputs);
@@ -738,7 +741,7 @@ void ProjectFileSystemModel::importUrls(const QList<QUrl> &urls, int row, bool a
}
if (addedDi) {
g_StudioApp.saveDataInputsToProjectFile();
- g_StudioApp.checkDeletedDatainputs(); // Updates externalPresBoundTypes
+ g_StudioApp.checkDeletedDatainputs(true); // Updates externalPresBoundTypes
}
for (const QString &expandPath : qAsConst(expandPaths)) {
@@ -746,6 +749,9 @@ void ProjectFileSystemModel::importUrls(const QList<QUrl> &urls, int row, bool a
if (expandRow >= 0 && !m_items[expandRow].expanded)
expand(expandRow);
}
+
+ // Refresh the variants model of inspector in case variants were imported
+ g_StudioApp.m_pMainWnd->getInspectorView()->variantsModel()->refresh();
}
/**
@@ -859,6 +865,8 @@ void ProjectFileSystemModel::importUrl(QDir &targetDir, const QUrl &url,
if (allDataInputs.contains(di))
outDataInputs.insert(di, allDataInputs[di]);
}
+ // Merge variant groups and tags from imported presentation's project
+ doc->GetCore()->getProjectFile().loadVariants(projFile);
} else if (qmlRoot && isQmlStream) { // importing a qml stream
presentationPath = doc->GetCore()->getProjectFile().getRelativeFilePathTo(destPath);
importQmlAssets(qmlRoot, fileInfo.dir(), targetDir, outImportedFiles,
@@ -1054,11 +1062,8 @@ void ProjectFileSystemModel::collapse(int row)
int ProjectFileSystemModel::modelIndexRow(const QModelIndex &modelIndex) const
{
- auto it = std::find_if(
- std::begin(m_items),
- std::end(m_items),
- [&modelIndex](const TreeItem &item)
- {
+ auto it = std::find_if(std::begin(m_items), std::end(m_items),
+ [&modelIndex](const TreeItem &item) {
return item.index == modelIndex;
});
@@ -1204,7 +1209,7 @@ void ProjectFileSystemModel::modelLayoutChanged()
return;
QSet<QPersistentModelIndex> expandedItems;
- for (const auto &item : m_items) {
+ for (const auto &item : qAsConst(m_items)) {
if (item.expanded)
expandedItems.insert(item.index);
}
@@ -1222,7 +1227,8 @@ void ProjectFileSystemModel::modelLayoutChanged()
const auto &childIndex = m_model->index(i, 0, parentIndex);
if (isVisible(childIndex)) {
const bool expanded = expandedItems.contains(childIndex);
- m_items.append({ childIndex, depth, expanded, parent, 0 });
+ m_items.append({childIndex, depth, expanded, parent, 0});
+
auto &item = m_items.last();
if (expanded) {
item.childCount = insertChildren(childIndex, &item);
@@ -1244,6 +1250,14 @@ void ProjectFileSystemModel::modelLayoutChanged()
Q_ASSERT(m_items.count() == itemCount);
Q_EMIT dataChanged(index(0), index(itemCount - 1));
+
+ // select m_selectFile (used for auto selecting newly created files)
+ if (!m_selectFile.isEmpty()) {
+ int row = rowForPath(m_selectFile);
+ if (row != -1)
+ Q_EMIT selectFileChanged(row);
+ m_selectFile.clear();
+ }
}
void ProjectFileSystemModel::updateDefaultDirMap()
@@ -1342,6 +1356,7 @@ void ProjectFileSystemModel::onFilesChanged(
m_projectReferencesUpdateMap.insert(filePath, false);
}
m_projectReferencesUpdateTimer.start();
+ m_shaderCheckTimer.start();
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h
index 8e9cefb8..8fb63805 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectFileSystemModel.h
@@ -59,10 +59,12 @@ public:
DepthRole,
ExpandedRole,
FileIdRole,
- ExtraIconRole
+ ExtraIconRole,
+ HasWarningRole
};
void setRootPath(const QString &path);
+ void selectFile(const QString &path);
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = {}) const override;
@@ -71,6 +73,7 @@ public:
QString filePath(int row) const;
bool isRefreshable(int row) const;
+ bool isCollapsable(int row) const;
bool isCurrentPresentation(const QString &path) const;
bool isInitialPresentation(const QString &path) const;
QString presentationId(const QString &path) const;
@@ -84,18 +87,19 @@ public:
Q_INVOKABLE void importUrls(const QList<QUrl> &urls, int row, bool autoSort = true);
Q_INVOKABLE bool hasValidUrlsForDropping(const QList<QUrl> &urls) const;
- Q_INVOKABLE void showInfo(int row);
- Q_INVOKABLE void duplicate(int row);
void asyncUpdateReferences();
void onFilesChanged(const Q3DStudio::TFileModificationList &inFileModificationList);
+ void clearModelData();
+ void checkShaders(const int startRow = -1, const int endRow = -1);
+ void showItemError(const QModelIndex index);
Q_SIGNALS:
void modelChanged(QAbstractItemModel *model);
+ void selectFileChanged(int idx);
private:
void setRootIndex(const QModelIndex &rootIndex);
- void clearModelData();
void showModelTopLevelItems();
void showModelChildItems(const QModelIndex &parentItem, int start, int end);
int modelIndexRow(const QModelIndex &modelIndex) const;
@@ -140,6 +144,7 @@ private:
bool expanded;
TreeItem *parent;
int childCount;
+ QString error;
};
QFileSystemModel *m_model = nullptr;
@@ -160,7 +165,9 @@ private:
// Value: if true, uip was modified or created. If false, it was removed.
QHash<QString, bool> m_projectReferencesUpdateMap;
QTimer m_projectReferencesUpdateTimer;
+ QTimer m_shaderCheckTimer;
std::shared_ptr<qt3dsdm::ISignalConnection> m_directoryConnection;
+ QString m_selectFile; // file to be selected on next layout change
};
#endif // TREEVIEWADAPTOR_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.cpp b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.cpp
index dadb5895..203952bc 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.cpp
@@ -214,6 +214,12 @@ void ProjectView::OnNewPresentation()
rebuild();
}
+void ProjectView::OnClosingPresentation()
+{
+ // Clear project view when closing presentation
+ m_ProjectModel->clearModelData();
+}
+
void ProjectView::OnOpenDocument(const QString &inFilename, bool inSucceeded)
{
Q_UNUSED(inFilename)
@@ -260,6 +266,22 @@ void ProjectView::mousePressEvent(QMouseEvent *event)
QQuickWidget::mousePressEvent(event);
}
+void ProjectView::keyReleaseEvent(QKeyEvent *event)
+{
+ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
+ if (m_selected >= 0) {
+ auto key = ke->key();
+ if (key == Qt::Key_Delete)
+ deleteFile(m_selected);
+ else if (key == Qt::Key_Right)
+ m_ProjectModel->expand(m_selected);
+ else if (key == Qt::Key_Left && m_ProjectModel->isCollapsable(m_selected))
+ m_ProjectModel->collapse(m_selected);
+ } else {
+ QQuickWidget::keyReleaseEvent(event);
+ }
+}
+
void ProjectView::startDrag(QQuickItem *item, int row)
{
item->grabMouse(); // Grab to make sure we can ungrab after the drag
@@ -296,6 +318,11 @@ void ProjectView::editPresentationId(int row, bool qmlStream)
dlg.exec();
}
+void ProjectView::showSpecificShaderError(const int row)
+{
+ m_ProjectModel->showItemError(m_ProjectModel->index(row));
+}
+
void ProjectView::renamePresentation(int row, bool qmlStream)
{
QString relativePresPath = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath())
@@ -421,7 +448,7 @@ void ProjectView::showContextMenu(int x, int y, int index)
bool ProjectView::toolTipsEnabled()
{
- return CStudioPreferences::ShouldShowTooltips();
+ return CStudioPreferences::isTooltipsOn();
}
void ProjectView::openFile(int row)
@@ -447,6 +474,11 @@ void ProjectView::openFile(int row)
});
}
+void ProjectView::setSelected(int row)
+{
+ m_selected = row;
+}
+
void ProjectView::refreshImport(int row) const
{
if (row == -1)
@@ -462,9 +494,15 @@ void ProjectView::refreshImport(int row) const
const QFileInfo newFile(g_StudioApp.GetDialogs()->ConfirmRefreshModelFile(fullSrcPath));
if (newFile.exists() && newFile.isFile()) {
// We don't want to create undo point of "Refresh Import", undoing this sort of
- // thing is supposed to be done in the DCC tool.
- g_StudioApp.GetCore()->GetDoc()->getSceneEditor()->RefreshImport(
- oldFile.canonicalFilePath(), newFile.canonicalFilePath());
+ // thing is supposed to be done in the DCC tool. However, we do want to do the
+ // refresh inside a transaction to make sure signaling works correctly.
+ SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), QObject::tr("Refresh Import"))
+ ->RefreshImport(oldFile.canonicalFilePath(), newFile.canonicalFilePath(), path);
+ // Clear undo/redo stack to ensure stack is not corrupted
+ // after refresh (stack may contain additions/deletions with chosen import,
+ // in which case undoing/redoing those actions can result in crashes or wrong meshes)
+ g_StudioApp.GetCore()->GetCmdStack()->Clear();
+ g_StudioApp.GetCore()->GetDoc()->SetModifiedFlag(true);
}
}
}
@@ -483,23 +521,70 @@ void ProjectView::addMaterial(int row) const
QFile file(path + extension);
int i = 1;
- while (file.exists()) {
- i++;
- file.setFileName(path + QString::number(i) + extension);
- }
+ while (file.exists())
+ file.setFileName(path + QString::number(i++) + extension);
file.open(QIODevice::WriteOnly);
file.write("<MaterialData version=\"1.0\">\n</MaterialData>");
+
+ m_ProjectModel->selectFile(file.fileName()); // select the added material
}
+// show material properties in the inspector
void ProjectView::editMaterial(int row) const
{
- m_ProjectModel->showInfo(row);
-}
+ QString path = m_ProjectModel->filePath(row);
+ QFileInfo fi(path);
-void ProjectView::duplicate(int row) const
-{
- m_ProjectModel->duplicate(row);
+ const auto doc = g_StudioApp.GetCore()->GetDoc();
+ bool isDocModified = doc->isModified();
+ { // Scope for the ScopedDocumentEditor
+ Q3DStudio::ScopedDocumentEditor sceneEditor(
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QString()));
+ const auto material = sceneEditor->getOrCreateMaterial(path);
+ QString name;
+ QMap<QString, QString> values;
+ QMap<QString, QMap<QString, QString>> textureValues;
+ sceneEditor->getMaterialInfo(fi.absoluteFilePath(), name, values, textureValues);
+ sceneEditor->setMaterialValues(fi.absoluteFilePath(), values, textureValues);
+ if (material.Valid())
+ doc->SelectDataModelObject(material);
+ }
+ // Several aspects of the editor are not updated correctly if the data core is changed without
+ // a transaction. The above scope completes the transaction for creating a new material. Next
+ // the added undo has to be popped from the stack and the modified flag has to be restored
+ // TODO: Find a way to update the editor fully without a transaction
+ doc->SetModifiedFlag(isDocModified);
+ g_StudioApp.GetCore()->GetCmdStack()->RemoveLastUndo();
+}
+
+void ProjectView::duplicateMaterial(int row)
+{
+ QString pathSrc = m_ProjectModel->filePath(row);
+ QString pathDest = pathSrc;
+ QRegExp rgxCopy(QLatin1String("Copy\\d*"));
+
+ do {
+ int copyIdx = rgxCopy.lastIndexIn(pathDest);
+ if (copyIdx != -1) { // src mat. name ends in Copy (+ a number >= 0)
+ QString copy = rgxCopy.cap();
+ int n = copy.length();
+ if (n > 4) { // name ends with a number, increment it
+ QString oldNumber = copy.mid(4);
+ QString newNumber = QString::number(oldNumber.toInt() + 1);
+ copy.replace(oldNumber, newNumber);
+ } else { // name ends with Copy, make it Copy2
+ copy += '2';
+ }
+
+ pathDest.replace(copyIdx, n, copy);
+ } else { // name doesn't end with Copy, add it
+ pathDest.replace(QLatin1String(".materialdef"), QLatin1String(" Copy.materialdef"));
+ }
+ } while (QFile::exists(pathDest));
+
+ m_ProjectModel->selectFile(pathDest); // select the duplicated material
+ QFile::copy(pathSrc, pathDest);
}
void ProjectView::duplicatePresentation(int row) const
@@ -530,5 +615,6 @@ void ProjectView::deleteFile(int row) const
void ProjectView::rebuild()
{
+ m_selected = -1;
m_ProjectModel->setRootPath(g_StudioApp.GetCore()->getProjectFile().getProjectPath());
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.h b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.h
index 7533e677..217aff1c 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.h
@@ -71,6 +71,7 @@ public:
Q_INVOKABLE void showContextMenu(int x, int y, int index);
Q_INVOKABLE bool toolTipsEnabled();
Q_INVOKABLE void openFile(int row);
+ Q_INVOKABLE void setSelected(int row);
void showContainingFolder(int row) const;
void copyPath(int row) const;
@@ -78,7 +79,7 @@ public:
void refreshImport(int row) const;
void addMaterial(int row) const;
void editMaterial(int row) const;
- void duplicate(int row) const;
+ void duplicateMaterial(int row);
void duplicatePresentation(int row) const;
void deleteFile(int row) const;
@@ -86,6 +87,7 @@ public:
Q_INVOKABLE bool isPresentation(int row) const;
Q_INVOKABLE bool isQmlStream(int row) const;
+
bool isCurrentPresentation(int row) const;
bool isMaterialFolder(int row) const;
bool isInMaterialFolder(int row) const;
@@ -96,10 +98,12 @@ public:
QString presentationId(int row) const;
void setInitialPresentation(int row);
Q_INVOKABLE void editPresentationId(int row, bool qmlStream);
+ Q_INVOKABLE void showSpecificShaderError(const int row);
void renamePresentation(int row, bool qmlStream);
// CPresentationChangeListener
void OnNewPresentation() override;
+ void OnClosingPresentation() override;
// CFileOpenListener
void OnOpenDocument(const QString &inFilename, bool inSucceeded) override;
void OnSaveDocument(const QString &inFilename, bool inSucceeded, bool inSaveCopy) override;
@@ -119,6 +123,7 @@ Q_SIGNALS:
protected:
void mousePressEvent(QMouseEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
private:
void initialize();
@@ -144,6 +149,7 @@ private:
QString m_qmlStreamDir;
QString m_assetImportDir;
QSize m_preferredSize;
+ int m_selected = -1;
};
#endif // PROJECTVIEW_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.qml b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.qml
index 043d9ba2..c72be3cc 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Project/ProjectView.qml
@@ -33,9 +33,15 @@ import "../controls"
Rectangle {
id: root
-
color: _backgroundColor
+ Connections {
+ target: _parentView.projectModel
+ onSelectFileChanged: {
+ projectTree.currentIndex = idx; // auto select a newly created file
+ }
+ }
+
ColumnLayout {
anchors.fill: parent
spacing: 4
@@ -57,8 +63,10 @@ Rectangle {
anchors.fill: parent
clip: true
+ focus: true
ScrollBar.vertical: ScrollBar {}
+ keyNavigationEnabled: true
model: _parentView.projectModel
@@ -66,6 +74,7 @@ Rectangle {
// Try to keep something selected always
if ((currentIndex < 0 || currentIndex >= count) && count > 0)
currentIndex = 0;
+ _parentView.setSelected(currentIndex);
}
delegate: Rectangle {
@@ -73,12 +82,13 @@ Rectangle {
property bool dragging: false
property bool dragStarted: false
property point pressPoint
- width: parent.width
+ width: projectTree.width
height: 20
color: (index == projectTree.currentIndex || dragging) ? _selectionColor
: "transparent"
function handlePress(mouse, tryDrag) {
projectTree.currentIndex = model.index;
+ _parentView.setSelected(model.index);
if (mouse.button === Qt.LeftButton && tryDrag && _isDraggable) {
pressPoint = Qt.point(mouse.x, mouse.y);
@@ -96,6 +106,7 @@ Rectangle {
}
function handleClick(mouse) {
+ _parentView.setSelected(projectTree.currentIndex)
if (mouse.button === Qt.RightButton) {
var rootPoint = mapToItem(root, mouse.x, mouse.y);
_parentView.showContextMenu(rootPoint.x, rootPoint.y,
@@ -139,6 +150,7 @@ Rectangle {
acceptedButtons: Qt.LeftButton
onPressed: delegateItem.handlePress(mouse, false)
onClicked: {
+ _parentView.setSelected(index);
if (_expanded)
projectTree.model.collapse(index)
else
@@ -165,9 +177,11 @@ Rectangle {
id: fileNameLabel
text: _fileId ? fileName + " <" + _fileId + ">" : fileName;
color: {
- _isReferenced ? _textColor
- : _isProjectReferenced ? _projectReferencedColor
- : _disabledColor
+ _hasWarning ? _invalidDataIndicatorColor :
+ _isReferenced ? _textColor :
+ _isProjectReferenced ?
+ _projectReferencedColor
+ : _disabledColor
}
leftPadding: 2
@@ -199,13 +213,16 @@ Rectangle {
hoverEnabled: true
onPressed: delegateItem.handlePress(mouse, false)
onClicked: delegateItem.handleClick(mouse)
- onDoubleClicked: _parentView.editPresentationId(
- index, _parentView.isQmlStream(index))
+ onDoubleClicked:
+ _hasWarning ? _parentView.showSpecificShaderError(index)
+ : _parentView.editPresentationId(
+ index, _parentView.isQmlStream(index))
}
StyledTooltip {
- text: _parentView.isPresentation(index)
- ? qsTr("No presentation Id")
- : qsTr("No Qml stream Id")
+ text: _hasWarning ? qsTr("Shader error")
+ : _parentView.isPresentation(index)
+ ? qsTr("No presentation Id")
+ : qsTr("No Qml stream Id")
enabled: warningMouseArea.containsMouse
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.cpp b/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.cpp
index c49f34d2..5106401c 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.cpp
@@ -133,7 +133,7 @@ void SlideView::showControllerDialog(const QPoint &point)
bool SlideView::toolTipsEnabled()
{
- return CStudioPreferences::ShouldShowTooltips();
+ return CStudioPreferences::isTooltipsOn();
}
QSize SlideView::sizeHint() const
@@ -424,6 +424,8 @@ void SlideView::onDockLocationChange(Qt::DockWidgetArea area)
void SlideView::updateDataInputStatus()
{
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ if (!doc->isValid())
+ return;
CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
qt3dsdm::Qt3DSDMInstanceHandle slideRoot = doc->GetActiveRootInstance();
diff --git a/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.qml b/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.qml
index 7100ed8a..c3393702 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/Slide/SlideView.qml
@@ -198,9 +198,8 @@ Rectangle {
property int dragIndex
property bool held : false
- anchors.horizontalCenter: parent.horizontalCenter
height: delegateItem.height
- width: parent.width
+ width: slideList.width
acceptedButtons: Qt.RightButton | Qt.LeftButton
drag.target: held ? delegateItem : null
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp
index b135e2c0..53a5cb08 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp
@@ -84,7 +84,7 @@ void CEmptyTimelineTimebar::RollbackTimeChange()
::CColor CEmptyTimelineTimebar::GetTimebarColor()
{
- return CStudioPreferences::GetObjectTimebarColor();
+ return CStudioPreferences::objectTimebarColor();
}
QString CEmptyTimelineTimebar::GetTimebarComment() const
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItem.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItem.h
index 4308fb2b..2c8b6ecc 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItem.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItem.h
@@ -47,6 +47,13 @@ class ITimelineTimebar;
class ITimelineItem : public INamable
{
public:
+ enum class ActivateAction {
+ None = 0,
+ Activate = 1,
+ Deactivate = 2
+ };
+ Q_DECLARE_FLAGS(ActivateActions, ActivateAction)
+
virtual ~ITimelineItem() {}
virtual EStudioObjectType GetObjectType() const = 0;
@@ -65,6 +72,7 @@ public:
virtual bool HasAction(bool inMaster) = 0;
virtual bool ChildrenHasAction(bool inMaster) = 0;
virtual bool ComponentHasAction(bool inMaster) = 0;
+ virtual ActivateActions getActivateActions() = 0;
// subpresentations
virtual bool hasSubpresentation() const = 0;
@@ -72,4 +80,6 @@ public:
virtual ITimelineTimebar *GetTimebar() = 0;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(ITimelineItem::ActivateActions)
+
#endif // INCLUDED_ITIMELINE_ITEM_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItemProperty.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItemProperty.h
index 72488480..c64bb5c7 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItemProperty.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/ITimelineItemProperty.h
@@ -28,12 +28,11 @@
****************************************************************************/
#ifndef INCLUDED_ITIMELINE_ITEM_PROPERTY_H
-#define INCLUDED_ITIMELINE_ITEM_PROPERTY_H 1
-
-#pragma once
+#define INCLUDED_ITIMELINE_ITEM_PROPERTY_H
#include "Qt3DSDMMetaData.h"
#include "Qt3DSString.h"
+#include "Qt3DSDMAnimation.h"
class RowTree;
class IKeyframe;
@@ -51,8 +50,6 @@ public:
virtual Q3DStudio::CString GetName() const = 0;
virtual bool IsMaster() const = 0;
virtual qt3dsdm::TDataTypePair GetType() const = 0;
- virtual float GetMaximumValue() const = 0;
- virtual float GetMinimumValue() const = 0;
virtual void SetSelected() = 0;
virtual void DeleteAllKeys() = 0;
@@ -60,13 +57,16 @@ public:
virtual void setRowTree(RowTree *row) = 0;
virtual RowTree *getRowTree() const = 0;
+ virtual qt3dsdm::Qt3DSDMPropertyHandle getPropertyHandle() const = 0;
+ virtual std::vector<qt3dsdm::Qt3DSDMAnimationHandle> animationHandles() const = 0;
+ virtual qt3dsdm::EAnimationType animationType() const = 0;
+
// Keyframes
virtual IKeyframe *GetKeyframeByTime(long inTime) const = 0;
virtual IKeyframe *GetKeyframeByIndex(long inIndex) const = 0;
virtual long GetKeyframeCount() const = 0;
- virtual long GetChannelCount() const = 0;
- virtual float GetChannelValueAtTime(long inChannelIndex, long inTime) = 0;
- virtual void SetChannelValueAtTime(long inChannelIndex, long inTime, float inValue) = 0;
+ virtual size_t GetChannelCount() const = 0;
+ virtual float GetChannelValueAtTime(size_t chIndex, long time) = 0;
virtual bool IsDynamicAnimation() = 0;
};
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp
index e3483969..283f98e5 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp
@@ -48,8 +48,8 @@
using namespace qt3dsdm;
-CMaterialTimelineItemBinding::CMaterialTimelineItemBinding(CTimelineTranslationManager *inMgr,
- Qt3DSDMInstanceHandle inDataHandle)
+CMaterialEffectTimelineItemBinding::CMaterialEffectTimelineItemBinding(
+ CTimelineTranslationManager *inMgr, Qt3DSDMInstanceHandle inDataHandle)
: Qt3DSDMTimelineItemBinding(inMgr, inDataHandle)
{
qt3dsdm::IPropertySystem *thePropertySystem = m_TransMgr->GetStudioSystem()->GetPropertySystem();
@@ -63,7 +63,8 @@ CMaterialTimelineItemBinding::CMaterialTimelineItemBinding(CTimelineTranslationM
AdditionalMetaDataType::Value theAdditionalMetaDataType =
thePropertySystem->GetAdditionalMetaDataType(inDataHandle, theProperty);
- if (theAdditionalMetaDataType == AdditionalMetaDataType::Image) {
+ if (theAdditionalMetaDataType == AdditionalMetaDataType::Image
+ || theAdditionalMetaDataType == AdditionalMetaDataType::Texture) {
TCharStr theName(thePropertySystem->GetName(theProperty));
TCharStr theFormalName(thePropertySystem->GetFormalName(inDataHandle, theProperty));
TNameFormalNamePair thePair = std::make_tuple(theName, theFormalName);
@@ -72,16 +73,16 @@ CMaterialTimelineItemBinding::CMaterialTimelineItemBinding(CTimelineTranslationM
}
}
-CMaterialTimelineItemBinding::~CMaterialTimelineItemBinding()
+CMaterialEffectTimelineItemBinding::~CMaterialEffectTimelineItemBinding()
{
}
-ITimelineTimebar *CMaterialTimelineItemBinding::GetTimebar()
+ITimelineTimebar *CMaterialEffectTimelineItemBinding::GetTimebar()
{ // No timebars on materials
return new CEmptyTimelineTimebar();
}
-bool CMaterialTimelineItemBinding::ShowToggleControls() const
+bool CMaterialEffectTimelineItemBinding::ShowToggleControls() const
{
// Materials have no toggle controls, by design
return false;
@@ -96,7 +97,7 @@ bool ImageSlotIsFilled(qt3dsdm::IPropertySystem *inPropertySystem, Qt3DSDMInstan
inPropertySystem->GetInstancePropertyValue(inInstance, theProperty, theValue);
// Prevent assertion down the path when changing from edited standard material to reference material
- if (qt3dsdm::GetValueType(theValue) == DataModelDataType::None)
+ if (qt3dsdm::GetValueType(theValue) != DataModelDataType::Long4)
return false;
SLong4 theLong4 = qt3dsdm::get<SLong4>(theValue);
@@ -106,7 +107,7 @@ bool ImageSlotIsFilled(qt3dsdm::IPropertySystem *inPropertySystem, Qt3DSDMInstan
return theReturn;
}
-long CMaterialTimelineItemBinding::GetChildrenCount()
+long CMaterialEffectTimelineItemBinding::GetChildrenCount()
{
long theReturnCount = 0;
if (m_TransMgr->GetStudioSystem()->IsInstance(m_DataHandle)) {
@@ -124,7 +125,7 @@ long CMaterialTimelineItemBinding::GetChildrenCount()
return theReturnCount;
}
-ITimelineItemBinding *CMaterialTimelineItemBinding::GetChild(long inIndex)
+ITimelineItemBinding *CMaterialEffectTimelineItemBinding::GetChild(long inIndex)
{
qt3dsdm::IPropertySystem *thePropertySystem = m_TransMgr->GetStudioSystem()->GetPropertySystem();
@@ -147,7 +148,7 @@ ITimelineItemBinding *CMaterialTimelineItemBinding::GetChild(long inIndex)
theImageProperty, std::get<1>(m_ImageNameFormalNamePairs[theSlotCursor]).wide_str());
}
-QList<ITimelineItemBinding *> CMaterialTimelineItemBinding::GetChildren()
+QList<ITimelineItemBinding *> CMaterialEffectTimelineItemBinding::GetChildren()
{
int childCount = GetChildrenCount();
QList<ITimelineItemBinding *> retlist;
@@ -158,7 +159,7 @@ QList<ITimelineItemBinding *> CMaterialTimelineItemBinding::GetChildren()
return retlist;
}
-void CMaterialTimelineItemBinding::OnAddChild(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
+void CMaterialEffectTimelineItemBinding::OnAddChild(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
using namespace qt3dsdm;
CClientDataModelBridge *theBridge = m_TransMgr->GetStudioSystem()->GetClientDataModelBridge();
@@ -169,18 +170,18 @@ void CMaterialTimelineItemBinding::OnAddChild(qt3dsdm::Qt3DSDMInstanceHandle inI
Qt3DSDMTimelineItemBinding::OnAddChild(inInstance);
}
-void CMaterialTimelineItemBinding::OnPropertyChanged(Qt3DSDMPropertyHandle inPropertyHandle)
+void CMaterialEffectTimelineItemBinding::OnPropertyChanged(Qt3DSDMPropertyHandle inPropertyHandle)
{
Qt3DSDMTimelineItemBinding::OnPropertyChanged(inPropertyHandle);
}
-void CMaterialTimelineItemBinding::OnPropertyLinked(Qt3DSDMPropertyHandle inPropertyHandle)
+void CMaterialEffectTimelineItemBinding::OnPropertyLinked(Qt3DSDMPropertyHandle inPropertyHandle)
{
Qt3DSDMTimelineItemBinding::OnPropertyLinked(inPropertyHandle);
}
qt3dsdm::Qt3DSDMInstanceHandle
-CMaterialTimelineItemBinding::GetImage(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle)
+CMaterialEffectTimelineItemBinding::GetImage(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle)
{
qt3dsdm::IPropertySystem *thePropertySystem = m_TransMgr->GetStudioSystem()->GetPropertySystem();
SValue theImageValue;
@@ -191,8 +192,8 @@ CMaterialTimelineItemBinding::GetImage(qt3dsdm::Qt3DSDMPropertyHandle inProperty
}
ITimelineItemBinding *
-CMaterialTimelineItemBinding::GetOrCreateImageBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle,
- const wchar_t *inName)
+CMaterialEffectTimelineItemBinding::GetOrCreateImageBinding(
+ qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, const wchar_t *inName)
{
qt3dsdm::Qt3DSDMInstanceHandle theImageInstance = GetImage(inPropertyHandle);
ITimelineItemBinding *theImageTimelineRow = m_TransMgr->GetBinding(theImageInstance);
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h
index 8e188a52..0ecbcb54 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h
@@ -47,7 +47,7 @@ class CTimelineTranslationManager;
/**
* Binding to a DataModel object of Material type
*/
-class CMaterialTimelineItemBinding : public Qt3DSDMTimelineItemBinding
+class CMaterialEffectTimelineItemBinding : public Qt3DSDMTimelineItemBinding
{
public: // Types
typedef std::tuple<qt3dsdm::TCharStr, qt3dsdm::TCharStr> TNameFormalNamePair;
@@ -57,9 +57,9 @@ protected: // Members
TNameFormalNamePairList m_ImageNameFormalNamePairs;
public: // Construction
- CMaterialTimelineItemBinding(CTimelineTranslationManager *inMgr,
- qt3dsdm::Qt3DSDMInstanceHandle inDataHandle);
- virtual ~CMaterialTimelineItemBinding();
+ CMaterialEffectTimelineItemBinding(CTimelineTranslationManager *inMgr,
+ qt3dsdm::Qt3DSDMInstanceHandle inDataHandle);
+ virtual ~CMaterialEffectTimelineItemBinding();
public: // Qt3DSDMTimelineItemBinding
ITimelineTimebar *GetTimebar() override;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp
deleted file mode 100644
index a0c4ee99..00000000
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSCommonPrecompile.h"
-#include "OffsetKeyframesCommandHelper.h"
-#include "Core.h"
-
-// Data model specific
-#include "IDoc.h"
-#include "CmdDataModelChangeKeyframe.h"
-#include "IDocumentEditor.h"
-
-#include "Qt3DSDMTimelineKeyframe.h" //TODO: remove once we resolve the precision issue
-
-using namespace qt3dsdm;
-
-COffsetKeyframesCommandHelper::COffsetKeyframesCommandHelper(CDoc &inDoc)
- : Q3DStudio::CUpdateableDocumentEditor(inDoc)
- , m_Doc(inDoc)
-{
-}
-
-COffsetKeyframesCommandHelper::~COffsetKeyframesCommandHelper()
-{
- Finalize();
-}
-
-//@param inTime time in millisecs
-void COffsetKeyframesCommandHelper::SetCommandTime(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe,
- long inTime)
-{
- // The DataModel system will take care of merging these under the hood.
- ENSURE_EDITOR(QObject::tr("Set Keyframe Time")).SetKeyframeTime(inKeyframe, inTime);
-}
-
-// equivalent to commit (onmouseup)
-void COffsetKeyframesCommandHelper::Finalize()
-{
- CommitEditor();
-}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h
index ead15d2e..54695cfe 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h
@@ -28,13 +28,8 @@
****************************************************************************/
#ifndef INCLUDED_PASTE_KEYFRAME_COMMAND_HELPER_H
-#define INCLUDED_PASTE_KEYFRAME_COMMAND_HELPER_H 1
+#define INCLUDED_PASTE_KEYFRAME_COMMAND_HELPER_H
-#pragma once
-
-//==============================================================================
-// Include
-//==============================================================================
#include "CmdDataModelInsertKeyframe.h"
#include "Qt3DSDMPropertyDefinition.h"
#include "Qt3DSDMDataCore.h"
@@ -48,12 +43,12 @@ protected:
typedef std::vector<CCmdDataModelInsertKeyframe::STimeKeyframeData> TCopiedKeyframeList;
TCopiedKeyframeList m_CopiedKeyframeList;
-public: // Construction
+public:
CPasteKeyframeCommandHelper() {}
~CPasteKeyframeCommandHelper() {}
// inTime should be relative to the earliest keyframe time in this list
- void AddKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inKeyframeTime,
+ void AddKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, long inKeyframeTime,
qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount)
{
m_CopiedKeyframeList.push_back(CCmdDataModelInsertKeyframe::STimeKeyframeData(
@@ -71,45 +66,28 @@ public: // Construction
// but that is not an issue in the new data model.
//
// 2. The first pasted keyframe is at current view time and the rest are offset accordingly.
- CCmdDataModelInsertKeyframe *GetCommand(CDoc *inDoc, long inTimeOffsetInMilliseconds,
- qt3dsdm::Qt3DSDMInstanceHandle inTargetInstance)
+ CCmdDataModelInsertKeyframe *GetCommand(CDoc *doc, long timeOffset,
+ qt3dsdm::Qt3DSDMInstanceHandle targetInstance)
{
using namespace qt3dsdm;
- CCmdDataModelInsertKeyframe *theInsertKeyframesCommand = nullptr;
- TCopiedKeyframeList::iterator theIter = m_CopiedKeyframeList.begin();
- qt3dsdm::IPropertySystem *thePropertySystem = inDoc->GetStudioSystem()->GetPropertySystem();
- CClientDataModelBridge *theBridge = inDoc->GetStudioSystem()->GetClientDataModelBridge();
+ CCmdDataModelInsertKeyframe *insertKeyframesCmd = nullptr;
+ CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
- for (; theIter != m_CopiedKeyframeList.end(); ++theIter) {
- TCharStr thePropertyName = thePropertySystem->GetName(theIter->m_Property);
- DataModelDataType::Value thePropertyType =
- thePropertySystem->GetDataType(theIter->m_Property);
- Qt3DSDMPropertyHandle theTargetPropertyHandle =
- theBridge->GetAggregateInstancePropertyByName(inTargetInstance, thePropertyName);
- if (theTargetPropertyHandle.Valid()) // property exists on target
- {
- // sanity check for type match
- DataModelDataType::Value theTargetPropertyType =
- thePropertySystem->GetDataType(theTargetPropertyHandle);
- if (theTargetPropertyType == thePropertyType) {
- // 2. Offset keyframe time by current view time
- double milliseconds = theIter->m_KeyframeTime * 1000.0;
- double theTimeInMilliseconds = milliseconds + inTimeOffsetInMilliseconds;
- float theTimeInSeconds = static_cast<float>(theTimeInMilliseconds / 1000.0);
+ for (auto &kfData : m_CopiedKeyframeList) {
+ // check property exists on target
+ if (bridge->hasAggregateInstanceProperty(targetInstance, kfData.m_Property)) {
+ if (!insertKeyframesCmd)
+ insertKeyframesCmd = new CCmdDataModelInsertKeyframe(doc, targetInstance);
- if (!theInsertKeyframesCommand)
- theInsertKeyframesCommand = new CCmdDataModelInsertKeyframe(
- inDoc, inTargetInstance, theTargetPropertyHandle, theTimeInSeconds,
- theIter->m_Infos, theIter->m_ValidInfoCount);
- else
- theInsertKeyframesCommand->AddKeyframeData(
- theTargetPropertyHandle, theTimeInSeconds, theIter->m_Infos,
- theIter->m_ValidInfoCount);
- }
+ // Offset keyframe time by current view time
+ long time = kfData.m_KeyframeTime + timeOffset;
+ insertKeyframesCmd->AddKeyframeData(kfData.m_Property, time, kfData.m_Infos,
+ kfData.m_ValidInfoCount);
}
}
- return theInsertKeyframesCommand;
+
+ return insertKeyframesCmd;
}
void Clear() { m_CopiedKeyframeList.clear(); }
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp
index f646415d..952c10da 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp
@@ -30,6 +30,7 @@
#include "PathTimelineItemBinding.h"
#include "TimelineTranslationManager.h"
#include "Doc.h"
+#include "IDocumentEditor.h"
bool CPathTimelineItemBinding::IsExternalizeable()
{
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
index d71ef582..58529ad4 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
@@ -234,6 +234,34 @@ bool Qt3DSDMTimelineItemBinding::HasAction(bool inMaster)
return theActions.size() > 0;
}
+ITimelineItem::ActivateActions Qt3DSDMTimelineItemBinding::getActivateActions()
+{
+ TActionHandleList theActions;
+ CDoc *theDoc = g_StudioApp.GetCore()->GetDoc();
+
+ Qt3DSDMSlideHandle theSlide = theDoc->GetActiveSlide();
+ qt3dsdm::ISlideCore &theSlideCore(*m_StudioSystem->GetSlideCore());
+ if (theSlideCore.IsSlide(theSlide)) {
+ m_StudioSystem->GetActionCore()->GetActions(theSlide, m_DataHandle, theActions);
+ // Check also master slide, to get actions inside component
+ TActionHandleList masterActions;
+ Qt3DSDMSlideHandle masterSlide = m_StudioSystem->GetSlideSystem()->GetMasterSlide(theSlide);
+ m_StudioSystem->GetActionCore()->GetActions(masterSlide, m_DataHandle, masterActions);
+ theActions.insert(theActions.end(), masterActions.begin(), masterActions.end());
+ }
+
+ ITimelineItem::ActivateActions activateActions = ITimelineItem::ActivateAction::None;
+ for (auto theIter = theActions.begin(); theIter != theActions.end(); ++theIter) {
+ auto info = m_StudioSystem->GetActionCore()->GetActionInfo(*theIter);
+ if (info.m_Event == L"onActivate")
+ activateActions |= ITimelineItem::ActivateAction::Activate;
+ else if (info.m_Event == L"onDeactivate")
+ activateActions |= ITimelineItem::ActivateAction::Deactivate;
+ }
+
+ return activateActions;
+}
+
bool Qt3DSDMTimelineItemBinding::ChildrenHasAction(bool inMaster)
{
// Get all the instances in this slidegraph
@@ -353,18 +381,17 @@ void Qt3DSDMTimelineItemBinding::SetName(const Q3DStudio::CString &inName)
return;
// Display warning dialog if user tried to enter an empty string
- if (inName.IsEmpty()) {
+ if (inName.IsEmpty() || inName.toQString().contains(QChar('.'))) {
QString theTitle = QObject::tr("Rename Object Error");
- QString theString = QObject::tr("Object name cannot be an empty string.");
+ QString theString = inName.IsEmpty() ? QObject::tr("Object name cannot be an empty string.")
+ : QObject::tr("Object name cannot contain a dot.");
g_StudioApp.GetDialogs()->DisplayMessageBox(theTitle, theString,
Qt3DSMessageBox::ICON_ERROR, false);
-
return;
}
CClientDataModelBridge *theBridge = m_StudioSystem->GetClientDataModelBridge();
const auto doc = g_StudioApp.GetCore()->GetDoc();
-
// Display warning if the name and path are the same as the material container
if (theBridge->GetParentInstance(m_DataHandle) == doc->GetSceneInstance()
&& inName.toQString() == theBridge->getMaterialContainerName()) {
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h
index 39c81c6d..4f7084d2 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h
@@ -42,7 +42,6 @@
#include "Qt3DSDMHandles.h"
#include "IDragable.h"
#include "Qt3DSDMAssetTimelineKeyframe.h"
-#include "OffsetKeyframesCommandHelper.h"
#include "Qt3DSDMTimeline.h"
#include "Qt3DSDMSignals.h"
#include "DispatchListeners.h"
@@ -108,6 +107,7 @@ public:
bool IsVisible() const override;
void SetVisible(bool) override;
bool HasAction(bool inMaster) override;
+ ITimelineItem::ActivateActions getActivateActions() override;
bool IsVisibilityControlled() const override;
bool ChildrenHasAction(bool inMaster) override;
bool ComponentHasAction(bool inMaster) override;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
index d89fcc98..453ebc8c 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp
@@ -38,6 +38,7 @@
#include "StudioApp.h"
#include "Core.h"
#include "RowTree.h"
+#include "IDocumentEditor.h"
// Link to data model
#include "TimeEditDlg.h"
@@ -56,12 +57,6 @@ bool SortKeyframeByTime(const Qt3DSDMTimelineKeyframe *inLHS, const Qt3DSDMTimel
return inLHS->GetTime() < inRHS->GetTime();
}
-// DataModel stores it from 0..1, UI expects 0..255
-inline float DataModelToColor(float inValue)
-{
- return inValue * 255;
-}
-
Qt3DSDMTimelineItemProperty::Qt3DSDMTimelineItemProperty(CTimelineTranslationManager *inTransMgr,
Qt3DSDMPropertyHandle inPropertyHandle,
Qt3DSDMInstanceHandle inInstance)
@@ -103,8 +98,8 @@ void Qt3DSDMTimelineItemProperty::CreateKeyframes()
DataModelDataType::Value theDataType = thePropertySystem->GetDataType(m_PropertyHandle);
IStudioAnimationSystem *theAnimationSystem =
m_TransMgr->GetStudioSystem()->GetAnimationSystem();
- std::tuple<bool, size_t> theArity = GetDatatypeAnimatableAndArity(theDataType);
- for (size_t i = 0; i < std::get<1>(theArity); ++i) {
+ size_t arity = getDatatypeAnimatableArity(theDataType);
+ for (size_t i = 0; i < arity; ++i) {
Qt3DSDMAnimationHandle theAnimationHandle =
theAnimationSystem->GetControllingAnimation(m_InstanceHandle, m_PropertyHandle, i);
if (theAnimationHandle.Valid())
@@ -131,6 +126,11 @@ qt3dsdm::Qt3DSDMPropertyHandle Qt3DSDMTimelineItemProperty::getPropertyHandle()
return m_PropertyHandle;
}
+std::vector<qt3dsdm::Qt3DSDMAnimationHandle> Qt3DSDMTimelineItemProperty::animationHandles() const
+{
+ return m_AnimationHandles;
+}
+
// Type doesn't change and due to the logic required to figure this out, cache it.
void Qt3DSDMTimelineItemProperty::InitializeCachedVariables(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
@@ -183,33 +183,6 @@ qt3dsdm::TDataTypePair Qt3DSDMTimelineItemProperty::GetType() const
return m_Type;
}
-void CompareAndSet(const Qt3DSDMTimelineKeyframe *inKeyframe, float &outRetValue, bool inGreaterThan)
-{
- float theValue = (inGreaterThan) ? inKeyframe->GetMaxValue() : inKeyframe->GetMinValue();
- if ((inGreaterThan && theValue > outRetValue) || (!inGreaterThan && theValue < outRetValue))
- outRetValue = theValue;
-}
-
-// return the max value of the current set of keyframes
-float Qt3DSDMTimelineItemProperty::GetMaximumValue() const
-{
- float theRetVal = FLT_MIN;
- do_all(m_Keyframes, std::bind(CompareAndSet, std::placeholders::_1, std::ref(theRetVal), true));
- if (m_Type.first == DataModelDataType::Float4 && m_Type.second == AdditionalMetaDataType::Color)
- theRetVal = DataModelToColor(theRetVal);
- return theRetVal;
-}
-
-// return the min value of the current set of keyframes
-float Qt3DSDMTimelineItemProperty::GetMinimumValue() const
-{
- float theRetVal = FLT_MAX;
- do_all(m_Keyframes, std::bind(CompareAndSet, std::placeholders::_1, std::ref(theRetVal), false));
- if (m_Type.first == DataModelDataType::Float4 && m_Type.second == AdditionalMetaDataType::Color)
- theRetVal = DataModelToColor(theRetVal);
- return theRetVal;
-}
-
RowTree *Qt3DSDMTimelineItemProperty::getRowTree() const
{
return m_rowTree;
@@ -267,19 +240,18 @@ long Qt3DSDMTimelineItemProperty::GetKeyframeCount() const
return (long)m_Keyframes.size();
}
-long Qt3DSDMTimelineItemProperty::GetChannelCount() const
+size_t Qt3DSDMTimelineItemProperty::GetChannelCount() const
{
- return (long)m_AnimationHandles.size();
+ return m_AnimationHandles.size();
}
-float Qt3DSDMTimelineItemProperty::GetChannelValueAtTime(long inChannelIndex, long inTime)
+float Qt3DSDMTimelineItemProperty::GetChannelValueAtTime(size_t chIndex, long time)
{
// if no keyframes, get current property value.
if (m_Keyframes.empty()) {
Qt3DSDMTimelineItemBinding *theParentBinding =
static_cast<Qt3DSDMTimelineItemBinding *>(GetParentBinding(m_rowTree));
if (theParentBinding) {
-
SValue theValue;
qt3dsdm::IPropertySystem *thePropertySystem =
m_TransMgr->GetStudioSystem()->GetPropertySystem();
@@ -287,64 +259,37 @@ float Qt3DSDMTimelineItemProperty::GetChannelValueAtTime(long inChannelIndex, lo
m_PropertyHandle, theValue);
switch (m_Type.first) {
case DataModelDataType::Float4: {
- if (m_Type.second == AdditionalMetaDataType::Color) {
- SFloat4 theFloat4 = qt3dsdm::get<SFloat4>(theValue);
- if (inChannelIndex >= 0 && inChannelIndex < 4)
- return DataModelToColor(theFloat4[inChannelIndex]);
- }
+ SFloat4 theFloat4 = qt3dsdm::get<SFloat4>(theValue);
+ if (chIndex < 4)
+ return theFloat4[chIndex];
break;
}
case DataModelDataType::Float3: {
-
SFloat3 theFloat3 = qt3dsdm::get<SFloat3>(theValue);
- if (inChannelIndex >= 0 && inChannelIndex < 3)
- return theFloat3[inChannelIndex];
+ if (chIndex < 3)
+ return theFloat3[chIndex];
break;
}
case DataModelDataType::Float2: {
SFloat2 theFloat2 = qt3dsdm::get<SFloat2>(theValue);
- if (inChannelIndex >= 0 && inChannelIndex < 2)
- return theFloat2[inChannelIndex];
+ if (chIndex < 2)
+ return theFloat2[chIndex];
break;
}
case DataModelDataType::Float:
return qt3dsdm::get<float>(theValue);
- break;
+
default: // TODO: handle other types
break;
}
}
}
- IAnimationCore *theAnimationCore = m_TransMgr->GetStudioSystem()->GetAnimationCore();
- if (!m_AnimationHandles.empty() && inChannelIndex >= 0
- && inChannelIndex < (long)m_AnimationHandles.size()) {
- float theValue = theAnimationCore->EvaluateAnimation(
- m_AnimationHandles[inChannelIndex], Qt3DSDMTimelineKeyframe::GetTimeInSecs(inTime));
- if (m_Type.first == DataModelDataType::Float4
- && m_Type.second == AdditionalMetaDataType::Color)
- theValue = DataModelToColor(theValue);
-
- return theValue;
- }
- return 0.f;
-}
-void Qt3DSDMTimelineItemProperty::SetChannelValueAtTime(long inChannelIndex, long inTime,
- float inValue)
-{
- Qt3DSDMTimelineKeyframe *theKeyframeWrapper =
- dynamic_cast<Qt3DSDMTimelineKeyframe *>(GetKeyframeByTime(inTime));
- if (theKeyframeWrapper) {
- Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframes;
- theKeyframeWrapper->GetKeyframeHandles(theKeyframes);
- if (!theKeyframes.empty() && inChannelIndex < (long)theKeyframes.size()) {
- inValue /= 255;
- if (!m_SetKeyframeValueCommand)
- m_SetKeyframeValueCommand = new CCmdDataModelSetKeyframeValue(
- g_StudioApp.GetCore()->GetDoc(), theKeyframes[inChannelIndex], inValue);
- m_SetKeyframeValueCommand->Update(inValue);
- }
- }
+ IAnimationCore *animCore = m_TransMgr->GetStudioSystem()->GetAnimationCore();
+ if (!m_AnimationHandles.empty() && chIndex < m_AnimationHandles.size())
+ return animCore->EvaluateAnimation(m_AnimationHandles[chIndex], time);
+
+ return 0.f;
}
void Qt3DSDMTimelineItemProperty::setRowTree(RowTree *rowTree)
@@ -357,7 +302,15 @@ bool Qt3DSDMTimelineItemProperty::IsDynamicAnimation()
return m_Keyframes.size() > 0 && m_Keyframes[0]->IsDynamic();
}
-//=============================================================================
+EAnimationType Qt3DSDMTimelineItemProperty::animationType() const
+{
+ if (m_AnimationHandles.empty())
+ return EAnimationTypeNone;
+
+ IAnimationCore *animCore = m_TransMgr->GetStudioSystem()->GetAnimationCore();
+ return animCore->GetAnimationInfo(m_AnimationHandles[0]).m_AnimationType;
+}
+
/**
* For updating the UI when keyframes are added/updated/deleted.
*/
@@ -433,16 +386,16 @@ bool Qt3DSDMTimelineItemProperty::CreateKeyframeIfNonExistent(
if (m_AnimationHandles.size()
> 1) { // assert assumption that is only called for the first handle
Q_ASSERT(m_AnimationHandles[0] == inOwningAnimation);
- IAnimationCore *theAnimationCore = m_TransMgr->GetStudioSystem()->GetAnimationCore();
- float theKeyframeTime = KeyframeTime(theAnimationCore->GetKeyframeData(inKeyframeHandle));
+ IAnimationCore *animCore = m_TransMgr->GetStudioSystem()->GetAnimationCore();
+ float keyframeTime = getKeyframeTime(animCore->GetKeyframeData(inKeyframeHandle));
for (size_t i = 1; i < m_AnimationHandles.size(); ++i) {
TKeyframeHandleList theKeyframes;
- theAnimationCore->GetKeyframes(m_AnimationHandles[i], theKeyframes);
+ animCore->GetKeyframes(m_AnimationHandles[i], theKeyframes);
// the data model ensures that there is only 1 keyframe created for a given time
for (size_t theKeyIndex = 0; theKeyIndex < theKeyframes.size(); ++theKeyIndex) {
float theValue =
- KeyframeTime(theAnimationCore->GetKeyframeData(theKeyframes[theKeyIndex]));
- if (theValue == theKeyframeTime) {
+ getKeyframeTime(animCore->GetKeyframeData(theKeyframes[theKeyIndex]));
+ if (theValue == keyframeTime) {
theNewKeyframe->AddKeyframeHandle(theKeyframes[theKeyIndex]);
break;
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h
index 1b1524e4..978f9b12 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h
@@ -36,6 +36,7 @@
#include "Qt3DSDMTimelineKeyframe.h"
#include "Qt3DSDMTimeline.h"
#include "Qt3DSDMPropertyDefinition.h"
+#include "Qt3DSDMAnimation.h"
class RowTree;
class CTimelineTranslationManager;
@@ -52,38 +53,37 @@ class Qt3DSDMTimelineItemProperty : public ITimelineItemProperty
{
public:
Qt3DSDMTimelineItemProperty(CTimelineTranslationManager *inTransMgr,
- qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle,
- qt3dsdm::Qt3DSDMInstanceHandle inInstance);
+ qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle,
+ qt3dsdm::Qt3DSDMInstanceHandle inInstance);
virtual ~Qt3DSDMTimelineItemProperty();
// ITimelineProperty
Q3DStudio::CString GetName() const override;
bool IsMaster() const override;
qt3dsdm::TDataTypePair GetType() const override;
- float GetMaximumValue() const override;
- float GetMinimumValue() const override;
void SetSelected() override;
void DeleteAllKeys() override;
IKeyframe *GetKeyframeByTime(long inTime) const override;
IKeyframe *GetKeyframeByIndex(long inIndex) const override;
long GetKeyframeCount() const override;
- long GetChannelCount() const override;
- float GetChannelValueAtTime(long inChannelIndex, long inTime) override;
- void SetChannelValueAtTime(long inChannelIndex, long inTime, float inValue) override;
+ size_t GetChannelCount() const override;
+ float GetChannelValueAtTime(size_t chIndex, long time) override;
bool IsDynamicAnimation() override;
-
void setRowTree(RowTree *rowTree) override;
RowTree *getRowTree() const override;
+ qt3dsdm::Qt3DSDMPropertyHandle getPropertyHandle() const override;
+ std::vector<qt3dsdm::Qt3DSDMAnimationHandle> animationHandles() const override;
bool RefreshKeyframe(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe,
ETimelineKeyframeTransaction inTransaction);
IKeyframe *GetKeyframeByHandle(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe);
void RefreshKeyFrames(void);
-
- qt3dsdm::Qt3DSDMPropertyHandle getPropertyHandle() const;
+ qt3dsdm::EAnimationType animationType() const override;
protected:
+ using TKeyframeList = std::vector<Qt3DSDMTimelineKeyframe *>;
+
void InitializeCachedVariables(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
bool CreateKeyframeIfNonExistent(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe,
qt3dsdm::Qt3DSDMAnimationHandle inOwningAnimation);
@@ -93,9 +93,6 @@ protected:
void CreateKeyframes();
void ReleaseKeyframes();
-protected:
- typedef std::vector<Qt3DSDMTimelineKeyframe *> TKeyframeList;
-
qt3dsdm::Qt3DSDMInstanceHandle m_InstanceHandle;
qt3dsdm::Qt3DSDMPropertyHandle m_PropertyHandle;
CTimelineTranslationManager *m_TransMgr;
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.cpp
index ae7e2035..081c2768 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.cpp
@@ -33,7 +33,6 @@
#include "CmdDataModelChangeKeyframe.h"
#include "CmdBatch.h"
#include "Qt3DSDMStudioSystem.h"
-#include "OffsetKeyframesCommandHelper.h"
#include "Doc.h"
#include "StudioApp.h"
@@ -43,8 +42,7 @@ using namespace qt3dsdm;
// TODO: figure out if we can just use IDoc instead of CDoc
Qt3DSDMTimelineKeyframe::Qt3DSDMTimelineKeyframe(IDoc *inDoc)
- : m_Doc(dynamic_cast<CDoc *>(inDoc))
- , m_Selected(false)
+ : m_Doc(static_cast<CDoc *>(inDoc))
{
}
@@ -57,59 +55,32 @@ bool Qt3DSDMTimelineKeyframe::IsSelected() const
return m_Selected;
}
-float my_roundf(float r)
-{
- return (r > 0.0f) ? floorf(r + 0.5f) : ceilf(r - 0.5f);
-}
-
long Qt3DSDMTimelineKeyframe::GetTime() const
{
if (!m_KeyframeHandles.empty()) {
- IAnimationCore *theAnimationCore = m_Doc->GetStudioSystem()->GetAnimationCore();
- Qt3DSDMKeyframeHandle theKeyframeHandle = *m_KeyframeHandles.begin();
- if (theAnimationCore->KeyframeValid(theKeyframeHandle)) {
- float theTimeinSecs =
- KeyframeTime(theAnimationCore->GetKeyframeData(theKeyframeHandle));
- // We always convert back and forth between between long and float.
- // This causes especially issues when we do comparisons
- return (long)my_roundf(theTimeinSecs * 1000);
- }
+ IAnimationCore *animaCore = m_Doc->GetStudioSystem()->GetAnimationCore();
+ Qt3DSDMKeyframeHandle kfHandle = *m_KeyframeHandles.begin();
+ if (animaCore->KeyframeValid(kfHandle))
+ return getKeyframeTime(animaCore->GetKeyframeData(kfHandle));
}
- return -1; // keyframe was deleted, and data cannot be retrieved.
-}
-float Qt3DSDMTimelineKeyframe::GetTimeInSecs(long inTime)
-{
- float theTimeinSecs = static_cast<float>(inTime) / 1000.f;
- // round off to 4 decimal place to workaround precision issues
- // TODO: fix this, either all talk float OR long. choose one.
- theTimeinSecs = (float)(((theTimeinSecs + 0.00005) * 10000.0) / 10000.0f);
- return theTimeinSecs;
+ return -1; // keyframe was deleted, and data cannot be retrieved.
}
void Qt3DSDMTimelineKeyframe::SetTime(const long inNewTime)
{
- float theTimeinSecs = GetTimeInSecs(inNewTime);
CCmd *theCmd = nullptr;
if (m_KeyframeHandles.size() == 1) {
- theCmd = new CCmdDataModelSetKeyframeTime(m_Doc, m_KeyframeHandles.front(), theTimeinSecs);
+ theCmd = new CCmdDataModelSetKeyframeTime(m_Doc, m_KeyframeHandles.front(), inNewTime);
} else { // more than 1 channel
CCmdBatch *theBatch = new CCmdBatch(m_Doc);
TKeyframeHandleList::iterator theIter = m_KeyframeHandles.begin();
for (; theIter != m_KeyframeHandles.end(); ++theIter)
- theBatch->AddCommand(new CCmdDataModelSetKeyframeTime(m_Doc, *theIter, theTimeinSecs));
+ theBatch->AddCommand(new CCmdDataModelSetKeyframeTime(m_Doc, *theIter, inNewTime));
theCmd = theBatch;
}
if (theCmd)
m_Doc->GetCore()->ExecuteCommand(theCmd);
-
-#ifdef _DEBUG
- // we have a precision issue from converting from long to float..
- IAnimationCore *theAnimationCore = m_Doc->GetStudioSystem()->GetAnimationCore();
- long theTest = static_cast<long>(
- KeyframeTime(theAnimationCore->GetKeyframeData(*m_KeyframeHandles.begin())) * 1000);
- Q_ASSERT(inNewTime == theTest);
-#endif
}
inline Qt3DSDMAnimationHandle GetAnimationHandle(qt3dsdm::IAnimationCore *inAnimationCore,
@@ -180,44 +151,7 @@ void Qt3DSDMTimelineKeyframe::SetSelected(bool inSelected)
m_Selected = inSelected;
}
-// For colors, there would be 3 keyframe handles
-void Qt3DSDMTimelineKeyframe::UpdateKeyframesTime(COffsetKeyframesCommandHelper *inCommandHelper,
- long inTime)
-{
- for (size_t i = 0; i < m_KeyframeHandles.size(); ++i)
- inCommandHelper->SetCommandTime(m_KeyframeHandles[i], inTime);
-}
-
void Qt3DSDMTimelineKeyframe::GetKeyframeHandles(TKeyframeHandleList &outList) const
{
outList = m_KeyframeHandles;
}
-
-void CompareAndSet(Qt3DSDMKeyframeHandle inKeyframe, IAnimationCore *inAnimationCore,
- float &outRetValue, bool inGreaterThan)
-{
- TKeyframe theKeyframeData = inAnimationCore->GetKeyframeData(inKeyframe);
- float theValue = KeyframeValueValue(theKeyframeData);
- if ((inGreaterThan && theValue > outRetValue) || (!inGreaterThan && theValue < outRetValue))
- outRetValue = theValue;
-}
-
-float Qt3DSDMTimelineKeyframe::GetMaxValue() const
-{
- IAnimationCore *theAnimationCore = m_Doc->GetStudioSystem()->GetAnimationCore();
- float theRetVal = FLT_MIN;
- do_all(m_KeyframeHandles,
- std::bind(CompareAndSet, std::placeholders::_1, theAnimationCore,
- std::ref(theRetVal), true));
- return theRetVal;
-}
-
-float Qt3DSDMTimelineKeyframe::GetMinValue() const
-{
- IAnimationCore *theAnimationCore = m_Doc->GetStudioSystem()->GetAnimationCore();
- float theRetVal = FLT_MAX;
- do_all(m_KeyframeHandles,
- std::bind(CompareAndSet, std::placeholders::_1, theAnimationCore,
- std::ref(theRetVal), false));
- return theRetVal;
-}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.h b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.h
index 7799cc0d..e131418a 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.h
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineKeyframe.h
@@ -27,9 +27,7 @@
**
****************************************************************************/
#ifndef QT3DSDM_KEYFRAME_H
-#define QT3DSDM_KEYFRAME_H 1
-
-#pragma once
+#define QT3DSDM_KEYFRAME_H
#include "IKeyframe.h"
@@ -39,29 +37,15 @@
class IDoc;
class CDoc;
class CCmdBatch;
-class COffsetKeyframesCommandHelper;
struct Keyframe;
-//==============================================================================
-/**
- * Wrapper for a keyframe in DataModel.
- */
-//==============================================================================
class Qt3DSDMTimelineKeyframe : public IKeyframe
{
public:
typedef std::vector<qt3dsdm::Qt3DSDMKeyframeHandle> TKeyframeHandleList;
-protected:
- TKeyframeHandleList
- m_KeyframeHandles; ///< no. corresponds to the channels the animated property has.
- CDoc *m_Doc;
- bool m_Selected;
- Keyframe *m_ui = nullptr;
-
-public:
Qt3DSDMTimelineKeyframe(IDoc *inDoc);
- virtual ~Qt3DSDMTimelineKeyframe();
+ virtual ~Qt3DSDMTimelineKeyframe() override;
// IKeyframe
bool IsSelected() const override;
@@ -75,14 +59,13 @@ public:
void AddKeyframeHandle(qt3dsdm::Qt3DSDMKeyframeHandle inHandle);
bool HasKeyframeHandle(qt3dsdm::Qt3DSDMKeyframeHandle inHandle) const;
void SetSelected(bool inSelected);
- void UpdateKeyframesTime(COffsetKeyframesCommandHelper *inCommandHelper, long inTime);
void GetKeyframeHandles(TKeyframeHandleList &outList) const;
- // support drawing graphs
- float GetMaxValue() const;
- float GetMinValue() const;
-
- static float GetTimeInSecs(long inTime);
+private:
+ TKeyframeHandleList m_KeyframeHandles; // channels handles of the animated property
+ CDoc *m_Doc = nullptr;
+ bool m_Selected = false;
+ Keyframe *m_ui = nullptr;
};
#endif // QT3DSDM_KEYFRAME_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp
index 0ecefefd..99f44185 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp
@@ -98,10 +98,10 @@ void Qt3DSDMTimelineTimebar::OnPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle in
} else {
switch (theClientDataModelBridge->GetObjectType(inInstance)) {
case OBJTYPE_LAYER:
- m_Color = CStudioPreferences::GetLayerTimebarColor();
+ m_Color = CStudioPreferences::layerTimebarColor();
break;
default:
- m_Color = CStudioPreferences::GetObjectTimebarColor();
+ m_Color = CStudioPreferences::objectTimebarColor();
break;
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp
index c03867a7..9a1e9eab 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp
@@ -64,8 +64,8 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa
EStudioObjectType objType = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
->GetClientDataModelBridge()->GetObjectType(inInstance);
- if (objType & OBJTYPE_IS_MATERIAL) {
- theReturn = new CMaterialTimelineItemBinding(this, inInstance);
+ if (objType & (OBJTYPE_IS_MATERIAL | OBJTYPE_EFFECT)) {
+ theReturn = new CMaterialEffectTimelineItemBinding(this, inInstance);
} else if (objType == OBJTYPE_IMAGE) {
theReturn = new CImageTimelineItemBinding(this, inInstance);
} else if (objType & (OBJTYPE_GROUP | OBJTYPE_COMPONENT)) {
@@ -80,9 +80,9 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa
theReturn = new CPathTimelineItemBinding(this, inInstance);
} else if (objType == OBJTYPE_LAYER) {
theReturn = new CLayerTimelineItemBinding(this, inInstance);
- } else if (objType & (OBJTYPE_MODEL | OBJTYPE_TEXT | OBJTYPE_CAMERA | OBJTYPE_EFFECT
+ } else if (objType & (OBJTYPE_MODEL | OBJTYPE_TEXT | OBJTYPE_CAMERA
| OBJTYPE_LIGHT | OBJTYPE_RENDERPLUGIN | OBJTYPE_ALIAS
- | OBJTYPE_SUBPATH))
+ | OBJTYPE_SUBPATH | OBJTYPE_SIGNAL))
theReturn = new Qt3DSDMTimelineItemBinding(this, inInstance);
else {
// Add support for additional DataModel types here.
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/Keyframe.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/Keyframe.h
index 7e4ea614..90210a6a 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/Keyframe.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/Keyframe.h
@@ -39,7 +39,6 @@ struct Keyframe
: time(time)
, rowProperty(propRow)
, rowMaster(propRow->parentRow())
- , propertyType(propRow->rowTree()->propertyType())
{}
bool selected() const
@@ -47,8 +46,7 @@ struct Keyframe
return binding && binding->IsSelected();
}
- long time;
- QString propertyType;
+ long time; // millis
RowTimeline *rowProperty = nullptr;
RowTimeline *rowMaster = nullptr;
Qt3DSDMTimelineKeyframe *binding = nullptr;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
index 9a12aab3..a4248fad 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.cpp
@@ -35,16 +35,19 @@
#include "StudioApp.h"
#include "Core.h"
#include "Doc.h"
+#include "SlideSystem.h"
#include "StudioClipboard.h"
#include "CmdDataModelRemoveKeyframe.h"
#include "CmdDataModelInsertKeyframe.h"
#include "CmdDataModelChangeKeyframe.h"
#include "ClientDataModelBridge.h"
-#include "Bindings/OffsetKeyframesCommandHelper.h"
#include "Bindings/PasteKeyframesCommandHelper.h"
+#include "Bindings/ITimelineItemBinding.h"
#include "StudioPreferences.h"
#include "Dialogs.h"
#include "TimeEnums.h"
+#include "RowTimelinePropertyGraph.h"
+#include "IDocumentEditor.h"
using namespace qt3dsdm;
@@ -138,14 +141,17 @@ QList<Keyframe *> KeyframeManager::selectedKeyframes() const
return m_selectedKeyframes;
}
-// update bindings after selected keyframes are moved
void KeyframeManager::commitMoveSelectedKeyframes()
{
- CDoc *theDoc = g_StudioApp.GetCore()->GetDoc();
- COffsetKeyframesCommandHelper h(*theDoc);
+ Q3DStudio::ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(),
+ QObject::tr("Set Keyframe Time"), __FILE__, __LINE__);
+ for (Keyframe *keyframe : qAsConst(m_selectedKeyframes)) {
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList kfHandles;
+ keyframe->binding->GetKeyframeHandles(kfHandles);
- for (Keyframe *keyframe : qAsConst(m_selectedKeyframes))
- keyframe->binding->UpdateKeyframesTime(&h, keyframe->time);
+ for (auto h : kfHandles)
+ editor->SetKeyframeTime(h, keyframe->time);
+ }
}
void KeyframeManager::selectKeyframesInRect(const QRectF &rect)
@@ -164,6 +170,11 @@ void KeyframeManager::selectKeyframesInRect(const QRectF &rect)
m_selectedKeyframesMasterRows.append(keyframe->rowMaster);
}
}
+
+ if (row->propertyExpanded()
+ && row->propBinding()->animationType() == EAnimationTypeBezier) {
+ row->rowTimeline()->propertyGraph()->selectBezierKeyframesInRange(rect);
+ }
}
row = m_scene->rowManager()->getRowAtPos(QPointF(0, row->y() + row->size().height()));
}
@@ -209,6 +220,11 @@ void KeyframeManager::deselectAllKeyframes()
m_selectedKeyframes.clear();
m_selectedKeyframesMasterRows.clear();
+
+ // deselect bezier keyframes
+ const auto expandedPropGraphs = m_scene->rowManager()->getExpandedPropertyGraphs();
+ for (auto g : expandedPropGraphs)
+ g->deselectAllBezierKeyframes();
}
void KeyframeManager::deselectRowKeyframes(RowTree *row)
@@ -296,7 +312,7 @@ void KeyframeManager::copySelectedKeyframes()
Qt3DSDMTimelineKeyframe *kf = keyframe->binding;
Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles;
kf->GetKeyframeHandles(theKeyframeHandles);
- qt3dsdm::SGetOrSetKeyframeInfo info[3];
+ qt3dsdm::SGetOrSetKeyframeInfo info[4];
size_t infoCount = 0;
if (!theKeyframeHandles.empty()) {
switch (theKeyframeHandles.size()) {
@@ -310,11 +326,18 @@ void KeyframeManager::copySelectedKeyframes()
info[2] = setKeyframeInfo(theKeyframeHandles[2], *animationCore);
infoCount = 3;
break;
+ case 4:
+ info[0] = setKeyframeInfo(theKeyframeHandles[0], *animationCore);
+ info[1] = setKeyframeInfo(theKeyframeHandles[1], *animationCore);
+ info[2] = setKeyframeInfo(theKeyframeHandles[2], *animationCore);
+ info[3] = setKeyframeInfo(theKeyframeHandles[3], *animationCore);
+ infoCount = 4;
+ break;
default:
break;
}
- float dt = Qt3DSDMTimelineKeyframe::GetTimeInSecs(kf->GetTime() - minTime);
+ long dt = kf->GetTime() - minTime;
qt3dsdm::Qt3DSDMAnimationHandle animation
= animationCore->GetAnimationForKeyframe(theKeyframeHandles[0]);
m_pasteKeyframeCommandHelper->AddKeyframeData(
@@ -325,19 +348,14 @@ void KeyframeManager::copySelectedKeyframes()
}
qt3dsdm::SGetOrSetKeyframeInfo KeyframeManager::setKeyframeInfo(
- qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe, qt3dsdm::IAnimationCore &inCore)
-{
- qt3dsdm::TKeyframe theKeyframeData = inCore.GetKeyframeData(inKeyframe);
- qt3dsdm::SEaseInEaseOutKeyframe keyframe =
- qt3dsdm::get<qt3dsdm::SEaseInEaseOutKeyframe>(theKeyframeData);
- bool isDynamic = false;
- if (inCore.IsFirstKeyframe(inKeyframe)) {
- isDynamic = inCore.GetAnimationInfo(inCore.GetAnimationForKeyframe(inKeyframe))
- .m_DynamicFirstKeyframe;
- }
+ qt3dsdm::Qt3DSDMKeyframeHandle keyframeHandle, qt3dsdm::IAnimationCore &animCore)
+{
+ qt3dsdm::TKeyframe keyframeData = animCore.GetKeyframeData(keyframeHandle);
- return qt3dsdm::SGetOrSetKeyframeInfo(keyframe.m_KeyframeValue, keyframe.m_EaseIn,
- keyframe.m_EaseOut, isDynamic);
+ bool isDynamic = animCore.IsFirstKeyframe(keyframeHandle) && animCore.GetAnimationInfo(
+ animCore.GetAnimationForKeyframe(keyframeHandle)).m_DynamicFirstKeyframe;
+
+ return qt3dsdm::SGetOrSetKeyframeInfo(keyframeData, isDynamic);
}
void KeyframeManager::pasteKeyframes()
@@ -346,10 +364,9 @@ void KeyframeManager::pasteKeyframes()
if (m_pasteKeyframeCommandHelper && m_pasteKeyframeCommandHelper->HasCopiedKeyframes()) {
qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = theDoc->GetSelectedInstance();
if (theSelectedInstance.Valid()) {
- long theCurrentViewTimeInMilliseconds = theDoc->GetCurrentViewTime();
- CCmdDataModelInsertKeyframe *theInsertKeyframesCommand =
- m_pasteKeyframeCommandHelper->GetCommand(theDoc, theCurrentViewTimeInMilliseconds,
- theSelectedInstance);
+ CCmdDataModelInsertKeyframe *theInsertKeyframesCommand
+ = m_pasteKeyframeCommandHelper->GetCommand(theDoc, theDoc->GetCurrentViewTime(),
+ theSelectedInstance);
if (theInsertKeyframesCommand)
g_StudioApp.GetCore()->ExecuteCommand(theInsertKeyframesCommand);
}
@@ -476,23 +493,33 @@ void KeyframeManager::RollbackChangedKeyframes()
row->updateKeyframes();
}
-// IKeyframesManager interface
-bool KeyframeManager::HasSelectedKeyframes()
+bool KeyframeManager::HasSelectedKeyframes() const
{
return hasSelectedKeyframes();
}
-bool KeyframeManager::HasDynamicKeyframes()
+bool KeyframeManager::HasDynamicKeyframes() const
{
return false; // Mahmoud_TODO: implement
}
-bool KeyframeManager::CanPerformKeyframeCopy()
+bool KeyframeManager::CanPerformKeyframeCopy() const
{
return !m_selectedKeyframes.empty() && m_selectedKeyframesMasterRows.count() == 1;
}
-bool KeyframeManager::CanPerformKeyframePaste()
+bool KeyframeManager::canSetKeyframeInterpolation() const
+{
+ for (Keyframe *kf : qAsConst(m_selectedKeyframes)) {
+ auto animType = kf->rowProperty->rowTree()->propBinding()->animationType();
+ if (animType == qt3dsdm::EAnimationTypeEaseInOut)
+ return true;
+ }
+
+ return false;
+}
+
+bool KeyframeManager::CanPerformKeyframePaste() const
{
if (m_pasteKeyframeCommandHelper && m_pasteKeyframeCommandHelper->HasCopiedKeyframes()) {
qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance =
@@ -526,36 +553,36 @@ void KeyframeManager::SetKeyframeInterpolation()
if (!hasSelectedKeyframes())
return;
- float theEaseIn = 0;
- float theEaseOut = 0;
- if (CStudioPreferences::GetInterpolation())
- theEaseIn = theEaseOut = 100;
-
- CDoc *theDoc = g_StudioApp.GetCore()->GetDoc();
- IAnimationCore *theAnimationCore = theDoc->GetStudioSystem()->GetAnimationCore();
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ IAnimationCore *animCore = doc->GetStudioSystem()->GetAnimationCore();
- if (!m_selectedKeyframes.empty()) {
- Qt3DSDMTimelineKeyframe *theTimelineKeyframe = m_selectedKeyframes.front()->binding;
- Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles;
- theTimelineKeyframe->GetKeyframeHandles(theKeyframeHandles);
- TKeyframe theKeyframeData = theAnimationCore->GetKeyframeData(theKeyframeHandles[0]);
- GetEaseInOutValues(theKeyframeData, theEaseIn, theEaseOut);
+ // find the first easing keyframe and use it to get the current easing values
+ auto firstEaseKeyframeIter = m_selectedKeyframes.begin();
+ while ((*firstEaseKeyframeIter)->rowProperty->rowTree()->propBinding()->animationType()
+ != EAnimationTypeEaseInOut) {
+ firstEaseKeyframeIter++;
}
- if (g_StudioApp.GetDialogs()->PromptForKeyframeInterpolation(theEaseIn, theEaseOut)) {
- // Note: Having "editor" variable here is important as its destructor
- // creates proper transaction
- Q3DStudio::ScopedDocumentEditor editor(*theDoc, QObject::tr("Set Keyframe Interpolation"),
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ (*firstEaseKeyframeIter)->binding->GetKeyframeHandles(keyframeHandles);
+
+ TKeyframe keyframeData = animCore->GetKeyframeData(keyframeHandles[0]);
+
+ float easeIn = CStudioPreferences::isInterpolation() ? 100 : 0;
+ float easeOut = CStudioPreferences::isInterpolation() ? 100 : 0;
+ getEaseInOutValues(keyframeData, easeIn, easeOut);
+
+ if (g_StudioApp.GetDialogs()->displayKeyframeInterpolation(easeIn, easeOut)) {
+ // Having "editor" variable here is important as its destructor creates proper transaction
+ Q3DStudio::ScopedDocumentEditor editor(*doc, QObject::tr("Set Keyframe Interpolation"),
__FILE__, __LINE__);
for (Keyframe *keyframe : qAsConst(m_selectedKeyframes)) {
- Qt3DSDMTimelineKeyframe *theTimelineKeyframe = keyframe->binding;
- Qt3DSDMTimelineKeyframe::TKeyframeHandleList theKeyframeHandles;
- theTimelineKeyframe->GetKeyframeHandles(theKeyframeHandles);
- for (size_t i = 0; i < theKeyframeHandles.size(); ++i) {
- TKeyframe theKeyframeData =
- theAnimationCore->GetKeyframeData(theKeyframeHandles[i]);
- SetEaseInOutValues(theKeyframeData, theEaseIn, theEaseOut);
- theAnimationCore->SetKeyframeData(theKeyframeHandles[i], theKeyframeData);
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ keyframe->binding->GetKeyframeHandles(keyframeHandles);
+ for (size_t i = 0; i < keyframeHandles.size(); ++i) {
+ TKeyframe keyframeData = animCore->GetKeyframeData(keyframeHandles[i]);
+ setEaseInOutValues(keyframeData, easeIn, easeOut);
+ animCore->SetKeyframeData(keyframeHandles[i], keyframeData);
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.h
index 9c160687..0012c047 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/KeyframeManager.h
@@ -76,10 +76,11 @@ public:
void SetKeyframesDynamic(bool inDynamic) override;
void CommitChangedKeyframes() override;
void RollbackChangedKeyframes() override;
- bool HasSelectedKeyframes() override;
- bool HasDynamicKeyframes() override;
- bool CanPerformKeyframeCopy() override;
- bool CanPerformKeyframePaste() override;
+ bool HasSelectedKeyframes() const override;
+ bool HasDynamicKeyframes() const override;
+ bool CanPerformKeyframeCopy() const override;
+ bool CanPerformKeyframePaste() const override;
+ bool canSetKeyframeInterpolation() const override;
void CopyKeyframes() override;
bool RemoveKeyframes(bool inPerformCopy) override;
void PasteKeyframes() override;
@@ -89,12 +90,12 @@ public:
long getPressedKeyframeOffset() const;
private:
- qt3dsdm::SGetOrSetKeyframeInfo setKeyframeInfo(qt3dsdm::Qt3DSDMKeyframeHandle inKeyframe,
- qt3dsdm::IAnimationCore &inCore);
+ qt3dsdm::SGetOrSetKeyframeInfo setKeyframeInfo(qt3dsdm::Qt3DSDMKeyframeHandle keyframeHandle,
+ qt3dsdm::IAnimationCore &animCore);
long getMinSelectedKeyframesTime() const;
CPasteKeyframeCommandHelper *m_pasteKeyframeCommandHelper = nullptr;
- TimelineGraphicsScene *m_scene;
+ TimelineGraphicsScene *m_scene = nullptr;
QList<Keyframe *> m_selectedKeyframes;
QList<RowTimeline *> m_selectedKeyframesMasterRows;
};
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.cpp
index 50eff996..70a18560 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.cpp
@@ -44,6 +44,7 @@
#include "StudioObjectTypes.h"
#include "Qt3DSDMStudioSystem.h"
#include "ClientDataModelBridge.h"
+#include "IDocumentEditor.h"
#include <QtWidgets/qgraphicslinearlayout.h>
#include <QtCore/qpointer.h>
@@ -75,9 +76,8 @@ void RowManager::removeAllRows()
clearSelection();
// delete rows
- RowTree *row_i;
for (int i = m_layoutTree->count() - 1; i >= 1; --i) {
- row_i = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
+ RowTree *row_i = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
m_layoutTree->removeAt(i);
m_layoutTimeline->removeAt(i);
delete row_i; // this will also delete the timeline row
@@ -219,6 +219,9 @@ void RowManager::selectRow(RowTree *row, bool multiSelect)
if (row->locked())
return;
+ if (multiSelect && row->propertyExpanded())
+ return;
+
if (row->isProperty())
row = row->parentRow();
@@ -234,6 +237,20 @@ void RowManager::selectRow(RowTree *row, bool multiSelect)
binding->SetSelected(multiSelect);
}
+QVector<RowTimelinePropertyGraph *> RowManager::getExpandedPropertyGraphs() const
+{
+ QVector<RowTimelinePropertyGraph *> graphs;
+
+ // the earliest possible property row index in the layout is 4
+ for (int i = 4; i < m_layoutTree->count(); ++i) {
+ RowTree *row_i = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
+ if (row_i->propertyExpanded())
+ graphs.append(row_i->rowTimeline()->propertyGraph());
+ }
+
+ return graphs;
+}
+
// Call this to update row selection UI status
void RowManager::setRowSelection(RowTree *row, bool selected)
{
@@ -275,15 +292,13 @@ void RowManager::updateRulerDuration(bool updateMaxDuration)
long maxDuration = 0; // for setting correct size for the view so scrollbars appear correctly
if (m_layoutTree->count() > 1) {
auto rootRow = static_cast<RowTree *>(m_layoutTree->itemAt(1)->graphicsItem());
- bool isComponent = rootRow->objectType() == OBJTYPE_COMPONENT;
- for (int i = 1; i < m_layoutTree->count(); ++i) {
+ bool insideComponent = rootRow->objectType() == OBJTYPE_COMPONENT;
+ for (int i = 2; i < m_layoutTree->count(); ++i) {
RowTree *row_i = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
long dur_i = row_i->rowTimeline()->getEndTime();
- if (((isComponent && i != 1) || row_i->objectType() == OBJTYPE_LAYER)
- && dur_i > duration) {
+ if ((insideComponent || row_i->objectType() == OBJTYPE_LAYER) && dur_i > duration)
duration = dur_i;
- }
if (dur_i > maxDuration)
maxDuration = dur_i;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.h
index 3a018577..32d3fb19 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowManager.h
@@ -36,6 +36,7 @@
class TimelineGraphicsScene;
class RowTree;
class RowTimeline;
+class RowTimelinePropertyGraph;
class ITimelineItemBinding;
class Qt3DSDMTimelineItemBinding;
@@ -69,6 +70,7 @@ public:
bool isRowSelected(RowTree *row) const;
QVector<RowTree *> selectedRows() const;
void ensureRowExpandedAndVisible(RowTree *row, bool forceChildUpdate) const;
+ QVector<RowTimelinePropertyGraph *> getExpandedPropertyGraphs() const;
private:
void deleteRowRecursive(RowTree *row, bool deferChildRows);
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowTypes.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowTypes.h
index 58a93115..faeeae68 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowTypes.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/RowTypes.h
@@ -31,14 +31,23 @@
#include <qglobal.h>
-enum class TimelineControlType {
- None,
- KeyFrame,
- Duration,
- StartHandle,
- EndHandle
+enum class TimelineControlType : int {
+ None = 0x00,
+ KeyFrame = 0x01,
+ Duration = 0x02,
+ DurationStartHandle = 0x04,
+ DurationEndHandle = 0x08,
+ BezierKeyframe = 0x10,
+ BezierInHandle = 0x20,
+ BezierOutHandle = 0x40,
+ IsBezierControl = BezierKeyframe | BezierInHandle | BezierOutHandle
};
+inline int operator &(TimelineControlType lhs, TimelineControlType rhs)
+{
+ return int(lhs) & int(rhs);
+}
+
enum class TreeControlType {
None,
Arrow,
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineConstants.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineConstants.h
index 61525718..365bb88b 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineConstants.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineConstants.h
@@ -33,18 +33,17 @@ namespace TimelineConstants
{
// Dimensions
const int ROW_H = 20;
- const int ROW_H_EXPANDED = 120; // property rows height when graph is shown
+ const int ROW_GRAPH_H = 120; // property row height when graph is shown
+ const int ROW_GRAPH_H_MAX = 300; // property row height when graph is shown maximized
const int ROW_SPACING = 2;
const int ROW_DEPTH_STEP = 15; // x-distance between 2 consecutive depths
- const double RULER_SEC_W = 30; // width of 1 second section (at scale 1)
+ const double RULER_SEC_W = 60; // width of 1 second section (at scale 1)
const double RULER_MILLI_W = RULER_SEC_W / 1000.0; // width of 1 millisecond section at scale 1
const int RULER_SEC_DIV = 10; // second divisions
const int RULER_DIV_H1 = 5; // height of main divisions
const int RULER_DIV_H2 = 3; // height of secondary divisions
const int RULER_DIV_H3 = 1; // height of minor divisions
const int RULER_BASE_Y = 18; // baseline Y
- const int RULER_LABEL_W = 60;
- const int RULER_LABEL_H = 10;
const int RULER_TICK_SCALE1 = 2;
const int RULER_TICK_SCALE2 = 3;
const int RULER_TICK_SCALE3 = 6;
@@ -63,6 +62,7 @@ namespace TimelineConstants
const int DURATION_HANDLE_W = 14; // width of duration end handles in a timeline row
const int NAVIGATION_BAR_H = 30; // height of navigation/breadcrumb bar
const int TIMEBAR_TOOLTIP_OFFSET_V = 10;
+ const int ACTION_W = 4;
// Other
const int EXPAND_ANIMATION_DURATION = 200;
@@ -74,8 +74,6 @@ namespace TimelineConstants
const int TIMELINE_SCROLL_MAX_DELTA = 25; // Maximum amount of pixels to scroll per frame
const int TIMELINE_SCROLL_DIVISOR = 6; // Divisor for timeline autoscroll distance
-
- // TODO: move the colors and dimensions to StudioPreferences.
}
#endif // TIMELINECONSTANTS_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
index b4a52760..bae5af8f 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
@@ -32,6 +32,7 @@
#include "Ruler.h"
#include "PlayHead.h"
#include "RowTree.h"
+#include "RowTimelinePropertyGraph.h"
#include "RowMover.h"
#include "RowTimeline.h"
#include "TimelineConstants.h"
@@ -188,8 +189,7 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
// Resize keyframe selection rect
const QPointF scenePoint = timelineContent->mapToScene(p);
- timelineContent->ensureVisible(scenePoint.x(), scenePoint.y(),
- 0, 0, 0, 0);
+ timelineContent->ensureVisible(scenePoint.x(), scenePoint.y(), 0, 0, 0, 0);
QRectF visibleScene(
timelineContent->mapToScene(contentRect.topLeft()),
timelineContent->mapToScene(contentRect.bottomRight()
@@ -226,7 +226,7 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
}
if (m_dragging) {
- if (m_clickedTimelineControlType == TimelineControlType::StartHandle) {
+ if (m_clickedTimelineControlType == TimelineControlType::DurationStartHandle) {
double visiblePtX = distance > 0 ? m_editedTimelineRow->getStartX() : 0;
if (distance > m_editedTimelineRow->getEndX())
visiblePtX += TimelineConstants::RULER_EDGE_OFFSET;
@@ -237,7 +237,8 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
+ TimelineConstants::RULER_EDGE_OFFSET
+ visiblePtX,
m_editedTimelineRow->y(), 0, 0, 0, 0);
- } else if (m_clickedTimelineControlType == TimelineControlType::EndHandle) {
+ } else if (m_clickedTimelineControlType
+ == TimelineControlType::DurationEndHandle) {
long time = m_ruler->distanceToTime(distance);
double edgeMargin = 0;
if (time > TimelineConstants::MAX_SLIDE_TIME) {
@@ -284,7 +285,7 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
});
QTimer::singleShot(0, this, [this]() {
- m_playHead->setPosition(0);
+ m_playHead->setTime(0);
m_widgetTimeline->viewTreeContent()->horizontalScrollBar()->setValue(0);
});
@@ -343,6 +344,7 @@ TimelineGraphicsScene::~TimelineGraphicsScene()
disconnect(qApp, &QApplication::focusChanged,
this, &TimelineGraphicsScene::handleApplicationFocusLoss);
delete m_dataInputSelector;
+ delete m_keyframeManager;
}
void TimelineGraphicsScene::setTimelineScale(int scl)
@@ -368,22 +370,12 @@ void TimelineGraphicsScene::setControllerText(const QString &controller)
void TimelineGraphicsScene::updateTimelineLayoutWidth()
{
double timelineWidth = TimelineConstants::RULER_EDGE_OFFSET * 2
- + m_ruler->maxDuration() * TimelineConstants::RULER_MILLI_W
- * m_ruler->timelineScale();
+ + m_ruler->timeToDistance(m_ruler->maxDuration());
m_layoutTimeline->setMinimumWidth(timelineWidth);
m_layoutTimeline->setMaximumWidth(timelineWidth);
}
-void TimelineGraphicsScene::updateControllerLayoutWidth()
-{
- if (m_layoutTimeline->count() < 2)
- return;
- auto root = m_layoutTimeline->itemAt(1);
-
- static_cast<RowTimeline *>(root->graphicsItem())->setEndTime(ruler()->duration());
-}
-
void TimelineGraphicsScene::updateController()
{
setControllerText(m_widgetTimeline->toolbar()->getCurrentController());
@@ -466,19 +458,34 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
g_StudioApp.setLastActiveView(m_widgetTimeline);
- if ((event->modifiers() & Qt::AltModifier) && !m_dragging) {
- if (event->button() == Qt::RightButton && !m_timelinePanning) {
- // Start zooming
- m_timelineZooming = true;
+ if ((event->modifiers() & Qt::AltModifier) && !m_dragging
+ && m_timelineAltModifierMode == TimelineAltModifierMode::None) {
+ if (event->button() == Qt::RightButton) {
+ // Start scaling
+ m_timelineAltModifierMode = TimelineAltModifierMode::ScaleTimeline;
m_pressScreenPos = event->screenPos();
event->accept();
return;
- } else if (event->button() == Qt::MiddleButton && !m_timelineZooming) {
+ } else if (event->button() == Qt::MiddleButton) {
// Start panning
- m_timelinePanning = true;
+ m_timelineAltModifierMode = TimelineAltModifierMode::PanTimeline;
m_pressPos = event->scenePos();
event->accept();
return;
+ } else if (event->button() == Qt::LeftButton) {
+ // Start property graph panning
+ m_pressPos = event->scenePos();
+ QGraphicsItem *item = getItemAt(m_pressPos);
+ if (item && item->type() == TimelineItem::TypeRowTimeline) {
+ RowTimeline *rowTimeline = static_cast<RowTimeline *>(item);
+ if (rowTimeline->propertyGraph()) {
+ m_timelineAltModifierMode = TimelineAltModifierMode::PanPropertyGraph;
+ m_panProperyGraph = rowTimeline->propertyGraph();
+ m_panProperyGraph->startPan();
+ event->accept();
+ return;
+ }
+ }
}
}
@@ -494,10 +501,11 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!m_widgetTimeline->isFullReconstructPending() && event->button() == Qt::LeftButton) {
resetMousePressParams();
m_pressPos = event->scenePos();
- QGraphicsItem *item = itemAt(m_pressPos, QTransform());
+
+ QGraphicsItem *item = getItemAt(m_pressPos);
+
const bool ctrlKeyDown = event->modifiers() & Qt::ControlModifier;
if (item) {
- item = getItemBelowType(TimelineItem::TypePlayHead, item, m_pressPos);
if (item->type() == TimelineItem::TypeRuler) {
m_rulerPressed = true;
m_autoScrollTimelineTimer.start();
@@ -506,9 +514,7 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
m_rowManager->updateFiltering();
updateSnapSteps();
}
- } else if (item->type() == TimelineItem::TypeRowTree
- || item->type() == TimelineItem::TypeRowTreeLabelItem) {
- item = getItemBelowType(TimelineItem::TypeRowTreeLabelItem, item, m_pressPos);
+ } else if (item->type() == TimelineItem::TypeRowTree) {
RowTree *rowTree = static_cast<RowTree *>(item);
m_clickedTreeControlType = rowTree->getClickedControl(m_pressPos);
if (m_clickedTreeControlType == TreeControlType::Shy
@@ -520,7 +526,7 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
// Prepare to change selection to single selection at release if a multiselected
// row is clicked without ctrl.
if (!ctrlKeyDown && m_rowManager->isRowSelected(rowTree)
- && !m_rowManager->isSingleSelected() ) {
+ && !m_rowManager->isSingleSelected()) {
m_releaseSelectRow = rowTree;
}
m_rowManager->selectRow(rowTree, ctrlKeyDown);
@@ -570,11 +576,13 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
m_rowManager->selectRow(m_editedTimelineRow->rowTree(), ctrlKeyDown);
// click position in ruler space
m_editedTimelineRow->startDurationMove(m_pressPos.x() - m_ruler->x());
- } else if (m_clickedTimelineControlType == TimelineControlType::StartHandle
- || m_clickedTimelineControlType == TimelineControlType::EndHandle) {
+ } else if (m_clickedTimelineControlType
+ == TimelineControlType::DurationStartHandle
+ || m_clickedTimelineControlType
+ == TimelineControlType::DurationEndHandle) {
m_editedTimelineRow->updateBoundChildren(
m_clickedTimelineControlType
- == TimelineControlType::StartHandle);
+ == TimelineControlType::DurationStartHandle);
}
m_autoScrollTimelineTimer.start();
}
@@ -594,9 +602,9 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
void TimelineGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
- if (m_timelineZooming) {
- int deltaY = event->screenPos().y() - m_pressScreenPos.y();
+ if (m_timelineAltModifierMode == TimelineAltModifierMode::ScaleTimeline) {
int deltaX = event->screenPos().x() - m_pressScreenPos.x();
+ int deltaY = event->screenPos().y() - m_pressScreenPos.y();
// Zooming in when moving down/right.
int delta = -deltaX - deltaY;
const int threshold = 20;
@@ -607,24 +615,31 @@ void TimelineGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
m_widgetTimeline->toolbar()->onZoomOutButtonClicked();
m_pressScreenPos = event->screenPos();
}
- } else if (m_timelinePanning) {
+ } else if (m_timelineAltModifierMode == TimelineAltModifierMode::PanTimeline) {
int deltaX = event->scenePos().x() - m_pressPos.x();
QScrollBar *scrollbar = m_widgetTimeline->viewTimelineContent()->horizontalScrollBar();
scrollbar->setValue(scrollbar->value() - deltaX);
+ } else if (m_timelineAltModifierMode == TimelineAltModifierMode::PanPropertyGraph) {
+ qreal deltaY = event->scenePos().y() - m_pressPos.y();
+ m_panProperyGraph->pan(deltaY);
}
if (m_editedTimelineRow.isNull())
updateHoverStatus(event->scenePos());
- if (!m_dragging && !m_timelineZooming && !m_timelinePanning
- && m_pressPos != invalidPoint
- && (event->scenePos() - m_pressPos).manhattanLength() > 10) {
+ if (!m_dragging && m_timelineAltModifierMode == TimelineAltModifierMode::None
+ && m_pressPos != invalidPoint && (event->scenePos() - m_pressPos).manhattanLength() > 10) {
m_dragging = true;
}
bool shift = event->modifiers() & Qt::ShiftModifier;
if (m_dragging) {
- if (m_startRowMoverOnNextDrag || m_rowMover->isActive()) {
+ if (m_clickedTimelineControlType & TimelineControlType::IsBezierControl) {
+ if (m_editedTimelineRow && m_editedTimelineRow->propertyGraph()) {
+ m_editedTimelineRow->propertyGraph()->updateBezierControlValue(
+ m_clickedTimelineControlType, event->scenePos());
+ }
+ } else if (m_startRowMoverOnNextDrag || m_rowMover->isActive()) {
// moving rows vertically (reorder/reparent)
if (m_startRowMoverOnNextDrag) {
m_startRowMoverOnNextDrag = false;
@@ -696,14 +711,16 @@ void TimelineGraphicsScene::updateSnapSteps()
// i = 1 is always the scene row (or component root)
for (int i = 2; i < m_layoutTimeline->count(); i++) {
RowTree *rowTree = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
- if (rowTree->hasDurationBar() && rowTree->isVisible()) {
- double startX = rowTree->rowTimeline()->getStartX();
- if (!m_snapSteps.contains(startX))
- m_snapSteps.push_back(startX);
-
- double endX = rowTree->rowTimeline()->getEndX();
- if (!m_snapSteps.contains(endX))
- m_snapSteps.push_back(endX);
+ if (rowTree->isVisible()) {
+ if (rowTree->hasDurationBar()) {
+ double startX = rowTree->rowTimeline()->getStartX();
+ if (!m_snapSteps.contains(startX))
+ m_snapSteps.push_back(startX);
+
+ double endX = rowTree->rowTimeline()->getEndX();
+ if (!m_snapSteps.contains(endX))
+ m_snapSteps.push_back(endX);
+ }
// add keyframes times
if (rowTree->hasPropertyChildren()) {
@@ -723,17 +740,22 @@ TExpandMap &TimelineGraphicsScene::expandMap()
return m_expandMap;
}
+TPropGraphHeightMap &TimelineGraphicsScene::propGraphHeightMap()
+{
+ return m_propGraphHeightMap;
+}
+
void TimelineGraphicsScene::resetMousePressParams()
{
m_autoScrollTimelineTimer.stop();
m_selectionRect->end();
m_rowMover->end();
m_dragging = false;
- m_timelineZooming = false;
- m_timelinePanning = false;
m_startRowMoverOnNextDrag = false;
m_rulerPressed = false;
m_pressedKeyframe = nullptr;
+ m_panProperyGraph = nullptr;
+ m_timelineAltModifierMode = TimelineAltModifierMode::None;
m_clickedTimelineControlType = TimelineControlType::None;
m_editedTimelineRow.clear();
m_releaseSelectRow.clear();
@@ -762,7 +784,7 @@ void TimelineGraphicsScene::snap(double &value, bool snapToPlayHead)
if (snapToPlayHead) {
double playHeadX = m_playHead->x() - TimelineConstants::TREE_BOUND_W
- TimelineConstants::RULER_EDGE_OFFSET;
- if (abs(value - playHeadX) < CStudioPreferences::GetSnapRange()) {
+ if (abs(value - playHeadX) < CStudioPreferences::snapRange()) {
value = playHeadX;
return;
}
@@ -770,22 +792,22 @@ void TimelineGraphicsScene::snap(double &value, bool snapToPlayHead)
// duration edges snap
for (double v : qAsConst(m_snapSteps)) {
- if (abs(value - v) < CStudioPreferences::GetSnapRange()) {
+ if (abs(value - v) < CStudioPreferences::snapRange()) {
value = v;
return;
}
}
// time steps snap
- if (CStudioPreferences::IsTimelineSnappingGridActive()) {
+ if (CStudioPreferences::isTimelineSnappingGridActive()) {
double snapStep = TimelineConstants::RULER_SEC_W * m_ruler->timelineScale();
- if (CStudioPreferences::GetTimelineSnappingGridResolution() == SNAPGRID_HALFSECONDS)
+ if (CStudioPreferences::timelineSnappingGridResolution() == SNAPGRID_HALFSECONDS)
snapStep *= .5;
- else if (CStudioPreferences::GetTimelineSnappingGridResolution() == SNAPGRID_TICKMARKS)
+ else if (CStudioPreferences::timelineSnappingGridResolution() == SNAPGRID_TICKMARKS)
snapStep *= .1;
double snapValue = round(value / snapStep) * snapStep;
- if (abs(value - snapValue) < CStudioPreferences::GetSnapRange())
+ if (abs(value - snapValue) < CStudioPreferences::snapRange())
value = snapValue;
}
}
@@ -797,16 +819,15 @@ void TimelineGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (m_rowMover->isActive()) { // moving rows (reorder/reparent)
commitMoveRows();
} else if (m_pressedKeyframe) {
- // update keyframe movement (time) to binding
m_keyframeManager->commitMoveSelectedKeyframes();
- } else if (m_clickedTimelineControlType == TimelineControlType::StartHandle) {
+ } else if (m_clickedTimelineControlType == TimelineControlType::DurationStartHandle) {
if (!m_editedTimelineRow.isNull()) {
ITimelineTimebar *timebar = m_editedTimelineRow->rowTree()->getBinding()
->GetTimelineItem()->GetTimebar();
timebar->ChangeTime(m_editedTimelineRow->getStartTime(), true);
timebar->CommitTimeChange();
}
- } else if (m_clickedTimelineControlType == TimelineControlType::EndHandle) {
+ } else if (m_clickedTimelineControlType == TimelineControlType::DurationEndHandle) {
if (!m_editedTimelineRow.isNull()) {
ITimelineTimebar *timebar = m_editedTimelineRow->rowTree()->getBinding()
->GetTimelineItem()->GetTimebar();
@@ -824,6 +845,9 @@ void TimelineGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (m_playHead->time() > ruler()->duration())
g_StudioApp.GetCore()->GetDoc()->NotifyTimeChanged(ruler()->duration());
}
+ } else if (m_clickedTimelineControlType & TimelineControlType::IsBezierControl) {
+ if (m_editedTimelineRow->propertyGraph())
+ m_editedTimelineRow->propertyGraph()->commitBezierEdit();
}
} else if (!m_rulerPressed && (!m_releaseSelectRow.isNull() || !itemAt(event->scenePos(),
QTransform()))) {
@@ -833,7 +857,7 @@ void TimelineGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
- if (m_timelineZooming)
+ if (m_timelineAltModifierMode == TimelineAltModifierMode::ScaleTimeline)
updateSnapSteps();
resetMousePressParams();
@@ -845,38 +869,32 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
{
if (event->button() == Qt::LeftButton) {
const QPointF scenePos = event->scenePos();
- QGraphicsItem *item = itemAt(scenePos, QTransform());
+ QGraphicsItem *item = getItemAt(scenePos);
+
if (item) {
- QGraphicsItem *itemBelowPlayhead =
- getItemBelowType(TimelineItem::TypePlayHead, item, scenePos);
- if (item->type() == TimelineItem::TypeRuler
- || itemBelowPlayhead->type() == TimelineItem::TypeRuler) {
- CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ if (item->type() == TimelineItem::TypeRuler) {
g_StudioApp.GetDialogs()->asyncDisplayTimeEditDialog(doc->GetCurrentViewTime(),
doc, PLAYHEAD,
m_keyframeManager);
} else {
- item = itemBelowPlayhead;
if (item->type() == TimelineItem::TypeRowTree) {
- RowTree *treeItem = static_cast<RowTree *>(item);
- if (treeItem->isProperty())
- treeItem->togglePropertyExpanded();
- } else if (item->type() == TimelineItem::TypeRowTreeLabelItem) {
- RowTreeLabelItem *treeLabelItem = static_cast<RowTreeLabelItem *>(item);
- if (treeLabelItem->parentRow()->isProperty()) {
- treeLabelItem->parentRow()->togglePropertyExpanded();
- } else if (!treeLabelItem->isLocked()
- && treeLabelItem->parentRow()->objectType() != OBJTYPE_SCENE
- && treeLabelItem->parentRow()->objectType() != OBJTYPE_IMAGE) {
- int instance = treeLabelItem->parentRow()->instance();
- const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
- ->GetClientDataModelBridge();
- if (bridge->GetObjectType(instance) != OBJTYPE_REFERENCEDMATERIAL
- || bridge->GetSourcePath(instance).isEmpty()) {
- // Tree labels text can be edited with double-click,
- // except for Scene label and basic materials
- treeLabelItem->setEnabled(true);
- treeLabelItem->setFocus();
+ RowTree *rowTree = static_cast<RowTree *>(item);
+ if (rowTree->isProperty()) { // toggle property graph
+ rowTree->togglePropertyExpanded(scenePos);
+ } else {
+ // check label edit
+ QGraphicsItem *topItem = itemAt(scenePos, {});
+ if (topItem->type() == TimelineItem::TypeRowTreeLabel) {
+ RowTreeLabel *rowTreeLabel = static_cast<RowTreeLabel *>(topItem);
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ EStudioObjectType rowObjType = rowTreeLabel->rowTree()->objectType();
+ int instance = rowTreeLabel->rowTree()->instance();
+ if (!rowTreeLabel->isLocked() && !bridge->isBasicMaterial(instance)
+ && rowObjType & ~(OBJTYPE_SCENE | OBJTYPE_IMAGE)) {
+ rowTreeLabel->setEnabled(true);
+ rowTreeLabel->setFocus();
+ }
}
}
} else if (item->type() == TimelineItem::TypeRowTimeline) {
@@ -901,6 +919,17 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
void TimelineGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
{
+ // adjust property graph scale
+ if (wheelEvent->modifiers() & Qt::AltModifier) {
+ const QPointF pos = wheelEvent->scenePos();
+ QGraphicsItem *item = getItemAt(pos);
+ if (item && item->type() == TimelineItem::TypeRowTimeline) {
+ RowTimeline *rowTimeline = static_cast<RowTimeline *>(item);
+ if (rowTimeline->propertyGraph())
+ rowTimeline->propertyGraph()->adjustScale(pos, wheelEvent->delta() > 0);
+ }
+ }
+
// Make sure drag states update on wheel scrolls done during drag
m_lastAutoScrollX = -1.0;
m_lastAutoScrollY = -1.0;
@@ -981,25 +1010,21 @@ bool TimelineGraphicsScene::event(QEvent *event)
void TimelineGraphicsScene::updateHoverStatus(const QPointF &scenePos)
{
bool variantsAreaHovered = false;
- QGraphicsItem *item = itemAt(scenePos, QTransform());
+ QGraphicsItem *item = getItemAt(scenePos);
if (item) {
- item = getItemBelowType(TimelineItem::TypePlayHead, item, scenePos);
// update timeline row cursor
if (item->type() == TimelineItem::TypeRowTimeline) {
- RowTimeline *timelineItem = static_cast<RowTimeline *>(item);
- TimelineControlType controlType = timelineItem->getClickedControl(scenePos);
- if (controlType == TimelineControlType::StartHandle
- || controlType == TimelineControlType::EndHandle) {
+ RowTimeline *rowTimeline = static_cast<RowTimeline *>(item);
+ TimelineControlType controlType = rowTimeline->getClickedControl(scenePos, true);
+ if (controlType == TimelineControlType::DurationStartHandle
+ || controlType == TimelineControlType::DurationEndHandle) {
setMouseCursor(CMouseCursor::CURSOR_RESIZE_LEFTRIGHT);
} else {
resetMouseCursor();
}
- } else if (!m_dragging && (item->type() == TimelineItem::TypeRowTree
- || item->type() == TimelineItem::TypeRowTreeLabelItem)) {
+ } else if (!m_dragging && item->type() == TimelineItem::TypeRowTree) {
// update tree row variants tooltip
- RowTree *rowTree = item->type() == TimelineItem::TypeRowTree
- ? static_cast<RowTree *>(item)
- : static_cast<RowTreeLabelItem *>(item)->parentRow();
+ RowTree *rowTree = static_cast<RowTree *>(item);
if (!rowTree->isProperty()) {
int left = rowTree->clipX();
int right = (int)rowTree->treeWidth() - TimelineConstants::TREE_ICONS_W;
@@ -1065,18 +1090,23 @@ void TimelineGraphicsScene::updateHoverStatus(const QPointF &scenePos)
}
}
-// Return next item below [type] item, or item itself
-// Used at least for skipping PlayHead and RowTreeLabelItem
-QGraphicsItem *TimelineGraphicsScene::getItemBelowType(TimelineItem::ItemType type,
- QGraphicsItem *item,
- const QPointF &scenePos) const
+// This method is similar to itemAt() but if it finds a playhead or tree label items, it returns
+// what is below them
+QGraphicsItem *TimelineGraphicsScene::getItemAt(const QPointF &scenePos) const
{
- if (item->type() == type) {
- const QList<QGraphicsItem *> hoverItems = items(scenePos);
- if (hoverItems.size() > 1)
- return hoverItems.at(1);
+ const QList<QGraphicsItem *> hoverItems = items(scenePos);
+
+ if (!hoverItems.empty()) {
+ QGraphicsItem *item = hoverItems.at(0);
+
+ int typeMask = TimelineItem::TypePlayHead | TimelineItem::TypeRowTreeLabel;
+ if (item->type() & typeMask && hoverItems.size() > 1)
+ item = hoverItems.at(1);
+
+ return item;
}
- return item;
+
+ return nullptr;
}
QPoint TimelineGraphicsScene::getScrollbarOffsets() const
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
index 146009ee..a6e6a1a6 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
@@ -50,14 +50,15 @@ class RowMover;
class RowManager;
class KeyframeManager;
class TimelineControl;
-class IKeyframesManager;
struct Keyframe;
QT_FORWARD_DECLARE_CLASS(QGraphicsLinearLayout)
QT_FORWARD_DECLARE_CLASS(QGraphicsView)
QT_FORWARD_DECLARE_CLASS(QLabel)
-typedef QHash<qt3dsdm::Qt3DSDMInstanceHandle, RowTree::ExpandState> TExpandMap;
+using TExpandMap = QHash<qt3dsdm::Qt3DSDMInstanceHandle, RowTree::ExpandState>;
+using TPropGraphHeightMap = QHash<qt3dsdm::Qt3DSDMInstanceHandle,
+ QHash<qt3dsdm::Qt3DSDMPropertyHandle, int>>;
class TimelineGraphicsScene : public QGraphicsScene
{
@@ -65,12 +66,11 @@ class TimelineGraphicsScene : public QGraphicsScene
public:
explicit TimelineGraphicsScene(TimelineWidget *timelineWidget);
- virtual ~TimelineGraphicsScene();
+ virtual ~TimelineGraphicsScene() override;
void setTimelineScale(int scale);
void setControllerText(const QString &controller);
void updateTimelineLayoutWidth();
- void updateControllerLayoutWidth();
void updateController();
Ruler *ruler() const;
PlayHead *playHead() const;
@@ -88,6 +88,7 @@ public:
void resetMouseCursor();
void updateSnapSteps();
TExpandMap &expandMap();
+ TPropGraphHeightMap &propGraphHeightMap();
void resetMousePressParams();
QLabel *timebarTooltip();
void updateAutoScrolling(double scenePosY);
@@ -111,12 +112,12 @@ protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
private:
+ enum class TimelineAltModifierMode {None, ScaleTimeline, PanTimeline, PanPropertyGraph};
+
void commitMoveRows();
void updateHoverStatus(const QPointF &scenePos);
void snap(double &value, bool snapToPlayHead = true);
- QGraphicsItem *getItemBelowType(TimelineItem::ItemType type,
- QGraphicsItem *item,
- const QPointF &scenePos) const;
+ QGraphicsItem *getItemAt(const QPointF &scenePos) const;
void handleInsertKeyframe();
void handleDeleteChannelKeyframes();
void handleSetTimeBarTime();
@@ -149,10 +150,10 @@ private:
bool m_rulerPressed = false;
Keyframe *m_pressedKeyframe = nullptr;
+ RowTimelinePropertyGraph *m_panProperyGraph = nullptr;
bool m_dragging = false;
bool m_startRowMoverOnNextDrag = false;
- bool m_timelineZooming = false;
- bool m_timelinePanning = false;
+ TimelineAltModifierMode m_timelineAltModifierMode = TimelineAltModifierMode::None;
TimelineControlType m_clickedTimelineControlType = TimelineControlType::None;
TreeControlType m_clickedTreeControlType = TreeControlType::None;
double m_pressPosInKeyframe;
@@ -160,6 +161,7 @@ private:
double m_lastAutoScrollX = -1.0;
double m_lastAutoScrollY = -1.0;
TExpandMap m_expandMap;
+ TPropGraphHeightMap m_propGraphHeightMap;
QPointer<RowTree> m_releaseSelectRow = nullptr;
bool m_autoScrollDownOn = false;
bool m_autoScrollUpOn = false;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
index d37825cb..4b599cbf 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
@@ -93,7 +93,7 @@ TimelineWidget::TimelineWidget(const QSize &preferredSize, QWidget *parent)
, m_graphicsScene(new TimelineGraphicsScene(this))
, m_preferredSize(preferredSize)
{
- int treeWidth = CStudioPreferences::GetTimelineSplitterLocation();
+ int treeWidth = CStudioPreferences::timelineSplitterLocation();
// Mahmoud_TODO: CTimelineTranslationManager should be eventually removed or cleaned. Already
// most of its functionality is implemented in this class
@@ -164,8 +164,7 @@ TimelineWidget::TimelineWidget(const QSize &preferredSize, QWidget *parent)
layoutRoot->addWidget(m_toolbar);
setLayout(layoutRoot);
- g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager(
- static_cast<IKeyframesManager *>(m_graphicsScene->keyframeManager()));
+ g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager(m_graphicsScene->keyframeManager());
// connect graphics scene geometryChanged
connect(m_graphicsScene->widgetRoot(), &QGraphicsWidget::geometryChanged, this, [this]() {
@@ -291,10 +290,6 @@ TimelineWidget::TimelineWidget(const QSize &preferredSize, QWidget *parent)
m_graphicsScene->updateTimelineLayoutWidth();
});
- connect(m_graphicsScene->ruler(), &Ruler::durationChanged, this, [this]() {
- m_graphicsScene->updateControllerLayoutWidth();
- });
-
// data model listeners
g_StudioApp.GetCore()->GetDispatch()->AddPresentationChangeListener(this);
g_StudioApp.GetCore()->GetDispatch()->AddClientPlayChangeListener(this);
@@ -321,8 +316,10 @@ Q3DStudio::CString TimelineWidget::getPlaybackMode()
TimelineWidget::~TimelineWidget()
{
- CStudioPreferences::SetTimelineSplitterLocation(m_graphicsScene->treeWidth());
+ CStudioPreferences::setTimelineSplitterLocation(m_graphicsScene->treeWidth());
+ CStudioPreferences::savePreferences();
m_graphicsScene->keyframeManager()->deselectAllKeyframes();
+ g_StudioApp.GetCore()->GetDoc()->SetKeyframesManager(nullptr);
delete m_BreadCrumbProvider;
}
@@ -388,6 +385,9 @@ void TimelineWidget::OnNewPresentation()
m_connections.push_back(theSignalProvider->ConnectActionDeleted(
std::bind(&TimelineWidget::onActionEvent, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
+ m_connections.push_back(theSignalProvider->ConnectEventSet(
+ std::bind(&TimelineWidget::onActionModifiedEvent, this,
+ std::placeholders::_1)));
// connect property linked/unlinked
m_connections.push_back(theSignalProvider->ConnectPropertyLinked(
@@ -418,12 +418,26 @@ void TimelineWidget::OnNewPresentation()
// Reset timeline time
OnTimeChanged(0);
+
+ // Show timeline widget when presentation is available
+ setVisible(true);
}
void TimelineWidget::OnClosingPresentation()
{
+ // Reset bindings for all property rows
+ for (auto *row : qAsConst(m_handlesMap)) {
+ const auto childProps = row->childProps();
+ for (const auto child : childProps)
+ child->setPropBinding(nullptr);
+ }
+
m_connections.clear();
m_graphicsScene->expandMap().clear();
+ m_graphicsScene->propGraphHeightMap().clear();
+
+ // Hide timeline widget when presentation is closed
+ setVisible(false);
}
void TimelineWidget::OnTimeChanged(long inTime)
@@ -470,6 +484,15 @@ void TimelineWidget::onActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster,
}
}
+void TimelineWidget::runFullReconstruct(bool forceSync)
+{
+ m_fullReconstruct = true;
+ if (forceSync)
+ onAsyncUpdate();
+ else if (!m_asyncUpdateTimer.isActive())
+ m_asyncUpdateTimer.start();
+}
+
void TimelineWidget::insertToHandlesMapRecursive(Qt3DSDMTimelineItemBinding *binding)
{
insertToHandlesMap(binding);
@@ -564,6 +587,7 @@ void TimelineWidget::onAssetDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
m_graphicsScene->rowManager()->deleteRow(row);
m_handlesMap.remove(inInstance);
m_graphicsScene->expandMap().remove(inInstance);
+ m_graphicsScene->propGraphHeightMap().remove(inInstance);
// Ensure row deletions are finalized
if (!m_asyncUpdateTimer.isActive())
m_asyncUpdateTimer.start();
@@ -579,7 +603,6 @@ void TimelineWidget::onAnimationCreated(qt3dsdm::Qt3DSDMInstanceHandle parentIns
Qt3DSDMTimelineItemBinding *binding = getBindingForHandle(parentInstance, m_binding);
if (binding) {
ITimelineItemProperty *propBinding = binding->GetPropertyBinding(property);
-
// create the binding if doesn't exist
if (!propBinding) {
propBinding = binding->GetOrCreatePropertyBinding(property);
@@ -605,6 +628,10 @@ void TimelineWidget::onAnimationCreated(qt3dsdm::Qt3DSDMInstanceHandle parentIns
}
propRow->update();
+ } else {
+ // prop binding exists in the case of undoing changing animation type. Must refresh the
+ // recreated animation handles within the prop binding
+ propBinding->getRowTree()->refreshPropBinding();
}
}
}
@@ -618,6 +645,8 @@ void TimelineWidget::onAnimationDeleted(qt3dsdm::Qt3DSDMInstanceHandle parentIns
Qt3DSDMTimelineItemBinding *binding = getBindingForHandle(parentInstance, m_binding);
if (binding) {
ITimelineItemProperty *propBinding = binding->GetPropertyBinding(property);
+ // this is needed because onAnimationDeleted can be triggered for unlinked property on
+ // different slide in undo/redo situations
bool propAnimated = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
->GetAnimationSystem()->IsPropertyAnimated(parentInstance, property);
@@ -715,6 +744,7 @@ void TimelineWidget::updateActionStates(const QSet<RowTree *> &rows)
states |= RowTree::ActionState::ComponentAction;
}
row->setActionStates(states);
+ row->setActivateActions(binding->getActivateActions());
}
}
@@ -781,7 +811,6 @@ void TimelineWidget::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance
void TimelineWidget::onAsyncUpdate()
{
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
-
if (m_fullReconstruct) {
m_translationManager->Clear();
m_binding = static_cast<Qt3DSDMTimelineItemBinding *>(
@@ -969,6 +998,15 @@ void TimelineWidget::onAsyncUpdate()
m_graphicsScene->rowManager()->finalizeRowDeletions();
}
+void TimelineWidget::onActionModifiedEvent(qt3dsdm::Qt3DSDMActionHandle inAction)
+{
+ // We don't have action owner here, so just do full reconstruct as action
+ // event types are anyway rarely changed.
+ m_fullReconstruct = true;
+ if (!m_asyncUpdateTimer.isActive())
+ m_asyncUpdateTimer.start();
+}
+
void TimelineWidget::onActionEvent(qt3dsdm::Qt3DSDMActionHandle inAction,
qt3dsdm::Qt3DSDMSlideHandle inSlide,
qt3dsdm::Qt3DSDMInstanceHandle inOwner)
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.h
index a45be156..9804a03e 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/TimelineWidget.h
@@ -97,6 +97,7 @@ public:
void SetSize(long inX, long inY) override;
bool isFullReconstructPending() const { return m_fullReconstruct; }
NavigationBar *navigationBar() const { return m_navigationBar; }
+ void runFullReconstruct(bool forceSync = false);
protected:
// DataModel callbacks
@@ -116,6 +117,7 @@ protected:
qt3dsdm::Qt3DSDMPropertyHandle property);
void onActionEvent(qt3dsdm::Qt3DSDMActionHandle inAction, qt3dsdm::Qt3DSDMSlideHandle inSlide,
qt3dsdm::Qt3DSDMInstanceHandle inOwner);
+ void onActionModifiedEvent(qt3dsdm::Qt3DSDMActionHandle inAction);
void onPropertyLinked(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3dsdm::Qt3DSDMPropertyHandle inProperty);
void onPropertyUnlinked(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/NavigationBarItem.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/NavigationBarItem.cpp
index b9b47642..328ac0dc 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/NavigationBarItem.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/NavigationBarItem.cpp
@@ -60,8 +60,8 @@ void NavigationBarItem::setIcon(const QPixmap &pixmap)
void NavigationBarItem::setText(const QString &text)
{
- QColor textColor = isEnabled() ? CStudioPreferences::GetNormalColor()
- : CStudioPreferences::GetInactiveColor();
+ QColor textColor = isEnabled() ? CStudioPreferences::normalColor()
+ : CStudioPreferences::inactiveColor();
const QString fonttemplate = tr("<font color='%1'>%2</font>");
m_textLabel.setText(fonttemplate.arg(textColor.name(), text));
}
@@ -69,7 +69,7 @@ void NavigationBarItem::setText(const QString &text)
void NavigationBarItem::setHighlight(bool highlight)
{
if (highlight) {
- QColor bgColor = CStudioPreferences::GetMouseOverHighlightColor();
+ QColor bgColor = CStudioPreferences::mouseOverHighlightColor();
QString bgColorStyle = QStringLiteral("background-color: ") + bgColor.name();
setStyleSheet(bgColorStyle);
} else {
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp
index 3ddfdcad..1a847112 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp
@@ -54,7 +54,8 @@ void PlayHead::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
static const QPixmap pixHead2x = QPixmap(":/images/PlaybackHead@2x.png");
static const int PLAY_HEAD_H = 999999; // theoretically big enough height
- painter->drawPixmap(-TimelineConstants::PLAYHEAD_W * .5, 0, hiResIcons ? pixHead2x : pixHead);
+ painter->drawPixmap(int(-TimelineConstants::PLAYHEAD_W * .5f), 0, hiResIcons ? pixHead2x
+ : pixHead);
painter->setPen(CStudioPreferences::timelinePlayheadLineColor());
painter->drawLine(0, 0, 0, PLAY_HEAD_H);
}
@@ -75,21 +76,9 @@ void PlayHead::setTime(long time)
updatePosition();
}
-void PlayHead::setPosition(double posX)
-{
- posX = qBound(TimelineConstants::RULER_EDGE_OFFSET, posX, m_ruler->duration()
- * TimelineConstants::RULER_MILLI_W * m_ruler->timelineScale()
- + TimelineConstants::RULER_EDGE_OFFSET);
-
- setX(m_ruler->x() + posX);
- m_time = (posX - TimelineConstants::RULER_EDGE_OFFSET)
- / (TimelineConstants::RULER_MILLI_W * m_ruler->timelineScale());
-}
-
void PlayHead::updatePosition()
{
- setX(m_ruler->x() + TimelineConstants::RULER_EDGE_OFFSET
- + m_time * TimelineConstants::RULER_MILLI_W * m_ruler->timelineScale());
+ setX(m_ruler->x() + TimelineConstants::RULER_EDGE_OFFSET + m_ruler->timeToDistance(m_time));
}
long PlayHead::time() const
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.h
index 395e6317..852e6aff 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.h
@@ -42,7 +42,6 @@ public:
explicit PlayHead(Ruler *m_ruler);
void setHeight(int height);
- void setPosition(double posX); // set x poisiotn
void updatePosition(); // sync x poisiotn based on time value
void setTime(long time); // set time (sets x based on time (ms) input)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
@@ -52,7 +51,7 @@ public:
private:
long m_time = 0;
- Ruler *m_ruler;
+ Ruler *m_ruler = nullptr;
};
#endif // PLAYHEAD_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp
index 25b66911..b2a8f6dc 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp
@@ -52,6 +52,8 @@
#include <QtWidgets/qlabel.h>
#include <QtCore/qdatetime.h>
+using namespace TimelineConstants;
+
RowTimeline::RowTimeline()
: InteractiveTimelineItem()
{
@@ -104,10 +106,13 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
if (!y()) // prevents flickering when the row is just inserted to the layout
return;
- const int currentHeight = size().height() - 1;
+ const int currHeight = size().height() - 1;
- if (isColorProperty() && !m_keyframes.empty()) {
- drawColorPropertyGradient(painter, widget->width());
+ if (m_isColorProperty && m_drawColorGradient && !m_keyframes.empty()) {
+ QRect gradRect(rowTree()->m_scene->ruler()->viewportX(), 0, widget->width(), currHeight);
+ if (gradRect.x() < RULER_EDGE_OFFSET)
+ gradRect.setX(int(RULER_EDGE_OFFSET));
+ drawColorPropertyGradient(painter, gradRect);
} else {
// Background
QColor bgColor;
@@ -119,28 +124,30 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
bgColor = CStudioPreferences::timelineRowColorOver();
else
bgColor = CStudioPreferences::timelineRowColorNormal();
- painter->fillRect(0, 0, size().width(), currentHeight, bgColor);
+ painter->fillRect(0, 0, size().width(), currHeight, bgColor);
}
const double edgeOffset = TimelineConstants::RULER_EDGE_OFFSET;
// Duration. Draw duration bar (for scene/component root) also if it has
- // datainput controller
+ // datainput controller.
if (m_rowTree->hasDurationBar() || m_controllerDataInput.size()) {
painter->save();
+ // do not draw anything beyond bar area left end
+ auto startXActual = edgeOffset + qMax(0.0, m_startX);
// fully outside ancestors' limits, draw fully hashed
if (m_minStartX > m_endX || m_maxEndX < m_startX) {
painter->setBrush(QBrush(CStudioPreferences::timelineRowColorDurationOff1(),
Qt::BDiagPattern));
painter->setPen(Qt::NoPen);
- painter->fillRect(QRect(edgeOffset + m_startX, 0, m_endX - m_startX, currentHeight),
+ painter->fillRect(startXActual, 0, edgeOffset + m_endX - startXActual, currHeight,
CStudioPreferences::timelineRowColorDurationOff2());
- painter->drawRect(QRect(edgeOffset + m_startX, 0, m_endX - m_startX, currentHeight));
+ painter->drawRect(startXActual, 0, edgeOffset + m_endX - startXActual, currHeight);
painter->setPen(QPen(CStudioPreferences::timelineRowColorDurationEdge(), 2));
- painter->drawLine(edgeOffset + m_startX, 0, edgeOffset + m_startX, currentHeight);
- painter->drawLine(edgeOffset + m_endX, 0, edgeOffset + m_endX, currentHeight);
+ painter->drawLine(startXActual, 0, startXActual, currHeight);
+ painter->drawLine(edgeOffset + m_endX, 0, edgeOffset + m_endX, currHeight);
} else {
// draw main duration part
double x = edgeOffset + qMax(m_startX, m_minStartX);
@@ -149,39 +156,36 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
painter->setPen(Qt::NoPen);
- if (m_controllerDataInput.size()) {
- painter->fillRect(QRect(x, 0, w, currentHeight),
- CStudioPreferences::dataInputColor());
- } else if (m_rowTree->indexInLayout() != 1) {
- painter->fillRect(QRect(x, 0, w, currentHeight), m_barColor);
- }
+ if (m_controllerDataInput.size())
+ painter->fillRect(QRect(x, 0, w, currHeight), CStudioPreferences::dataInputColor());
+ else if (m_rowTree->indexInLayout() != 1)
+ painter->fillRect(QRect(x, 0, w, currHeight), m_barColor);
if (m_state == Selected) {
// draw selection overlay on bar
- painter->fillRect(QRect(x, marginY, w, currentHeight - marginY * 2),
+ painter->fillRect(QRect(x, marginY, w, currHeight - marginY * 2),
CStudioPreferences::timelineRowColorDurationSelected());
}
if (m_controllerDataInput.size()) {
- static const QPixmap pixDataInput = QPixmap(":/images/Objects-DataInput-White.png");
- static const QPixmap pixDataInput2x
- = QPixmap(":/images/Objects-DataInput-White@2x.png");
+ static const QPixmap pixDataInput(":/images/Objects-DataInput-White.png");
+ static const QPixmap pixDataInput2x(":/images/Objects-DataInput-White@2x.png");
static const QFontMetrics fm(painter->font());
// need clip region to limit datainput icon visibility to the same rect as we use
// for text
- painter->setClipRect(x, 0, w, currentHeight);
+ painter->setClipRect(x, 0, w, currHeight);
painter->setClipping(true);
painter->setPen(QPen(CStudioPreferences::textColor(), 2));
// +5 added to text location to make margin comparable to other datainput controls
- painter->drawText(QRect(x + pixDataInput.width() + 5, 0, w, currentHeight),
+ painter->drawText(QRect(x + pixDataInput.width() + 5, 0, w, currHeight),
m_controllerDataInput, QTextOption(Qt::AlignCenter));
// place the icon in front of the text
int textwidth = fm.width(m_controllerDataInput);
- int iconx = x + (w - textwidth) / 2;
- if (iconx < x)
- iconx = x;
- painter->drawPixmap(iconx, marginY, hiResIcons ? pixDataInput2x : pixDataInput);
+ int iconX = x + (w - textwidth) / 2;
+ if (iconX < x)
+ iconX = x;
+ painter->drawPixmap(iconX, marginY, hiResIcons ? pixDataInput2x : pixDataInput);
painter->setPen(Qt::NoPen);
painter->setClipping(false);
}
@@ -191,55 +195,63 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
Qt::BDiagPattern));
if (m_startX < m_minStartX) {
painter->setPen(Qt::NoPen);
- painter->fillRect(QRect(edgeOffset + m_startX, 0, m_minStartX - m_startX,
- currentHeight),
+ painter->fillRect(QRect(startXActual, 0, qMin(m_minStartX - m_startX, m_minStartX),
+ currHeight),
CStudioPreferences::timelineRowColorDurationOff2());
- painter->drawRect(QRect(edgeOffset + m_startX, 0, m_minStartX - m_startX,
- currentHeight));
+ painter->drawRect(QRect(startXActual, 0, qMin(m_minStartX - m_startX, m_minStartX),
+ currHeight));
painter->setPen(CStudioPreferences::timelineRowColorDurationEdge());
- painter->drawLine(edgeOffset + m_minStartX, 0, edgeOffset + m_minStartX,
- currentHeight);
+ painter->drawLine(startXActual, 0, startXActual, currHeight);
}
// draw hashed part after
if (m_endX > m_maxEndX) {
painter->setPen(Qt::NoPen);
- painter->fillRect(QRect(edgeOffset + m_maxEndX, 0, m_endX - m_maxEndX,
- currentHeight),
+ painter->fillRect(QRect(edgeOffset + m_maxEndX, 0, m_endX - m_maxEndX, currHeight),
CStudioPreferences::timelineRowColorDurationOff2());
- painter->drawRect(QRect(edgeOffset + m_maxEndX, 0, m_endX - m_maxEndX,
- currentHeight));
+ painter->drawRect(QRect(edgeOffset + m_maxEndX, 0, m_endX - m_maxEndX, currHeight));
painter->setPen(CStudioPreferences::timelineRowColorDurationEdge());
- painter->drawLine(edgeOffset + m_maxEndX, 0, edgeOffset + m_maxEndX, currentHeight);
+ painter->drawLine(edgeOffset + m_maxEndX, 0, edgeOffset + m_maxEndX, currHeight);
}
if (m_rowTree->indexInLayout() != 1) {
painter->setPen(QPen(CStudioPreferences::timelineRowColorDurationEdge(), 2));
- painter->drawLine(edgeOffset + m_startX, 0, edgeOffset + m_startX, currentHeight);
- painter->drawLine(edgeOffset + m_endX, 0, edgeOffset + m_endX, currentHeight);
+ painter->drawLine(startXActual, 0, startXActual, currHeight);
+ painter->drawLine(edgeOffset + m_endX, 0, edgeOffset + m_endX, currHeight);
}
+
+ // Paint possible timeline actions
+ auto actions = m_rowTree->m_activateActions;
+ bool paintActivate = actions.testFlag(ITimelineItem::ActivateAction::Activate);
+ bool paintDeactivate = actions.testFlag(ITimelineItem::ActivateAction::Deactivate);
+ int aw = TimelineConstants::ACTION_W;
+ QColor aColor = CStudioPreferences::timelineActionColor();
+ if (paintActivate)
+ painter->fillRect(QRect(x - aw/2, 0, aw, currHeight), aColor);
+ if (paintDeactivate)
+ painter->fillRect(QRect(x + w - aw/2, 0, aw, currHeight), aColor);
+
}
painter->restore();
}
if (m_propertyGraph) { // Property graph
- QRectF graphRect(edgeOffset, 0, widget->width(), currentHeight);
+ QRectF graphRect(rowTree()->m_scene->ruler()->viewportX(), 0, widget->width(), currHeight);
m_propertyGraph->paintGraphs(painter, graphRect);
}
// Keyframes
const qreal keyFrameH = 16.0;
const qreal keyFrameHalfH = keyFrameH / 2.0;
- const qreal keyFrameY = (qMin(currentHeight, TimelineConstants::ROW_H) / 2.0) - keyFrameHalfH;
+ const qreal keyFrameY = (qMin(currHeight, TimelineConstants::ROW_H) / 2.0) - keyFrameHalfH;
const qreal hiddenKeyFrameY = keyFrameY + (keyFrameH * 2.0 / 3.0) + 2.0;
const qreal keyFrameOffset = hiResIcons ? 8 : 7.5;
// Hidden descendant keyframe indicators
if (!m_rowTree->expanded()) {
- static const QPixmap pixKeyframeHidden = QPixmap(":/images/keyframe-hidden-normal.png");
- static const QPixmap pixKeyframeHidden2x
- = QPixmap(":/images/keyframe-hidden-normal@2x.png");
+ static const QPixmap pixKeyframeHidden(":/images/keyframe-hidden-normal.png");
+ static const QPixmap pixKeyframeHidden2x(":/images/keyframe-hidden-normal@2x.png");
QVector<long> childKeyframeTimes;
collectChildKeyframeTimes(childKeyframeTimes);
@@ -255,30 +267,26 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
}
if (m_rowTree->hasPropertyChildren()) { // object row keyframes
- static const QPixmap pixKeyframeMasterDisabled
- = QPixmap(":/images/Keyframe-Master-Disabled.png");
- static const QPixmap pixKeyframeMasterNormal
- = QPixmap(":/images/Keyframe-Master-Normal.png");
- static const QPixmap pixKeyframeMasterSelected
- = QPixmap(":/images/Keyframe-Master-Selected.png");
- static const QPixmap pixKeyframeMasterDynamicDisabled
- = QPixmap(":/images/Keyframe-MasterDynamic-Disabled.png");
- static const QPixmap pixKeyframeMasterDynamicNormal
- = QPixmap(":/images/Keyframe-MasterDynamic-Normal.png");
- static const QPixmap pixKeyframeMasterDynamicSelected
- = QPixmap(":/images/Keyframe-MasterDynamic-Selected.png");
- static const QPixmap pixKeyframeMasterDisabled2x
- = QPixmap(":/images/Keyframe-Master-Disabled@2x.png");
- static const QPixmap pixKeyframeMasterNormal2x
- = QPixmap(":/images/Keyframe-Master-Normal@2x.png");
- static const QPixmap pixKeyframeMasterSelected2x
- = QPixmap(":/images/Keyframe-Master-Selected@2x.png");
- static const QPixmap pixKeyframeMasterDynamicDisabled2x
- = QPixmap(":/images/Keyframe-MasterDynamic-Disabled@2x.png");
- static const QPixmap pixKeyframeMasterDynamicNormal2x
- = QPixmap(":/images/Keyframe-MasterDynamic-Normal@2x.png");
- static const QPixmap pixKeyframeMasterDynamicSelected2x
- = QPixmap(":/images/Keyframe-MasterDynamic-Selected@2x.png");
+ static const QPixmap pixKeyframeMasterDisabled(":/images/Keyframe-Master-Disabled.png");
+ static const QPixmap pixKeyframeMasterNormal(":/images/Keyframe-Master-Normal.png");
+ static const QPixmap pixKeyframeMasterSelected(":/images/Keyframe-Master-Selected.png");
+ static const QPixmap pixKeyframeMasterDynamicDisabled(":/images/Keyframe-MasterDynamic-"
+ "Disabled.png");
+ static const QPixmap pixKeyframeMasterDynamicNormal(":/images/Keyframe-MasterDynamic-Normal"
+ ".png");
+ static const QPixmap pixKeyframeMasterDynamicSelected(":/images/Keyframe-MasterDynamic-"
+ "Selected.png");
+ static const QPixmap pixKeyframeMasterDisabled2x(":/images/Keyframe-Master-Disabled@2x"
+ ".png");
+ static const QPixmap pixKeyframeMasterNormal2x(":/images/Keyframe-Master-Normal@2x.png");
+ static const QPixmap pixKeyframeMasterSelected2x(":/images/Keyframe-Master-Selected@2x"
+ ".png");
+ static const QPixmap pixKeyframeMasterDynamicDisabled2x(":/images/Keyframe-MasterDynamic-"
+ "Disabled@2x.png");
+ static const QPixmap pixKeyframeMasterDynamicNormal2x(":/images/Keyframe-MasterDynamic-"
+ "Normal@2x.png");
+ static const QPixmap pixKeyframeMasterDynamicSelected2x(":/images/Keyframe-MasterDynamic-"
+ "Selected@2x.png");
for (auto keyframe : qAsConst(m_keyframes)) {
QPixmap pixmap;
if (m_rowTree->locked()) {
@@ -287,7 +295,7 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
: pixKeyframeMasterDynamicDisabled;
} else {
pixmap = hiResIcons ? pixKeyframeMasterDisabled2x
- : pixKeyframeMasterDisabled;
+ : pixKeyframeMasterDisabled;
}
} else if (keyframe->selected()) {
if (keyframe->dynamic) {
@@ -321,30 +329,27 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
}
}
} else if (m_rowTree->isProperty()) { // property row keyframes
- static const QPixmap pixKeyframePropertyDisabled
- = QPixmap(":/images/Keyframe-Property-Disabled.png");
- static const QPixmap pixKeyframePropertyNormal
- = QPixmap(":/images/Keyframe-Property-Normal.png");
- static const QPixmap pixKeyframePropertySelected
- = QPixmap(":/images/Keyframe-Property-Selected.png");
- static const QPixmap pixKeyframePropertyDynamicDisabled
- = QPixmap(":/images/Keyframe-PropertyDynamic-Disabled.png");
- static const QPixmap pixKeyframePropertyDynamicNormal
- = QPixmap(":/images/Keyframe-PropertyDynamic-Normal.png");
- static const QPixmap pixKeyframePropertyDynamicSelected
- = QPixmap(":/images/Keyframe-PropertyDynamic-Selected.png");
- static const QPixmap pixKeyframePropertyDisabled2x
- = QPixmap(":/images/Keyframe-Property-Disabled@2x.png");
- static const QPixmap pixKeyframePropertyNormal2x
- = QPixmap(":/images/Keyframe-Property-Normal@2x.png");
- static const QPixmap pixKeyframePropertySelected2x
- = QPixmap(":/images/Keyframe-Property-Selected@2x.png");
- static const QPixmap pixKeyframePropertyDynamicDisabled2x
- = QPixmap(":/images/Keyframe-PropertyDynamic-Disabled@2x.png");
- static const QPixmap pixKeyframePropertyDynamicNormal2x
- = QPixmap(":/images/Keyframe-PropertyDynamic-Normal@2x.png");
- static const QPixmap pixKeyframePropertyDynamicSelected2x
- = QPixmap(":/images/Keyframe-PropertyDynamic-Selected@2x.png");
+ static const QPixmap pixKeyframePropertyDisabled(":/images/Keyframe-Property-Disabled.png");
+ static const QPixmap pixKeyframePropertyNormal(":/images/Keyframe-Property-Normal.png");
+ static const QPixmap pixKeyframePropertySelected(":/images/Keyframe-Property-Selected.png");
+ static const QPixmap pixKeyframePropertyDynamicDisabled(":/images/Keyframe-PropertyDynamic-"
+ "Disabled.png");
+ static const QPixmap pixKeyframePropertyDynamicNormal(":/images/Keyframe-PropertyDynamic-"
+ "Normal.png");
+ static const QPixmap pixKeyframePropertyDynamicSelected(":/images/Keyframe-PropertyDynamic-"
+ "Selected.png");
+ static const QPixmap pixKeyframePropertyDisabled2x(":/images/Keyframe-Property-Disabled@2x"
+ ".png");
+ static const QPixmap pixKeyframePropertyNormal2x(":/images/Keyframe-Property-Normal@2x"
+ ".png");
+ static const QPixmap pixKeyframePropertySelected2x(":/images/Keyframe-Property-Selected@2x"
+ ".png");
+ static const QPixmap pixKeyframePropertyDynamicDisabled2x(":/images/Keyframe-Property"
+ "Dynamic-Disabled@2x.png");
+ static const QPixmap pixKeyframePropertyDynamicNormal2x(":/images/Keyframe-PropertyDynamic-"
+ "Normal@2x.png");
+ static const QPixmap pixKeyframePropertyDynamicSelected2x(":/images/Keyframe-Property"
+ "Dynamic-Selected@2x.png");
for (auto keyframe : qAsConst(m_keyframes)) {
QPixmap pixmap;
if (m_rowTree->locked()) {
@@ -382,44 +387,30 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
}
}
-bool RowTimeline::isColorProperty() const
+void RowTimeline::toggleColorGradient()
{
- ITimelineItemProperty *propBinding = m_rowTree->propBinding();
- if (propBinding) {
- qt3dsdm::TDataTypePair type = propBinding->GetType();
- if (m_rowTree->isProperty()
- && type.first == qt3dsdm::DataModelDataType::Float4
- && type.second == qt3dsdm::AdditionalMetaDataType::Color) {
- return true;
- }
- }
- return false;
+ m_drawColorGradient = !m_drawColorGradient;
+ update();
}
-void RowTimeline::drawColorPropertyGradient(QPainter *painter, int width)
+void RowTimeline::drawColorPropertyGradient(QPainter *painter, const QRect &rect)
{
- // Gradient scaled width, or at least widget width
- double minWidth = width;
- double timelineScale = m_rowTree->m_scene->ruler()->timelineScale();
- double scaledWidth = width * (timelineScale / 2);
- width = qMax(minWidth, scaledWidth);
-
ITimelineItemProperty *propBinding = m_rowTree->propBinding();
- QLinearGradient bgGradient(0, 0, width, 0);
-
- for (auto keyframe : qAsConst(m_keyframes)) {
- double xPos = m_rowTree->m_scene->ruler()->timeToDistance(keyframe->time);
- double gradPos = xPos / width;
- gradPos = qBound(0.0, gradPos, 1.0);
- QColor currentColor;
- // Get the color at the specified time.
- currentColor.setRed(propBinding->GetChannelValueAtTime(0, keyframe->time));
- currentColor.setGreen(propBinding->GetChannelValueAtTime(1, keyframe->time));
- currentColor.setBlue(propBinding->GetChannelValueAtTime(2, keyframe->time));
- bgGradient.setColorAt(gradPos, currentColor);
+ QLinearGradient bgGradient(rect.topLeft(), rect.topRight());
+ for (int x = rect.x(); x < rect.right() + 20; x += 20) { // 20 = sampling step in pixels
+ if (x > rect.right())
+ x = int(rect.right());
+ long time = rowTree()->m_scene->ruler()->distanceToTime(x - RULER_EDGE_OFFSET);
+ double ratio = qBound(0.0, double(x - rect.x()) / rect.width(), 1.0);
+
+ bgGradient.setColorAt(ratio, QColor::fromRgbF(
+ qBound(0.0, double(propBinding->GetChannelValueAtTime(0, time)), 1.0),
+ qBound(0.0, double(propBinding->GetChannelValueAtTime(1, time)), 1.0),
+ qBound(0.0, double(propBinding->GetChannelValueAtTime(2, time)), 1.0),
+ qBound(0.0, double(propBinding->GetChannelValueAtTime(3, time)), 1.0)));
}
- painter->fillRect(TimelineConstants::RULER_EDGE_OFFSET, 0,
- width, size().height() - 1, bgGradient);
+
+ painter->fillRect(rect, bgGradient);
}
Keyframe *RowTimeline::getClickedKeyframe(const QPointF &scenePos)
@@ -498,7 +489,6 @@ void RowTimeline::updateKeyframesFromBinding(const QList<int> &properties)
for (int i = 0; i < child->m_PropBinding->GetKeyframeCount(); i++) {
Qt3DSDMTimelineKeyframe *kf = static_cast<Qt3DSDMTimelineKeyframe *>
(child->m_PropBinding->GetKeyframeByIndex(i));
-
Keyframe *kfUI = new Keyframe(kf->GetTime(), child->rowTimeline());
kfUI->binding = kf;
kfUI->dynamic = kf->IsDynamic();
@@ -565,15 +555,25 @@ void RowTimeline::updateKeyframes()
}
}
-TimelineControlType RowTimeline::getClickedControl(const QPointF &scenePos) const
+/**
+ * Get the clicked control in a timeline row.
+ * @param scenePos click position in scene coordinates space
+ * @param isHover when true this is a hover, else a click
+ * @return
+ */
+TimelineControlType RowTimeline::getClickedControl(const QPointF &scenePos, bool isHover) const
{
- if (!m_rowTree->hasDurationBar())
+ QPointF p = mapFromScene(scenePos.x(), scenePos.y());
+ p.setX(p.x() - TimelineConstants::RULER_EDGE_OFFSET);
+
+ if (!m_rowTree->hasDurationBar()) {
+ if (m_propertyGraph && !m_rowTree->locked())
+ return m_propertyGraph->getClickedBezierControl(p, isHover);
+
return TimelineControlType::None;
+ }
if (!m_rowTree->locked()) {
- QPointF p = mapFromScene(scenePos.x(), scenePos.y());
- p.setX(p.x() - TimelineConstants::RULER_EDGE_OFFSET);
-
const int halfHandle = TimelineConstants::DURATION_HANDLE_W * .5;
// Never choose start handle if end time is zero, as you cannot adjust it in that case
bool startHandle = p.x() > m_startX - halfHandle && p.x() < m_startX + halfHandle
@@ -585,10 +585,10 @@ TimelineControlType RowTimeline::getClickedControl(const QPointF &scenePos) cons
endHandle = !startHandle;
}
if (startHandle)
- return TimelineControlType::StartHandle;
+ return TimelineControlType::DurationStartHandle;
else if (endHandle)
- return TimelineControlType::EndHandle;
- else if (p.x() > m_startX && p.x() < m_endX && !rowTree()->locked())
+ return TimelineControlType::DurationEndHandle;
+ else if (p.x() > m_startX && p.x() < m_endX)
return TimelineControlType::Duration;
}
@@ -636,9 +636,6 @@ void RowTimeline::clearBoundChildren()
// move the duration area (start/end x)
void RowTimeline::moveDurationBy(double dx)
{
- if (m_startX + dx < 0)
- dx = -m_startX;
-
m_startX += dx;
m_endX += dx;
@@ -654,8 +651,10 @@ void RowTimeline::moveDurationBy(double dx)
// move keyframes with the row
if (!m_rowTree->isProperty()) { // make sure we don't move the keyframes twice
- for (Keyframe *keyframe : qAsConst(m_keyframes))
- keyframe->time += rowTree()->m_scene->ruler()->distanceToTime(dx);
+ for (Keyframe *keyframe : qAsConst(m_keyframes)) {
+ keyframe->time += rowTree()->m_scene->ruler()->distanceToTime(
+ (m_startX + dx < 0) ? 0 : dx);
+ }
}
update();
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h
index 00c81696..c28dfdcd 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h
@@ -69,7 +69,7 @@ public:
void removeKeyframe(Keyframe *keyframe);
void updateKeyframesFromBinding(const QList<int> &properties);
void updateDurationFromBinding();
- TimelineControlType getClickedControl(const QPointF &scenePos) const;
+ TimelineControlType getClickedControl(const QPointF &scenePos, bool isHover = false) const;
double getStartX() const;
double getEndX() const;
long getStartTime() const;
@@ -85,6 +85,9 @@ public:
QList<Keyframe *> getKeyframesInRange(const QRectF &rect) const;
QList<Keyframe *> keyframes() const;
void showToolTip(const QPointF &pos);
+ void toggleColorGradient();
+ bool isColorProperty() const { return m_isColorProperty; }
+ RowTimelinePropertyGraph *propertyGraph() const { return m_propertyGraph; }
protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
@@ -97,8 +100,7 @@ private:
void updateChildrenMaxEndXRecursive(RowTree *rowTree);
void updateCommentItem();
void updateCommentItemPos();
- void drawColorPropertyGradient(QPainter *painter, int width);
- bool isColorProperty() const;
+ void drawColorPropertyGradient(QPainter *painter, const QRect &rect);
QString formatTime(long millis) const;
void collectChildKeyframeTimes(QVector<long> &childKeyframeTimes);
@@ -114,6 +116,8 @@ private:
double m_minStartX = 0;
double m_maxEndX = 0;
bool m_isProperty = false; // used in the destructor
+ bool m_isColorProperty = false;
+ bool m_drawColorGradient = true;
QString m_controllerDataInput;
QList<Keyframe *> m_keyframes;
QColor m_barColor;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.cpp
index 7861bb19..526d1961 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.cpp
@@ -32,6 +32,12 @@
#include "KeyframeManager.h"
#include "MainFrm.h"
#include "StudioApp.h"
+#include "Core.h"
+#include "Doc.h"
+#include "IDocumentEditor.h"
+#include "Qt3DSDMStudioSystem.h"
+#include "SlideSystem.h"
+#include "StudioPreferences.h"
#include "TimelineControl.h"
#include "Bindings/ITimelineItemBinding.h"
#include "TimelineGraphicsScene.h"
@@ -140,6 +146,26 @@ void RowTimelineContextMenu::initialize()
&RowTimelineContextMenu::setKeyframeTime);
addAction(m_setKeyframeTimeAction);
} else {
+ m_animType = addMenu(tr("Animation type"));
+ QAction *actionLinear = m_animType->addAction(tr("Linear"));
+ QAction *actionEase = m_animType->addAction(tr("Ease In/Out"));
+ QAction *actionBezier = m_animType->addAction(tr("Bezier"));
+ actionLinear->setData(qt3dsdm::EAnimationTypeLinear);
+ actionLinear->setCheckable(true);
+ actionEase->setData(qt3dsdm::EAnimationTypeEaseInOut);
+ actionEase->setCheckable(true);
+ actionBezier->setData(qt3dsdm::EAnimationTypeBezier);
+ actionBezier->setCheckable(true);
+ connect(m_animType, &QMenu::triggered, this, &RowTimelineContextMenu::onAnimTypeChange);
+ if (m_rowTree->isProperty()) {
+ qt3dsdm::EAnimationType animaType = m_rowTree->propBinding()->animationType();
+ if (animaType == qt3dsdm::EAnimationTypeLinear)
+ actionLinear->setChecked(true);
+ else if (animaType == qt3dsdm::EAnimationTypeEaseInOut)
+ actionEase->setChecked(true);
+ else if (animaType == qt3dsdm::EAnimationTypeBezier)
+ actionBezier->setChecked(true);
+ }
m_setTimeBarColorAction = new QAction(tr("Change Time Bar Color..."), this);
connect(m_setTimeBarColorAction, &QAction::triggered, this,
&RowTimelineContextMenu::changeTimeBarColor);
@@ -170,7 +196,12 @@ void RowTimelineContextMenu::showEvent(QShowEvent *event)
m_pasteKeyframesAction->setEnabled(m_keyframeManager->hasCopiedKeyframes());
m_deleteSelectedKeyframesAction->setEnabled(m_keyframeManager->hasSelectedKeyframes());
m_deleteRowKeyframesAction->setEnabled(!m_rowTree->rowTimeline()->keyframes().empty());
- if (!m_keyframe) {
+ if (m_keyframe) {
+ RowTree *row = propRow ? m_rowTree : m_keyframe->rowProperty->rowTree();
+ qt3dsdm::EAnimationType animaType = row->propBinding()->animationType();
+ m_setInterpolationAction->setEnabled(animaType == qt3dsdm::EAnimationTypeEaseInOut);
+ } else {
+ m_animType->setEnabled(propRow);
m_setTimeBarColorAction->setEnabled(m_rowTree->hasDurationBar());
m_setTimeBarTimeAction->setEnabled(m_rowTree->hasDurationBar());
}
@@ -178,6 +209,88 @@ void RowTimelineContextMenu::showEvent(QShowEvent *event)
QMenu::showEvent(event);
}
+void RowTimelineContextMenu::onAnimTypeChange(QAction *action)
+{
+ if (!action->isChecked())
+ return;
+
+ using namespace qt3dsdm;
+
+ // m_rowTree in this method is guaranteed to be a property row
+
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ IAnimationCore *animCore = doc->GetAnimationCore();
+ ISlideSystem *slideSys = doc->GetStudioSystem()->GetSlideSystem();
+
+ Q3DStudio::ScopedDocumentEditor editor(*doc, tr("Set Animation Type"), __FILE__, __LINE__);
+
+ EAnimationType animType = EAnimationType(action->data().toInt());
+ Qt3DSDMInstanceHandle instance = m_rowTree->parentRow()->instance();
+ Qt3DSDMPropertyHandle property = m_rowTree->propBinding()->getPropertyHandle();
+
+ Qt3DSDMSlideHandle slide = slideSys->IsPropertyLinked(instance, property)
+ ? slideSys->GetAssociatedSlide(instance) : doc->GetActiveSlide();
+ TCharStr propType = doc->GetStudioSystem()->GetPropertySystem()->GetName(property);
+
+ std::vector<qt3dsdm::Qt3DSDMAnimationHandle> animHandles
+ = m_rowTree->propBinding()->animationHandles();
+ for (size_t i = 0; i < animHandles.size(); ++i) {
+ qt3dsdm::TKeyframeHandleList keyframeHandles;
+ animCore->GetKeyframes(animHandles[i], keyframeHandles);
+ if (animType == EAnimationTypeLinear) {
+ QVector<SLinearKeyframe> keyframes;
+ for (Qt3DSDMKeyframeHandle kfHandle : keyframeHandles) {
+ TKeyframe kfData = animCore->GetKeyframeData(kfHandle);
+ keyframes.append(SLinearKeyframe(getKeyframeTime(kfData),
+ getKeyframeValue(kfData)));
+ }
+ long numFloatsPerKeyframe = sizeof(SLinearKeyframe) / sizeof(float);
+ long numValues = long(keyframeHandles.size()) * numFloatsPerKeyframe;
+ editor->CreateOrSetAnimation(slide, instance, propType.wide_str(), long(i),
+ animType,
+ reinterpret_cast<float *>(keyframes.begin()),
+ numValues);
+ } else if (animType == EAnimationTypeEaseInOut) {
+ float easeIn = CStudioPreferences::isInterpolation() ? 100 : 0;
+ float easeOut = CStudioPreferences::isInterpolation() ? 100 : 0;
+ QVector<SEaseInEaseOutKeyframe> keyframes;
+ for (Qt3DSDMKeyframeHandle kfHandle : keyframeHandles) {
+ TKeyframe kfData = animCore->GetKeyframeData(kfHandle);
+ keyframes.append(SEaseInEaseOutKeyframe(getKeyframeTime(kfData),
+ getKeyframeValue(kfData),
+ easeIn, easeOut));
+ }
+ long numFloatsPerKeyframe = sizeof(SEaseInEaseOutKeyframe) / sizeof(float);
+ long numValues = long(keyframeHandles.size()) * numFloatsPerKeyframe;
+ editor->CreateOrSetAnimation(slide, instance, propType.wide_str(), long(i),
+ animType,
+ reinterpret_cast<float *>(keyframes.begin()),
+ numValues);
+ } else if (animType == EAnimationTypeBezier) {
+ QVector<SBezierKeyframe> keyframes;
+ for (Qt3DSDMKeyframeHandle kfHandle : keyframeHandles) {
+ TKeyframe kfData = animCore->GetKeyframeData(kfHandle);
+ long kfTime = getKeyframeTime(kfData);
+ float kfValue = getKeyframeValue(kfData);
+ keyframes.append(SBezierKeyframe(kfTime, kfValue,
+ kfTime - 500, kfValue,
+ kfTime + 500, kfValue));
+ }
+ long numFloatsPerKeyframe = sizeof(SBezierKeyframe) / sizeof(float);
+ long numValues = long(keyframeHandles.size()) * numFloatsPerKeyframe;
+ editor->CreateOrSetAnimation(slide, instance, propType.wide_str(), long(i),
+ animType,
+ reinterpret_cast<float *>(keyframes.begin()),
+ numValues);
+ }
+ }
+
+ // macOS and Linux require this to be done synchronously after animation type change, or
+ // keyframes will be invalid. Does not break anything on Windows either, so it can be done
+ // synchronously for all.
+ m_rowTree->refreshPropBinding(true);
+}
+
void RowTimelineContextMenu::insertKeyframe()
{
RowTree *destinationRowTree = nullptr;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.h
index b8c2f922..d6b4a97f 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelineContextMenu.h
@@ -65,6 +65,7 @@ private:
void changeTimeBarColor();
void setTimeBarTime();
void toggleDynamicKeyframes();
+ void onAnimTypeChange(QAction *action);
RowTree *m_rowTree = nullptr;
Keyframe *m_keyframe = nullptr;
@@ -81,6 +82,7 @@ private:
QAction *m_setTimeBarColorAction = nullptr;
QAction *m_setTimeBarTimeAction = nullptr;
QAction *m_dynamicKeyframesAction = nullptr;
+ QMenu *m_animType = nullptr;
TimelineControl *m_timelineControl = nullptr;
bool m_hasDynamicKeyframes = false;
};
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp
index 3c82d73b..51c0d299 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp
@@ -29,72 +29,529 @@
#include "RowTimelinePropertyGraph.h"
#include "RowTimeline.h"
#include "RowTree.h"
+#include "StudioApp.h"
+#include "Core.h"
+#include "Doc.h"
+#include "IDocumentEditor.h"
+#include "Qt3DSDMAnimation.h"
+#include "Keyframe.h"
#include "Ruler.h"
#include "TimelineGraphicsScene.h"
+#include "StudioPreferences.h"
+#include "HotKeys.h"
#include "Bindings/ITimelineItemProperty.h"
+using namespace qt3dsdm;
+using namespace TimelineConstants;
+
RowTimelinePropertyGraph::RowTimelinePropertyGraph(QObject *parent)
: QObject(parent)
+ , m_rowTimeline(static_cast<RowTimeline *>(parent))
+ , m_animCore(g_StudioApp.GetCore()->GetDoc()->GetAnimationCore())
+ , m_UpdatableEditor(*g_StudioApp.GetCore()->GetDoc())
{
- m_rowTimeline = static_cast<RowTimeline *>(parent);
+ m_fitCurveTimer.setInterval(10);
+
+ // smooth animation for when curve height change
+ connect(&m_fitCurveTimer, &QTimer::timeout, [this]() {
+ fitGraph();
+ if (m_rowTimeline->size().height() == m_expandHeight)
+ m_fitCurveTimer.stop();
+ });
}
void RowTimelinePropertyGraph::paintGraphs(QPainter *painter, const QRectF &rect)
{
- m_rect = rect;
m_propBinding = m_rowTimeline->rowTree()->propBinding();
+ if (!m_propBinding)
+ return;
+
+ if (rect.height() < ROW_H) // rect height = row height - 1
+ return;
+
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setClipRect(rect);
+
+ static const QPointF edgeOffset(RULER_EDGE_OFFSET, 0);
+
+ // draw graph baseline (graph_Y)
+ painter->setPen(QPen(CStudioPreferences::studioColor3()));
+ painter->drawLine(edgeOffset.x(), m_graphY, rect.right(), m_graphY);
+
+ // draw value ruler
+ static const int STEP_MIN = 20;
+ static const int STEP_MAX = 40;
+ static const QVector<qreal> RULER_VALS {1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000};
+
+ int rulerValIdx = 5; // start at val 100
+ qreal step = RULER_VALS[rulerValIdx] * m_valScale;
+
+ while (step < STEP_MIN && rulerValIdx < RULER_VALS.size() - 1)
+ step = RULER_VALS[++rulerValIdx] * m_valScale;
+ while (step > STEP_MAX && rulerValIdx > 0)
+ step = RULER_VALS[--rulerValIdx] * m_valScale;
+
+ qreal dy = rect.bottom() - m_graphY;
+ qreal d_start = dy > 0 ? std::fmod(dy, step) : step - std::fmod(-dy, step); // start delta
+ qreal start_y = rect.bottom() - d_start;
+ painter->setFont(QFont(CStudioPreferences::fontFaceName(), 7));
+ for (qreal i = start_y; i > rect.y(); i -= step) {
+ // draw ruler line
+ painter->setPen(QPen(CStudioPreferences::studioColor2(), 1));
+ painter->drawLine(rect.x(), rect.y() + i, rect.right(), rect.y() + i);
+
+ // draw ruler value text
+ painter->setPen(QPen(CStudioPreferences::studioColor3(), 1));
+ qreal val_i = (m_graphY - i) / m_valScale;
+ painter->drawText(rect.x() + edgeOffset.x() + 8, i - 2, QString::number(qRound(val_i)));
+ }
+
+ // draw vertical keyframe separator lines
+ painter->setPen(QPen(CStudioPreferences::studioColor2(), 1));
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ m_animCore->GetKeyframes(m_activeChannels[0], keyframeHandles);
+ for (size_t i = 0; i < keyframeHandles.size(); ++i) {
+ TKeyframe kf = m_animCore->GetKeyframeData(keyframeHandles[i]);
+ QPointF centerPos = getKeyframePosition(getKeyframeTime(kf), getKeyframeValue(kf))
+ + edgeOffset;
+ painter->drawLine(centerPos.x(), rect.y(), centerPos.x(), rect.height());
+ }
+
+ // draw channel curves
+ painter->setPen(CStudioPreferences::studioColor3()); // default to locked color
+ for (int i = 0; i < m_activeChannels.size(); ++i) {
+ QPainterPath path;
+ int start_j = qMax(rect.x(), edgeOffset.x());
+ for (int j = start_j; j < rect.right(); j += 5) { // 5 = sampling step in pixels
+ long time = m_rowTimeline->rowTree()->m_scene->ruler()
+ ->distanceToTime(j - edgeOffset.x());
+ float value = m_propBinding->GetChannelValueAtTime(m_activeChannelsIndex[i], time);
+ adjustColorProperty(value);
+
+ qreal yPos = m_graphY - value * m_valScale;
+
+ if (j == start_j)
+ path.moveTo(j, yPos);
+ else
+ path.lineTo(j, yPos);
+ }
+
+ static const QColor chColors[4] {
+ CStudioPreferences::xAxisColor(),
+ CStudioPreferences::yAxisColor(),
+ CStudioPreferences::zAxisColor(),
+ CStudioPreferences::wAxisColor()
+ };
+
+ if (!m_rowTimeline->rowTree()->locked())
+ painter->setPen(chColors[m_activeChannelsIndex[i]]);
+ painter->drawPath(path);
+ }
+
+ // draw bezier keyframes and their control points
+ if (m_rowTimeline->rowTree()->propBinding()->animationType() == EAnimationTypeBezier) {
+ for (size_t i = 0; i < m_activeChannels.size(); ++i) {
+ // draw bezier control points
+ static const QPixmap pixBezierHandle("://images/breadcrumb_component_button.png");
+
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ m_animCore->GetKeyframes(m_activeChannels[i], keyframeHandles);
+
+ for (auto &kfHandle : keyframeHandles) {
+ SBezierKeyframe kf = get<SBezierKeyframe>(m_animCore->GetKeyframeData(kfHandle));
+
+ QPointF centerPos = getBezierControlPosition(kf) + edgeOffset;
+ const QPointF PIX_HALF_W = QPointF(8.0, 8.0);
+
+ bool kfSelected = m_selectedBezierKeyframes.contains(kfHandle)
+ && !m_rowTimeline->rowTree()->locked();
+ if (kfSelected) {
+ // draw tangent-in part
+ painter->setPen(CStudioPreferences::bezierControlColor());
+ if (kfHandle != *keyframeHandles.begin()) {
+ QPointF cInPos = getBezierControlPosition(kf, BezierControlType::In)
+ + edgeOffset;
+ painter->drawLine(cInPos, centerPos);
+ painter->drawPixmap(cInPos - PIX_HALF_W, pixBezierHandle);
+ }
+
+ // draw tangent-out part
+ if (kfHandle != *(keyframeHandles.end() - 1)) {
+ QPointF cOutPos = getBezierControlPosition(kf, BezierControlType::Out)
+ + edgeOffset;
+ painter->drawLine(cOutPos, centerPos);
+ painter->drawPixmap(cOutPos - PIX_HALF_W, pixBezierHandle);
+ }
+ } else if (kfHandle == m_hoveredBezierKeyframe) {
+ // a bezier keyframe hovered
+ painter->setPen(QPen(CStudioPreferences::bezierControlColor()));
+ painter->drawRect(centerPos.x() - 4, centerPos.y() - 4, 8, 8);
+ }
+
+ // draw center point
+ painter->setPen(QPen(m_rowTimeline->rowTree()->locked()
+ ? CStudioPreferences::studioColor3()
+ : CStudioPreferences::bezierControlColor(), kfSelected
+ ? 6 : 3));
+ painter->drawPoint(centerPos);
+ }
+ }
+ }
+}
+
+/**
+ * This method is called when the user mouse-presses the property graph. If the press is on a
+ * bezier keyframe handle, it returns the handle type and saves the list of keyframe channels
+ * handles to be precessed while the user drags the handle (in updateBezierControlValue())
+ *
+ * @param pos press position in local coordinate system
+ * @param isHover when true this is a hover, else a click
+ * @return the pressed handle type, or None if no handle is pressed
+ */
+TimelineControlType RowTimelinePropertyGraph::getClickedBezierControl(const QPointF &pos,
+ bool isHover)
+{
+ if (m_rowTimeline->rowTree()->propBinding()->animationType() != EAnimationTypeBezier)
+ return TimelineControlType::None;
+
+ bool aKeyframeWasHovered = m_hoveredBezierKeyframe.Valid();
+
+ // reset data
+ m_hoveredBezierKeyframe = 0;
+ m_pressedKeyframeHandle = 0;
+
+ if (aKeyframeWasHovered)
+ m_rowTimeline->update();
+
+ for (int i = 0; i < m_activeChannels.size(); ++i) {
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ m_animCore->GetKeyframes(m_activeChannels[i], keyframeHandles);
+ const double CONTROL_RADIUS = 8;
+ for (auto kfHandle : keyframeHandles) {
+ SBezierKeyframe kf = get<SBezierKeyframe>(m_animCore->GetKeyframeData(kfHandle));
+
+ QPointF kfPos = getBezierControlPosition(kf);
+ if (QLineF(kfPos, pos).length() < CONTROL_RADIUS) { // over a bezier keyframe
+ m_pressedKeyframeHandle = kfHandle;
+ if (isHover) {
+ m_hoveredBezierKeyframe = kfHandle;
+ } else {
+ if (CHotKeys::isCtrlDown()) {
+ if (m_selectedBezierKeyframes.contains(kfHandle))
+ m_selectedBezierKeyframes.remove(kfHandle);
+ else
+ m_selectedBezierKeyframes.insert(kfHandle);
+ } else {
+ if (!m_selectedBezierKeyframes.contains(kfHandle))
+ m_selectedBezierKeyframes.clear();
+ m_selectedBezierKeyframes.insert(kfHandle);
+ }
+ }
+ m_rowTimeline->update();
+
+ return TimelineControlType::BezierKeyframe;
+ }
+
+ if (m_selectedBezierKeyframes.contains(kfHandle)) {
+ QPointF cInPos = getBezierControlPosition(kf, BezierControlType::In);
+ QPointF cOutPos = getBezierControlPosition(kf, BezierControlType::Out);
+ bool clickedInHandle = QLineF(cInPos, pos).length() < CONTROL_RADIUS;
+ bool clickedOutHandle = QLineF(cOutPos, pos).length() < CONTROL_RADIUS;
+ if (clickedInHandle || clickedOutHandle) {
+ m_pressedKeyframeHandle = kfHandle;
+
+ return clickedInHandle ? TimelineControlType::BezierInHandle
+ : TimelineControlType::BezierOutHandle;
+ }
+ }
+ }
+ }
+
+ return TimelineControlType::None;
+}
+
+QPointF RowTimelinePropertyGraph::getBezierControlPosition(const SBezierKeyframe &kf,
+ BezierControlType type) const
+{
+ long time = 0;
+ float value = 0;
+ if (type == BezierControlType::None) {
+ time = kf.m_time;
+ value = kf.m_value;
+ } else if (type == BezierControlType::In) {
+ time = kf.m_InTangentTime;
+ value = kf.m_InTangentValue;
+ } else if (type == BezierControlType::Out) {
+ time = kf.m_OutTangentTime;
+ value = kf.m_OutTangentValue;
+ }
+
+ return getKeyframePosition(time, value);
+}
+
+QPointF RowTimelinePropertyGraph::getKeyframePosition(long time, float value) const
+{
+ adjustColorProperty(value);
+
+ return QPointF(m_rowTimeline->rowTree()->m_scene->ruler()->timeToDistance(time),
+ m_graphY - value * m_valScale);
+}
+
+/**
+ * This method is called when the user drags a bezier control. It updates the bezier control
+ * values based on the current position of the handle.
+ *
+ * @param controlType which handle is being dragged? (BezierInHandle or BezierOutHandle)
+ * @param scenePos handle position in timeline scene coordinates
+ */
+void RowTimelinePropertyGraph::updateBezierControlValue(TimelineControlType controlType,
+ const QPointF &scenePos)
+{
+ QPointF p = m_rowTimeline->mapFromScene(scenePos.x() - RULER_EDGE_OFFSET, scenePos.y());
+
+ // time and value at current mouse position
+ float time = float(m_rowTimeline->rowTree()->m_scene->ruler()->distanceToTime(p.x()));
+ float value = (m_graphY - p.y()) / m_valScale;
+ adjustColorProperty(value, false);
- // Animate alpha 0..255 while expanding
- int alpha = 255 * (m_rect.height() - TimelineConstants::ROW_H)
- / (TimelineConstants::ROW_H_EXPANDED - TimelineConstants::ROW_H);
- alpha = std::max(0, alpha);
+ SBezierKeyframe kf = get<SBezierKeyframe>(m_animCore->GetKeyframeData(m_pressedKeyframeHandle));
- if (alpha == 0)
+ // moving selected keyframes (vertically)
+ if (controlType == TimelineControlType::BezierKeyframe) {
+ float dVal = value - kf.m_value;
+
+ for (auto kfHandle : qAsConst(m_selectedBezierKeyframes)) {
+ SBezierKeyframe kf_i = get<SBezierKeyframe>(m_animCore->GetKeyframeData(kfHandle));
+ kf_i.m_value += dVal;
+ kf_i.m_InTangentValue += dVal;
+ kf_i.m_OutTangentValue += dVal;
+ m_UpdatableEditor.EnsureEditor(QObject::tr("Edit Bezier curve"), __FILE__, __LINE__)
+ .setBezierKeyframeValue(kfHandle, kf_i);
+ }
+ // immediate refresh is needed to update the value in the inspector, this is not needed
+ // when moving the control points as they are not shown in the inspector
+ m_UpdatableEditor.FireImmediateRefresh(m_rowTimeline->rowTree()->parentRow()->instance());
+ m_rowTimeline->update();
return;
+ }
+
+ bool isBezierIn = controlType == TimelineControlType::BezierInHandle;
+
+ // prevent handles from moving to the other side of the keyframe
+ if ((isBezierIn && time > kf.m_time)
+ || (!isBezierIn && time < kf.m_time)) {
+ time = kf.m_time;
+ }
+
+ // prevent handles from going beyond prev. and next keyframes
+ Qt3DSDMAnimationHandle anim = m_animCore->GetAnimationForKeyframe(m_pressedKeyframeHandle);
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ m_animCore->GetKeyframes(anim, keyframeHandles);
+ for (size_t i = 0; i < keyframeHandles.size(); ++i) {
+ if (keyframeHandles[i] == m_pressedKeyframeHandle) {
+ float currKfTime = float(getKeyframeTime(m_animCore->GetKeyframeData(
+ keyframeHandles[i])));
+ // FLT_MAX is divided by 2 so that it doesn't cause an overflow in the calculations
+ // below
+ float prevKfTime = i > 0
+ ? float(getKeyframeTime(m_animCore->GetKeyframeData(keyframeHandles[i - 1])))
+ : -FLT_MAX / 2.f;
+ float nextKfTime = i < keyframeHandles.size() - 1.f
+ ? float(getKeyframeTime(m_animCore->GetKeyframeData(keyframeHandles[i + 1])))
+ : FLT_MAX / 2.f;
+
+ if (isBezierIn) {
+ if (time < prevKfTime)
+ time = prevKfTime;
+ if (!CHotKeys::isCtrlDown() && time < currKfTime * 2.f - nextKfTime)
+ time = currKfTime * 2.f - nextKfTime;
+ } else { // bezier out
+ if (time > nextKfTime)
+ time = nextKfTime;
+ if (!CHotKeys::isCtrlDown() && time > currKfTime * 2.f - prevKfTime)
+ time = currKfTime * 2.f - prevKfTime;
+ }
+ break;
+ }
+ }
+
+ float &currHandleTime = isBezierIn ? kf.m_InTangentTime : kf.m_OutTangentTime;
+ float &currHandleValue = isBezierIn ? kf.m_InTangentValue : kf.m_OutTangentValue;
+ float &otherHandleTime = isBezierIn ? kf.m_OutTangentTime : kf.m_InTangentTime;
+ float &otherHandleValue = isBezierIn ? kf.m_OutTangentValue : kf.m_InTangentValue;
- // Available line colors
- QColor colors[6] = { QColor(255, 0, 0, alpha), QColor(0, 255, 0, alpha),
- QColor(0, 0, 255, alpha), QColor(255, 255, 0, alpha),
- QColor(255, 0, 255, alpha), QColor(0, 255, 255, alpha) };
+ currHandleTime = time;
+ currHandleValue = value;
+
+ if (!CHotKeys::isCtrlDown()) {
+ otherHandleTime = kf.m_time + (kf.m_time - time);
+ otherHandleValue = kf.m_value + (kf.m_value - currHandleValue);
+ }
- long channelCount = m_propBinding->GetChannelCount();
+ m_UpdatableEditor.EnsureEditor(QObject::tr("Edit Bezier curve"), __FILE__, __LINE__)
+ .setBezierKeyframeValue(m_pressedKeyframeHandle, kf);
+ m_rowTimeline->update();
+}
+
+void RowTimelinePropertyGraph::updateChannelFiltering(const QVector<bool> &activeChannels)
+{
+ m_activeChannels.clear();
+ m_activeChannelsIndex.clear();
- // Don't want to overflow the color array
- if (channelCount <= 6) {
- // For each channel graph it.
- for (long i = 0; i < channelCount; ++i)
- paintSingleChannel(painter, i, colors[i]);
+ const auto animHandles = m_rowTimeline->rowTree()->propBinding()->animationHandles();
+ for (int i = 0; i < activeChannels.size(); ++i) {
+ if (activeChannels[i]) {
+ m_activeChannels.append(animHandles[i]);
+ m_activeChannelsIndex.append(i);
+ }
}
+
+ fitGraph();
}
-void RowTimelinePropertyGraph::paintSingleChannel(QPainter *painter, long inChannelIndex,
- const QColor &inColor)
+// adjust graph scale and y so that all keyframe and control points are visible
+void RowTimelinePropertyGraph::fitGraph()
{
- float maxVal = m_propBinding->GetMaximumValue();
- float minVal = m_propBinding->GetMinimumValue();
+ // get min/max keyframes values in the active channels
+ float minVal = FLT_MAX;
+ float maxVal = -FLT_MAX;
+
+ auto ruler = m_rowTimeline->rowTree()->m_scene->ruler();
+ int startX = qMax(ruler->viewportX() - int(RULER_EDGE_OFFSET), 0);
+ int endX = ruler->viewportX() + m_rowTimeline->rowTree()->m_scene->widgetTimeline()
+ ->viewTimelineContent()->width();
+ long startTime = ruler->distanceToTime(startX);
+ long endTime = ruler->distanceToTime(endX);
- double timelineScale = m_rowTimeline->rowTree()->m_scene->ruler()->timelineScale();
+ for (int i = 0; i < m_activeChannels.size(); ++i) {
+ auto extrema = m_animCore->getAnimationExtrema(m_activeChannels[i], startTime, endTime);
+ if (extrema.second < minVal)
+ minVal = extrema.second;
+ if (extrema.first > maxVal)
+ maxVal = extrema.first;
- // Step in pixels
- int interval = 5;
- // Margin at top & bottom of graph
- float marginY = 10;
- float graphY = m_rect.y() + marginY;
- float graphHeight = m_rect.height() - marginY * 2;
+ // for bezier keyframes check selected tangents in/out also
+ for (auto kfHandle : qAsConst(m_selectedBezierKeyframes)) {
+ TKeyframe keyframeData = m_animCore->GetKeyframeData(kfHandle);
- QPainterPath path;
- for (int i = 0; i < m_rect.width(); i += interval) {
- // Value time in ms
- long time = i / (TimelineConstants::RULER_MILLI_W * timelineScale);
- float value = m_propBinding->GetChannelValueAtTime(inChannelIndex, time);
- float yPos = graphY + (1.0 - (value - minVal) / (maxVal - minVal)) * graphHeight;
+ if (keyframeData.getType() == qt3dsdm::EAnimationTypeBezier) {
+ long timeIn, timeOut;
+ float valueIn, valueOut;
+ getBezierValues(keyframeData, timeIn, valueIn, timeOut, valueOut);
- if (i == 0)
- path.moveTo(m_rect.x() + i, yPos);
- else
- path.lineTo(m_rect.x() + i, yPos);
+ if (!m_animCore->IsFirstKeyframe(kfHandle)) { // check tangent-in value
+ if (valueIn < minVal)
+ minVal = valueIn;
+ if (valueIn > maxVal)
+ maxVal = valueIn;
+ }
+
+ if (!m_animCore->IsLastKeyframe(kfHandle)) { // check tangent-out value
+ if (valueOut < minVal)
+ minVal = valueOut;
+ if (valueOut > maxVal)
+ maxVal = valueOut;
+ }
+ }
+ }
}
- painter->setPen(QPen(inColor, 2));
- painter->drawPath(path);
+ adjustColorProperty(maxVal);
+ adjustColorProperty(minVal);
+
+ const float marginT = 20.f;
+ const float marginB = 10.f;
+ const float graphH = float(m_rowTimeline->size().height()) - (marginT + marginB);
+ m_valScale = graphH / (maxVal - minVal);
+ checkValScaleLimits();
+
+ m_graphY = double(marginT + maxVal * m_valScale);
+
+ // if value range is < min scale, center the range
+ float rangeH = (maxVal - minVal) * m_valScale;
+ if (rangeH < graphH)
+ m_graphY += double(graphH - rangeH) / 2.;
+
+ m_rowTimeline->update();
+}
+
+// show color properties values in the range 0-255
+void RowTimelinePropertyGraph::adjustColorProperty(float &val, bool scaleUp) const
+{
+ if (m_rowTimeline->isColorProperty())
+ scaleUp ? val *= 255.f : val /= 255.f;
+}
+
+void RowTimelinePropertyGraph::checkValScaleLimits()
+{
+ // m_valScale can be NaN if maxVal and minVal are same (i.e. horizontal line curve)
+ if (isnan(m_valScale) || m_valScale > 10.f)
+ m_valScale = 10.f;
+ else if (m_valScale < .01f)
+ m_valScale = .01f;
+}
+
+void RowTimelinePropertyGraph::selectBezierKeyframesInRange(const QRectF &rect)
+{
+ QRectF localRect = m_rowTimeline->mapFromScene(rect).boundingRect();
+ localRect.translate(-RULER_EDGE_OFFSET, 0);
+
+ for (int i = 0; i < m_activeChannels.size(); ++i) {
+ Qt3DSDMTimelineKeyframe::TKeyframeHandleList keyframeHandles;
+ m_animCore->GetKeyframes(m_activeChannels[i], keyframeHandles);
+ for (auto kfHandle : keyframeHandles) {
+ SBezierKeyframe kf = get<SBezierKeyframe>(m_animCore->GetKeyframeData(kfHandle));
+
+ QPointF kfPosition = getKeyframePosition(getKeyframeTime(kf), getKeyframeValue(kf));
+ if (localRect.contains(kfPosition))
+ m_selectedBezierKeyframes.insert(kfHandle);
+ else
+ m_selectedBezierKeyframes.remove(kfHandle);
+ }
+ }
+}
+
+void RowTimelinePropertyGraph::deselectAllBezierKeyframes()
+{
+ if (!m_pressedKeyframeHandle.Valid()) // not currently editing a bezier control
+ m_selectedBezierKeyframes.clear();
+}
+
+void RowTimelinePropertyGraph::adjustScale(const QPointF &scenePos, bool isIncrement)
+{
+ QPointF p = m_rowTimeline->mapFromScene(scenePos.x() - RULER_EDGE_OFFSET, scenePos.y());
+
+ float oldScale = m_valScale;
+ float pitch = m_valScale * .3f;
+ m_valScale += isIncrement ? pitch : -pitch;
+ checkValScaleLimits();
+
+ float d1 = m_graphY - p.y(); // dY before scale
+ float d2 = d1 * m_valScale / oldScale; // dY after scale
+
+ m_graphY += d2 - d1;
+
+ m_rowTimeline->update();
+}
+
+void RowTimelinePropertyGraph::startPan()
+{
+ m_graphYPanInit = m_graphY;
+}
+
+void RowTimelinePropertyGraph::pan(qreal dy)
+{
+ m_graphY = m_graphYPanInit + dy;
+ m_rowTimeline->update();
+}
+
+void RowTimelinePropertyGraph::commitBezierEdit()
+{
+ m_UpdatableEditor.CommitEditor();
+}
+
+void RowTimelinePropertyGraph::setExpandHeight(int h)
+{
+ m_expandHeight = h;
+ m_fitCurveTimer.start();
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h
index 275c24e2..7d6bffc8 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h
@@ -29,26 +29,67 @@
#ifndef ROWTIMELINEPROPERTYGRAPH_H
#define ROWTIMELINEPROPERTYGRAPH_H
+#include "Qt3DSDMAnimation.h"
+#include "RowTypes.h"
+#include "TimelineConstants.h"
+#include "Bindings/Qt3DSDMTimelineKeyframe.h"
+#include "IDocumentEditor.h"
+
#include <QtCore/qobject.h>
-#include <QtGui/qpainter.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qset.h>
+
+QT_FORWARD_DECLARE_CLASS(QPainter);
class RowTimeline;
class ITimelineItemProperty;
+namespace qt3dsdm {
+class IAnimationCore;
+class Qt3DSDMAnimationHandle;
+}
class RowTimelinePropertyGraph : public QObject
{
Q_OBJECT
+
public:
explicit RowTimelinePropertyGraph(QObject *parent = nullptr);
+ TimelineControlType getClickedBezierControl(const QPointF &pos, bool isHover = false);
void paintGraphs(QPainter *painter, const QRectF &rect);
+ void updateBezierControlValue(TimelineControlType controlType, const QPointF &scenePos);
+ void adjustScale(const QPointF &scenePos, bool isIncrement);
+ void startPan();
+ void pan(qreal dy);
+ void fitGraph();
+ void commitBezierEdit();
+ void setExpandHeight(int h);
+ void selectBezierKeyframesInRange(const QRectF &rect);
+ void deselectAllBezierKeyframes();
+ void updateChannelFiltering(const QVector<bool> &activeChannels);
private:
- void paintSingleChannel(QPainter *painter, long inChannelIndex,
- const QColor &inColor);
+ enum class BezierControlType {None, In, Out};
+
+ QPointF getBezierControlPosition(const qt3dsdm::SBezierKeyframe &kf,
+ BezierControlType type = BezierControlType::None) const;
+ QPointF getKeyframePosition(long time, float value) const;
+ void checkValScaleLimits();
+ void adjustColorProperty(float &val, bool scaleUp = true) const;
+ qt3dsdm::Qt3DSDMKeyframeHandle m_pressedKeyframeHandle;
RowTimeline *m_rowTimeline = nullptr;
ITimelineItemProperty *m_propBinding = nullptr;
- QRectF m_rect;
+ qt3dsdm::IAnimationCore *m_animCore = nullptr;
+ float m_valScale = .5f;
+ qreal m_graphY = 0;
+ qreal m_graphYPanInit = 0; // value of graph_y when panning starts
+ int m_expandHeight = TimelineConstants::ROW_GRAPH_H; // height when expanded
+ qt3dsdm::Qt3DSDMKeyframeHandle m_hoveredBezierKeyframe;
+ QSet<qt3dsdm::Qt3DSDMKeyframeHandle> m_selectedBezierKeyframes;
+ QVector<qt3dsdm::Qt3DSDMAnimationHandle> m_activeChannels; // active channels anim. handles
+ QVector<int> m_activeChannelsIndex;
+ QTimer m_fitCurveTimer;
+ Q3DStudio::CUpdateableDocumentEditor m_UpdatableEditor;
};
#endif // ROWTIMELINEPROPERTYGRAPH_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index e15258cd..aca0ef3c 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -28,6 +28,7 @@
#include "RowTree.h"
#include "RowTimeline.h"
+#include "RowTimelinePropertyGraph.h"
#include "RowManager.h"
#include "TimelineConstants.h"
#include "StudioObjectTypes.h"
@@ -47,6 +48,7 @@
#include "Qt3DSDMSlides.h"
#include "StudioUtils.h"
#include "TimelineToolbar.h"
+#include "HotKeys.h"
#include <QtGui/qpainter.h>
#include "QtGui/qtextcursor.h"
@@ -74,7 +76,6 @@ RowTree::RowTree(TimelineGraphicsScene *timelineScene, const QString &propType)
, m_rowTimeline(new RowTimeline())
, m_isProperty(true)
, m_scene(timelineScene)
- , m_propertyType(propType)
, m_label(propType)
{
m_rowTimeline->m_isProperty = true;
@@ -112,7 +113,7 @@ void RowTree::initialize()
initializeAnimations();
m_labelItem.setParentItem(this);
- m_labelItem.setParentRow(this);
+ m_labelItem.setRowTree(this);
m_labelItem.setLabel(m_label);
updateLabelPosition();
@@ -120,7 +121,7 @@ void RowTree::initialize()
setRowVisible(false);
m_expandState = ExpandState::HiddenCollapsed;
- connect(&m_labelItem, &RowTreeLabelItem::labelChanged, this,
+ connect(&m_labelItem, &RowTreeLabel::labelChanged, this,
[this](const QString &label) {
// Update label on timeline and on model
m_label = label;
@@ -169,8 +170,7 @@ void RowTree::animateExpand(ExpandState state)
int endHeight = 0; // hidden states
float endOpacity = 0;
if (state == ExpandState::Expanded) {
- endHeight = m_isPropertyExpanded ? TimelineConstants::ROW_H_EXPANDED
- : TimelineConstants::ROW_H;
+ endHeight = m_propGraphExpanded ? m_propGraphHeight : TimelineConstants::ROW_H;
endOpacity = 1;
} else if (state == ExpandState::Collapsed) {
endHeight = TimelineConstants::ROW_H;
@@ -179,10 +179,8 @@ void RowTree::animateExpand(ExpandState state)
// Changing end values while animation is running does not affect currently running animation,
// so let's make sure the animation is stopped first.
m_expandAnimation.stop();
-
m_expandHeightAnimation->setEndValue(QSizeF(size().width(), endHeight));
- m_expandTimelineHeightAnimation->setEndValue(QSizeF(m_rowTimeline->size().width(),
- endHeight));
+ m_expandTimelineHeightAnimation->setEndValue(QSizeF(m_rowTimeline->size().width(), endHeight));
m_expandOpacityAnimation->setEndValue(endOpacity);
m_expandTimelineOpacityAnimation->setEndValue(endOpacity);
@@ -201,15 +199,15 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
static const int ICON_SIZE = 16;
static const int LEFT_DIVIDER = 18;
+ static const int ICON_Y = (TimelineConstants::ROW_H - ICON_SIZE) / 2;
const int offset = 5 + m_depth * TimelineConstants::ROW_DEPTH_STEP;
- const int iconY = (TimelineConstants::ROW_H / 2) - (ICON_SIZE / 2);
// update button bounds rects
- m_rectArrow .setRect(offset, iconY, ICON_SIZE, ICON_SIZE);
- m_rectType .setRect(offset + ICON_SIZE, iconY, ICON_SIZE, ICON_SIZE);
- m_rectShy .setRect(treeWidth() - 16 * 3.3, iconY, ICON_SIZE, ICON_SIZE);
- m_rectVisible.setRect(treeWidth() - 16 * 2.2, iconY, ICON_SIZE, ICON_SIZE);
- m_rectLocked .setRect(treeWidth() - 16 * 1.1, iconY, ICON_SIZE, ICON_SIZE);
+ m_rectArrow .setRect(offset, ICON_Y, ICON_SIZE, ICON_SIZE);
+ m_rectType .setRect(offset + ICON_SIZE, ICON_Y, ICON_SIZE, ICON_SIZE);
+ m_rectShy .setRect(treeWidth() - 16 * 3.3, ICON_Y, ICON_SIZE, ICON_SIZE);
+ m_rectVisible.setRect(treeWidth() - 16 * 2.2, ICON_Y, ICON_SIZE, ICON_SIZE);
+ m_rectLocked .setRect(treeWidth() - 16 * 1.1, ICON_Y, ICON_SIZE, ICON_SIZE);
// Background
QColor bgColor;
@@ -235,23 +233,22 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
painter->drawLine(LEFT_DIVIDER, 0, LEFT_DIVIDER, size().height() - 1);
// Shy, eye, lock separator
- painter->fillRect(QRect(treeWidth() - TimelineConstants::TREE_ICONS_W,
- 0, 1, size().height()),
+ painter->fillRect(QRect(rightDividerX(), 0, 1, size().height()),
CStudioPreferences::timelineWidgetBgColor());
// Shy, eye, lock
- static const QPixmap pixEmpty = QPixmap(":/images/Toggle-Empty.png");
- static const QPixmap pixShy = QPixmap(":/images/Toggle-Shy.png");
- static const QPixmap pixHide = QPixmap(":/images/Toggle-HideShow.png");
- static const QPixmap pixHideDisabled = QPixmap(":/images/Toggle-HideShow-disabled.png");
- static const QPixmap pixHideCtrld = QPixmap(":/images/Toggle-HideShowControlled.png");
- static const QPixmap pixLock = QPixmap(":/images/Toggle-Lock.png");
- static const QPixmap pixEmpty2x = QPixmap(":/images/Toggle-Empty@2x.png");
- static const QPixmap pixShy2x = QPixmap(":/images/Toggle-Shy@2x.png");
- static const QPixmap pixHide2x = QPixmap(":/images/Toggle-HideShow@2x.png");
- static const QPixmap pixHideDisabled2x = QPixmap(":/images/Toggle-HideShow-disabled@2x.png");
- static const QPixmap pixHideCtrld2x = QPixmap(":/images/Toggle-HideShowControlled@2x.png");
- static const QPixmap pixLock2x = QPixmap(":/images/Toggle-Lock@2x.png");
+ static const QPixmap pixEmpty(":/images/Toggle-Empty.png");
+ static const QPixmap pixShy(":/images/Toggle-Shy.png");
+ static const QPixmap pixHide(":/images/Toggle-HideShow.png");
+ static const QPixmap pixHideDisabled(":/images/Toggle-HideShow-disabled.png");
+ static const QPixmap pixHideCtrld(":/images/Toggle-HideShowControlled.png");
+ static const QPixmap pixLock(":/images/Toggle-Lock.png");
+ static const QPixmap pixEmpty2x(":/images/Toggle-Empty@2x.png");
+ static const QPixmap pixShy2x(":/images/Toggle-Shy@2x.png");
+ static const QPixmap pixHide2x(":/images/Toggle-HideShow@2x.png");
+ static const QPixmap pixHideDisabled2x(":/images/Toggle-HideShow-disabled@2x.png");
+ static const QPixmap pixHideCtrld2x(":/images/Toggle-HideShowControlled@2x.png");
+ static const QPixmap pixLock2x(":/images/Toggle-Lock@2x.png");
if (hasActionButtons()) {
painter->drawPixmap(m_rectShy, hiResIcons ? (m_shy ? pixShy2x : pixEmpty2x)
: (m_shy ? pixShy : pixEmpty));
@@ -274,34 +271,31 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
: (m_locked ? pixLock : pixEmpty));
}
- static const QPixmap pixInsertLeft = QPixmap(":/images/Insert-Left.png");
- static const QPixmap pixInsertRight = QPixmap(":/images/Insert-Right.png");
- static const QPixmap pixInsertLeft2x = QPixmap(":/images/Insert-Left@2x.png");
- static const QPixmap pixInsertRight2x = QPixmap(":/images/Insert-Right@2x.png");
+ static const QPixmap pixInsertLeft(":/images/Insert-Left.png");
+ static const QPixmap pixInsertRight(":/images/Insert-Right.png");
+ static const QPixmap pixInsertLeft2x(":/images/Insert-Left@2x.png");
+ static const QPixmap pixInsertRight2x(":/images/Insert-Right@2x.png");
if (m_dndState == DnDState::SP_TARGET) { // Candidate target of a subpresentation drop
painter->drawPixmap(19, 2, hiResIcons ? pixInsertLeft2x : pixInsertLeft);
- painter->drawPixmap(treeWidth() - TimelineConstants::TREE_ICONS_W - 8, 2, hiResIcons
- ? pixInsertRight2x : pixInsertRight);
+ painter->drawPixmap(rightDividerX() - 8, 2, hiResIcons ? pixInsertRight2x : pixInsertRight);
} else if (m_dndState == DnDState::Parent) { // Candidate parent of a dragged row
painter->setPen(QPen(CStudioPreferences::timelineRowMoverColor(), 1));
painter->drawRect(QRect(1, 1, treeWidth() - 2, size().height() - 3));
}
// Action indicators
- static const QPixmap pixMasterAction = QPixmap(":/images/Action-MasterAction.png");
- static const QPixmap pixAction = QPixmap(":/images/Action-Action.png");
- static const QPixmap pixChildMasterAction = QPixmap(":/images/Action-ChildMasterAction.png");
- static const QPixmap pixChildAction = QPixmap(":/images/Action-ChildAction.png");
- static const QPixmap pixCompMasterAction = QPixmap(":/images/Action-ComponentMasterAction.png");
- static const QPixmap pixCompAction = QPixmap(":/images/Action-ComponentAction.png");
- static const QPixmap pixMasterAction2x = QPixmap(":/images/Action-MasterAction@2x.png");
- static const QPixmap pixAction2x = QPixmap(":/images/Action-Action@2x.png");
- static const QPixmap pixChildMasterAction2x
- = QPixmap(":/images/Action-ChildMasterAction@2x.png");
- static const QPixmap pixChildAction2x = QPixmap(":/images/Action-ChildAction@2x.png");
- static const QPixmap pixCompMasterAction2x
- = QPixmap(":/images/Action-ComponentMasterAction@2x.png");
- static const QPixmap pixCompAction2x = QPixmap(":/images/Action-ComponentAction@2x.png");
+ static const QPixmap pixMasterAction(":/images/Action-MasterAction.png");
+ static const QPixmap pixAction(":/images/Action-Action.png");
+ static const QPixmap pixChildMasterAction(":/images/Action-ChildMasterAction.png");
+ static const QPixmap pixChildAction(":/images/Action-ChildAction.png");
+ static const QPixmap pixCompMasterAction(":/images/Action-ComponentMasterAction.png");
+ static const QPixmap pixCompAction(":/images/Action-ComponentAction.png");
+ static const QPixmap pixMasterAction2x(":/images/Action-MasterAction@2x.png");
+ static const QPixmap pixAction2x(":/images/Action-Action@2x.png");
+ static const QPixmap pixChildMasterAction2x(":/images/Action-ChildMasterAction@2x.png");
+ static const QPixmap pixChildAction2x(":/images/Action-ChildAction@2x.png");
+ static const QPixmap pixCompMasterAction2x(":/images/Action-ComponentMasterAction@2x.png");
+ static const QPixmap pixCompAction2x(":/images/Action-ComponentAction@2x.png");
if (!isProperty()) {
// subpresentation indicators
@@ -333,6 +327,67 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
painter->drawPixmap(0, 0, hiResIcons ? pixCompMasterAction2x : pixCompMasterAction);
else if (m_actionStates & ActionState::ComponentAction) // component has action
painter->drawPixmap(0, 0, hiResIcons ? pixCompAction2x : pixCompAction);
+ } else { // property row
+ if (m_propGraphExpanded) {
+ if (m_hoveredRect)
+ painter->fillRect(*m_hoveredRect, CStudioPreferences::studioColor1());
+
+ // draw maximize, fit graph buttons
+ static const QPixmap pixMaximize(":/images/maximize.png");
+ static const QPixmap pixFit(":/images/editcamera_tools_hi-00.png");
+ static const QPixmap pixGradient(":/images/gradient.png");
+ static const QPixmap pixMaximizeDisabled(":/images/maximize_disabled.png");
+ static const QPixmap pixFitDisabled(":/images/editcamera_tools_hi-00_disabled.png");
+ static const QPixmap pixGradientDisabled(":/images/gradient_disabled.png");
+
+ m_rectMaximizePropGraph.setRect(rightDividerX() - 16 * 1.2, TimelineConstants::ROW_H,
+ ICON_SIZE, ICON_SIZE);
+ painter->setPen(m_propGraphHeight != TimelineConstants::ROW_GRAPH_H && !m_locked
+ ? CStudioPreferences::bezierControlColor()
+ : CStudioPreferences::studioColor3());
+ painter->drawRect(m_rectMaximizePropGraph);
+
+ m_rectFitPropGraph.setRect(rightDividerX() - 16 * 2.4, TimelineConstants::ROW_H,
+ ICON_SIZE, ICON_SIZE);
+ painter->setPen(CStudioPreferences::studioColor3());
+ painter->drawRect(m_rectFitPropGraph);
+ painter->drawPixmap(m_rectMaximizePropGraph, m_locked ? pixMaximizeDisabled
+ : pixMaximize);
+ painter->drawPixmap(m_rectFitPropGraph, m_locked ? pixFitDisabled : pixFit);
+
+ if (m_rowTimeline->isColorProperty()) {
+ m_rectColorGradient.setRect(rightDividerX() - 16 * 3.6,
+ TimelineConstants::ROW_H, ICON_SIZE, ICON_SIZE);
+ painter->setPen(m_rowTimeline->m_drawColorGradient && !m_locked
+ ? CStudioPreferences::bezierControlColor()
+ : CStudioPreferences::studioColor3());
+ painter->drawRect(m_rectColorGradient);
+ painter->drawPixmap(m_rectColorGradient, m_locked ? pixGradientDisabled
+ : pixGradient);
+ }
+
+ // draw channel selection buttons
+ const QString channelNames = m_rowTimeline->isColorProperty() ? QStringLiteral("rgba")
+ : QStringLiteral("xyzw");
+ for (int i = 0; i < m_rectChannels.size(); ++i) {
+ if (m_activeChannels[i])
+ painter->fillRect(m_rectChannels[i], CStudioPreferences::studioColor1());
+
+ painter->setPen(m_activeChannels[i] && !m_locked
+ ? CStudioPreferences::bezierControlColor()
+ : CStudioPreferences::studioColor3());
+ painter->drawRect(m_rectChannels[i]);
+
+ painter->setPen(m_locked ? CStudioPreferences::studioColor3()
+ : CStudioPreferences::textColor());
+ painter->drawText(m_rectChannels[i].topLeft() + QPointF(5, 12), channelNames.at(i));
+ }
+
+ if (m_hoveredRect) {
+ painter->setPen(CStudioPreferences::textColor());
+ painter->drawRect(*m_hoveredRect);
+ }
+ }
}
// variants indicator
@@ -351,77 +406,77 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
painter->setClipRect(0, 0, clipX(), TimelineConstants::ROW_H);
// expand/collapse arrow
- static const QPixmap pixArrow = QPixmap(":/images/arrow.png");
- static const QPixmap pixArrowDown = QPixmap(":/images/arrow_down.png");
- static const QPixmap pixArrow2x = QPixmap(":/images/arrow@2x.png");
- static const QPixmap pixArrowDown2x = QPixmap(":/images/arrow_down@2x.png");
+ static const QPixmap pixArrow(":/images/arrow.png");
+ static const QPixmap pixArrowDown(":/images/arrow_down.png");
+ static const QPixmap pixArrow2x(":/images/arrow@2x.png");
+ static const QPixmap pixArrowDown2x(":/images/arrow_down@2x.png");
if (m_arrowVisible) {
painter->drawPixmap(m_rectArrow, hiResIcons ? (expanded() ? pixArrowDown2x : pixArrow2x)
: (expanded() ? pixArrowDown : pixArrow));
}
// Row type icon
- static const QPixmap pixSceneNormal = QPixmap(":/images/Objects-Scene-Normal.png");
- static const QPixmap pixLayerNormal = QPixmap(":/images/Objects-Layer-Normal.png");
- static const QPixmap pixObjectNormal = QPixmap(":/images/Objects-Model-Normal.png");
- static const QPixmap pixLightNormal = QPixmap(":/images/Objects-Light-Normal.png");
- static const QPixmap pixCameraNormal = QPixmap(":/images/Objects-Camera-Normal.png");
- static const QPixmap pixTextNormal = QPixmap(":/images/Objects-Text-Normal.png");
- static const QPixmap pixAliasNormal = QPixmap(":/images/Objects-Alias-Normal.png");
- static const QPixmap pixGroupNormal = QPixmap(":/images/Objects-Group-Normal.png");
- static const QPixmap pixComponentNormal = QPixmap(":/images/Objects-Component-Normal.png");
- static const QPixmap pixMaterialNormal = QPixmap(":/images/Objects-Material-Normal.png");
- static const QPixmap pixPropertyNormal = QPixmap(":/images/Objects-Property-Normal.png");
- static const QPixmap pixImageNormal = QPixmap(":/images/Objects-Image-Normal.png");
- static const QPixmap pixBehaviorNormal = QPixmap(":/images/Objects-Behavior-Normal.png");
- static const QPixmap pixEffectNormal= QPixmap(":/images/Objects-Effect-Normal.png");
- static const QPixmap pixSceneNormal2x = QPixmap(":/images/Objects-Scene-Normal@2x.png");
- static const QPixmap pixLayerNormal2x = QPixmap(":/images/Objects-Layer-Normal@2x.png");
- static const QPixmap pixObjectNormal2x = QPixmap(":/images/Objects-Model-Normal@2x.png");
- static const QPixmap pixLightNormal2x = QPixmap(":/images/Objects-Light-Normal@2x.png");
- static const QPixmap pixCameraNormal2x = QPixmap(":/images/Objects-Camera-Normal@2x.png");
- static const QPixmap pixTextNormal2x = QPixmap(":/images/Objects-Text-Normal@2x.png");
- static const QPixmap pixAliasNormal2x = QPixmap(":/images/Objects-Alias-Normal@2x.png");
- static const QPixmap pixGroupNormal2x = QPixmap(":/images/Objects-Group-Normal@2x.png");
- static const QPixmap pixComponentNormal2x = QPixmap(":/images/Objects-Component-Normal@2x.png");
- static const QPixmap pixMaterialNormal2x = QPixmap(":/images/Objects-Material-Normal@2x.png");
- static const QPixmap pixPropertyNormal2x = QPixmap(":/images/Objects-Property-Normal@2x.png");
- static const QPixmap pixImageNormal2x = QPixmap(":/images/Objects-Image-Normal@2x.png");
- static const QPixmap pixBehaviorNormal2x = QPixmap(":/images/Objects-Behavior-Normal@2x.png");
- static const QPixmap pixEffectNormal2x = QPixmap(":/images/Objects-Effect-Normal@2x.png");
-
- static const QPixmap pixSceneDisabled = QPixmap(":/images/Objects-Scene-Disabled.png");
- static const QPixmap pixLayerDisabled = QPixmap(":/images/Objects-Layer-Disabled.png");
- static const QPixmap pixObjectDisabled = QPixmap(":/images/Objects-Model-Disabled.png");
- static const QPixmap pixLightDisabled = QPixmap(":/images/Objects-Light-Disabled.png");
- static const QPixmap pixCameraDisabled = QPixmap(":/images/Objects-Camera-Disabled.png");
- static const QPixmap pixTextDisabled = QPixmap(":/images/Objects-Text-Disabled.png");
- static const QPixmap pixAliasDisabled = QPixmap(":/images/Objects-Alias-Disabled.png");
- static const QPixmap pixGroupDisabled = QPixmap(":/images/Objects-Group-Disabled.png");
- static const QPixmap pixComponentDisabled = QPixmap(":/images/Objects-Component-Disabled.png");
- static const QPixmap pixMaterialDisabled = QPixmap(":/images/Objects-Material-Disabled.png");
- static const QPixmap pixPropertyDisabled = QPixmap(":/images/Objects-Property-Disabled.png");
- static const QPixmap pixImageDisabled = QPixmap(":/images/Objects-Image-Disabled.png");
- static const QPixmap pixBehaviorDisabled = QPixmap(":/images/Objects-Behavior-Disabled.png");
- static const QPixmap pixEffectDisabled = QPixmap(":/images/Objects-Effect-Disabled.png");
- static const QPixmap pixSceneDisabled2x = QPixmap(":/images/Objects-Scene-Disabled@2x.png");
- static const QPixmap pixLayerDisabled2x = QPixmap(":/images/Objects-Layer-Disabled@2x.png");
- static const QPixmap pixObjectDisabled2x = QPixmap(":/images/Objects-Model-Disabled@2x.png");
- static const QPixmap pixLightDisabled2x = QPixmap(":/images/Objects-Light-Disabled@2x.png");
- static const QPixmap pixCameraDisabled2x = QPixmap(":/images/Objects-Camera-Disabled@2x.png");
- static const QPixmap pixTextDisabled2x = QPixmap(":/images/Objects-Text-Disabled@2x.png");
- static const QPixmap pixAliasDisabled2x = QPixmap(":/images/Objects-Alias-Disabled@2x.png");
- static const QPixmap pixGroupDisabled2x = QPixmap(":/images/Objects-Group-Disabled@2x.png");
- static const QPixmap pixComponentDisabled2x
- = QPixmap(":/images/Objects-Component-Disabled@2x.png");
- static const QPixmap pixMaterialDisabled2x
- = QPixmap(":/images/Objects-Material-Disabled@2x.png");
- static const QPixmap pixPropertyDisabled2x
- = QPixmap(":/images/Objects-Property-Disabled@2x.png");
- static const QPixmap pixImageDisabled2x = QPixmap(":/images/Objects-Image-Disabled@2x.png");
- static const QPixmap pixBehaviorDisabled2x
- = QPixmap(":/images/Objects-Behavior-Disabled@2x.png");
- static const QPixmap pixEffectDisabled2x = QPixmap(":/images/Objects-Effect-Disabled@2x.png");
+ static const QPixmap pixSceneNormal(":/images/Objects-Scene-Normal.png");
+ static const QPixmap pixLayerNormal(":/images/Objects-Layer-Normal.png");
+ static const QPixmap pixObjectNormal(":/images/Objects-Model-Normal.png");
+ static const QPixmap pixLightNormal(":/images/Objects-Light-Normal.png");
+ static const QPixmap pixCameraNormal(":/images/Objects-Camera-Normal.png");
+ static const QPixmap pixTextNormal(":/images/Objects-Text-Normal.png");
+ static const QPixmap pixAliasNormal(":/images/Objects-Alias-Normal.png");
+ static const QPixmap pixGroupNormal(":/images/Objects-Group-Normal.png");
+ static const QPixmap pixSignalNormal(":/images/Objects-Signal-Normal.png");
+ static const QPixmap pixComponentNormal(":/images/Objects-Component-Normal.png");
+ static const QPixmap pixMaterialNormal(":/images/Objects-Material-Normal.png");
+ static const QPixmap pixPropertyNormal(":/images/Objects-Property-Normal.png");
+ static const QPixmap pixImageNormal(":/images/Objects-Image-Normal.png");
+ static const QPixmap pixBehaviorNormal(":/images/Objects-Behavior-Normal.png");
+ static const QPixmap pixEffectNormal(":/images/Objects-Effect-Normal.png");
+ static const QPixmap pixSceneNormal2x(":/images/Objects-Scene-Normal@2x.png");
+ static const QPixmap pixLayerNormal2x(":/images/Objects-Layer-Normal@2x.png");
+ static const QPixmap pixObjectNormal2x(":/images/Objects-Model-Normal@2x.png");
+ static const QPixmap pixLightNormal2x(":/images/Objects-Light-Normal@2x.png");
+ static const QPixmap pixCameraNormal2x(":/images/Objects-Camera-Normal@2x.png");
+ static const QPixmap pixTextNormal2x(":/images/Objects-Text-Normal@2x.png");
+ static const QPixmap pixAliasNormal2x(":/images/Objects-Alias-Normal@2x.png");
+ static const QPixmap pixGroupNormal2x(":/images/Objects-Group-Normal@2x.png");
+ static const QPixmap pixSignalNormal2x(":/images/Objects-Signal-Normal@2x.png");
+ static const QPixmap pixComponentNormal2x(":/images/Objects-Component-Normal@2x.png");
+ static const QPixmap pixMaterialNormal2x(":/images/Objects-Material-Normal@2x.png");
+ static const QPixmap pixPropertyNormal2x(":/images/Objects-Property-Normal@2x.png");
+ static const QPixmap pixImageNormal2x(":/images/Objects-Image-Normal@2x.png");
+ static const QPixmap pixBehaviorNormal2x(":/images/Objects-Behavior-Normal@2x.png");
+ static const QPixmap pixEffectNormal2x(":/images/Objects-Effect-Normal@2x.png");
+
+ static const QPixmap pixSceneDisabled(":/images/Objects-Scene-Disabled.png");
+ static const QPixmap pixLayerDisabled(":/images/Objects-Layer-Disabled.png");
+ static const QPixmap pixObjectDisabled(":/images/Objects-Model-Disabled.png");
+ static const QPixmap pixLightDisabled(":/images/Objects-Light-Disabled.png");
+ static const QPixmap pixCameraDisabled(":/images/Objects-Camera-Disabled.png");
+ static const QPixmap pixTextDisabled(":/images/Objects-Text-Disabled.png");
+ static const QPixmap pixAliasDisabled(":/images/Objects-Alias-Disabled.png");
+ static const QPixmap pixGroupDisabled(":/images/Objects-Group-Disabled.png");
+ static const QPixmap pixSignalDisabled(":/images/Objects-Signal-Disabled.png");
+ static const QPixmap pixComponentDisabled(":/images/Objects-Component-Disabled.png");
+ static const QPixmap pixMaterialDisabled(":/images/Objects-Material-Disabled.png");
+ static const QPixmap pixPropertyDisabled(":/images/Objects-Property-Disabled.png");
+ static const QPixmap pixImageDisabled(":/images/Objects-Image-Disabled.png");
+ static const QPixmap pixBehaviorDisabled(":/images/Objects-Behavior-Disabled.png");
+ static const QPixmap pixEffectDisabled(":/images/Objects-Effect-Disabled.png");
+ static const QPixmap pixSceneDisabled2x(":/images/Objects-Scene-Disabled@2x.png");
+ static const QPixmap pixLayerDisabled2x(":/images/Objects-Layer-Disabled@2x.png");
+ static const QPixmap pixObjectDisabled2x(":/images/Objects-Model-Disabled@2x.png");
+ static const QPixmap pixLightDisabled2x(":/images/Objects-Light-Disabled@2x.png");
+ static const QPixmap pixCameraDisabled2x(":/images/Objects-Camera-Disabled@2x.png");
+ static const QPixmap pixTextDisabled2x(":/images/Objects-Text-Disabled@2x.png");
+ static const QPixmap pixAliasDisabled2x(":/images/Objects-Alias-Disabled@2x.png");
+ static const QPixmap pixGroupDisabled2x(":/images/Objects-Group-Disabled@2x.png");
+ static const QPixmap pixSignalDisabled2x(":/images/Objects-Signal-Disabled@2x.png");
+ static const QPixmap pixComponentDisabled2x(":/images/Objects-Component-Disabled@2x.png");
+ static const QPixmap pixMaterialDisabled2x(":/images/Objects-Material-Disabled@2x.png");
+ static const QPixmap pixPropertyDisabled2x(":/images/Objects-Property-Disabled@2x.png");
+ static const QPixmap pixImageDisabled2x(":/images/Objects-Image-Disabled@2x.png");
+ static const QPixmap pixBehaviorDisabled2x(":/images/Objects-Behavior-Disabled@2x.png");
+ static const QPixmap pixEffectDisabled2x(":/images/Objects-Effect-Disabled@2x.png");
QPixmap pixRowType;
if (m_isProperty) {
@@ -461,6 +516,10 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
pixRowType = hiResIcons ? (m_locked ? pixGroupDisabled2x : pixGroupNormal2x)
: (m_locked ? pixGroupDisabled : pixGroupNormal);
break;
+ case OBJTYPE_SIGNAL:
+ pixRowType = hiResIcons ? (m_locked ? pixSignalDisabled2x : pixSignalNormal2x)
+ : (m_locked ? pixSignalDisabled : pixSignalNormal);
+ break;
case OBJTYPE_COMPONENT:
pixRowType = hiResIcons ? (m_locked ? pixComponentDisabled2x : pixComponentNormal2x)
: (m_locked ? pixComponentDisabled : pixComponentNormal);
@@ -541,7 +600,12 @@ void RowTree::setBinding(ITimelineItemBinding *binding)
// x value where label should clip
int RowTree::clipX() const
{
- return treeWidth() - TimelineConstants::TREE_ICONS_W - m_variantsGroups.size() * 8 - 2;
+ return rightDividerX() - m_variantsGroups.size() * 8 - 2;
+}
+
+int RowTree::rightDividerX() const
+{
+ return treeWidth() - TimelineConstants::TREE_ICONS_W;
}
ITimelineItemProperty *RowTree::propBinding()
@@ -549,13 +613,65 @@ ITimelineItemProperty *RowTree::propBinding()
return m_PropBinding;
}
+void RowTree::refreshPropBinding(bool forceSync)
+{
+ // Mahmoud_TODO: update only the changed property binding
+ m_scene->widgetTimeline()->runFullReconstruct(forceSync);
+}
+
void RowTree::setPropBinding(ITimelineItemProperty *binding)
{
m_PropBinding = binding;
+ if (!m_PropBinding)
+ return;
+
+ // update timeline isColorProperty
+ qt3dsdm::TDataTypePair propType = m_PropBinding->GetType();
+ if (propType.first == qt3dsdm::DataModelDataType::Float4
+ && propType.second == qt3dsdm::AdditionalMetaDataType::Color) {
+ m_rowTimeline->m_isColorProperty = true;
+ }
+
+ int chCount = int(m_PropBinding->GetChannelCount());
+
+ // for color properties only show alpha channel for custom materials
+ if (m_rowTimeline->m_isColorProperty && m_parentRow->m_objectType != OBJTYPE_CUSTOMMATERIAL)
+ chCount = 3;
- if (parentRow()->expanded())
+ m_activeChannels.resize(chCount);
+
+ if (chCount == 1) // if property has only 1 channel (ex: alpha), don't show channel buttons
+ chCount = 0;
+
+ m_rectChannels.resize(chCount);
+
+ // For bezier animation select first channel (ie x) only by default, else select all channels
+ if (m_PropBinding->animationType() == qt3dsdm::EAnimationTypeBezier)
+ m_activeChannels[0] = true;
+ else
+ std::fill(m_activeChannels.begin(), m_activeChannels.end(), true);
+
+ for (int i = 0; i < m_rectChannels.size(); ++i)
+ m_rectChannels[i].setRect(22, TimelineConstants::ROW_H * (i+1), 16, 16);
+
+ if (m_parentRow->expanded()) {
setRowVisible(true);
+ // restore property graph expand state if saved
+ if (m_scene->propGraphHeightMap().contains(m_parentRow->instance())) {
+ int propGraphH = m_scene->propGraphHeightMap().value(m_parentRow->instance())
+ .value(m_PropBinding->getPropertyHandle(), 0);
+ m_propGraphExpanded = propGraphH > 0;
+ if (m_propGraphExpanded) {
+ m_propGraphHeight = propGraphH;
+ setMaximumSize(QSizeF(size().width(), m_propGraphHeight));
+ m_rowTimeline->setMaximumSize(QSizeF(size().width(), m_propGraphHeight));
+ m_rowTimeline->propertyGraph()->setExpandHeight(m_propGraphHeight);
+ m_rowTimeline->propertyGraph()->updateChannelFiltering(m_activeChannels);
+ }
+ }
+ }
+
// Update label color
m_labelItem.setMaster(m_PropBinding->IsMaster());
}
@@ -604,11 +720,6 @@ EStudioObjectType RowTree::objectType() const
return m_objectType;
}
-QString RowTree::propertyType() const
-{
- return m_propertyType;
-}
-
int RowTree::type() const
{
// Enable the use of qgraphicsitem_cast with this item.
@@ -947,17 +1058,57 @@ bool RowTree::hasPropertyChildren() const
void RowTree::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
- QPointF p = event->pos();
- if (m_rectType.contains(p.x(), p.y()) && !m_locked)
+ if (m_rectType.contains(event->pos().toPoint()) && !m_locked)
if (m_binding)
m_binding->OpenAssociatedEditor();
}
+void RowTree::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ if (m_locked)
+ return;
+
+ QPoint p = mapFromScene(event->scenePos()).toPoint();
+ QRect *hoveredRect = nullptr;
+ if (m_rectMaximizePropGraph.contains(p)) {
+ setToolTip(tr("Toggle property graph size"));
+ hoveredRect = &m_rectMaximizePropGraph;
+ } else if (m_rectFitPropGraph.contains(p)) {
+ setToolTip(tr("Fit curves"));
+ hoveredRect = &m_rectFitPropGraph;
+ } else if (m_rectColorGradient.contains(p)) {
+ setToolTip(tr("Toggle color gradient"));
+ hoveredRect = &m_rectColorGradient;
+ } else {
+ setToolTip({});
+
+ // check hovering a channel button
+ auto it = std::find_if(m_rectChannels.begin(), m_rectChannels.end(),
+ [&p](const QRect &r){ return r.contains(p); });
+ if (it != m_rectChannels.end())
+ hoveredRect = it;
+ }
+
+ if (m_hoveredRect != hoveredRect) {
+ // Update hover status only if it has changed
+ m_hoveredRect = hoveredRect;
+ update();
+ }
+}
+
+void RowTree::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ InteractiveTimelineItem::hoverLeaveEvent(event);
+
+ m_hoveredRect = nullptr;
+ update();
+}
+
// handle clicked control and return its type
TreeControlType RowTree::getClickedControl(const QPointF &scenePos)
{
- QPointF p = mapFromScene(scenePos.x(), scenePos.y());
- if (m_arrowVisible && m_rectArrow.contains(p.x(), p.y())) {
+ QPoint p = mapFromScene(scenePos).toPoint();
+ if (m_arrowVisible && m_rectArrow.contains(p)) {
updateExpandStatus(m_expandState == ExpandState::Expanded ? ExpandState::Collapsed
: ExpandState::Expanded, false);
update();
@@ -965,19 +1116,57 @@ TreeControlType RowTree::getClickedControl(const QPointF &scenePos)
}
if (hasActionButtons()) {
- if (m_rectShy.contains(p.x(), p.y())) {
+ if (m_rectShy.contains(p)) {
toggleShy();
return TreeControlType::Shy;
- } else if (!m_onMasterSlide && m_rectVisible.contains(p.x(), p.y())) {
+ } else if (!m_onMasterSlide && m_rectVisible.contains(p)) {
// Prevent toggling hide on master slide
toggleVisible();
return TreeControlType::Hide;
- } else if (m_rectLocked.contains(p.x(), p.y())) {
+ } else if (m_rectLocked.contains(p)) {
toggleLocked();
return TreeControlType::Lock;
}
}
+ if (isProperty() && !m_locked) {
+ if (m_rectFitPropGraph.contains(p)) { // toggle fit graph
+ m_rowTimeline->propertyGraph()->fitGraph();
+ } else if (m_rectMaximizePropGraph.contains(p)) { // toggle maximize graph
+ m_propGraphHeight = m_propGraphHeight == TimelineConstants::ROW_GRAPH_H
+ ? TimelineConstants::ROW_GRAPH_H_MAX : TimelineConstants::ROW_GRAPH_H;
+ m_rowTimeline->propertyGraph()->setExpandHeight(m_propGraphHeight);
+ animateExpand(ExpandState::Expanded);
+ m_scene->propGraphHeightMap()[m_parentRow->instance()]
+ .insert(m_PropBinding->getPropertyHandle(), m_propGraphHeight);
+ } else if (m_rectColorGradient.contains(p)) { // toggle color gradient
+ m_rowTimeline->toggleColorGradient();
+ } else { // toggle channels
+ auto it = std::find_if(m_rectChannels.begin(), m_rectChannels.end(),
+ [&p](const QRect &r){ return r.contains(p); });
+
+ if (it != m_rectChannels.end()) { // clicked a channel button
+ bool ctrlDown = CHotKeys::isCtrlDown();
+ int chIdx = int(it->y() / TimelineConstants::ROW_H) - 1;
+ int numSelectedChannel = std::count(m_activeChannels.begin(),
+ m_activeChannels.end(), true);
+ bool isSingleSelected = numSelectedChannel == 1 && m_activeChannels[chIdx];
+ bool isMultiSelected = numSelectedChannel > 1 && m_activeChannels[chIdx];
+ if (!isSingleSelected && !(isMultiSelected && !ctrlDown))
+ m_activeChannels[chIdx] = !m_activeChannels[chIdx];
+
+ if (!ctrlDown) {
+ for (int i = 0; i < m_activeChannels.size(); ++i) {
+ if (i != chIdx)
+ m_activeChannels[i] = false;
+ }
+ }
+ m_rowTimeline->propertyGraph()->updateChannelFiltering(m_activeChannels);
+ update();
+ }
+ }
+ }
+
return TreeControlType::None;
}
@@ -1155,6 +1344,14 @@ void RowTree::setActionStates(ActionStates states)
}
}
+void RowTree::setActivateActions(ITimelineItem::ActivateActions activateActions)
+{
+ if (activateActions != m_activateActions) {
+ m_activateActions = activateActions;
+ update();
+ }
+}
+
bool RowTree::isContainer() const
{
return !m_isProperty && m_objectType & OBJTYPE_IS_CONTAINER;
@@ -1306,21 +1503,48 @@ bool RowTree::hasDurationBar() const
bool RowTree::propertyExpanded() const
{
- return m_isPropertyExpanded;
+ return m_propGraphExpanded;
}
-void RowTree::togglePropertyExpanded()
+/**
+ * toggle property graph if the mouse isn't over other buttons
+ *
+ * @param scenePos mouse position in graphics scene coordinates
+ */
+void RowTree::togglePropertyExpanded(const QPointF &scenePos)
{
- setPropertyExpanded(!m_isPropertyExpanded);
-}
+ QPoint p = mapFromScene(scenePos).toPoint();
-void RowTree::setPropertyExpanded(bool expand)
-{
- m_isPropertyExpanded = expand;
- if (m_isPropertyExpanded)
+ // check mouse over a channel button
+ for (int i = 0; i < m_rectChannels.size(); ++i) {
+ if (m_rectChannels[i].contains(p))
+ return;
+ }
+
+ // check mouse over fit, maximize, or toggle color gradient buttons
+ if (m_rectFitPropGraph.contains(p) || m_rectMaximizePropGraph.contains(p)
+ || m_rectColorGradient.contains(p)) {
+ return;
+ }
+
+ // toggle property graph expand
+ m_propGraphExpanded = !m_propGraphExpanded;
+
+ if (m_propGraphExpanded) {
+ // start graph in normal (not maximized) size
+ m_propGraphHeight = TimelineConstants::ROW_GRAPH_H;
+ m_rowTimeline->propertyGraph()->setExpandHeight(m_propGraphHeight);
+ m_rowTimeline->propertyGraph()->updateChannelFiltering(m_activeChannels);
animateExpand(ExpandState::Expanded);
- else
+
+ m_scene->propGraphHeightMap()[m_parentRow->instance()]
+ .insert(m_PropBinding->getPropertyHandle(), m_propGraphHeight);
+ } else {
animateExpand(ExpandState::Collapsed);
+
+ m_scene->propGraphHeightMap()[m_parentRow->instance()]
+ .remove(m_PropBinding->getPropertyHandle());
+ }
}
void RowTree::showDataInputSelector(const QString &propertyname, const QPoint &pos)
@@ -1334,4 +1558,3 @@ void RowTree::showDataInputSelector(const QString &propertyname, const QPoint &p
m_scene->handleShowDISelector(propertyname, refInstance.Valid() ? refInstance : instance(),
pos);
}
-
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
index b028e94d..179292c9 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -33,8 +33,9 @@
#include "TimelineConstants.h"
#include "RowTypes.h"
#include "StudioObjectTypes.h"
-#include "RowTreeLabelItem.h"
+#include "RowTreeLabel.h"
#include "Qt3DSDMHandles.h"
+#include "Bindings/ITimelineItem.h"
#include <QtCore/qpropertyanimation.h>
#include <QtCore/qparallelanimationgroup.h>
@@ -93,14 +94,15 @@ public:
void removeChild(RowTree *child);
void setDnDState(DnDState state, DnDState onlyIfState = DnDState::Any, bool recursive = false);
void setActionStates(ActionStates states);
+ void setActivateActions(ITimelineItem::ActivateActions activateActions);
void setTreeWidth(double w);
void setBinding(ITimelineItemBinding *binding);
void setPropBinding(ITimelineItemProperty *binding); // for property rows
void selectLabel();
- void togglePropertyExpanded();
- void setPropertyExpanded(bool expand);
+ void togglePropertyExpanded(const QPointF &scenePos = {});
void showDataInputSelector(const QString &propertyname, const QPoint &pos);
ITimelineItemProperty *propBinding();
+ void refreshPropBinding(bool forceSync = false);
TreeControlType getClickedControl(const QPointF &scenePos);
bool shy() const;
bool visible() const;
@@ -152,11 +154,14 @@ public:
void updateFilter();
void updateLock(bool state);
void updateSubpresentations(int updateParentsOnlyVal = 0);
+ int rightDividerX() const;
int clipX() const;
qt3dsdm::Qt3DSDMInstanceHandle instance() const;
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
private:
void initialize();
@@ -183,7 +188,8 @@ private:
bool m_visible = true;
bool m_locked = false;
bool m_isProperty = false;
- bool m_isPropertyExpanded = false;
+ bool m_propGraphExpanded = false;
+ int m_propGraphHeight = TimelineConstants::ROW_GRAPH_H;
bool m_master = false;
bool m_filtered = false;
bool m_arrowVisible = false;
@@ -192,25 +198,32 @@ private:
bool m_onMasterSlide = false;
DnDState m_dndState = DnDState::None;
ActionStates m_actionStates = ActionState::None;
+ ITimelineItem::ActivateActions m_activateActions = ITimelineItem::ActivateAction::None;
bool m_hasSubpresentation = false;
int m_numDescendantSubpresentations = 0;
ExpandState m_expandState = ExpandState::HiddenCollapsed;
TimelineGraphicsScene *m_scene;
- RowTreeLabelItem m_labelItem;
+ RowTreeLabel m_labelItem;
EStudioObjectType m_objectType = OBJTYPE_UNKNOWN;
- QString m_propertyType; // for property rows
QString m_label;
QList<RowTree *> m_childRows;
QList<RowTree *> m_childProps;
QStringList m_variantsGroups;
ITimelineItemBinding *m_binding = nullptr;
ITimelineItemProperty *m_PropBinding = nullptr; // for property rows
+ QRect *m_hoveredRect = nullptr;
QRect m_rectArrow;
QRect m_rectShy;
QRect m_rectVisible;
QRect m_rectLocked;
QRect m_rectType;
+ QRect m_rectMaximizePropGraph;
+ QRect m_rectFitPropGraph;
+ QRect m_rectColorGradient;
+ QVector<QRect> m_rectChannels;
+ QVector<bool> m_activeChannels;
+
QParallelAnimationGroup m_expandAnimation;
QPropertyAnimation *m_expandHeightAnimation;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp
index ae5c0bbb..90bdc3f3 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp
@@ -38,6 +38,7 @@
#include "Qt3DSDMStudioSystem.h"
#include "ClientDataModelBridge.h"
#include "qcursor.h"
+#include "IDocumentEditor.h"
RowTreeContextMenu::RowTreeContextMenu(RowTree *inRowTree, QWidget *parent)
: QMenu(parent)
@@ -75,40 +76,39 @@ void RowTreeContextMenu::initialize()
m_diMenu = addMenu(tr("Set datainput controller"));
connect(m_diMenu, &QMenu::triggered, this, &RowTreeContextMenu::addDiController);
- QVector<qt3dsdm::Qt3DSDMPropertyHandle> propList;
-
// If this is a referenced material instance, we need to get the property list from
// the referenced source, and set datainput control to point to the property
// in the referenced source.
auto refInstance = doc.GetStudioSystem()->GetClientDataModelBridge()
->getMaterialReference(instance);
- propList = doc.GetStudioSystem()->GetPropertySystem()
- ->GetControllableProperties(refInstance ? refInstance : instance);
-
- QMap<int, QAction *> sections;
- for (const auto &prop : propList) {
- QAction *action
- = new QAction(QString::fromStdWString(doc.GetPropertySystem()
- ->GetFormalName(
- refInstance ? refInstance : instance,
- prop).wide_str()));
- action->setData(QString::fromStdWString(
- doc.GetPropertySystem()
- ->GetName(prop).wide_str()));
-
- auto metadata = doc.GetStudioSystem()->GetActionMetaData()->GetMetaDataPropertyInfo(
- doc.GetStudioSystem()->GetActionMetaData()->GetMetaDataProperty(
- refInstance ? refInstance : instance, prop));
-
- if (sections.contains(metadata->m_CompleteType) ) {
- m_diMenu->insertAction(sections[metadata->m_CompleteType], action);
- } else {
- // Create a QAction for a section so that we can insert properties above it
- // to maintain category groupings. Sections are shown as separators in Studio
- // style i.e. enum text is not shown.
- QAction *section = m_diMenu->addSection(QString(metadata->m_CompleteType));
- sections.insert(metadata->m_CompleteType, section);
- m_diMenu->insertAction(section, action);
+ const QVector<QPair<QString, QVector<qt3dsdm::Qt3DSDMPropertyHandle>>> propGroups
+ = doc.GetStudioSystem()->GetPropertySystem()
+ ->GetControllableProperties(refInstance ? refInstance : instance);
+
+ QMap<QString, QAction *> sections;
+ for (const auto &propGroup : propGroups) {
+ const QString group = propGroup.first;
+ const auto &propList = propGroup.second;
+ for (const auto &prop : propList) {
+ QAction *action
+ = new QAction(QString::fromStdWString(
+ doc.GetPropertySystem()->GetFormalName(
+ refInstance ? refInstance : instance,
+ prop).wide_str()));
+ action->setData(QString::fromStdWString(
+ doc.GetPropertySystem()
+ ->GetName(prop).wide_str()));
+
+ if (sections.contains(group) ) {
+ m_diMenu->insertAction(sections[group], action);
+ } else {
+ // Create a QAction for a section so that we can insert properties above it
+ // to maintain category groupings. Sections are shown as separators in Studio
+ // style i.e. enum text is not shown.
+ QAction *section = m_diMenu->addSection(group);
+ sections.insert(group, section);
+ m_diMenu->insertAction(section, action);
+ }
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
index 21b57aaa..7428c47c 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
@@ -26,7 +26,7 @@
**
****************************************************************************/
-#include "RowTreeLabelItem.h"
+#include "RowTreeLabel.h"
#include "TimelineConstants.h"
#include "TimelineItem.h"
#include "RowTree.h"
@@ -36,23 +36,27 @@
#include <QtGui/qevent.h>
#include <QtGui/qtextcursor.h>
-RowTreeLabelItem::RowTreeLabelItem(QGraphicsItem *parent)
+RowTreeLabel::RowTreeLabel(QGraphicsItem *parent)
: QGraphicsTextItem(parent)
, m_locked(false)
, m_master(false)
, m_acceptOnFocusOut(true)
+ , m_labelWidth(100)
{
setTextInteractionFlags(Qt::TextEditorInteraction);
setEnabled(false);
updateLabelColor();
+ QFont font;
+ font.setPixelSize(12);
+ setFont(font);
}
-QString RowTreeLabelItem::label() const
+QString RowTreeLabel::label() const
{
return m_label;
}
-void RowTreeLabelItem::setLabel(const QString &label)
+void RowTreeLabel::setLabel(const QString &label)
{
setPlainText(label);
if (m_label != label) {
@@ -61,43 +65,48 @@ void RowTreeLabelItem::setLabel(const QString &label)
}
}
-void RowTreeLabelItem::setMaster(bool isMaster) {
+void RowTreeLabel::setMaster(bool isMaster) {
if (m_master != isMaster) {
m_master = isMaster;
updateLabelColor();
}
}
-void RowTreeLabelItem::setLocked(bool isLocked) {
+void RowTreeLabel::setLocked(bool isLocked) {
if (m_locked != isLocked) {
m_locked = isLocked;
updateLabelColor();
}
}
-RowTree *RowTreeLabelItem::parentRow() const
+RowTree *RowTreeLabel::rowTree() const
{
return m_rowTree;
}
-void RowTreeLabelItem::setParentRow(RowTree *row)
+void RowTreeLabel::setRowTree(RowTree *row)
{
m_rowTree = row;
}
-int RowTreeLabelItem::type() const
+int RowTreeLabel::type() const
{
// Enable the use of qgraphicsitem_cast with this item.
- return TimelineItem::TypeRowTreeLabelItem;
+ return TimelineItem::TypeRowTreeLabel;
}
-void RowTreeLabelItem::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget)
+void RowTreeLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (!m_rowTree->y()) // prevents flickering when the row is just inserted to the layout
return;
+ // Limit the painted label width, see QT3DS-3913
+ int labelWidth = m_rowTree->treeWidth() - int(TimelineConstants::TREE_ICONS_W) - 30;
+ if (labelWidth != m_labelWidth) {
+ m_labelWidth = labelWidth;
+ setTextWidth(m_labelWidth);
+ }
+
// Remove the HasFocus style state, to prevent the dotted line from being drawn.
QStyleOptionGraphicsItem *style = const_cast<QStyleOptionGraphicsItem *>(option);
style->state &= ~QStyle::State_HasFocus;
@@ -105,7 +114,7 @@ void RowTreeLabelItem::paint(QPainter *painter,
QGraphicsTextItem::paint(painter, option, widget);
}
-void RowTreeLabelItem::focusOutEvent(QFocusEvent *event)
+void RowTreeLabel::focusOutEvent(QFocusEvent *event)
{
if (m_acceptOnFocusOut)
validateLabel();
@@ -122,7 +131,7 @@ void RowTreeLabelItem::focusOutEvent(QFocusEvent *event)
m_acceptOnFocusOut = true;
}
-void RowTreeLabelItem::keyPressEvent(QKeyEvent *event)
+void RowTreeLabel::keyPressEvent(QKeyEvent *event)
{
int key = event->key();
if (key == Qt::Key_Return || key == Qt::Key_Enter) {
@@ -140,7 +149,7 @@ void RowTreeLabelItem::keyPressEvent(QKeyEvent *event)
QGraphicsTextItem::keyPressEvent(event);
}
-QRectF RowTreeLabelItem::boundingRect() const
+QRectF RowTreeLabel::boundingRect() const
{
if (!m_rowTree)
return QGraphicsTextItem::boundingRect();
@@ -151,7 +160,7 @@ QRectF RowTreeLabelItem::boundingRect() const
return QRectF(0, 0, w, TimelineConstants::ROW_H);
}
-void RowTreeLabelItem::validateLabel()
+void RowTreeLabel::validateLabel()
{
QString text = toPlainText().trimmed();
if (text.isEmpty()) {
@@ -159,17 +168,21 @@ void RowTreeLabelItem::validateLabel()
emit labelChanged("");
setLabel(m_label);
return;
+ } else if (text.contains(QChar('.'))) {
+ emit labelChanged(".");
+ setLabel(m_label);
+ return;
}
setLabel(text);
}
-void RowTreeLabelItem::updateLabelColor()
+void RowTreeLabel::updateLabelColor()
{
if (m_locked)
- setDefaultTextColor(CStudioPreferences::GetDisabledTextColor());
+ setDefaultTextColor(CStudioPreferences::disabledTextColor());
else if (m_master)
- setDefaultTextColor(CStudioPreferences::GetMasterColor());
+ setDefaultTextColor(CStudioPreferences::masterColor());
else
- setDefaultTextColor(CStudioPreferences::GetNormalColor());
+ setDefaultTextColor(CStudioPreferences::normalColor());
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
index edffbef5..edddcb99 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
@@ -37,19 +37,19 @@
class RowTree;
-class RowTreeLabelItem : public QGraphicsTextItem
+class RowTreeLabel : public QGraphicsTextItem
{
Q_OBJECT
public:
- explicit RowTreeLabelItem(QGraphicsItem *parent = nullptr);
+ explicit RowTreeLabel(QGraphicsItem *parent = nullptr);
QString label() const;
void setLabel(const QString &label);
void setLocked(bool isLocked);
void setMaster(bool isMaster);
- RowTree *parentRow() const;
- void setParentRow(RowTree *row);
- int type() const;
+ RowTree *rowTree() const;
+ void setRowTree(RowTree *row);
+ int type() const override;
bool isLocked() const { return m_locked; }
protected:
@@ -70,7 +70,7 @@ private:
bool m_locked;
bool m_master;
bool m_acceptOnFocusOut;
-
+ int m_labelWidth;
};
#endif // ROWTREELABELITEM_H
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.cpp
index 62c6de01..a72509df 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.cpp
@@ -33,6 +33,8 @@
#include <QtGui/qpainter.h>
#include <QtWidgets/qwidget.h>
+using namespace TimelineConstants;
+
Ruler::Ruler(TimelineItem *parent) : TimelineItem(parent)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
@@ -42,95 +44,141 @@ void Ruler::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
{
Q_UNUSED(option)
- double xStep = TimelineConstants::RULER_SEC_W / TimelineConstants::RULER_SEC_DIV * m_timeScale;
- double activeSegmentsWidth = TimelineConstants::RULER_EDGE_OFFSET
- + m_duration / 1000.0 * xStep * TimelineConstants::RULER_SEC_DIV;
- double totalSegmentsWidth = TimelineConstants::RULER_EDGE_OFFSET
- + m_maxDuration / 1000.0 * xStep * TimelineConstants::RULER_SEC_DIV;
-
- // Ruler painted width to be at least widget width
- double minRulerWidth = widget->width();
- double rowXMax = std::max(minRulerWidth, totalSegmentsWidth);
+ painter->translate(RULER_EDGE_OFFSET, RULER_BASE_Y);
- painter->save();
+ // draw inactive base line
+ int startX = qMax(m_viewportX - int(RULER_EDGE_OFFSET), 0);
+ int endX = m_viewportX + widget->width();
painter->setPen(CStudioPreferences::timelineRulerColorDisabled());
- painter->drawLine(TimelineConstants::RULER_EDGE_OFFSET,
- TimelineConstants::RULER_BASE_Y,
- rowXMax + TimelineConstants::RULER_EDGE_OFFSET,
- TimelineConstants::RULER_BASE_Y);
- painter->setPen(CStudioPreferences::timelineRulerColor());
- painter->drawLine(TimelineConstants::RULER_EDGE_OFFSET,
- TimelineConstants::RULER_BASE_Y,
- activeSegmentsWidth,
- TimelineConstants::RULER_BASE_Y);
+ painter->drawLine(startX, 0, endX, 0);
+
+ // draw active base line
+ int durEndX = qMin(endX, int(timeToDistance(m_duration)));
+ if (durEndX > startX) {
+ painter->setPen(CStudioPreferences::timelineRulerColor());
+ painter->drawLine(startX, 0, durEndX, 0);
+ }
+ // draw ruler steps and text
QFont font = painter->font();
font.setPointSize(8);
painter->setFont(font);
- const int margin = 50;
- const int secDiv = TimelineConstants::RULER_SEC_DIV;
- double rowX = 0;
bool useDisabledColor = false;
- for (int i = 0; rowX < rowXMax; i++) {
- rowX = TimelineConstants::RULER_EDGE_OFFSET + xStep * i;
-
- // Optimization to skip painting outside the visible area
- if (rowX < (m_viewportX - margin) || rowX > (m_viewportX + minRulerWidth + margin))
+ int startSecond = int(distanceToTime(startX) / 1000);
+ int endSecond = int(distanceToTime(endX) / 1000) + 1;
+
+ static const int LABEL_W = 40;
+ static const int LABEL_H = 10;
+ static const int MIN_SEC_STEP_DIVISION = 20;
+ static const int MIN_SEC_STEP_LABEL = 60;
+ static const int MIN_HALF_SEC_STEP_DIVISION = 10;
+ static const int MIN_HALF_SEC_STEP_LABEL = 70;
+ static const int MIN_ONE_TENTH_STEP_DIVISION = 4;
+ static const int MIN_ONE_TENTH_STEP_LABEL = 30;
+
+ QRectF labelRect(0, 0, LABEL_W, LABEL_H);
+ double secStep = timeToDistance(1000);
+ double halfSecStep = timeToDistance(500);
+ double oneTenthStep = timeToDistance(100);
+
+ int skipperSecLabel = qMax(int(MIN_SEC_STEP_LABEL / secStep), 1);
+ if (skipperSecLabel > 5)
+ skipperSecLabel = lroundf(skipperSecLabel / 5.f) * 5;
+
+ int skipperSecDivision = qMax(int(MIN_SEC_STEP_DIVISION / secStep), 1);
+
+ // keep skipperSecLabel and skipperSecDivision in sync
+ if (skipperSecLabel > 5 && skipperSecDivision % 5)
+ skipperSecDivision = lroundf(skipperSecLabel / 10.f) * 5;
+
+ bool drawHalfSecDiv = halfSecStep > MIN_HALF_SEC_STEP_DIVISION;
+ bool drawHalfSecLabel = halfSecStep > MIN_HALF_SEC_STEP_LABEL;
+ bool drawOneTenthDiv = oneTenthStep > MIN_ONE_TENTH_STEP_DIVISION;
+ bool drawOneTenthLabel = oneTenthStep > MIN_ONE_TENTH_STEP_LABEL;
+
+ for (int i = startSecond; i <= endSecond; ++i) { // draw seconds
+ if (i % skipperSecDivision)
continue;
- const int h = i % secDiv == 0 ? TimelineConstants::RULER_DIV_H1
- : i % secDiv == secDiv * 0.5 ? TimelineConstants::RULER_DIV_H2
- : TimelineConstants::RULER_DIV_H3;
-
- if (!useDisabledColor && rowX > activeSegmentsWidth) {
+ int x = int(timeToDistance(i * 1000));
+ if (!useDisabledColor && x > durEndX) {
painter->setPen(CStudioPreferences::timelineRulerColorDisabled());
useDisabledColor = true;
}
- painter->drawLine(QPointF(rowX, TimelineConstants::RULER_BASE_Y - h),
- QPointF(rowX, TimelineConstants::RULER_BASE_Y - 1));
-
- // See if label should be shown at this tick at this zoom level
- bool drawTimestamp = false;
- if ((i % (secDiv * 4) == 0)
- || (i % (secDiv * 2) == 0 && m_timeScale >= TimelineConstants::RULER_TICK_SCALE1)
- || (i % secDiv == 0 && m_timeScale >= TimelineConstants::RULER_TICK_SCALE2)
- || (i % secDiv == secDiv * 0.5
- && m_timeScale >= TimelineConstants::RULER_TICK_SCALE3)
- || (m_timeScale >= TimelineConstants::RULER_TICK_SCALE4)) {
- drawTimestamp = true;
+
+ // draw second division
+ painter->drawLine(x, -RULER_DIV_H1, x, 0);
+
+ if (i % skipperSecLabel == 0) { // draw label if not skipped
+ labelRect.moveTo(x - LABEL_W / 2, -LABEL_H - 7);
+ painter->drawText(labelRect, Qt::AlignCenter, formatTime(i));
}
- if (drawTimestamp) {
- QRectF timestampPos = QRectF(TimelineConstants::RULER_EDGE_OFFSET
- + xStep * i - TimelineConstants::RULER_LABEL_W / 2,
- 1, TimelineConstants::RULER_LABEL_W,
- TimelineConstants::RULER_LABEL_H);
- painter->drawText(timestampPos, Qt::AlignCenter,
- timestampString(i * 1000 / TimelineConstants::RULER_SEC_DIV));
+ // draw half seconds
+ if (!drawHalfSecDiv || i == endSecond)
+ continue;
+
+ x = int(timeToDistance(i * 1000 + 500));
+ if (!useDisabledColor && x > durEndX) {
+ painter->setPen(CStudioPreferences::timelineRulerColorDisabled());
+ useDisabledColor = true;
}
+ painter->drawLine(x, -RULER_DIV_H2, x, 0);
- }
+ if (drawHalfSecLabel) {
+ labelRect.moveTo(x - LABEL_W / 2, -LABEL_H - 7);
+ painter->drawText(labelRect, Qt::AlignCenter, formatTime(i + .5));
+ }
+
+ // draw one tenth
+ if (!drawOneTenthDiv)
+ continue;
- painter->restore();
+ for (int j = 1; j <= 9; ++j) {
+ if (j != 5) {
+ x = int(timeToDistance(i * 1000 + j * 100));
+ if (!useDisabledColor && x > durEndX) {
+ painter->setPen(CStudioPreferences::timelineRulerColorDisabled());
+ useDisabledColor = true;
+ }
+ painter->drawLine(x, -RULER_DIV_H3, x, 0);
+
+ if (drawOneTenthLabel) {
+ labelRect.moveTo(x - LABEL_W / 2, -LABEL_H - 7);
+ painter->drawText(labelRect, Qt::AlignCenter, formatTime(i + .1 * j));
+ }
+ }
+ }
+ }
}
-void Ruler::setTimelineScale(double scl)
+void Ruler::setTimelineScale(int scl)
{
- m_timeScale = scl;
+ // scl is in the range 0..100, project it to an exponential value
+ bool isScaleDown = scl < 50;
+ const double normVal = abs(scl - 50) / 10.; // normalize to range 5..0..5 from scale down to up
+ double scaleVal = pow(normVal, 1.3);
+
+ // For scaling down normalize to range -1..0. 5^1.3 is max scaleVal but 5.1 is used to make
+ // sure scaleVal doesn't reach -1 in which case m_timeScale would become 0.
+ if (isScaleDown)
+ scaleVal /= -pow(5.1, 1.3);
+
+ m_timeScale = 1 + scaleVal;
update();
}
// convert distance values to time (milliseconds)
long Ruler::distanceToTime(double distance) const
{
- return distance / (TimelineConstants::RULER_MILLI_W * m_timeScale);
+ return long(distance / (RULER_MILLI_W * m_timeScale));
}
// convert time (milliseconds) values to distance
double Ruler::timeToDistance(long time) const
{
- return time * TimelineConstants::RULER_MILLI_W * m_timeScale;
+ return time * RULER_MILLI_W * m_timeScale;
}
double Ruler::timelineScale() const
@@ -159,7 +207,6 @@ void Ruler::setDuration(long duration)
if (m_duration != duration) {
m_duration = duration;
update();
- emit durationChanged(m_duration);
}
}
@@ -181,35 +228,23 @@ void Ruler::setViewportX(int viewportX)
}
}
+// x position at the left edge of the timeline (0 when no scrolling)
int Ruler::viewportX() const
{
return m_viewportX;
}
-// Returns timestamp in mm:ss.ttt or ss.ttt format
-const QString Ruler::timestampString(int timeMs)
+// Returns ruler time in m:s.t or s.t format
+const QString Ruler::formatTime(double seconds)
{
- static const QString zeroString = tr("0");
- static const QChar fillChar = tr("0").at(0);
- static const QString noMinutesTemplate = tr("%1.%2");
- static const QString minutesTemplate = tr("%1:%2.%3");
-
- int ms = timeMs % 1000;
- int s = timeMs % 60000 / 1000;
- int m = timeMs % 3600000 / 60000;
- const QString msString = QString::number(ms).rightJustified(3, fillChar);
- const QString sString = QString::number(s);
-
- if (timeMs == 0) {
- return zeroString;
- } else if (m == 0) {
- if (s < 10)
- return noMinutesTemplate.arg(sString).arg(msString);
- else
- return noMinutesTemplate.arg(sString.rightJustified(2, fillChar)).arg(msString);
- } else {
- return minutesTemplate.arg(m).arg(sString.rightJustified(2, fillChar)).arg(msString);
- }
+ if (seconds < 60)
+ return QString::number(seconds);
+
+ int mins = int(seconds) / 60;
+ double secs = seconds - mins * 60;
+
+ const QChar fillChar = tr("0").at(0);
+ return QStringLiteral("%1:%2").arg(mins).arg(QString::number(secs).rightJustified(2, fillChar));
}
int Ruler::type() const
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.h
index 005a23c3..355d3447 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/Ruler.h
@@ -41,7 +41,7 @@ signals:
public:
explicit Ruler(TimelineItem *parent = nullptr);
- void setTimelineScale(double scl);
+ void setTimelineScale(int scl);
long distanceToTime(double distance) const;
double timeToDistance(long time) const;
double timelineScale() const;
@@ -59,12 +59,12 @@ protected:
signals:
void maxDurationChanged(long maxDuration);
- void durationChanged(long duration);
void viewportXChanged(int viewportX);
private:
- const QString timestampString(int timeMs);
- double m_timeScale = 2;
+ const QString formatTime(double seconds);
+
+ double m_timeScale = 1.;
long m_duration = 0; // milliseconds
long m_maxDuration = 0; // milliseconds
int m_viewportX = 0;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.cpp
index 866d8109..205158e1 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.cpp
@@ -33,7 +33,7 @@
TimelineItem::TimelineItem(TimelineItem *parent) : QGraphicsWidget(parent)
{
- setPreferredHeight(TimelineConstants::ROW_H_EXPANDED);
+ setPreferredHeight(TimelineConstants::ROW_GRAPH_H_MAX);
setMaximumHeight(TimelineConstants::ROW_H);
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h
index 71d26c0d..e84eb73b 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineItem.h
@@ -39,16 +39,16 @@ public:
explicit TimelineItem(TimelineItem *parent = nullptr);
enum ItemType {
- TypeTimelineItem = UserType + 1,
- TypeInteractiveTimelineItem,
- TypeTreeHeader,
- TypeRowTree,
- TypeRowTreeLabelItem,
- TypeRowTimeline,
- TypeRowTimelineCommentItem,
- TypePlayHead,
- TypeRuler,
- TypeRowMover
+ TypeTimelineItem = UserType << 1,
+ TypeInteractiveTimelineItem = UserType << 2,
+ TypeTreeHeader = UserType << 3,
+ TypeRowTree = UserType << 4,
+ TypeRowTreeLabel = UserType << 5,
+ TypeRowTimeline = UserType << 6,
+ TypeRowTimelineCommentItem = UserType << 7,
+ TypePlayHead = UserType << 8,
+ TypeRuler = UserType << 9,
+ TypeRowMover = UserType << 10
};
int type() const override;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
index 05d24fa6..b587cf51 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp
@@ -46,6 +46,24 @@
#include <QtWidgets/qpushbutton.h>
#include <QtWidgets/qshortcut.h>
+class TimelineScaleEventfilter : public QObject
+{
+public:
+ TimelineScaleEventfilter(QObject *parent) : QObject(parent) {}
+
+ bool eventFilter(QObject *obj, QEvent *event) override
+ {
+ // reset scale upon double clicking the scale slider's head
+ if (event->type() == QEvent::MouseButtonDblClick) {
+ static_cast<QSlider *>(obj)->setValue(50);
+ event->accept();
+ return true;
+ }
+
+ return QObject::eventFilter(obj, event);
+ }
+};
+
TimelineToolbar::TimelineToolbar() : QToolBar()
{
setContentsMargins(0, 0, 0, 0);
@@ -85,16 +103,17 @@ TimelineToolbar::TimelineToolbar() : QToolBar()
m_scaleSlider = new QSlider();
m_scaleSlider->setOrientation(Qt::Horizontal);
m_scaleSlider->setFixedWidth(100);
- m_scaleSlider->setMinimum(1);
- m_scaleSlider->setMaximum(22);
- m_scaleSlider->setValue(2);
+ m_scaleSlider->setMinimum(0);
+ m_scaleSlider->setMaximum(100);
+ m_scaleSlider->setValue(50);
+ m_scaleSlider->installEventFilter(new TimelineScaleEventfilter(this));
m_timeLabel->setObjectName(QLatin1String("timelineButton"));
m_timeLabel->setFlat(true);
m_timeLabel->setMinimumWidth(80);
m_timeLabel->setToolTip(tr("Go To Time (%1%2T)").arg(ctrlKey).arg(altKey));
- m_diLabel->setText("");
+ m_diLabel->clear();
m_diLabel->setMinimumWidth(100);
m_diLabel->setAlignment(Qt::AlignCenter);
QString styleString = "QLabel { background: transparent; color: "
@@ -256,12 +275,12 @@ void TimelineToolbar::onZoomLevelChanged(int scale)
void TimelineToolbar::onZoomInButtonClicked()
{
- m_scaleSlider->setValue(m_scaleSlider->value() + 1);
+ m_scaleSlider->setValue(m_scaleSlider->value() + 5);
}
void TimelineToolbar::onZoomOutButtonClicked()
{
- m_scaleSlider->setValue(m_scaleSlider->value() - 1);
+ m_scaleSlider->setValue(m_scaleSlider->value() - 5);
}
void TimelineToolbar::onDiButtonClicked()
@@ -283,6 +302,8 @@ bool TimelineToolbar::isVariantsFilterOn() const
void TimelineToolbar::updateDataInputStatus()
{
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ if (!doc->isValid())
+ return;
qt3dsdm::Qt3DSDMPropertyHandle ctrldProp;
qt3dsdm::Qt3DSDMInstanceHandle timeCtxRoot = doc->GetActiveRootInstance();
CClientDataModelBridge *theClientBridge = doc->GetStudioSystem()->GetClientDataModelBridge();
@@ -391,29 +412,29 @@ void TimelineToolbar::onDataInputChange(int handle, int instance, const QString
timeCtxRoot, ctrldPropertyHandle, controlledPropertyVal);
auto existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal);
- int slideStrPos = existingCtrl.indexOf("@timeline");
+ int slideStrPos = existingCtrl.indexOf(QLatin1String("@timeline"));
if (slideStrPos != -1) {
// find the controlling datainput name and build the string to replace
- int ctrStrPos = existingCtrl.lastIndexOf("$", slideStrPos - 2);
+ int ctrStrPos = existingCtrl.lastIndexOf(QLatin1Char('$'), slideStrPos - 2);
QString prevCtrler = existingCtrl.mid(ctrStrPos, slideStrPos - ctrStrPos);
existingCtrl.replace(prevCtrler + "@timeline", fullTimeControlStr);
} else {
if (!existingCtrl.isEmpty() && m_currController.size())
- existingCtrl.append(" ");
+ existingCtrl.append(QLatin1Char(' '));
existingCtrl.append(fullTimeControlStr);
}
- if (existingCtrl.endsWith(" "))
+ if (existingCtrl.endsWith(QLatin1Char(' ')))
existingCtrl.chop(1);
- if (existingCtrl.startsWith(" "))
+ if (existingCtrl.startsWith(QLatin1Char(' ')))
existingCtrl.remove(0, 1);
m_diLabel->setText(m_currController);
qt3dsdm::SValue fullCtrlPropVal
= std::make_shared<qt3dsdm::CDataStr>(
Q3DStudio::CString::fromQString(existingCtrl));
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Timeline control"))
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Timeline control"))
->SetInstancePropertyValue(timeCtxRoot, ctrldPropertyHandle, fullCtrlPropVal);
}
@@ -438,18 +459,12 @@ void TimelineToolbar::OnImmediateRefreshInstanceMultiple(qt3dsdm::Qt3DSDMInstanc
Q_UNUSED(inInstanceCount)
}
-// Notify the user about control state change also with timeline dock
-// title color change.
+// Notify the user about control state change also with timeline dock title color change.
void TimelineToolbar::updateTimelineTitleColor(bool controlled)
{
- QString styleString;
- if (controlled) {
- styleString = "QDockWidget#timeline { color: "
- + QString(CStudioPreferences::dataInputColor().name()) + "; }";
- } else {
- styleString = "QDockWidget#timeline { color: "
- + QString(CStudioPreferences::textColor().name()) + "; }";
- }
+ QString styleString = QStringLiteral("QDockWidget#timeline { color: %1; }")
+ .arg(controlled ? CStudioPreferences::dataInputColor().name()
+ : CStudioPreferences::textColor().name());
QWidget *timelineDock = parentWidget()->parentWidget()->parentWidget();
timelineDock->setStyleSheet(styleString);
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeader.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeader.cpp
index 55e0a8fe..180b6ab4 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeader.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeader.cpp
@@ -144,22 +144,22 @@ void TreeHeader::toggleFilterLocked()
void TreeHeader::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
- QPointF p = event->scenePos();
+ QPoint p = event->scenePos().toPoint();
TreeControlType hoveredItem = TreeControlType::None;
- if (m_rectShy.contains(p.x(), p.y())) {
+ if (m_rectShy.contains(p)) {
QString action = m_shy ? tr("Show") : tr("Hide");
setToolTip(tr("%1 shy objects").arg(action));
hoveredItem = TreeControlType::Shy;
- } else if (m_rectVisible.contains(p.x(), p.y())) {
+ } else if (m_rectVisible.contains(p)) {
QString action = m_visible ? tr("Show") : tr("Hide");
setToolTip(tr("%1 inactive objects").arg(action));
hoveredItem = TreeControlType::Hide;
- } else if (m_rectLock.contains(p.x(), p.y())) {
+ } else if (m_rectLock.contains(p)) {
QString action = m_lock ? tr("Show") : tr("Hide");
setToolTip(tr("%1 locked objects").arg(action));
hoveredItem = TreeControlType::Lock;
} else {
- setToolTip("");
+ setToolTip({});
}
if (m_hoveredItem != hoveredItem) {
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp
index df784418..3efc033d 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/TreeHeaderView.cpp
@@ -33,14 +33,15 @@ TreeHeaderView::TreeHeaderView(QWidget *parent)
{
}
-void TreeHeaderView::scrollContentsBy(int dx, int dy)
+/**
+ * Overridden to ignore scrolling after initial show related scrolling has been finished
+ *
+ * When RowTreeLabel (QGraphicsTextItem) gets focus for text editing, it forces views to scroll
+ * themselves so that editable text item is always visible. We don't want tree header view to move.
+ * @see QGraphicsTextItemPrivate::textControl() and _q_ensureVisible()
+ */
+void TreeHeaderView::scrollContentsBy(int dx, int dy)
{
- // Overridden to ignore scrolling after initial show related scrolling has been finished
- //
- // Longer explanation: When RowTreeLabelItem (QGraphicsTextItem) gets focus
- // for text editing, it forces views to scroll themselves so that editable
- // text item is always visible. But we don't want tree header view to move.
- // See QGraphicsTextItemPrivate::textControl() and _q_ensureVisible()
if (m_allowScrolling)
QGraphicsView::scrollContentsBy(dx, dy);
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml b/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml
index 727488f4..c6b50832 100644
--- a/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/controls/BrowserCombo.qml
@@ -36,6 +36,7 @@ MouseArea {
property alias value: value.text
property var activeBrowser
property bool blockShow: false
+ property bool validData
signal showBrowser
@@ -64,6 +65,7 @@ MouseArea {
StyledLabel {
id: value
+ validData: root.validData
anchors.fill: parent
horizontalAlignment: Text.AlignLeft
rightPadding: 6 + img.width
diff --git a/src/Authoring/Qt3DStudio/Palettes/controls/FloatTextField.qml b/src/Authoring/Qt3DStudio/Palettes/controls/FloatTextField.qml
index 95458889..dbeb81ea 100644
--- a/src/Authoring/Qt3DStudio/Palettes/controls/FloatTextField.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/controls/FloatTextField.qml
@@ -38,6 +38,8 @@ TextField {
property bool ignoreHotkeys: true
signal previewValueChanged
+ signal triggerUndo
+ signal triggerRedo
selectByMouse: true
text: "0.000"
@@ -198,6 +200,13 @@ TextField {
if (!rateLimiter.running)
rateLimiter.start();
+ } else if ((event.modifiers & Qt.ControlModifier)
+ && !(event.modifiers & Qt.ShiftModifier)) {
+ // Undo & redo handling (QT3DS-4000)
+ if (event.key === Qt.Key_Z)
+ floatTextFieldId.triggerUndo();
+ else if (event.key === Qt.Key_Y)
+ floatTextFieldId.triggerRedo();
}
}
}
diff --git a/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml b/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml
index 5185b2ad..4f101f05 100644
--- a/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml
+++ b/src/Authoring/Qt3DStudio/Palettes/controls/StyledLabel.qml
@@ -32,8 +32,10 @@ import QtQuick.Layouts 1.3
Label {
id: styledLabelId
+ property bool validData: true
+
font.pixelSize: _fontSize
- color: _textColor
+ color: validData ? _textColor : _invalidDataIndicatorColor
Layout.preferredHeight: _controlBaseHeight
Layout.preferredWidth: _idWidth
verticalAlignment: Text.AlignVCenter
diff --git a/src/Authoring/Qt3DStudio/PreviewHelper.cpp b/src/Authoring/Qt3DStudio/PreviewHelper.cpp
index 56d08804..24d7ee91 100644
--- a/src/Authoring/Qt3DStudio/PreviewHelper.cpp
+++ b/src/Authoring/Qt3DStudio/PreviewHelper.cpp
@@ -62,7 +62,7 @@ void CPreviewHelper::OnPreview(const QString &viewerExeName)
Q3DStudio::CBuildConfigurations &theConfigurations =
g_StudioApp.GetCore()->GetBuildConfigurations();
Q3DStudio::CBuildConfiguration *theBuildConfiguration =
- theConfigurations.GetConfiguration(CStudioPreferences::GetPreviewConfig());
+ theConfigurations.GetConfiguration(CStudioPreferences::previewConfig());
if (theBuildConfiguration)
PreviewViaConfig(theBuildConfiguration, EXECMODE_PREVIEW, viewerExeName);
}
@@ -76,7 +76,7 @@ void CPreviewHelper::OnDeploy(RemoteDeploymentSender &project)
Q3DStudio::CBuildConfigurations &theConfigurations =
g_StudioApp.GetCore()->GetBuildConfigurations();
Q3DStudio::CBuildConfiguration *theBuildConfiguration =
- theConfigurations.GetConfiguration(CStudioPreferences::GetPreviewConfig());
+ theConfigurations.GetConfiguration(CStudioPreferences::previewConfig());
if (theBuildConfiguration) {
// ItemDataPtr != nullptr ==> Build configurations specified NANT pipeline exporter
PreviewViaConfig(theBuildConfiguration, EXECMODE_DEPLOY, QString(), &project);
@@ -118,18 +118,15 @@ QString CPreviewHelper::getViewerFilePath(const QString &exeName)
viewerFile = QStringLiteral("%1.exe").arg(exeName);
QString viewer = viewerDir.filePath() + QStringLiteral("/") + viewerFile;
- if (!QFileInfo(viewer).exists()
- && exeName == QLatin1String("q3dsviewer")) {
- viewer = viewerDir.filePath() + QStringLiteral("/../src/Runtime/qt3d-runtime/bin/")
+ if (!QFileInfo(viewer).exists() && exeName == QLatin1String("Qt3DViewer")) {
+ viewer = viewerDir.filePath() + QStringLiteral("/../src/Runtime/ogl-runtime/bin/")
+ viewerFile;
}
#else
#ifdef Q_OS_MACOS
- // Check if we're looking for Viewer 2.x that has a different development
- // time path for the executable
QString viewerDevPath;
- if (exeName == QLatin1String("q3dsviewer"))
- viewerDevPath = QStringLiteral("../src/Runtime/qt3d-runtime/bin/");
+ if (exeName == QLatin1String("Qt3DViewer"))
+ viewerDevPath = QStringLiteral("../src/Runtime/ogl-runtime/bin/");
// Name of the executable file on macOS
viewerFile = QStringLiteral("%1.app/Contents/MacOS/%1").arg(exeName);
@@ -151,9 +148,8 @@ QString CPreviewHelper::getViewerFilePath(const QString &exeName)
viewerFile = exeName;
QString viewer = viewerDir.filePath() + QStringLiteral("/") + viewerFile;
- if (!QFileInfo(viewer).exists()
- && exeName == QLatin1String("q3dsviewer")) {
- viewer = viewerDir.filePath() + QStringLiteral("/../src/Runtime/qt3d-runtime/bin/")
+ if (!QFileInfo(viewer).exists() && exeName == QLatin1String("Qt3DViewer")) {
+ viewer = viewerDir.filePath() + QStringLiteral("/../src/Runtime/ogl-runtime/bin/")
+ viewerFile;
}
#endif
@@ -202,7 +198,8 @@ void CPreviewHelper::DoPreviewViaConfig(Q3DStudio::CBuildConfiguration * /*inSel
Q_ASSERT(project);
project->streamProject(inDocumentFile);
} else if (inMode == EXECMODE_PREVIEW
- && CStudioPreferences::GetPreviewProperty("PLATFORM") == "PC") {
+ && CStudioPreferences::previewProperty(QStringLiteral("PLATFORM"))
+ == QLatin1String("PC")) {
// Quick Preview on PC without going via NANT
QString theCommandStr = getViewerFilePath(viewerExeName);
QString *pDocStr = new QString(inDocumentFile);
diff --git a/src/Authoring/Qt3DStudio/Qt3DStudio.pro b/src/Authoring/Qt3DStudio/Qt3DStudio.pro
index 5a7af2a3..ddece619 100644
--- a/src/Authoring/Qt3DStudio/Qt3DStudio.pro
+++ b/src/Authoring/Qt3DStudio/Qt3DStudio.pro
@@ -105,12 +105,31 @@ STATICRUNTIME = \
QMAKE_LFLAGS += $$STATICRUNTIME
} else {
DEFINES += WIN32_LEAN_AND_MEAN
- LIBS += $$STATICRUNTIME
- !mingw: QMAKE_LFLAGS += /NODEFAULTLIB:tinyxml.lib
+ mingw {
+ LIBS += -lEASTL$$qtPlatformTargetSuffix() \
+ -lpcre$$qtPlatformTargetSuffix() \
+ -lTinyXML$$qtPlatformTargetSuffix() \
+ -lColladaDOM$$qtPlatformTargetSuffix() \
+ -lQT3DSDM$$qtPlatformTargetSuffix() \
+ -lCommonLib$$qtPlatformTargetSuffix() \
+ -lCoreLib$$qtPlatformTargetSuffix() \
+ -lqt3dsruntimestatic$$qtPlatformTargetSuffix()
+ } else {
+ LIBS += $$STATICRUNTIME
+ QMAKE_LFLAGS += /NODEFAULTLIB:tinyxml.lib
+ }
+
}
-!macos {
- LIBS += -lQt5Studio3D$$qtPlatformTargetSuffix()
+if (qtHaveModule(3dstudio)) {
+ QT += 3dstudio 3dstudio-private
+} else {
+ RUNTIME_LIB = $$qt5LibraryTarget(QtStudio3D$$QT_LIBINFIX)
+ macos {
+ LIBS += -framework QtStudio3D
+ } else {
+ LIBS += -l$$RUNTIME_LIB
+ }
}
LIBS += \
@@ -194,7 +213,7 @@ HEADERS += \
Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.h \
Palettes/TimelineGraphicsView/ui/RowTree.h \
Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.h \
- Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h \
+ Palettes/TimelineGraphicsView/ui/RowTreeLabel.h \
Palettes/TimelineGraphicsView/ui/Ruler.h \
Palettes/TimelineGraphicsView/ui/TimelineItem.h \
Palettes/TimelineGraphicsView/ui/TimelineToolbar.h \
@@ -204,7 +223,9 @@ HEADERS += \
remotedeploymentsender.h \
Render/StudioGradientWidget.h \
Render/StudioVisualAidWidget.h \
+ Render/StudioHelperGridWidget.h \
Render/StudioSubPresentationRenderer.h \
+ Render/StudioRendererTranslation.h \
UI/EditCameraBar.h \
UI/GLVersionDlg.h \
UI/InterpolationDlg.h \
@@ -314,7 +335,6 @@ SOURCES += \
Palettes/Inspector/Qt3DSDMInspectable.cpp \
Palettes/Inspector/Qt3DSDMInspectorGroup.cpp \
Palettes/Inspector/Qt3DSDMInspectorRow.cpp \
- Palettes/Inspector/Qt3DSDMMaterialInspectable.cpp \
Palettes/Inspector/TabOrderHandler.cpp \
Palettes/Inspector/TextureChooserView.cpp \
Palettes/PaletteManager.cpp \
@@ -331,7 +351,6 @@ SOURCES += \
Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp \
Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp \
Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp \
- Palettes/Timeline/Bindings/OffsetKeyframesCommandHelper.cpp \
Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.cpp \
Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp \
Palettes/Timeline/Bindings/Qt3DSDMAssetTimelineKeyframe.cpp \
@@ -359,7 +378,7 @@ SOURCES += \
Palettes/TimelineGraphicsView/ui/RowTimelinePropertyGraph.cpp \
Palettes/TimelineGraphicsView/ui/RowTree.cpp \
Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp \
- Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp \
+ Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp \
Palettes/TimelineGraphicsView/ui/Ruler.cpp \
Palettes/TimelineGraphicsView/ui/TimelineItem.cpp \
Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp \
@@ -376,6 +395,7 @@ SOURCES += \
Render/StudioScaleWidget.cpp \
Render/StudioTranslationWidget.cpp \
Render/StudioVisualAidWidget.cpp \
+ Render/StudioHelperGridWidget.cpp \
Render/StudioWidget.cpp \
Render/WGLRenderContext.cpp \
Render/StudioSubPresentationRenderer.cpp \
@@ -479,19 +499,19 @@ ABS_PRJ_ROOT = $$absolute_path($$PWD/../../..)
macos:ABS_DEST_DIR = $$absolute_path($$BINDIR)/$${TARGET}.app/Contents/Resources
!macos:ABS_DEST_DIR = $$absolute_path($$BINDIR)
-copy_content.files = $$PWD/../../Runtime/ogl-runtime/Studio/*
+copy_content.files = $$files($$PWD/../../Runtime/ogl-runtime/Studio/*)
copy_content.path = $$ABS_DEST_DIR
COPIES += copy_content
-install_content.files = $$PWD/../../Runtime/ogl-runtime/Studio/*
+install_content.files = $$files($$PWD/../../Runtime/ogl-runtime/Studio/*)
install_content.path = $$[QT_INSTALL_BINS]
INSTALLS += install_content
-copy_buildconfig.files = $$PWD/../../../Studio/*
+copy_buildconfig.files = $$files($$PWD/../../../Studio/*)
copy_buildconfig.path = $$ABS_DEST_DIR
COPIES += copy_buildconfig
-install_buildconfig.files = $$PWD/../../../Studio/*
+install_buildconfig.files = $$files($$PWD/../../../Studio/*)
install_buildconfig.path = $$[QT_INSTALL_BINS]
INSTALLS += install_buildconfig
diff --git a/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h b/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h
index fc543a89..6adaafbf 100644
--- a/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h
+++ b/src/Authoring/Qt3DStudio/Render/IStudioRenderer.h
@@ -67,6 +67,8 @@ public:
virtual void SetGuidesEnabled(bool val) = 0;
virtual bool AreGuidesEditable() const = 0;
virtual void SetGuidesEditable(bool val) = 0;
+ virtual bool getObjectError(qt3dsdm::Qt3DSDMInstanceHandle theInstance,
+ QString &error) const = 0;
// Setting the camera to -1 disables the edit cameras
// So setting the camera to 0- (numcameras - 1) will set change the active
// edit camera.
diff --git a/src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.cpp b/src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.cpp
new file mode 100644
index 00000000..f1020fb1
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "Qt3DSCommonPrecompile.h"
+#include "StudioHelperGridWidget.h"
+#include "render/Qt3DSRenderContext.h"
+#include "Qt3DSRenderShaderCodeGeneratorV2.h"
+#include "render/Qt3DSRenderShaderProgram.h"
+
+#include <QtGui/qcolor.h>
+
+using namespace qt3ds::render;
+
+namespace qt3ds {
+namespace widgets {
+
+SHelperGridWidget::SHelperGridWidget(NVAllocatorCallback &inAlloc)
+ : IRenderWidget()
+ , m_rotation(QT3DSMat44::createIdentity())
+ , m_dirty(true)
+ , m_allocator(inAlloc)
+ , mRefCount(0)
+{
+}
+
+void SHelperGridWidget::setNode(SNode *node)
+{
+ m_Node = node;
+}
+
+void SHelperGridWidget::rotate(float angleRadians, const QT3DSVec3 &axis)
+{
+ m_rotation = QT3DSMat44::createIdentity();
+ if (angleRadians != 0.f)
+ m_rotation.rotate(angleRadians, axis);
+}
+
+void SHelperGridWidget::setColors(const QColor &gridColor, const QColor &xColor,
+ const QColor &yColor)
+{
+ QT3DSVec3 theGridColor = QT3DSVec3(gridColor.redF(), gridColor.greenF(), gridColor.blueF());
+ QT3DSVec3 theXColor = QT3DSVec3(xColor.redF(), xColor.greenF(), xColor.blueF());
+ QT3DSVec3 theYColor = QT3DSVec3(yColor.redF(), yColor.greenF(), yColor.blueF());
+
+ if (theGridColor != m_gridColor || theXColor != m_xColor || theYColor != m_yColor)
+ m_dirty = true;
+
+ m_gridColor = theGridColor;
+ m_xColor = theXColor;
+ m_yColor = theYColor;
+}
+
+void SHelperGridWidget::setLines(int count, float spacing)
+{
+ if (count != m_lineCount || spacing != m_lineSpacing)
+ m_dirty = true;
+
+ m_lineCount = count;
+ m_lineSpacing = spacing;
+}
+
+void SHelperGridWidget::setupShader(IRenderWidgetContext &context)
+{
+ m_shader = context.GetShader(m_itemName);
+ if (!m_shader) {
+ qt3ds::render::IShaderProgramGenerator &generator(context.GetProgramGenerator());
+ generator.BeginProgram();
+ qt3ds::render::IShaderStageGenerator &vertexGenerator(
+ *generator.GetStage(qt3ds::render::ShaderGeneratorStages::Vertex));
+ qt3ds::render::IShaderStageGenerator &fragmentGenerator(
+ *generator.GetStage(qt3ds::render::ShaderGeneratorStages::Fragment));
+ vertexGenerator.AddIncoming("attr_pos", "vec3");
+ vertexGenerator.AddIncoming("attr_color", "vec3");
+ vertexGenerator.AddOutgoing("output_color", "vec3");
+ vertexGenerator.AddUniform("model_view_projection", "mat4");
+ vertexGenerator.Append("void main() {");
+ vertexGenerator.Append(
+ "\tgl_Position = model_view_projection * vec4(attr_pos, 1.0);");
+ vertexGenerator.Append("\toutput_color = attr_color;");
+ vertexGenerator.Append("}");
+ fragmentGenerator.Append("void main() {");
+ fragmentGenerator.Append("\tgl_FragColor.rgb = output_color;");
+ fragmentGenerator.Append("\tgl_FragColor.a = 1.0;");
+ fragmentGenerator.Append("}");
+ m_shader = context.CompileAndStoreShader(m_itemName);
+ }
+}
+
+void SHelperGridWidget::setupGraphicsObjects(IRenderWidgetContext &context,
+ NVDataRef<QT3DSVec3> lines)
+{
+ qt3ds::render::NVRenderVertexBufferEntry entries[] = {
+ qt3ds::render::NVRenderVertexBufferEntry(
+ "attr_pos", qt3ds::render::NVRenderComponentTypes::QT3DSF32, 3),
+ qt3ds::render::NVRenderVertexBufferEntry(
+ "attr_color", qt3ds::render::NVRenderComponentTypes::QT3DSF32, 3, 12),
+ };
+
+ NVRenderVertexBuffer *vertexBuffer = &context.GetOrCreateVertexBuffer(
+ m_itemName, 6 * sizeof(QT3DSF32), toU8DataRef(lines.begin(), lines.size()));
+ m_inputAssembler = context.GetInputAssembler(m_itemName);
+ if (!m_inputAssembler && vertexBuffer) {
+ // create our attribute layout
+ NVRenderAttribLayout *attribLayout
+ = &context.CreateAttributeLayout(toConstDataRef(entries, 2));
+
+ QT3DSU32 strides = vertexBuffer->GetStride();
+ QT3DSU32 offsets = 0;
+ m_inputAssembler = &context.GetOrCreateInputAssembler(
+ m_itemName, attribLayout, toConstDataRef(&vertexBuffer, 1), nullptr,
+ toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
+ }
+}
+
+void SHelperGridWidget::Render(IRenderWidgetContext &widgetContext, NVRenderContext &renderContext)
+{
+ m_itemName = renderContext.GetStringTable().RegisterStr("SHelperGridWidget");
+
+ setupShader(widgetContext);
+
+ if (m_shader) {
+ SWidgetRenderInformation theInfo(widgetContext.GetWidgetRenderInformation(
+ *m_Node, QT3DSVec3(0), RenderWidgetModes::Local));
+
+ QT3DSMat44 nodeToCamera = theInfo.m_NodeParentToCamera * m_Node->m_LocalTransform
+ * m_rotation;
+
+ if (m_dirty) {
+ m_dirty = false;
+ // Line data is line end points and color for each point
+ const int lineCount = m_lineCount * 2 + 1;
+ const int centerLineIndex = m_lineCount;
+ const float lineStart = float(m_lineCount) * -m_lineSpacing;
+ const int totalCount = lineCount * 8;
+ m_lineData.resize(totalCount);
+ // Create grid of lines along y-plane. Center lines are colored according to axes.
+ for (int i = 0; i < lineCount; ++i) {
+ int idx = i * 8;
+ m_lineData[idx] = QT3DSVec3(lineStart + m_lineSpacing * i, 0.f, lineStart);
+ m_lineData[idx + 2] = QT3DSVec3(lineStart + m_lineSpacing * i, 0.f, -lineStart);
+ m_lineData[idx + 4] = QT3DSVec3(lineStart, 0.f, lineStart + m_lineSpacing * i);
+ m_lineData[idx + 6] = QT3DSVec3(-lineStart, 0.f, lineStart + m_lineSpacing * i);
+ if (i == centerLineIndex) {
+ m_lineData[idx + 1] = m_yColor;
+ m_lineData[idx + 3] = m_yColor;
+ m_lineData[idx + 5] = m_xColor;
+ m_lineData[idx + 7] = m_xColor;
+ } else {
+ m_lineData[idx + 1] = m_gridColor;
+ m_lineData[idx + 3] = m_gridColor;
+ m_lineData[idx + 5] = m_gridColor;
+ m_lineData[idx + 7] = m_gridColor;
+ }
+ }
+ setupGraphicsObjects(widgetContext,
+ toDataRef(static_cast<QT3DSVec3 *>(m_lineData.data()),
+ QT3DSU32(totalCount)));
+ }
+
+ if (m_inputAssembler) {
+ renderContext.SetBlendingEnabled(false);
+ renderContext.SetDepthWriteEnabled(true);
+ renderContext.SetDepthTestEnabled(true);
+ renderContext.SetCullingEnabled(false);
+ renderContext.SetActiveShader(m_shader);
+ m_shader->SetPropertyValue("model_view_projection",
+ theInfo.m_LayerProjection * nodeToCamera);
+ renderContext.SetInputAssembler(m_inputAssembler);
+ renderContext.Draw(qt3ds::render::NVRenderDrawMode::Lines, m_lineCount * 8 + 8, 0);
+ }
+ }
+}
+
+SHelperGridWidget &SHelperGridWidget::createHelperGridWidget(NVAllocatorCallback &alloc)
+{
+ return *QT3DS_NEW(alloc, SHelperGridWidget)(alloc);
+}
+
+}
+}
diff --git a/src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.h b/src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.h
new file mode 100644
index 00000000..d3c8c497
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/Render/StudioHelperGridWidget.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QT3DS_STUDIO_HELPER_GRID_WIDGET_H
+#define QT3DS_STUDIO_HELPER_GRID_WIDGET_H
+
+#include "Qt3DSRender.h"
+#include "Qt3DSRenderWidgets.h"
+#include "Qt3DSRenderNode.h"
+#include "foundation/Qt3DSContainers.h"
+
+using namespace qt3ds::render;
+
+namespace qt3ds {
+namespace widgets {
+
+struct SHelperGridWidget : public IRenderWidget, public NVRefCounted
+{
+ QT3DSVec3 m_gridColor = QT3DSVec3(0.5f, 0.5f, 0.5f);
+ QT3DSVec3 m_xColor = QT3DSVec3(1.f, 0.f, 0.f);
+ QT3DSVec3 m_yColor = QT3DSVec3(0.f, 1.f, 0.f);
+ QVector<QT3DSVec3> m_lineData;
+ int m_lineCount = 10; // Number of lines each side of center line
+ float m_lineSpacing = 50;
+ QT3DSMat44 m_rotation;
+ NVScopedRefCounted<NVRenderInputAssembler> m_inputAssembler;
+ NVScopedRefCounted<NVRenderShaderProgram> m_shader;
+ CRegisteredString m_itemName;
+ bool m_dirty;
+
+ NVAllocatorCallback &m_allocator;
+ volatile QT3DSI32 mRefCount;
+
+ SHelperGridWidget(NVAllocatorCallback &inAlloc);
+ virtual ~SHelperGridWidget() override {}
+
+ QT3DS_IMPLEMENT_REF_COUNT_ADDREF_RELEASE(m_allocator)
+
+ void setNode(SNode *node);
+ void rotate(float angleRadians, const QT3DSVec3 &axis);
+ void setColors(const QColor &gridColor, const QColor &xColor, const QColor &yColor);
+ void setLines(int count, float spacing);
+ void setupShader(IRenderWidgetContext &context);
+ void setupGraphicsObjects(IRenderWidgetContext &context, NVDataRef<QT3DSVec3> lines);
+ void Render(IRenderWidgetContext &widgetContext, NVRenderContext &renderContext) override;
+
+ static SHelperGridWidget &createHelperGridWidget(NVAllocatorCallback &alloc);
+};
+
+}
+}
+
+
+#endif // QT3DS_STUDIO_HELPER_GRID_WIDGET_H
diff --git a/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp b/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp
index 678fd6c0..e2af9606 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp
@@ -38,6 +38,8 @@
#include "q3dsqmlrender.h"
#include "q3dsqmlstreamproxy.h"
#include "StudioSubPresentationRenderer.h"
+#include "Qt3DSRenderCustomMaterialSystem.h"
+#include "Qt3DSRenderEffectSystem.h"
#include <QtCore/qdebug.h>
@@ -91,7 +93,7 @@ struct SRendererImpl : public IStudioRenderer,
public CToolbarChangeListener,
public IOffscreenRenderer::IOffscreenRendererCallback
{
- typedef eastl::vector<Option<SEditCameraPersistentInformation>> TEditCameraInfoList;
+ typedef eastl::vector<Option<SEditorCameraInformation>> TEditCameraInfoList;
std::shared_ptr<CWGLRenderContext> m_RenderContext;
NVScopedRefCounted<IQt3DSRenderContext> m_Context;
QRect m_Rect;
@@ -107,7 +109,7 @@ struct SRendererImpl : public IStudioRenderer,
bool m_MaybeDragStart;
TEditCameraInfoList m_EditCameraInformation;
QT3DSI32 m_EditCameraIndex;
- SEditCameraPersistentInformation m_MouseDownCameraInformation;
+ SEditorCameraInformation m_MouseDownCameraInformation;
SStudioPickValue m_PickResult;
bool m_RenderRequested;
int m_LastToolMode;
@@ -271,6 +273,14 @@ struct SRendererImpl : public IStudioRenderer,
return m_Context->GetTextRenderer();
return nullptr;
}
+
+ ITextRenderer *GetDistanceFieldRenderer() override
+ {
+ if (m_Context.mPtr)
+ return m_Context->getDistanceFieldRenderer();
+ return nullptr;
+ }
+
// The buffer manager may not be available
IBufferManager *GetBufferManager() override
{
@@ -311,7 +321,10 @@ struct SRendererImpl : public IStudioRenderer,
m_RenderContext->GetRenderContext().GetFoundation(),
m_RenderContext->GetRenderContext().GetStringTable());
- // Create text renderer
+ // Create legacy text renderer - studio needs this for drag widget text rendering.
+ // Legacy renderer also has better separation between project and system fonts, so
+ // we also want to keep it around for those purposes. Actual rendering of text is done
+ // with distance field renderer if it is enabled.
qt3ds::render::ITextRendererCore &theTextRenderer(
qt3ds::render::ITextRendererCore::CreateQtTextRenderer(
m_RenderContext->GetRenderContext().GetFoundation(),
@@ -319,16 +332,18 @@ struct SRendererImpl : public IStudioRenderer,
theCore->SetTextRendererCore(theTextRenderer);
#if QT_VERSION >= QT_VERSION_CHECK(5,12,2)
- ITextRendererCore &distanceFieldRenderer(
- ITextRendererCore::createDistanceFieldRenderer(
- m_RenderContext->GetRenderContext().GetFoundation()));
- theCore->setDistanceFieldRenderer(distanceFieldRenderer);
+ if (qt3ds::render::IQt3DSRenderContextCore::distanceFieldEnabled()) {
+ ITextRendererCore &distanceFieldRenderer(
+ ITextRendererCore::createDistanceFieldRenderer(
+ m_RenderContext->GetRenderContext().GetFoundation()));
+ theCore->setDistanceFieldRenderer(distanceFieldRenderer);
+ }
#endif
m_Context = theCore->CreateRenderContext(
m_RenderContext->GetRenderContext(),
m_RenderContext->GetRenderContext().GetStringTable().RegisterStr(
- theResourcePath.c_str()), false);
+ theResourcePath.c_str()), false, nullptr);
// Allow the artist to interact with the top level objects alone.
m_Context->GetRenderer().PickRenderPlugins(false);
@@ -363,12 +378,7 @@ struct SRendererImpl : public IStudioRenderer,
m_Rect = inRect;
if (IsInitialized()) {
m_pixelRatio = StudioUtils::devicePixelRatio();
- m_RenderContext->BeginRender();
- NVRenderContext &theContext = m_RenderContext->GetRenderContext();
- theContext.SetViewport(qt3ds::render::NVRenderRect(0, 0, inRect.width(),
- inRect.height()));
SetTranslationViewport();
- m_RenderContext->EndRender();
}
}
@@ -402,6 +412,17 @@ struct SRendererImpl : public IStudioRenderer,
Render();
}
+ bool getObjectError(qt3dsdm::Qt3DSDMInstanceHandle theInstance, QString &error) const
+ {
+ auto translator = m_Translation->GetOrCreateTranslator(theInstance);
+ if (translator) {
+ error = static_cast<SGraphObjectTranslator *>(translator)->GetError();
+ return true;
+ }
+ error = QString();
+ return false;
+ }
+
void getPreviewFbo(QSize &outFboDim, qt3ds::QT3DSU32 &outFboTexture) override
{
if (m_Translation) {
@@ -428,12 +449,14 @@ struct SRendererImpl : public IStudioRenderer,
void MakeContextCurrent() override
{
- m_RenderContext->BeginRender();
+ if (m_RenderContext)
+ m_RenderContext->BeginRender();
}
void ReleaseContext() override
{
- m_RenderContext->EndRender();
+ if (m_RenderContext)
+ m_RenderContext->EndRender();
}
void Render()
@@ -441,26 +464,20 @@ struct SRendererImpl : public IStudioRenderer,
m_RenderRequested = false;
if (!m_Closed && IsInitialized()) {
m_RenderContext->BeginRender();
- bool overlayPreview = false;
- if (m_Translation) {
- overlayPreview = CStudioPreferences::showEditModePreview()
- && m_Translation->m_EditCameraEnabled
- && m_Translation->hasRoomForOverlayPreview();
- m_Translation->PreRender(overlayPreview || m_fullSizePreview);
- }
+ if (m_Translation)
+ m_Translation->PreRender(m_fullSizePreview);
NVRenderContext &theContext = m_RenderContext->GetRenderContext();
theContext.SetDepthWriteEnabled(true);
theContext.Clear(qt3ds::render::NVRenderClearFlags(
qt3ds::render::NVRenderClearValues::Color
| qt3ds::render::NVRenderClearValues::Depth));
if (m_Translation) {
- if (overlayPreview || m_fullSizePreview) {
- // Full size preview is used for both scene camera tab and overlay preview
- m_Translation->Render(0, false, true, false);
+ if (m_fullSizePreview) {
+ // Full size preview is used for scene camera tab
+ m_Translation->Render(0, false, true);
m_Translation->PreRender(false);
}
- m_Translation->Render(m_PickResult.GetWidgetId(), m_GuidesEnabled, false,
- overlayPreview);
+ m_Translation->Render(m_PickResult.GetWidgetId(), m_GuidesEnabled, false);
}
m_RenderContext->EndRender();
@@ -474,7 +491,7 @@ struct SRendererImpl : public IStudioRenderer,
}
void SetPolygonFillModeEnabled(bool inEnableLight) override
{
- CStudioPreferences::SetEditViewFillMode(inEnableLight);
+ CStudioPreferences::setEditViewFillMode(inEnableLight);
RequestRender();
}
@@ -521,7 +538,7 @@ struct SRendererImpl : public IStudioRenderer,
bool IsPolygonFillModeEnabled() const override
{
- return GetEditCamera() >= 0 && CStudioPreferences::GetEditViewFillMode();
+ return GetEditCamera() >= 0 && CStudioPreferences::isEditViewFillMode();
}
void EditCameraZoomToFit() override
@@ -649,12 +666,18 @@ struct SRendererImpl : public IStudioRenderer,
Render();
}
- void OnReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) override
+ void onReloadEffectInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) override
{
if (m_Translation)
m_Translation->ReleaseEffect(inInstance);
}
+ void onReloadMaterialInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance) override
+ {
+ if (m_Translation)
+ m_Translation->releaseMaterial(inInstance);
+ }
+
void ApplyEditCameraIndex()
{
if (!m_Translation)
@@ -667,11 +690,11 @@ struct SRendererImpl : public IStudioRenderer,
while ((size_t)m_EditCameraIndex >= m_EditCameraInformation.size())
m_EditCameraInformation.push_back(Empty());
- Option<SEditCameraPersistentInformation> &theCameraInfo =
+ Option<SEditorCameraInformation> &theCameraInfo =
m_EditCameraInformation[m_EditCameraIndex];
if (!theCameraInfo.hasValue()) {
- theCameraInfo = SEditCameraPersistentInformation();
+ theCameraInfo = SEditorCameraInformation();
// TODO - consider resizing clip planes to scene so we use the depth buffer more
// accurately
// or consider requesting a larger depth buffer from the windowing system.
@@ -690,6 +713,7 @@ struct SRendererImpl : public IStudioRenderer,
m_Translation->m_EditCameraEnabled = true;
m_Translation->m_EditCameraInfo = theCameraInfo;
+ m_Translation->updateHelperGridFromSettings();
}
}
@@ -767,6 +791,12 @@ struct SRendererImpl : public IStudioRenderer,
*/
void OnClosingPresentation() override
{
+ // Clear the shader cache so that shaders are reloaded when loading the next presentation
+ if (m_Context) {
+ m_Context->GetCustomMaterialSystem().clearCaches();
+ m_Context->GetEffectSystem().clearCaches();
+ }
+
// Destroy translation
m_Translation = std::shared_ptr<STranslation>();
m_HasPresentation = false;
@@ -875,7 +905,7 @@ struct SRendererImpl : public IStudioRenderer,
void OnSceneMouseDrag(SceneDragSenderType::Enum, QPoint inPoint, int inToolMode,
int inFlags) override
{
- if (m_Translation == nullptr)
+ if (m_Translation == nullptr || !m_mouseDown)
return;
inPoint.setX(inPoint.x() * m_pixelRatio);
@@ -1064,18 +1094,20 @@ struct SRendererImpl : public IStudioRenderer,
{
m_MaybeDragStart = false;
m_mouseDown = false;
+ bool guideExists = true;
Qt3DSDMGuideHandle theSelectedGuide;
if (m_PickResult.getType() == StudioPickValueTypes::Guide) {
theSelectedGuide = m_PickResult.getData<Qt3DSDMGuideHandle>();
- m_Translation->CheckGuideInPresentationRect(theSelectedGuide, m_UpdatableEditor);
+ guideExists = m_Translation->CheckGuideInPresentationRect(theSelectedGuide,
+ m_UpdatableEditor);
}
m_UpdatableEditor.CommitEditor();
m_PickResult = SStudioPickValue();
if (m_Translation)
m_Translation->EndDrag();
if (theSelectedGuide.GetHandleValue()) {
- // Get rid of selection if things aren't editable.
- if (m_Doc.GetDocumentReader().AreGuidesEditable())
+ // Get rid of selection if things aren't editable or if guide has been deleted.
+ if (guideExists && m_Doc.GetDocumentReader().AreGuidesEditable())
m_Doc.NotifySelectionChanged(theSelectedGuide);
else
m_Doc.NotifySelectionChanged();
diff --git a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp
index 82678986..d24f1061 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp
@@ -345,6 +345,7 @@ struct STranslatorDataModelParser
#define Node_LocalOpacity m_Node.m_Opacity
#define Node_RotationOrder m_Node.m_RotationOrder
#define Node_LeftHanded m_Node.m_Orientation
+#define Group_ordered m_Node.m_ordered
#define Layer_TemporalAAEnabled m_Layer.m_TemporalAA
#define Layer_LayerEnableDepthTest m_Layer.m_DisableDepthTest
#define Layer_LayerEnableDepthPrePass m_Layer.m_DisableDepthPrepass
@@ -355,6 +356,10 @@ struct STranslatorDataModelParser
#define Layer_Location m_Layer.m_Location
#define Layer_ProgressiveAAMode m_Layer.m_ProgressiveAA
#define Layer_MultisampleAAMode m_Layer.m_MultisampleAA
+#define Layer_DynamicResize m_Layer.m_DynamicResize
+#define Layer_DynamicPaddingUnits m_Layer.m_DynamicPaddingUnits
+#define Layer_DynamicPadding m_Layer.m_DynamicPadding
+#define Layer_DynamicCombine m_Layer.m_DynamicCombine
#define Layer_HorizontalFieldValues m_Layer.m_HorizontalFieldValues
#define Layer_Left m_Layer.m_Left
#define Layer_LeftUnits m_Layer.m_LeftUnits
@@ -369,6 +374,7 @@ struct STranslatorDataModelParser
#define Layer_HeightUnits m_Layer.m_HeightUnits
#define Layer_Bottom m_Layer.m_Bottom
#define Layer_BottomUnits m_Layer.m_BottomUnits
+#define Layer_AoEnabled m_Layer.m_AoEnabled
#define Layer_AoStrength m_Layer.m_AoStrength
#define Layer_AoDistance m_Layer.m_AoDistance
#define Layer_AoSoftness m_Layer.m_AoSoftness
@@ -393,6 +399,7 @@ struct STranslatorDataModelParser
#define Camera_ClipFar m_Camera.m_ClipFar
#define Camera_FOV m_Camera.m_Fov
#define Camera_FOVHorizontal m_Camera.m_FovHorizontal
+#define Camera_EnableFrustumCulling m_Camera.m_EnableFrustumCulling
#define Camera_Orthographic m_Camera.m_Orthographic
#define Camera_ScaleMode m_Camera.m_ScaleMode
#define Camera_ScaleAnchor m_Camera.m_ScaleAnchor
@@ -453,6 +460,8 @@ struct STranslatorDataModelParser
#define Material_DiffuseLightWrap m_Material.m_DiffuseLightWrap
#define Material_ReferencedMaterial m_ReferencedMaterial.m_ReferencedMaterial
#define Material_VertexColors m_Material.m_VertexColors
+#define Material_TransparencyMode m_Material.m_TransparencyMode
+#define Material_CullMode m_Material.m_CullMode
#define Image_ImagePath m_Asset.m_SourcePath
#define Image_OffscreenRendererId m_Image.m_SubPresentation
#define Image_Scale_X m_Image.m_RepeatU
@@ -465,6 +474,8 @@ struct STranslatorDataModelParser
#define Image_MappingMode m_Image.m_TextureMapping
#define Image_HorizontalTilingMode m_Image.m_TilingU
#define Image_VerticalTilingMode m_Image.m_TilingV
+#define Image_MinFilter m_Image.m_MinFilter
+#define Image_MagFilter m_Image.m_MagFilter
#define Text_Text m_Text.m_TextString
#define Text_Font m_Text.m_Font
#define Text_FontSize m_Text.m_Size
@@ -634,6 +645,8 @@ struct SNodeTranslator : public SGraphObjectTranslator
ITERATE_QT3DS_RENDER_NODE_PROPERTIES
theParser.ParseProperty(inContext.m_ObjectDefinitions.m_Node.m_BoneId,
theItem.m_SkeletonId);
+ theParser.ParseProperty(inContext.m_ObjectDefinitions.m_Group.m_ordered,
+ theItem.m_ordered);
bool ignoresParent = false;
if (theParser.ParseProperty(inContext.m_ObjectDefinitions.m_Node.m_IgnoresParent,
ignoresParent))
@@ -1021,19 +1034,20 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
TIdxToPropertyMap m_PropertyMap;
SDynamicObjectTranslator(qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3ds::NVAllocatorCallback &,
- SDynamicObject &inObject)
+ SDynamicGraphObject &inObject)
: SGraphObjectTranslator(inInstance, inObject)
{
}
void PushTranslation(STranslation &inContext) override
{
- SDynamicObject &theItem = static_cast<SDynamicObject &>(GetGraphObject());
+ SDynamicGraphObject &theItem = static_cast<SDynamicGraphObject &>(GetGraphObject());
+ SDynamicObject &dynObj = *theItem.m_dynamicObject;
IDynamicObjectSystem &theSystem = inContext.m_Context.GetDynamicObjectSystem();
using namespace qt3ds::render::dynamic;
using qt3ds::foundation::NVConstDataRef;
- NVConstDataRef<SPropertyDefinition> theProperties =
- theSystem.GetProperties(theItem.m_ClassName);
+ NVConstDataRef<SPropertyDefinition> theProperties
+ = theSystem.GetProperties(dynObj.m_ClassName);
if (m_PropertyMap.size() == 0) {
for (QT3DSU32 idx = 0, end = theProperties.size(); idx < end; ++idx) {
const SPropertyDefinition &theDefinition(theProperties[idx]);
@@ -1064,7 +1078,7 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
case qt3dsdm::DataModelDataType::Long:
if (theDefinition.m_DataType
== qt3ds::render::NVRenderShaderDataTypes::QT3DSI32) {
- theItem.SetPropertyValue(theDefinition,
+ dynObj.SetPropertyValue(theDefinition,
qt3dsdm::get<qt3ds::QT3DSI32>(theValue));
} else {
QT3DS_ASSERT(false);
@@ -1073,7 +1087,7 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
case qt3dsdm::DataModelDataType::Bool:
if (theDefinition.m_DataType
== qt3ds::render::NVRenderShaderDataTypes::QT3DSRenderBool) {
- theItem.SetPropertyValue(theDefinition, qt3dsdm::get<bool>(theValue));
+ dynObj.SetPropertyValue(theDefinition, qt3dsdm::get<bool>(theValue));
} else {
QT3DS_ASSERT(false);
}
@@ -1081,7 +1095,7 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
case qt3dsdm::DataModelDataType::Float:
if (theDefinition.m_DataType
== qt3ds::render::NVRenderShaderDataTypes::QT3DSF32) {
- theItem.SetPropertyValue(theDefinition, qt3dsdm::get<float>(theValue));
+ dynObj.SetPropertyValue(theDefinition, qt3dsdm::get<float>(theValue));
} else {
QT3DS_ASSERT(false);
}
@@ -1089,7 +1103,7 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
case qt3dsdm::DataModelDataType::Float2:
if (theDefinition.m_DataType
== qt3ds::render::NVRenderShaderDataTypes::QT3DSVec2) {
- theItem.SetPropertyValue(
+ dynObj.SetPropertyValue(
theDefinition, ToRenderType(qt3dsdm::get<qt3dsdm::SFloat2>(theValue)));
} else {
QT3DS_ASSERT(false);
@@ -1098,7 +1112,7 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
case qt3dsdm::DataModelDataType::Float3:
if (theDefinition.m_DataType
== qt3ds::render::NVRenderShaderDataTypes::QT3DSVec3) {
- theItem.SetPropertyValue(
+ dynObj.SetPropertyValue(
theDefinition, ToRenderType(qt3dsdm::get<qt3dsdm::SFloat3>(theValue)));
} else {
QT3DS_ASSERT(false);
@@ -1107,12 +1121,40 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
case qt3dsdm::DataModelDataType::Float4:
if (theDefinition.m_DataType
== qt3ds::render::NVRenderShaderDataTypes::QT3DSVec4) {
- theItem.SetPropertyValue(
+ dynObj.SetPropertyValue(
theDefinition, ToRenderType(qt3dsdm::get<qt3dsdm::SFloat4>(theValue)));
} else {
QT3DS_ASSERT(false);
}
break;
+ case qt3dsdm::DataModelDataType::Long4: {
+ // Image
+ qt3dsdm::SLong4 theData = qt3dsdm::get<qt3dsdm::SLong4>(theValue);
+ qt3dsdm::Qt3DSDMInstanceHandle imageInstance
+ = inContext.m_Reader.GetInstanceForObjectRef(
+ GetInstanceHandle(), theData);
+ if (imageInstance.Valid()) {
+ SGraphObjectTranslator *imageTranslator
+ = inContext.GetOrCreateTranslator(imageInstance);
+ if (imageTranslator) {
+ SImage *img = static_cast<SImage *>(&imageTranslator->GetGraphObject());
+ theItem.setImage(theDefinition.m_Name, img);
+ eastl::string theWorkspace;
+ dynObj.SetPropertyValue(
+ theDefinition, theDefinition.m_Name.c_str(),
+ inContext.m_Doc.GetCore()->getProjectFile()
+ .getProjectPath().toLocal8Bit().constData(),
+ theWorkspace, inContext.m_Context.GetStringTable());
+ }
+ } else {
+ eastl::string theWorkspace;
+ dynObj.SetPropertyValue(
+ theDefinition, nullptr,
+ inContext.m_Doc.GetCore()->getProjectFile()
+ .getProjectPath().toLocal8Bit().constData(),
+ theWorkspace, inContext.m_Context.GetStringTable());
+ }
+ } break;
// Could be either an enum or a texture.
case qt3dsdm::DataModelDataType::String: {
qt3dsdm::TDataStrPtr theData = qt3dsdm::get<qt3dsdm::TDataStrPtr>(theValue);
@@ -1120,11 +1162,31 @@ struct SDynamicObjectTranslator : public SGraphObjectTranslator
eastl::string theStr;
qt3ds::render::ConvertWideUTF(theData->GetData(), 0, theStr);
eastl::string theWorkspace;
- theItem.SetPropertyValue(
- theDefinition, theStr.c_str(),
- inContext.m_Doc.GetCore()->getProjectFile()
- .getProjectPath().toLocal8Bit().constData(),
- theWorkspace, inContext.m_Context.GetStringTable());
+ if (theDefinition.m_DataType == NVRenderShaderDataTypes::NVRenderTexture2DPtr) {
+ if (g_StudioApp.getDocumentVersion() < 7) {
+ // Old style texture. This needs to be run trough document editor
+ Qt3DSDMInstanceHandle instance = GetInstanceHandle();
+ Qt3DSDMPropertyHandle property = theProperty;
+ SValue value = theValue;
+ CDoc &doc = inContext.m_Doc;
+ QTimer::singleShot(10, [instance, property, value, &doc](){
+ Q3DStudio::CUpdateableDocumentEditor updatableEditor(doc);
+ updatableEditor.EnsureEditor("Set Property", __FILE__,
+ __LINE__)
+ .SetInstancePropertyValue(instance, property,
+ value);
+ });
+ g_StudioApp.SetConvertingPresentationOn();
+ } else {
+ // Ignore the value
+ }
+ } else {
+ dynObj.SetPropertyValue(
+ theDefinition, theStr.c_str(),
+ inContext.m_Doc.GetCore()->getProjectFile()
+ .getProjectPath().toLocal8Bit().constData(),
+ theWorkspace, inContext.m_Context.GetStringTable());
+ }
}
} break;
default:
@@ -1159,10 +1221,13 @@ struct SEffectTranslator : public SDynamicObjectTranslator
void SetActive(bool inActive) override
{
SEffect &theItem = static_cast<SEffect &>(GetGraphObject());
- if (m_EffectSystem)
+ if (m_EffectSystem) {
theItem.SetActive(inActive, *m_EffectSystem);
- else
+ if (inActive && inActive != theItem.m_Flags.IsActive())
+ m_EffectSystem->SetEffectRequiresCompilation(theItem.m_ClassName, true);
+ } else {
theItem.m_Flags.SetActive(inActive);
+ }
}
void ResetEffect() override
@@ -1171,6 +1236,19 @@ struct SEffectTranslator : public SDynamicObjectTranslator
if (m_EffectSystem)
theItem.Reset(*m_EffectSystem);
}
+
+ const QString GetError() override
+ {
+ SEffect &theItem = static_cast<SEffect &>(GetGraphObject());
+ return QString::fromUtf8(theItem.GetError().c_str());
+ }
+
+ void SetError(const QString &error) override
+ {
+ SEffect &theItem = static_cast<SEffect &>(GetGraphObject());
+ theItem.SetError(m_EffectSystem->GetResourceManager().GetRenderContext()
+ .GetStringTable().RegisterStr(error));
+ }
};
struct SCustomMaterialTranslator : public SDynamicObjectTranslator
{
@@ -1204,10 +1282,27 @@ struct SCustomMaterialTranslator : public SDynamicObjectTranslator
SCustomMaterial &theItem = static_cast<SCustomMaterial &>(GetGraphObject());
if (inActive != theItem.m_Flags.IsActive()) {
theItem.m_Flags.SetActive(inActive);
+ // Force compilation in Studio if custom shader became active, so we know
+ // if it has any compilation errors.
+ if (inActive)
+ m_MaterialSystem->setRequiresCompilation(theItem.m_ClassName, true);
+
m_MaterialSystem->OnMaterialActivationChange(theItem, inActive);
}
}
}
+
+ const QString GetError() override
+ {
+ SCustomMaterial &theItem = static_cast<SCustomMaterial &>(GetGraphObject());
+ return QString::fromUtf8(theItem.GetError().c_str());
+ }
+
+ void SetError(const QString &error) override
+ {
+ SCustomMaterial &theItem = static_cast<SCustomMaterial &>(GetGraphObject());
+ theItem.SetError(m_MaterialSystem->getContext()->GetStringTable().RegisterStr(error));
+ }
};
struct SReferencedMaterialTranslator : public SGraphObjectTranslator
{
@@ -1607,25 +1702,25 @@ bool STranslation::IncludeNode(const SNode &inNode)
void STranslation::ReleaseEffect(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
- if (m_Reader.IsInstance(inInstance) == false)
+ if (!m_Reader.IsInstance(inInstance))
return;
qt3dsdm::ComposerObjectTypes::Enum theType = m_ObjectDefinitions.GetType(inInstance);
qt3dsdm::Qt3DSDMInstanceHandle theParentClass = m_Reader.GetFirstBaseClass(inInstance);
- if (theType == NULL && theParentClass.Valid())
+ if (theType == qt3dsdm::ComposerObjectTypes::Unknown && theParentClass.Valid())
theType = m_ObjectDefinitions.GetType(theParentClass);
if (theType == qt3dsdm::ComposerObjectTypes::Effect) {
IEffectSystem &theSystem = m_Context.GetEffectSystem();
if (theParentClass.Valid()) {
Q3DStudio::CString theInstanceName = m_Reader.GetName(theParentClass);
- CRegisteredString theNameStr =
- m_Context.GetStringTable().RegisterStr(theInstanceName);
+ CRegisteredString theNameStr
+ = m_Context.GetStringTable().RegisterStr(theInstanceName);
if (theSystem.IsEffectRegistered(theNameStr)) {
- TInstanceToTranslatorMap::iterator theTranslatorList =
- m_TranslatorMap.find(inInstance);
+ TInstanceToTranslatorMap::iterator theTranslatorList
+ = m_TranslatorMap.find(inInstance);
if (theTranslatorList != m_TranslatorMap.end())
m_TranslatorMap.erase(theTranslatorList);
theSystem.SetEffectRequiresCompilation(theNameStr, true);
@@ -1634,6 +1729,35 @@ void STranslation::ReleaseEffect(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
}
}
+void STranslation::releaseMaterial(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
+{
+ if (!m_Reader.IsInstance(inInstance))
+ return;
+
+ qt3dsdm::ComposerObjectTypes::Enum theType = m_ObjectDefinitions.GetType(inInstance);
+ qt3dsdm::Qt3DSDMInstanceHandle theParentClass = m_Reader.GetFirstBaseClass(inInstance);
+
+ if (theType == qt3dsdm::ComposerObjectTypes::Unknown && theParentClass.Valid())
+ theType = m_ObjectDefinitions.GetType(theParentClass);
+
+ if (theType == qt3dsdm::ComposerObjectTypes::CustomMaterial) {
+ ICustomMaterialSystem &theSystem = m_Context.GetCustomMaterialSystem();
+ if (theParentClass.Valid()) {
+ Q3DStudio::CString theInstanceName = m_Reader.GetName(theParentClass);
+ CRegisteredString theNameStr
+ = m_Context.GetStringTable().RegisterStr(theInstanceName);
+
+ if (theSystem.IsMaterialRegistered(theNameStr)) {
+ TInstanceToTranslatorMap::iterator theTranslatorList
+ = m_TranslatorMap.find(inInstance);
+ if (theTranslatorList != m_TranslatorMap.end())
+ m_TranslatorMap.erase(theTranslatorList);
+ theSystem.setRequiresCompilation(theNameStr, true);
+ }
+ }
+ }
+}
+
SGraphObjectTranslator *STranslation::CreateTranslator(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
{
SGraphObjectTranslator *theNewTranslator = nullptr;
@@ -1645,6 +1769,7 @@ SGraphObjectTranslator *STranslation::CreateTranslator(qt3dsdm::Qt3DSDMInstanceH
// For the subset of possible instances, pick out the valid translators.
switch (theType) {
case qt3dsdm::ComposerObjectTypes::Group:
+ case qt3dsdm::ComposerObjectTypes::Signal:
case qt3dsdm::ComposerObjectTypes::Component:
case qt3dsdm::ComposerObjectTypes::Node:
theNewTranslator = QT3DS_NEW(m_Allocator, SNodeTranslator)(inInstance, m_Allocator);
@@ -1724,30 +1849,38 @@ SGraphObjectTranslator *STranslation::CreateTranslator(qt3dsdm::Qt3DSDMInstanceH
}
break;
case qt3dsdm::ComposerObjectTypes::CustomMaterial: {
- ICustomMaterialSystem &theSystem = m_Context.GetCustomMaterialSystem();
+ ICustomMaterialSystem &system = m_Context.GetCustomMaterialSystem();
if (theParentClass.Valid()) {
- Q3DStudio::CString theInstanceName = m_Reader.GetName(theParentClass);
- CRegisteredString theNameStr =
- m_Context.GetStringTable().RegisterStr(theInstanceName);
- if (!theSystem.IsMaterialRegistered(theNameStr)) {
+ Q3DStudio::CString instanceName = m_Reader.GetName(theParentClass);
+ CRegisteredString name
+ = m_Context.GetStringTable().RegisterStr(instanceName);
+
+ bool requiresCompilation = false;
+ if (system.IsMaterialRegistered(name) && system.requiresCompilation(name)) {
+ system.unregisterMaterial(name);
+ requiresCompilation = true;
+ }
+
+ if (!system.IsMaterialRegistered(name)) {
// We assume the effect has already been registered and such.
- qt3dsdm::IMetaData &theMetaData(*m_StudioSystem.GetActionMetaData());
- Q3DStudio::CString theInstancePath = m_Reader.GetSourcePath(theParentClass);
- Option<qt3dsdm::SMetaDataCustomMaterial> theMaterialData =
- theMetaData.GetMaterialBySourcePath(
- m_Context.GetStringTable().GetNarrowStr(theInstancePath));
- if (theMaterialData.hasValue()) {
+ qt3dsdm::IMetaData &metaData(*m_StudioSystem.GetActionMetaData());
+ Q3DStudio::CString instancePath = m_Reader.GetSourcePath(theParentClass);
+ Option<qt3dsdm::SMetaDataCustomMaterial> materialData
+ = metaData.GetMaterialBySourcePath(m_Context.GetStringTable()
+ .GetNarrowStr(instancePath));
+ if (materialData.hasValue()) {
qt3ds::render::IUIPLoader::CreateMaterialClassFromMetaMaterial(
- theNameStr, m_Context.GetFoundation(), theSystem, theMaterialData,
+ name, m_Context.GetFoundation(), system, materialData,
m_Context.GetStringTable());
+ system.setRequiresCompilation(name, requiresCompilation);
}
}
- if (theSystem.IsMaterialRegistered(theNameStr)) {
+ if (system.IsMaterialRegistered(name)) {
theNewTranslator = QT3DS_NEW(m_Allocator, SCustomMaterialTranslator)(
inInstance, m_Allocator,
- *theSystem.CreateCustomMaterial(theNameStr, m_Allocator));
- static_cast<SCustomMaterialTranslator *>(theNewTranslator)->m_MaterialSystem =
- &theSystem;
+ *system.CreateCustomMaterial(name, m_Allocator));
+ static_cast<SCustomMaterialTranslator *>(theNewTranslator)
+ ->m_MaterialSystem = &system;
}
}
}
@@ -1853,6 +1986,43 @@ qt3dsdm::Qt3DSDMInstanceHandle STranslation::GetAnchorPoint(QT3DSU32 inAnchorInd
return qt3dsdm::Qt3DSDMInstanceHandle();
}
+void STranslation::updateHelperGridFromSettings()
+{
+ m_helperGridEnabled = CStudioPreferences::isHelperGridOn();
+ if (m_helperGridEnabled && m_helperGridWidget && m_EditCameraEnabled) {
+ if (m_EditCameraInfo.m_CameraType == EditCameraTypes::Directional) {
+ if (m_EditCameraInfo.m_Direction.x != 0.f) {
+ m_helperGridWidget->setColors(CStudioPreferences::helperGridColor(),
+ CStudioPreferences::yAxisColor(),
+ CStudioPreferences::zAxisColor());
+ m_helperGridWidget->rotate(float(M_PI) / 2.f, QT3DSVec3(0.f, 0.f, 1.f));
+ } else if (m_EditCameraInfo.m_Direction.y != 0.f) {
+ m_helperGridWidget->setColors(CStudioPreferences::helperGridColor(),
+ CStudioPreferences::xAxisColor(),
+ CStudioPreferences::zAxisColor());
+ m_helperGridWidget->rotate(0.f, QT3DSVec3());
+ } else {
+ m_helperGridWidget->setColors(CStudioPreferences::helperGridColor(),
+ CStudioPreferences::xAxisColor(),
+ CStudioPreferences::yAxisColor());
+ m_helperGridWidget->rotate(float(M_PI) / 2.f, QT3DSVec3(1.f, 0.f, 0.f));
+ }
+ } else {
+ m_helperGridWidget->setColors(CStudioPreferences::helperGridColor(),
+ CStudioPreferences::xAxisColor(),
+ CStudioPreferences::zAxisColor());
+ m_helperGridWidget->rotate(0.f, QT3DSVec3());
+ }
+ m_helperGridWidget->setLines(CStudioPreferences::helperGridLines(),
+ float(CStudioPreferences::helperGridSpacing()));
+ }
+}
+
+void STranslation::updateAxisHelperFromSettings()
+{
+ m_axisHelperEnabled = CStudioPreferences::isAxisHelperOn();
+}
+
qt3dsdm::Qt3DSDMInstanceHandle STranslation::GetAnchorPoint(SPathPick &inPick)
{
return GetAnchorPoint(inPick.m_AnchorIndex);
@@ -1860,9 +2030,9 @@ qt3dsdm::Qt3DSDMInstanceHandle STranslation::GetAnchorPoint(SPathPick &inPick)
namespace qt3ds {
namespace studio {
- struct SEditCameraLayerTranslator : public SLayerTranslator
+ struct SEditorLayerTranslator : public SLayerTranslator
{
- SEditCameraLayerTranslator(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
+ SEditorLayerTranslator(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3ds::NVAllocatorCallback &inAlloc)
: SLayerTranslator(inInstance, inAlloc)
{
@@ -1897,12 +2067,13 @@ STranslation::STranslation(IStudioRenderer &inRenderer, IQt3DSRenderContext &inC
, m_DirtySet(inContext.GetAllocator(), "STranslation::m_DirtySet")
, m_Scene(nullptr)
, m_SignalConnections(inContext.GetAllocator(), "STranslation::m_SignalConnections")
- , m_ComponentSecondsDepth(0)
+ , m_ComponentTimeDepth(0)
, m_KeyRepeat(0)
, m_EditCameraEnabled(false)
, m_EditLightEnabled(false)
, m_Viewport(0, 0)
, m_EditCameraLayerTranslator(nullptr)
+ , m_AxisHelperLayerTranslator(nullptr)
, m_PixelBuffer(inContext.GetAllocator(), "STranslation::m_PixelBuffer")
, m_editModeCamerasAndLights(inContext.GetAllocator(),
"STranslation::m_editModeCamerasAndLights")
@@ -1935,37 +2106,37 @@ STranslation::STranslation(IStudioRenderer &inRenderer, IQt3DSRenderContext &inC
m_SignalConnections.push_back(m_AssetGraph.ConnectChildRemoved(
std::bind(&STranslation::MarkGraphInstanceDirty, this, std::placeholders::_1,
std::placeholders::_2)));
- m_SignalConnections.push_back(theProvider->ConnectBeginComponentSeconds(
- std::bind(&STranslation::MarkBeginComponentSeconds, this, std::placeholders::_1)));
- m_SignalConnections.push_back(theProvider->ConnectComponentSeconds(
- std::bind(&STranslation::MarkComponentSeconds, this, std::placeholders::_1)));
+ m_SignalConnections.push_back(theProvider->ConnectBeginComponentTime(
+ std::bind(&STranslation::MarkBeginComponentTime, this, std::placeholders::_1)));
+ m_SignalConnections.push_back(theProvider->ConnectComponentTime(
+ std::bind(&STranslation::MarkComponentTime, this, std::placeholders::_1)));
- ::CColor color = CStudioPreferences::GetRulerBackgroundColor(); // Rectangles under tick marks
+ ::CColor color = CStudioPreferences::rulerBackgroundColor(); // Rectangles under tick marks
m_rectColor = QT3DSVec4(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f,
1.f);
- color = CStudioPreferences::GetRulerTickColor(); // Tick marks
+ color = CStudioPreferences::rulerTickColor(); // Tick marks
m_lineColor = QT3DSVec4(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f,
1.f);
- color = CStudioPreferences::GetGuideColor();
+ color = CStudioPreferences::guideNormalColor();
m_guideColor = QT3DSVec4(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f,
1.f);
- color = CStudioPreferences::GetGuideSelectedColor();
+ color = CStudioPreferences::guideSelectedColor();
m_selectedGuideColor = QT3DSVec4(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f,
1.f);
- color = CStudioPreferences::GetGuideFillColor(); // Not sure what this is used for
+ color = CStudioPreferences::guideFillColor(); // Not sure what this is used for
m_guideFillColor = QT3DSVec4(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f,
1.f);
- color = CStudioPreferences::GetGuideFillSelectedColor(); // Not sure what this is used for
+ color = CStudioPreferences::guideFillSelectedColor(); // Not sure what this is used for
m_selectedGuideFillColor = QT3DSVec4(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f,
@@ -1977,6 +2148,52 @@ void STranslation::BuildRenderGraph(SGraphObjectTranslator &inParent, bool scene
{
SGraphObjectTranslator &theParentTranslator(inParent);
theParentTranslator.ClearChildren();
+
+ updateAxisHelperFromSettings();
+ if (theParentTranslator.GetGraphObject().m_Type == GraphObjectTypes::Scene &&
+ m_axisHelperEnabled && !scenePreviewPass) {
+ if (m_AxisHelperLayerTranslator && m_AxisHelperLayerTranslator->GetInstanceHandle()
+ != inParent.GetInstanceHandle()) {
+ QT3DS_FREE(m_Allocator, m_AxisHelperLayerTranslator);
+ m_AxisHelperLayerTranslator = nullptr;
+ }
+ if (!m_AxisHelperLayerTranslator) {
+ m_AxisHelperLayerTranslator =
+ QT3DS_NEW(m_Allocator, SEditorLayerTranslator)(inParent.GetInstanceHandle(), m_Allocator);
+ SLayer &layer = static_cast<SLayer &>(m_AxisHelperLayerTranslator->GetGraphObject());
+ layer.m_Background = LayerBackground::Color;
+ static const QT3DSVec4 matteColor(CStudioPreferences::matteColor().redF(),
+ CStudioPreferences::matteColor().greenF(),
+ CStudioPreferences::matteColor().blueF(), 0.5f);
+ layer.m_ClearColor = m_EditCameraEnabled ? QT3DSVec4(0, 0, 0, 0.5) : matteColor;
+ layer.m_LeftUnits = LayerUnitTypes::Pixels;
+ layer.m_RightUnits = LayerUnitTypes::Pixels;
+ layer.m_HeightUnits = LayerUnitTypes::Pixels;
+ layer.m_WidthUnits = LayerUnitTypes::Pixels;
+ layer.m_TopUnits = LayerUnitTypes::Pixels;
+ layer.m_BottomUnits = LayerUnitTypes::Pixels;
+ layer.m_HorizontalFieldValues = HorizontalFieldValues::LeftWidth;
+ layer.m_VerticalFieldValues = VerticalFieldValues::HeightBottom;
+ float pixelRatio = float(StudioUtils::devicePixelRatio());
+ layer.m_Top = 10 * pixelRatio;
+ layer.m_Left = 10 * pixelRatio;
+ layer.m_Right = 10 * pixelRatio;
+ layer.m_Bottom = 10 * pixelRatio;
+ layer.m_Width = 120 * pixelRatio;
+ layer.m_Height = 120 * pixelRatio;
+ layer.m_Flags.SetDirty(true);
+ m_AxisCamera.m_Id = m_Context.GetStringTable().RegisterStr("AxisCamera");
+ }
+ theParentTranslator.AppendChild(m_AxisHelperLayerTranslator->GetGraphObject());
+ SLayer &layer = static_cast<SLayer &>(m_AxisHelperLayerTranslator->GetGraphObject());
+ layer.m_NextSibling = layer.m_PreviousSibling = nullptr;
+ m_AxisHelperLayerTranslator->SetActive(true);
+ m_AxisHelperLayerTranslator->AppendChild(m_AxisCamera);
+ m_AxisCamera.m_Flags.SetActive(true);
+ // Make sure axis helper layer children gets updated
+ m_Context.GetRenderer().ChildrenUpdated(layer);
+ }
+
if (m_EditCameraEnabled && !scenePreviewPass) {
const auto objectType = theParentTranslator.GetGraphObject().m_Type;
if (objectType == GraphObjectTypes::Layer) {
@@ -2019,7 +2236,7 @@ void STranslation::BuildRenderGraph(SGraphObjectTranslator &inParent, bool scene
}
if (!m_EditCameraLayerTranslator) {
m_EditCameraLayerTranslator =
- QT3DS_NEW(m_Allocator, SEditCameraLayerTranslator)(theChild,
+ QT3DS_NEW(m_Allocator, SEditorLayerTranslator)(theChild,
m_Allocator);
}
theTranslator = m_EditCameraLayerTranslator;
@@ -2122,26 +2339,6 @@ QT3DSVec2 STranslation::GetPreviewViewportDimensions() const
return QT3DSVec2(thePresSize.width(), thePresSize.height());
}
-qt3ds::QT3DSVec2 STranslation::GetOverlayPreviewDimensions() const
-{
- QT3DSVec2 ret(0.0f);
- if (hasRoomForOverlayPreview()) {
- CStudioProjectSettings *theSettings = m_Doc.GetCore()->GetStudioProjectSettings();
- QSize thePresSize = theSettings->getPresentationSize();
- ret = QT3DSVec2(thePresSize.width(), thePresSize.height());
-
- const float aspect = ret.x / ret.y;
- if (aspect > 1.0) {
- ret.x = m_overlayPreviewSize > ret.x ? ret.x : m_overlayPreviewSize;
- ret.y = ret.x / aspect;
- } else {
- ret.y = m_overlayPreviewSize > ret.y ? ret.y : m_overlayPreviewSize;
- ret.x = ret.y * aspect;
- }
- }
- return ret;
-}
-
void STranslation::PreRender(bool scenePreviewPass)
{
// Run through the entire asset graph and mark active or inactive if we have an
@@ -2153,7 +2350,7 @@ void STranslation::PreRender(bool scenePreviewPass)
if (!scenePreviewPass)
m_editModeCamerasAndLights.clear();
ClearDirtySet();
- m_EditLightEnabled = CStudioPreferences::editModeLightingEnabled();
+ m_EditLightEnabled = CStudioPreferences::isEditModeLightingEnabled();
BuildRenderGraph(theRoot, scenePreviewPass);
QT3DSVec2 theViewportDims(GetViewportDimensions());
if (scenePreviewPass) {
@@ -2167,10 +2364,32 @@ void STranslation::PreRender(bool scenePreviewPass)
CStudioPreferences::matteColor().greenF(),
CStudioPreferences::matteColor().blueF(), 1.0f);
m_Context.SetMatteColor(matteColor);
+ m_Context.setMatteEnabled(true);
// Ensure the camera points where it should
if (m_EditCameraEnabled && !scenePreviewPass) {
m_EditCameraInfo.ApplyToCamera(m_EditCamera, theViewportDims);
m_EditLight.MarkDirty(qt3ds::render::NodeTransformDirtyFlag::TransformIsDirty);
+ updateHelperGridFromSettings();
+ }
+ if (m_axisHelperEnabled && !scenePreviewPass) {
+ if (m_EditCameraEnabled) {
+ m_EditCameraInfo.ApplyToCamera(m_AxisCamera, theViewportDims, true);
+ } else {
+ // Get scene camera
+ SLayerTranslator *layerTranslator = static_cast<SLayerTranslator *>(GetOrCreateTranslator(m_Doc.GetActiveLayer()));
+ SNode *layerNode = static_cast<SNode *>(layerTranslator->m_GraphObject);
+ for (SNode *child = layerNode->m_FirstChild; child; child = child->m_NextSibling) {
+ if (child->m_Type == GraphObjectTypes::Enum::Camera) {
+ m_AxisCamera = *(SCamera *)child;
+ m_AxisCamera.m_Parent = (SNode *)&m_AxisHelperLayerTranslator->GetGraphObject();
+ m_AxisCamera.m_NextSibling = nullptr;
+ m_AxisCamera.m_PreviousSibling = nullptr;
+ m_AxisCamera.m_FirstChild = nullptr;
+ m_AxisCamera.m_PreviousSibling = nullptr;
+ break;
+ }
+ }
+ }
}
if (m_Scene) {
@@ -2187,7 +2406,7 @@ void STranslation::PreRender(bool scenePreviewPass)
(QT3DSU32)m_Presentation.m_PresentationDimensions.y));
// set if we draw geometry in wireframe mode
- m_Context.SetWireframeMode(CStudioPreferences::IsWireframeModeOn());
+ m_Context.SetWireframeMode(CStudioPreferences::isWireframeModeOn());
if (m_EditCameraEnabled && !scenePreviewPass) {
m_Presentation.m_PresentationDimensions = theViewportDims;
@@ -2213,6 +2432,8 @@ void STranslation::PreRender(bool scenePreviewPass)
}
}
}
+ m_Presentation.m_preferKTX = theSettings->getPreferCompressedTextures();
+ m_Presentation.m_flipCompressedTextures = theSettings->getFlipCompressedTextures();
}
if (m_EditCameraEnabled == false && g_StudioApp.IsAuthorZoom()) {
if (m_Presentation.m_PresentationDimensions.x > theViewportDims.x
@@ -2268,7 +2489,7 @@ static void DrawTickMarksOnHorizontalRects(STranslation &inTranslation, QT3DSF32
QT3DSF32 innerRight, QT3DSF32 innerBottom, QT3DSF32 innerTop,
QT3DSF32 outerBottom, QT3DSF32 outerTop, QT3DSVec4 lineColor)
{
- QT3DSF32 centerPosX = floor(innerLeft + (innerRight - innerLeft) / 2.0f + .5f);
+ QT3DSF32 centerPosX = qFloor(innerLeft + (innerRight - innerLeft) / 2.0f + .5f);
CreateTopBottomTickMarks(inTranslation, centerPosX, innerBottom, innerTop, outerBottom,
outerTop, 15, lineColor);
for (QT3DSU32 incrementor = 10;
@@ -2305,7 +2526,7 @@ static void DrawTickMarksOnVerticalRects(STranslation &inTranslation, QT3DSF32 i
QT3DSF32 innerRight, QT3DSF32 innerBottom, QT3DSF32 innerTop,
QT3DSF32 outerLeft, QT3DSF32 outerRight, QT3DSVec4 lineColor)
{
- QT3DSF32 centerPosY = floor(innerBottom + (innerTop - innerBottom) / 2.0f + .5f);
+ QT3DSF32 centerPosY = qFloor(innerBottom + (innerTop - innerBottom) / 2.0f + .5f);
CreateLeftRightTickMarks(inTranslation, centerPosY, innerLeft, innerRight, outerLeft,
outerRight, 15, lineColor);
for (QT3DSU32 incrementor = 10;
@@ -2342,7 +2563,7 @@ public:
static void CreateGuide(IGuideElementFactory &inFactory, QT3DSF32 inPos, QT3DSF32 inWidth)
{
QT3DSF32 halfWidth = inWidth / 2.0f;
- QT3DSF32 leftLine = floor(inPos + 1.0f - halfWidth);
+ QT3DSF32 leftLine = qFloor(inPos + 1.0f - halfWidth);
inFactory.CreateLine(leftLine);
// Then we are done if not enough width
if (inWidth < 2.0f)
@@ -2418,20 +2639,7 @@ qt3ds::render::NVRenderRect STranslation::GetPreviewViewport() const
return qt3ds::render::NVRenderRect(0, 0, vp.x, vp.y);
}
-qt3ds::render::NVRenderRect STranslation::GetOverlayPreviewViewport() const
-{
- QT3DSVec2 vp = GetOverlayPreviewDimensions();
- return qt3ds::render::NVRenderRect(0, 0, vp.x, vp.y);
-}
-
-bool STranslation::hasRoomForOverlayPreview() const
-{
- QT3DSVec2 vp(GetViewportDimensions());
- return vp.x > m_overlayPreviewSize && vp.y > m_overlayPreviewSize;
-}
-
-void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPass,
- bool overlayPreview)
+void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPass)
{
// For now, we just render.
// Next step will be to get the bounding boxes and such setup.
@@ -2483,6 +2691,21 @@ void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPa
// This is called *before* the render because these sort of appendages need to be added
// to the layer renderables.
+ // The helper grid is drawn when in edit camera mode
+ if (m_EditCameraEnabled && m_helperGridEnabled) {
+ // Helper grid is a child of the currently selected layer
+ if (!m_helperGridWidget) {
+ m_helperGridWidget = qt3ds::widgets::SHelperGridWidget
+ ::createHelperGridWidget(m_Context.GetAllocator());
+ updateHelperGridFromSettings();
+ }
+ SNode *helperGridParent = GetEditCameraLayer();
+ if (helperGridParent) {
+ m_helperGridWidget->setNode(helperGridParent);
+ m_Context.GetRenderer().AddRenderWidget(*m_helperGridWidget);
+ }
+ }
+
// Don't show the bounding box or pivot for the component we are *in* the component
SGraphObjectTranslator *theTranslator = nullptr;
long theToolMode = g_StudioApp.GetToolMode();
@@ -2517,7 +2740,7 @@ void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPa
// Get the tool mode right now.
if (theTranslator) {
GraphObjectTypes::Enum theType(theTranslator->GetGraphObject().m_Type);
- if (CStudioPreferences::IsBoundingBoxesOn()) {
+ if (CStudioPreferences::isBoundingBoxesOn()) {
switch (theType) {
case GraphObjectTypes::Node:
DrawGroupBoundingBoxes(*theTranslator);
@@ -2535,7 +2758,7 @@ void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPa
}
// Don't draw the axis if there is a widget.
- if (CStudioPreferences::ShouldDisplayPivotPoint()) {
+ if (CStudioPreferences::isPivotPointOn()) {
switch (theTranslator->GetGraphObject().m_Type) {
case GraphObjectTypes::Node:
case GraphObjectTypes::Text:
@@ -2643,14 +2866,35 @@ void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPa
}
}
}
- Option<NVRenderRect> viewport = m_Context.GetRenderContext().GetViewport();
+
+ if (!m_AxisHelperWidget ) {
+ m_AxisHelperWidget
+ = qt3ds::widgets::IStudioWidget::CreateTranslationWidget(
+ m_Context.GetAllocator());
+ m_AxisHelperWidget->setAsAxisHelper(true);
+ }
+
+ auto layer = GetAxisHelperLayer();
+ if (layer != nullptr) {
+ updateAxisHelperFromSettings();
+ m_AxisHelperWidget->SetNode(*layer);
+ if (m_axisHelperEnabled)
+ m_Context.GetRenderer().AddRenderWidget(*m_AxisHelperWidget);
+ }
+ QVector<bool> layerDepthPrepasses = {};
if (scenePreviewPass) {
m_Context.GetRenderContext().SetViewport(GetPreviewViewport());
m_Context.SetSceneColor(Option<QT3DSVec4>());
+ } else {
+ SLayer *child = m_Scene->m_FirstChild;
+ do {
+ layerDepthPrepasses.append(child->m_Flags.IsLayerEnableDepthPrepass());
+ child->m_Flags.SetLayerEnableDepthPrepass(true);
+ child = (SLayer *)child->m_NextSibling;
+ } while (child);
}
- m_Scene->PrepareForRender(scenePreviewPass ? GetPreviewViewportDimensions()
- : GetViewportDimensions(), m_Context);
+ m_Scene->PrepareForRender(m_Context);
m_Context.RunRenderTasks();
@@ -2785,44 +3029,17 @@ void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPa
}
if (!scenePreviewPass && m_previewTexture) {
- if (overlayPreview) {
- // Draw the overlay framebuffer
- qt3ds::render::NVRenderContext &renderContext(m_Context.GetRenderContext());
- renderContext.SetViewport(GetOverlayPreviewViewport());
- qt3ds::render::SCamera camera;
- camera.MarkDirty(qt3ds::render::NodeTransformDirtyFlag::TransformIsDirty);
- camera.m_Flags.SetOrthographic(true);
- QT3DSVec2 previewDims(GetOverlayPreviewDimensions());
- camera.CalculateGlobalVariables(
- render::NVRenderRectF(0, 0, previewDims.x, previewDims.y), previewDims);
- QT3DSMat44 theVP;
- camera.CalculateViewProjectionMatrix(theVP);
- renderContext.SetCullingEnabled(false);
- renderContext.SetBlendingEnabled(false);
- renderContext.SetDepthTestEnabled(false);
- renderContext.SetDepthWriteEnabled(false);
- m_Context.GetRenderer().RenderQuad(previewDims, theVP, *m_previewTexture);
- } else {
- // Hack: For some reason, the m_previewTexture is only valid later if it is
- // actually drawn somewhere during the main render pass, so draw a dummy quad
- m_Context.GetRenderContext().SetViewport(NVRenderRect(0, 0, 0, 0));
- m_Context.GetRenderer().RenderQuad(QT3DSVec2(0.0f), QT3DSMat44(),
- *m_previewTexture);
- }
+ // Hack: For some reason, the m_previewTexture is only valid later if it is
+ // actually drawn somewhere during the main render pass, so draw a dummy quad
+ m_Context.GetRenderContext().SetViewport(NVRenderRect(0, 0, 0, 0));
+ m_Context.GetRenderer().RenderQuad(QT3DSVec2(0.0f), QT3DSMat44(),
+ *m_previewTexture);
}
if (scenePreviewPass)
m_Context.GetRenderContext().SetRenderTarget(nullptr);
m_Context.EndFrame();
- m_Context.GetRenderContext().SetViewport(viewport);
- QT3DSVec2 theViewportDims(GetViewportDimensions());
- m_Context.SetWindowDimensions(QSize((QT3DSU32)theViewportDims.x,
- (QT3DSU32)theViewportDims.y));
- CStudioProjectSettings *theSettings = m_Doc.GetCore()->GetStudioProjectSettings();
- QSize thePresSize = theSettings->getPresentationSize();
- m_Presentation.m_PresentationDimensions =
- QT3DSVec2((QT3DSF32)thePresSize.width(), (QT3DSF32)thePresSize.height());
if (m_ZoomRender.hasValue()) {
RenderZoomRender(*m_ZoomRender);
@@ -2851,6 +3068,15 @@ void STranslation::Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPa
theRenderContext.SetDepthWriteEnabled( false );
m_Context.GetRenderer().RenderQuad( theDimensions, theVP, *m_PickBuffer );
}*/
+ if (!scenePreviewPass) {
+ SLayer *child = m_Scene->m_FirstChild;
+ int childIndex = 0;
+ do {
+ child->m_Flags.SetLayerEnableDepthPrepass(layerDepthPrepasses.at(childIndex));
+ child = (SLayer *)child->m_NextSibling;
+ ++childIndex;
+ } while (child);
+ }
}
}
@@ -3093,7 +3319,8 @@ SStudioPickValue STranslation::Pick(CPt inMouseCoords, TranslationSelectMode::En
|| m_LastRenderedWidget->GetNode().m_Type
== GraphObjectTypes::Light
|| m_LastRenderedWidget->GetNode().m_Type
- == GraphObjectTypes::Camera)) {
+ == GraphObjectTypes::Camera)
+ && !m_LastRenderedWidget->isNodeBehindCamera()) {
Option<QT3DSU32> picked = PickWidget(inMouseCoords, inSelectMode,
*m_LastRenderedWidget);
if (picked.hasValue()) {
@@ -3724,6 +3951,23 @@ STranslation::PrepareWidgetDrag(qt3ds::widgets::StudioWidgetComponentIds::Enum i
retval.m_OriginalPlaneCoords = theOriginalRay.Intersect(retval.m_Plane);
retval.m_CurrentPlaneCoords = theCurrentRay.Intersect(retval.m_Plane);
retval.m_PreviousPlaneCoords = thePreviousRay.Intersect(retval.m_Plane);
+
+ // Resolve t-value from current ray intersection calculation
+ // Its sign indicates the position relative to the camera
+ float t = 0.f;
+
+ // Ray direction is normalized, so one of the components must be > .1f
+ if (qAbs(theCurrentRay.m_Direction.x) > .1f) {
+ t = (retval.m_CurrentPlaneCoords->x - theCurrentRay.m_Origin.x)
+ / theCurrentRay.m_Direction.x;
+ } else if (qAbs(theCurrentRay.m_Direction.y) > .1f) {
+ t = (retval.m_CurrentPlaneCoords->y - theCurrentRay.m_Origin.y)
+ / theCurrentRay.m_Direction.y;
+ } else if (qAbs(theCurrentRay.m_Direction.z) > .1f) {
+ t = (retval.m_CurrentPlaneCoords->z - theCurrentRay.m_Origin.z)
+ / theCurrentRay.m_Direction.z;
+ }
+ retval.m_isBehindCamera = t < 0;
return retval;
}
@@ -3746,6 +3990,7 @@ void STranslation::PerformWidgetDrag(int inWidgetSubComponent, CPt inOriginalCoo
Option<QT3DSVec3> theCurrentPlaneCoords(thePrepResult->m_CurrentPlaneCoords);
QT3DSVec3 globalPos(thePrepResult->m_GlobalPos);
bool isPlane(thePrepResult->m_IsPlane);
+ bool isBehindCamera(thePrepResult->m_isBehindCamera);
QT3DSVec3 theAxis(thePrepResult->m_Axis);
QT3DSU32 axisIndex(thePrepResult->m_AxisIndex);
SNode *theNode(thePrepResult->m_Node);
@@ -3760,7 +4005,8 @@ void STranslation::PerformWidgetDrag(int inWidgetSubComponent, CPt inOriginalCoo
QT3DS_ASSERT(false);
return;
case qt3ds::widgets::StudioWidgetTypes::Scale: {
- if (theOriginalPlaneCoords.hasValue() && theCurrentPlaneCoords.hasValue()) {
+ if (theOriginalPlaneCoords.hasValue() && theCurrentPlaneCoords.hasValue()
+ && !isBehindCamera) {
QT3DSVec3 objToOriginal = globalPos - *theOriginalPlaneCoords;
QT3DSVec3 objToCurrent = globalPos - *theCurrentPlaneCoords;
QT3DSVec3 theScaleMultiplier(1, 1, 1);
@@ -3874,11 +4120,19 @@ void STranslation::PerformWidgetDrag(int inWidgetSubComponent, CPt inOriginalCoo
TORAD(theRad);
theRad = MakeNiceRotation(theRad);
QT3DSQuat theRotation(theRad, thePlaneNormal);
+
+ // Call SetRotationEdges also here so rotation angle text gets drawn.
+ // Here just draw it in the middle of rotation circle for simplicity.
+ m_CumulativeRotation = ShortestAngleDifference(m_CumulativeRotation, theRad);
+ m_LastRenderedWidget->SetRotationEdges(QT3DSVec3(0.0f), thePlaneNormal,
+ m_CumulativeRotation, 0.0f);
+
ApplyRotationToSelectedInstance(theRotation, *theNode, inEditor, false);
}
} break;
case qt3ds::widgets::StudioWidgetTypes::Translation: {
- if (theOriginalPlaneCoords.hasValue() && theCurrentPlaneCoords.hasValue()) {
+ if (theOriginalPlaneCoords.hasValue() && theCurrentPlaneCoords.hasValue()
+ && !isBehindCamera) {
QT3DSVec3 theDiff = *theCurrentPlaneCoords - *theOriginalPlaneCoords;
if (isPlane) {
ApplyPositionalChange(theDiff, *theNode, inEditor);
@@ -3895,7 +4149,7 @@ static float RoundToNearest(float inValue, float inMin, float inMax, float inRou
{
float half = (inMin + inMax) / 2.0f;
inValue -= half;
- inValue = inRound * floor(inValue / inRound + .5f);
+ inValue = inRound * qFloor(inValue / inRound + .5f);
inValue += half;
inValue -= inMin;
return inValue;
@@ -3925,7 +4179,7 @@ void STranslation::PerformGuideDrag(Qt3DSDMGuideHandle inGuide, CPt inPoint,
inEditor.FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle());
}
-void STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide,
+bool STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide,
CUpdateableDocumentEditor &inEditor)
{
qt3dsdm::SGuideInfo theInfo = m_Doc.GetDocumentReader().GetGuideInfo(inGuide);
@@ -3945,6 +4199,8 @@ void STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide,
if (!inPresentation)
inEditor.EnsureEditor(QObject::tr("Delete Guide"), __FILE__, __LINE__).DeleteGuide(inGuide);
+
+ return inPresentation;
}
void STranslation::PerformPathDrag(qt3ds::studio::SPathPick &inPathPick, CPt inOriginalCoords,
@@ -4067,6 +4323,13 @@ SNode *STranslation::GetEditCameraLayer()
return nullptr;
}
+SNode *STranslation::GetAxisHelperLayer()
+{
+ if (m_AxisHelperLayerTranslator)
+ return static_cast<SNode *>(&m_AxisHelperLayerTranslator->GetGraphObject());
+ return nullptr;
+}
+
PickTargetAreas::Enum STranslation::GetPickArea(CPt inPoint)
{
qt3ds::render::NVRenderRectF displayViewport = m_Context.GetDisplayViewport();
diff --git a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h
index 2d3e965a..ed7ea70d 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h
+++ b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h
@@ -42,6 +42,7 @@
#include "StudioPreferences.h"
#include "StudioGradientWidget.h"
#include "StudioVisualAidWidget.h"
+#include "StudioHelperGridWidget.h"
namespace qt3ds {
namespace studio {
@@ -95,6 +96,8 @@ namespace studio {
virtual void ClearChildren() = 0;
virtual void AppendChild(SGraphObject &inChild) = 0;
virtual void ResetEffect() {}
+ virtual const QString GetError() { return {}; }
+ virtual void SetError(const QString &error) { Q_UNUSED(error); }
virtual SGraphObject &GetGraphObject() { return *m_GraphObject; }
virtual SGraphObject &GetNonAliasedGraphObject() { return *m_GraphObject; }
virtual qt3dsdm::Qt3DSDMInstanceHandle GetInstanceHandle() { return m_InstanceHandle; }
@@ -150,7 +153,7 @@ namespace studio {
const QT3DSF32 g_EditCameraFOV = 45.0f;
const QT3DSF32 g_RotationScaleFactor = 2.0f * QT3DSF32(M_PI) / 180.0f;
- struct SEditCameraPersistentInformation
+ struct SEditorCameraInformation
{
QT3DSVec3 m_Position;
QT3DSVec3 m_Direction;
@@ -158,7 +161,7 @@ namespace studio {
EditCameraTypes::Enum m_CameraType;
NVReal m_xRotation = 0.0f;
NVReal m_yRotation = 0.0f;
- SEditCameraPersistentInformation()
+ SEditorCameraInformation()
: m_Position(0, 0, 0)
, m_Direction(0, 0, 0)
, m_ViewRadius(600)
@@ -166,11 +169,18 @@ namespace studio {
{
}
- void ApplyToCamera(SCamera &inCamera, QT3DSVec2 inViewport)
+ void ApplyToCamera(SCamera &inCamera, QT3DSVec2 inViewport, bool noScale = false)
{
// Setup shared default values.
inCamera.m_ClipFar = 2000000.0f;
inCamera.m_ClipNear = 1.0f;
+
+ // In orthographic view adjust near clipping based on zoom level
+ if (m_CameraType == EditCameraTypes::Orthographic) {
+ // This seems like a suitable math
+ inCamera.m_ClipNear = (100000 / m_ViewRadius) - (50 * m_ViewRadius);
+ }
+
if (m_CameraType == EditCameraTypes::Perspective) {
inCamera.m_FOV = g_EditCameraFOV;
TORAD(inCamera.m_FOV);
@@ -202,6 +212,7 @@ namespace studio {
if (m_CameraType != EditCameraTypes::Directional) {
theRotationTransform.rotate(-m_xRotation, QT3DSVec3(0.0f, 1.0f, 0.0f));
theRotationTransform.rotate(m_yRotation, QT3DSVec3(1.0f, 0.0f, 0.0f));
+ inCamera.m_Rotation = inCamera.GetRotationVectorFromRotationMatrix(theRotationTransform.getUpper3x3());
}
// The view radius dictates the zoom.
@@ -220,7 +231,8 @@ namespace studio {
thePositionMatrix.column3.y = m_Position.y;
thePositionMatrix.column3.z = m_Position.z + 600;
theGlobalTransform = theGlobalTransform * theRotationTransform;
- theGlobalTransform = theGlobalTransform * theScaleMatrix;
+ if (!noScale)
+ theGlobalTransform = theGlobalTransform * theScaleMatrix;
theGlobalTransform = theGlobalTransform * thePivotMatrix.getInverse();
theGlobalTransform = theGlobalTransform * thePositionMatrix;
// This works because the camera has no hierarchy.
@@ -246,7 +258,7 @@ namespace studio {
};
};
- struct SEditCameraLayerTranslator;
+ struct SEditorLayerTranslator;
struct SZoomRender
{
CPt m_Point;
@@ -326,6 +338,7 @@ namespace studio {
Option<QT3DSVec3> m_CurrentPlaneCoords;
Option<QT3DSVec3> m_PreviousPlaneCoords;
bool m_IsPlane;
+ bool m_isBehindCamera;
SDragPreparationResult() {}
};
@@ -366,7 +379,7 @@ namespace studio {
qt3ds::render::SScene *m_Scene;
Q3DStudio::CGraphIterator m_GraphIterator;
nvvector<TSignalConnection> m_SignalConnections;
- QT3DSI32 m_ComponentSecondsDepth;
+ QT3DSI32 m_ComponentTimeDepth;
SNode m_MouseDownNode;
SCamera m_MouseDownCamera;
Option<QT3DSMat44> m_MouseDownParentGlobalTransformInverse;
@@ -375,18 +388,24 @@ namespace studio {
QT3DSI32 m_KeyRepeat;
bool m_EditCameraEnabled;
bool m_EditLightEnabled;
- SEditCameraPersistentInformation m_EditCameraInfo;
+ bool m_helperGridEnabled = true;
+ bool m_axisHelperEnabled = true;
+ SEditorCameraInformation m_EditCameraInfo;
SCamera m_EditCamera;
+ SCamera m_AxisCamera;
SLight m_EditLight;
QT3DSVec2 m_Viewport;
- SEditCameraLayerTranslator *m_EditCameraLayerTranslator;
+ SEditorLayerTranslator *m_EditCameraLayerTranslator;
+ SEditorLayerTranslator *m_AxisHelperLayerTranslator;
Option<SZoomRender> m_ZoomRender;
NVScopedRefCounted<qt3ds::widgets::IStudioWidget> m_TranslationWidget;
+ NVScopedRefCounted<qt3ds::widgets::IStudioWidget> m_AxisHelperWidget;
NVScopedRefCounted<qt3ds::widgets::IStudioWidget> m_RotationWidget;
NVScopedRefCounted<qt3ds::widgets::IStudioWidget> m_ScaleWidget;
NVScopedRefCounted<qt3ds::widgets::IStudioWidget> m_LastRenderedWidget;
NVScopedRefCounted<qt3ds::widgets::SGradientWidget> m_GradientWidget;
NVScopedRefCounted<qt3ds::widgets::SVisualAidWidget> m_VisualAidWidget;
+ NVScopedRefCounted<qt3ds::widgets::SHelperGridWidget> m_helperGridWidget;
NVScopedRefCounted<qt3ds::widgets::IPathWidget> m_PathWidget;
NVScopedRefCounted<qt3ds::render::NVRenderTexture2D> m_PickBuffer;
@@ -408,20 +427,18 @@ namespace studio {
QT3DSVec4 m_guideFillColor;
QT3DSVec4 m_selectedGuideFillColor;
- const float m_overlayPreviewSize = 600.0f;
-
NVScopedRefCounted<qt3ds::render::NVRenderTexture2D> m_previewTexture;
NVScopedRefCounted<qt3ds::render::NVRenderFrameBuffer> m_previewFbo;
NVScopedRefCounted<qt3ds::render::NVRenderRenderBuffer> m_previewRenderBuffer;
QT3DSVec2 m_previewFboDimensions;
STranslation(IStudioRenderer &inRenderer, IQt3DSRenderContext &inContext);
- void MarkBeginComponentSeconds(qt3dsdm::Qt3DSDMSlideHandle) { ++m_ComponentSecondsDepth; }
+ void MarkBeginComponentTime(qt3dsdm::Qt3DSDMSlideHandle) { ++m_ComponentTimeDepth; }
- void MarkComponentSeconds(qt3dsdm::Qt3DSDMSlideHandle)
+ void MarkComponentTime(qt3dsdm::Qt3DSDMSlideHandle)
{
- m_ComponentSecondsDepth = qMax(0, m_ComponentSecondsDepth - 1);
- if (m_ComponentSecondsDepth == 0)
+ m_ComponentTimeDepth = qMax(0, m_ComponentTimeDepth - 1);
+ if (m_ComponentTimeDepth == 0)
RequestRender();
}
@@ -447,7 +464,7 @@ namespace studio {
void DrawChildBoundingBoxes(SNode &inNode)
{
- ::CColor color = CStudioPreferences::GetGroupBoundingBoxColor();
+ ::CColor color = CStudioPreferences::groupBoundingBoxColor();
QT3DSVec3 colorVec(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f);
@@ -462,7 +479,7 @@ namespace studio {
{
SNode &theNode = static_cast<SNode &>(inTranslator.GetGraphObject());
if (theNode.m_FirstChild) {
- ::CColor color = CStudioPreferences::GetGroupBoundingBoxColor();
+ ::CColor color = CStudioPreferences::groupBoundingBoxColor();
QT3DSVec3 colorVec(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f);
@@ -476,14 +493,14 @@ namespace studio {
{
SNode &theNode = static_cast<SNode &>(inTranslator.GetGraphObject());
if (inTranslator.GetGraphObject().m_Type != GraphObjectTypes::Layer) {
- ::CColor color = CStudioPreferences::GetSingleBoundingBoxColor();
+ ::CColor color = CStudioPreferences::singleBoundingBoxColor();
QT3DSVec3 colorVec(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f);
DrawBoundingBox(theNode, colorVec);
DrawChildBoundingBoxes(theNode);
} else {
- ::CColor color = CStudioPreferences::GetSingleBoundingBoxColor();
+ ::CColor color = CStudioPreferences::singleBoundingBoxColor();
QT3DSVec3 colorVec(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f);
@@ -498,10 +515,7 @@ namespace studio {
QT3DSVec2 GetViewportDimensions() const { return m_Viewport; }
QT3DSVec2 GetPreviewViewportDimensions() const;
- QT3DSVec2 GetOverlayPreviewDimensions() const;
qt3ds::render::NVRenderRect GetPreviewViewport() const;
- qt3ds::render::NVRenderRect GetOverlayPreviewViewport() const;
- bool hasRoomForOverlayPreview() const;
void ClearDirtySet()
{
@@ -524,8 +538,7 @@ namespace studio {
DeactivateScan(SGraphObjectTranslator &inParent,
qt3dsdm::Qt3DSDMInstanceHandle inAliasHandle = qt3dsdm::Qt3DSDMInstanceHandle());
void PreRender(bool scenePreviewPass);
- void Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPass,
- bool overlayPreview);
+ void Render(int inWidgetId, bool inDrawGuides, bool scenePreviewPass);
void EndRender();
void DoPrepareForDrag(SNode *inSelectedNode);
void ResetWidgets();
@@ -634,7 +647,7 @@ namespace studio {
void PerformGuideDrag(Qt3DSDMGuideHandle inGuide, CPt inPoint,
CUpdateableDocumentEditor &inEditor);
- void CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide,
+ bool CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide,
CUpdateableDocumentEditor &inEditor);
void PerformPathDrag(qt3ds::studio::SPathPick &inPathPick, CPt inOriginalCoords,
@@ -643,7 +656,7 @@ namespace studio {
void RequestRender()
{
- if (m_ComponentSecondsDepth == 0)
+ if (m_ComponentTimeDepth == 0)
m_Renderer.RequestRender();
}
@@ -655,8 +668,10 @@ namespace studio {
PickTargetAreas::Enum GetPickArea(CPt inPoint);
SNode *GetEditCameraLayer();
+ SNode *GetAxisHelperLayer();
void ReleaseEffect(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
+ void releaseMaterial(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
// Create a new translator for this type. Do not add to any maps or anything else.
SGraphObjectTranslator *CreateTranslator(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
// Returns the canonical translator for a given instance or creates a new translator if none
@@ -669,6 +684,9 @@ namespace studio {
GetTranslatorsForInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
qt3dsdm::Qt3DSDMInstanceHandle GetAnchorPoint(SPathPick &inPick);
qt3dsdm::Qt3DSDMInstanceHandle GetAnchorPoint(QT3DSU32 inAnchorIndex);
+
+ void updateHelperGridFromSettings();
+ void updateAxisHelperFromSettings();
};
struct SDisableUseClearColor
diff --git a/src/Authoring/Qt3DStudio/Render/StudioRotationWidget.cpp b/src/Authoring/Qt3DStudio/Render/StudioRotationWidget.cpp
index f3e06cd6..a44bf9b7 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioRotationWidget.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioRotationWidget.cpp
@@ -251,8 +251,8 @@ struct SRotationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Rotation>
NVRenderBlendEquation::Add, NVRenderBlendEquation::Add));
float pixelRatio = float(StudioUtils::devicePixelRatio());
- QT3DSF32 theRingRadius = 2 * CStudioPreferences::getSelectorLineLength() * pixelRatio;
- QT3DSF32 theRingWidth = CStudioPreferences::getSelectorLineWidth() * pixelRatio;
+ QT3DSF32 theRingRadius = 2 * CStudioPreferences::selectorLineLength() * pixelRatio;
+ QT3DSF32 theRingWidth = CStudioPreferences::selectorLineWidth() * pixelRatio;
QT3DSF32 theRingInner = theRingRadius;
QT3DSF32 theRingOuter = theRingRadius + theRingWidth;
if (m_XAxis == nullptr) {
@@ -279,6 +279,10 @@ struct SRotationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Rotation>
QT3DSVec3 theRingColor(QT3DSVec3(.8f, .8f, .8f));
QT3DSMat44 theMVP = TBase::SetupMVP(inWidgetContext);
+
+ if (isNodeBehindCamera())
+ return;
+
inRenderContext.SetCullingEnabled(false);
QT3DSMat44 theCameraMVP = m_WidgetInfo.m_LayerProjection * m_CameraTranslationScale;
diff --git a/src/Authoring/Qt3DStudio/Render/StudioScaleWidget.cpp b/src/Authoring/Qt3DStudio/Render/StudioScaleWidget.cpp
index 9b5eec1f..287f7b01 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioScaleWidget.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioScaleWidget.cpp
@@ -151,9 +151,9 @@ struct SScaleWidget : public SStudioWidgetImpl<StudioWidgetTypes::Scale>
inRenderContext.Clear(qt3ds::render::NVRenderClearValues::Depth);
float pixelRatio = float(StudioUtils::devicePixelRatio());
QT3DSF32 axisWidth = pixelRatio;
- QT3DSF32 triWidth = 3 * CStudioPreferences::getSelectorLineWidth() * pixelRatio;
- QT3DSF32 axisStart = CStudioPreferences::getSelectorLineLength() / 3.0f * pixelRatio;
- QT3DSF32 axisLength = CStudioPreferences::getSelectorLineLength() * pixelRatio;
+ QT3DSF32 triWidth = 3 * CStudioPreferences::selectorLineWidth() * pixelRatio;
+ QT3DSF32 axisStart = CStudioPreferences::selectorLineLength() / 3.0f * pixelRatio;
+ QT3DSF32 axisLength = CStudioPreferences::selectorLineLength() * pixelRatio;
QT3DSF32 axisTotalLength = triWidth + axisLength;
if (m_XAxis == nullptr) {
TBase::SetupRender(inWidgetContext, inRenderContext);
@@ -189,6 +189,10 @@ struct SScaleWidget : public SStudioWidgetImpl<StudioWidgetTypes::Scale>
}
QT3DSMat44 theMVP = TBase::SetupMVP(inWidgetContext);
+
+ if (isNodeBehindCamera())
+ return;
+
inRenderContext.SetBlendingEnabled(false);
inRenderContext.SetDepthTestEnabled(true);
inRenderContext.SetDepthWriteEnabled(true);
diff --git a/src/Authoring/Qt3DStudio/Render/StudioSubPresentationRenderer.cpp b/src/Authoring/Qt3DStudio/Render/StudioSubPresentationRenderer.cpp
index b04233cd..e76f9ba4 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioSubPresentationRenderer.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioSubPresentationRenderer.cpp
@@ -200,12 +200,9 @@ SOffscreenRendererEnvironment
StudioSubpresentationRenderer::GetDesiredEnvironment(QT3DSVec2 inPresentationScaleFactor)
{
// If we aren't using a clear color, then we are expected to blend with the background
- if (!m_thread->m_initialized) {
+ if (!m_thread->m_initialized)
initialize();
- }
- bool hasTransparency = true;
- NVRenderTextureFormats::Enum format =
- hasTransparency ? NVRenderTextureFormats::RGBA8 : NVRenderTextureFormats::RGB8;
+ NVRenderTextureFormats::Enum format = NVRenderTextureFormats::RGBA8;
return SOffscreenRendererEnvironment(
QT3DSU32(m_thread->m_size.width() * inPresentationScaleFactor.x),
QT3DSU32(m_thread->m_size.height() * inPresentationScaleFactor.y),
@@ -257,7 +254,7 @@ void StudioSubpresentationRenderer::Render(const SOffscreenRendererEnvironment &
else
func->glEnable(GL_BLEND);
func->glBlendEquation(GL_FUNC_ADD);
- func->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ func->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
if (!m_program)
initializeFboCopy();
diff --git a/src/Authoring/Qt3DStudio/Render/StudioTranslationWidget.cpp b/src/Authoring/Qt3DStudio/Render/StudioTranslationWidget.cpp
index 0897a866..1ff7bd48 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioTranslationWidget.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioTranslationWidget.cpp
@@ -46,7 +46,9 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
NVRenderInputAssembler *m_XAxis;
NVRenderInputAssembler *m_YAxis;
NVRenderInputAssembler *m_ZAxis;
-
+ NVRenderInputAssembler *m_wideXAxis;
+ NVRenderInputAssembler *m_wideYAxis;
+ NVRenderInputAssembler *m_wideZAxis;
NVRenderInputAssembler *m_XPlane;
NVRenderInputAssembler *m_YPlane;
NVRenderInputAssembler *m_ZPlane;
@@ -58,6 +60,9 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
, m_XAxis(nullptr)
, m_YAxis(nullptr)
, m_ZAxis(nullptr)
+ , m_wideXAxis(nullptr)
+ , m_wideYAxis(nullptr)
+ , m_wideZAxis(nullptr)
, m_XPlane(nullptr)
, m_YPlane(nullptr)
, m_ZPlane(nullptr)
@@ -78,9 +83,9 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
TBase::SetupRender(inWidgetContext, inRenderContext);
float pixelRatio = float(StudioUtils::devicePixelRatio());
QT3DSF32 axisWidth = pixelRatio;
- QT3DSF32 triWidth = 4 * CStudioPreferences::getSelectorLineWidth() * pixelRatio;
- QT3DSF32 axisStart = CStudioPreferences::getSelectorLineLength() / 3.0f * pixelRatio;
- QT3DSF32 axisLength = CStudioPreferences::getSelectorLineLength() * pixelRatio;
+ QT3DSF32 triWidth = 4 * CStudioPreferences::selectorLineWidth() * pixelRatio;
+ QT3DSF32 axisStart = CStudioPreferences::selectorLineLength() / 3.0f * pixelRatio;
+ QT3DSF32 axisLength = CStudioPreferences::selectorLineLength() * pixelRatio;
QT3DSF32 triLength = axisStart;
m_XAxis = CreateAxis(m_Allocator, inWidgetContext, inRenderContext, QT3DSVec3(1, 0, 0),
axisStart, axisLength, triLength, axisWidth, triWidth,
@@ -108,7 +113,76 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
QT3DSVec3(axisPos, axisPos, 0), axisDiscRadius, axisRingRadius,
0.0f, 1.0f, "TranslationWidgetZPlane");
}
- QT3DSMat44 theMVP = TBase::SetupMVP(inWidgetContext);
+
+ QT3DSMat44 theMVP;
+
+ if (m_isAxisHelper) {
+ auto helpWidgetInfo
+ = inWidgetContext.GetWidgetRenderInformation(*m_Node,
+ QT3DSVec3(0, 0, 0),
+ RenderWidgetModes::Global);
+ auto viewport = inRenderContext.GetViewport();
+ SCamera theTempCamera;
+
+ QT3DSMat44 theViewProjection;
+ theTempCamera.m_Flags.SetOrthographic(true);
+
+ // Move the camera back far enough that we can see everything
+ static QT3DSF32 theCameraSetback(600);
+
+ // Move the camera to position axis helper to the lower left.
+ theTempCamera.m_Position.z = -theCameraSetback;
+ theTempCamera.m_Position.x = 0;
+ theTempCamera.m_Position.y = 0;
+ theTempCamera.m_ClipFar = 2.0f * theCameraSetback;
+ // Use entire viewport
+ theTempCamera.CalculateGlobalVariables(
+ viewport,
+ QT3DSVec2((QT3DSF32)viewport.m_Width, (QT3DSF32)viewport.m_Height));
+ theTempCamera.CalculateViewProjectionMatrix(theViewProjection);
+
+ // Get the rotation for the scene view camera (the actual direction of world axes)
+ // and rotate the widget axes to match world axes. Scale the widget to be smaller
+ // and less intrusive than actual translation widget.
+ auto rot = QT3DSMat44::createIdentity();
+ if (helpWidgetInfo.m_Camera->m_Flags.IsOrthographic()) {
+ rot = helpWidgetInfo.m_Camera->m_LocalTransform;
+ rot.setPosition({0, 0, 0});
+ rot = rot.getInverse().getTranspose();
+ } else {
+ helpWidgetInfo.m_Camera->CalculateRotationMatrix(rot);
+ }
+
+ helpWidgetInfo.m_Camera->FlipCoordinateSystem(rot);
+ // In the scale calculation 200.f = 120 / 0.6; 120 being the default width and 0.6
+ // being the default scale for the axis helper
+ const float scale = float(viewport.m_Width) / 200.f;
+ rot.scale(QT3DSVec4(scale, scale, scale, 1));
+ theMVP = theViewProjection * rot.getTranspose();
+
+ if (m_wideXAxis == nullptr) {
+ QT3DSF32 axisWidth = 6;
+ QT3DSF32 triWidth = axisWidth * 3;
+ QT3DSF32 axisStart = 0;
+ QT3DSF32 axisLength = axisWidth * 10;
+ QT3DSF32 triLength = axisWidth * 5;
+ m_wideXAxis = CreateAxis(m_Allocator, inWidgetContext, inRenderContext,
+ QT3DSVec3(1, 0, 0), axisStart, axisLength, triLength,
+ axisWidth, triWidth, "TranslationWidgetWideXAxis");
+ m_wideYAxis = CreateAxis(m_Allocator, inWidgetContext, inRenderContext,
+ QT3DSVec3(0, 1, 0), axisStart, axisLength, triLength,
+ axisWidth, triWidth, "TranslationWidgetWideYAxis");
+ m_wideZAxis = CreateAxis(m_Allocator, inWidgetContext, inRenderContext,
+ QT3DSVec3(0, 0, -1), axisStart, axisLength, triLength,
+ axisWidth, triWidth, "TranslationWidgetWideZAxis");
+ }
+ } else {
+ theMVP = TBase::SetupMVP(inWidgetContext);
+ }
+
+ if (isNodeBehindCamera())
+ return;
+
inRenderContext.SetBlendingEnabled(false);
inRenderContext.SetDepthTestEnabled(true);
inRenderContext.SetDepthWriteEnabled(true);
@@ -123,18 +197,27 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
QT3DSVec3 theZColor(GetZAxisColor());
QT3DSVec3 theRingColor(QT3DSVec3(.8f, .8f, .8f));
- RenderSingleToneGeometry(StudioWidgetComponentIds::XAxis, theXColor, inRenderContext,
- m_XAxis);
- RenderSingleToneGeometry(StudioWidgetComponentIds::YAxis, theYColor, inRenderContext,
- m_YAxis);
- RenderSingleToneGeometry(StudioWidgetComponentIds::ZAxis, theZColor, inRenderContext,
- m_ZAxis);
- RenderTwoToneGeometry(StudioWidgetComponentIds::XPlane, theXColor, theRingColor,
- inRenderContext, m_XPlane);
- RenderTwoToneGeometry(StudioWidgetComponentIds::YPlane, theYColor, theRingColor,
- inRenderContext, m_YPlane);
- RenderTwoToneGeometry(StudioWidgetComponentIds::ZPlane, theZColor, theRingColor,
- inRenderContext, m_ZPlane);
+ if (!m_isAxisHelper) {
+ RenderSingleToneGeometry(StudioWidgetComponentIds::XAxis, theXColor, inRenderContext,
+ m_XAxis);
+ RenderSingleToneGeometry(StudioWidgetComponentIds::YAxis, theYColor, inRenderContext,
+ m_YAxis);
+ RenderSingleToneGeometry(StudioWidgetComponentIds::ZAxis, theZColor, inRenderContext,
+ m_ZAxis);
+ RenderTwoToneGeometry(StudioWidgetComponentIds::XPlane, theXColor, theRingColor,
+ inRenderContext, m_XPlane);
+ RenderTwoToneGeometry(StudioWidgetComponentIds::YPlane, theYColor, theRingColor,
+ inRenderContext, m_YPlane);
+ RenderTwoToneGeometry(StudioWidgetComponentIds::ZPlane, theZColor, theRingColor,
+ inRenderContext, m_ZPlane);
+ } else {
+ RenderSingleToneGeometry(StudioWidgetComponentIds::XAxis, theXColor, inRenderContext,
+ m_wideXAxis);
+ RenderSingleToneGeometry(StudioWidgetComponentIds::YAxis, theYColor, inRenderContext,
+ m_wideYAxis);
+ RenderSingleToneGeometry(StudioWidgetComponentIds::ZAxis, theZColor, inRenderContext,
+ m_wideZAxis);
+ }
m_Highlight = StudioWidgetComponentIds::NoId;
}
@@ -164,6 +247,11 @@ struct STranslationWidget : public SStudioWidgetImpl<StudioWidgetTypes::Translat
RenderPickBuffer(StudioWidgetComponentIds::ZPlane, m_ZPlane, inRenderContext);
}
}
+
+ void setAsAxisHelper(bool isAxisHelper) override
+ {
+ m_isAxisHelper = isAxisHelper;
+ }
};
}
diff --git a/src/Authoring/Qt3DStudio/Render/StudioVisualAidWidget.cpp b/src/Authoring/Qt3DStudio/Render/StudioVisualAidWidget.cpp
index faadd7e6..f1e9d7d2 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioVisualAidWidget.cpp
+++ b/src/Authoring/Qt3DStudio/Render/StudioVisualAidWidget.cpp
@@ -482,7 +482,7 @@ void SVisualAidWidget::renderCamera(SNode *node, IRenderWidgetContext &inWidgetC
inRenderContext.SetDepthWriteEnabled(false);
inRenderContext.SetCullingEnabled(false);
- SWidgetRenderSetupResult theSetup(inWidgetContext, *node, RenderWidgetModes::Local);
+ SWidgetRenderSetupResult theSetup(inWidgetContext, *node, RenderWidgetModes::Global);
m_renderCameraShader->SetPropertyValue("orthographic",
camera->m_Flags.IsOrthographic() ? 1 : 0);
@@ -491,7 +491,7 @@ void SVisualAidWidget::renderCamera(SNode *node, IRenderWidgetContext &inWidgetC
* theSetup.m_WidgetInfo.m_NodeParentToCamera
* node->m_GlobalTransform);
- ::CColor color = CStudioPreferences::GetSingleBoundingBoxColor();
+ ::CColor color = CStudioPreferences::singleBoundingBoxColor();
QT3DSVec3 colorVec(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f);
@@ -554,7 +554,7 @@ void SVisualAidWidget::renderBillboard(SNode *node, IRenderWidgetContext &inWidg
qt3ds::render::NVRenderBlendEquationArgument(
NVRenderBlendEquation::Add, NVRenderBlendEquation::Add));
- SWidgetRenderSetupResult theSetup(inWidgetContext, *node, RenderWidgetModes::Local);
+ SWidgetRenderSetupResult theSetup(inWidgetContext, *node, RenderWidgetModes::Global);
QT3DSMat44 billboardMatrix = QT3DSMat44::createIdentity();
billboardMatrix.setPosition((theSetup.m_WidgetInfo.m_NodeParentToCamera
* node->m_GlobalTransform).getPosition());
@@ -616,14 +616,14 @@ void SVisualAidWidget::renderLight(SNode *node, IRenderWidgetContext &inWidgetCo
inRenderContext.SetDepthWriteEnabled(false);
inRenderContext.SetCullingEnabled(false);
- SWidgetRenderSetupResult theSetup(inWidgetContext, *node, RenderWidgetModes::Local);
+ SWidgetRenderSetupResult theSetup(inWidgetContext, *node, RenderWidgetModes::Global);
m_renderShader->SetPropertyValue("mvpMatrix", theSetup.m_PureProjection
* theSetup.m_WidgetInfo.m_NodeParentToCamera
* node->m_GlobalTransform
* areaScaleMatrix);
- ::CColor color = CStudioPreferences::GetSingleBoundingBoxColor();
+ ::CColor color = CStudioPreferences::singleBoundingBoxColor();
QT3DSVec3 colorVec(color.GetRed() / 255.f,
color.GetGreen() / 255.f,
color.GetBlue() / 255.f);
@@ -673,7 +673,7 @@ void SVisualAidWidget::Render(IRenderWidgetContext &inWidgetContext,
bool SVisualAidWidget::pick(IRenderWidgetContext &inWidgetContext, float &dist, QT3DSVec2 viewport,
QT3DSVec2 pos)
{
- SWidgetRenderSetupResult theSetup(inWidgetContext, *m_node, RenderWidgetModes::Local);
+ SWidgetRenderSetupResult theSetup(inWidgetContext, *m_node, RenderWidgetModes::Global);
SCamera *pickCamera = theSetup.m_WidgetInfo.m_Camera;
QT3DSMat44 pip = pickCamera->m_Projection.getInverse();
float x = pos.x / viewport.x;
diff --git a/src/Authoring/Qt3DStudio/Render/StudioWidget.h b/src/Authoring/Qt3DStudio/Render/StudioWidget.h
index 0d40f195..1287612e 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioWidget.h
+++ b/src/Authoring/Qt3DStudio/Render/StudioWidget.h
@@ -115,6 +115,8 @@ namespace widgets {
QT3DSF32 inColorIndex, TResultVecType &outResult);
void SetNode(SNode &inNode) override = 0;
+ virtual void setAsAxisHelper(bool isAxisWidget) = 0;
+
virtual StudioWidgetTypes::Enum GetWidgetType() const = 0;
virtual void SetSubComponentId(int inSubComponentId) = 0;
virtual void SetRenderWidgetMode(RenderWidgetModes::Enum inSpace) = 0;
@@ -128,6 +130,7 @@ namespace widgets {
virtual void SetRotationEdges(const QT3DSVec3 &inStartDirection, const QT3DSVec3 &inRotationAxis,
QT3DSF32 inAngleRad, QT3DSF32 inEndLineLen) = 0;
virtual void ClearRotationEdges() = 0;
+ virtual bool isNodeBehindCamera() const = 0;
static IStudioWidget &CreateTranslationWidget(NVAllocatorCallback &inAlloc);
static IStudioWidget &CreateRotationWidget(NVAllocatorCallback &inAlloc);
diff --git a/src/Authoring/Qt3DStudio/Render/StudioWidgetImpl.h b/src/Authoring/Qt3DStudio/Render/StudioWidgetImpl.h
index b78c1edf..9205fc5d 100644
--- a/src/Authoring/Qt3DStudio/Render/StudioWidgetImpl.h
+++ b/src/Authoring/Qt3DStudio/Render/StudioWidgetImpl.h
@@ -36,6 +36,7 @@
#include "Qt3DSRenderNode.h"
#include "Qt3DSRenderShaderCodeGeneratorV2.h"
+#include "Qt3DSRenderCamera.h"
#include "StudioPreferences.h"
namespace qt3ds {
@@ -91,6 +92,7 @@ namespace widgets {
NVRenderVertexBuffer *m_ImmediateVertexBuffer;
NVRenderInputAssembler *m_ImmediateInputAssembler;
NVRenderShaderProgram *m_ImmediateShader;
+ bool m_isAxisHelper;
SStudioWidgetImpl(NVAllocatorCallback &inAlloc)
: m_Allocator(inAlloc)
@@ -103,6 +105,7 @@ namespace widgets {
, m_ImmediateVertexBuffer(NULL)
, m_ImmediateInputAssembler(NULL)
, m_ImmediateShader(NULL)
+ , m_isAxisHelper(false)
{
}
@@ -318,6 +321,8 @@ namespace widgets {
void SetAxisScale(const QT3DSVec3 &inAxisScale) override { m_AxisScale = inAxisScale; }
+ void setAsAxisHelper(bool isAxisHelper) override { m_isAxisHelper = isAxisHelper; }
+
void SetRotationEdges(const QT3DSVec3 &inStartDirection, const QT3DSVec3 &inRotationAxis,
QT3DSF32 inAngleRad, QT3DSF32 inEndLineLen) override
{
@@ -327,14 +332,21 @@ namespace widgets {
void ClearRotationEdges() override { m_RotationWedge = Empty(); }
+ bool isNodeBehindCamera() const override
+ {
+ return m_WidgetInfo.m_Camera && m_Node
+ && m_WidgetInfo.m_Camera->GetDirection().dot(
+ (m_Node->GetGlobalPos() - m_WidgetInfo.m_Camera->GetGlobalPos())) > 0.f;
+ }
+
static inline QT3DSVec3 ToGLSLColor(const QColor &c)
{
return QT3DSVec3(c.redF(), c.greenF(), c.blueF());
}
- static QT3DSVec3 GetXAxisColor() { return ToGLSLColor(CStudioPreferences::GetXAxisColor()); }
- static QT3DSVec3 GetYAxisColor() { return ToGLSLColor(CStudioPreferences::GetYAxisColor()); }
- static QT3DSVec3 GetZAxisColor() { return ToGLSLColor(CStudioPreferences::GetZAxisColor()); }
+ static QT3DSVec3 GetXAxisColor() { return ToGLSLColor(CStudioPreferences::xAxisColor()); }
+ static QT3DSVec3 GetYAxisColor() { return ToGLSLColor(CStudioPreferences::yAxisColor()); }
+ static QT3DSVec3 GetZAxisColor() { return ToGLSLColor(CStudioPreferences::zAxisColor()); }
static inline QT3DSF32 GetDiscPos() { return 65.0f; }
static inline QT3DSF32 GetDiscRadius() { return 7.0f; }
diff --git a/src/Authoring/Qt3DStudio/UI/EditCameraBar.cpp b/src/Authoring/Qt3DStudio/UI/EditCameraBar.cpp
index 5675f978..04a717c9 100644
--- a/src/Authoring/Qt3DStudio/UI/EditCameraBar.cpp
+++ b/src/Authoring/Qt3DStudio/UI/EditCameraBar.cpp
@@ -69,7 +69,7 @@ void CEditCameraBar::setupCameras()
qobject_cast<QListView *>(m_CameraSelector->view())->setSpacing(1);
// set initial view
- int viewIndex = CStudioPreferences::GetPreferredStartupView();
+ int viewIndex = CStudioPreferences::preferredStartupView();
// if not set or invalid index, use the scene camera view (last index)
if (viewIndex == -1 || viewIndex > m_CameraSelector->count() - 3)
viewIndex = m_CameraSelector->count() - 1;
@@ -87,8 +87,11 @@ void CEditCameraBar::setupCameras()
void CEditCameraBar::setCameraIndex(int inIndex)
{
- m_CameraSelector->setCurrentIndex(inIndex);
- handleCameraChanged(inIndex);
+ // Only handle camera shortcuts if toolbar is enabled
+ if (isEnabled()) {
+ m_CameraSelector->setCurrentIndex(inIndex);
+ handleCameraChanged(inIndex);
+ }
}
/**
diff --git a/src/Authoring/Qt3DStudio/UI/InterpolationDlg.cpp b/src/Authoring/Qt3DStudio/UI/InterpolationDlg.cpp
index 9c4c5c38..be69bed6 100644
--- a/src/Authoring/Qt3DStudio/UI/InterpolationDlg.cpp
+++ b/src/Authoring/Qt3DStudio/UI/InterpolationDlg.cpp
@@ -27,22 +27,18 @@
**
****************************************************************************/
-#include "Qt3DSCommonPrecompile.h"
#include "InterpolationDlg.h"
#include "ui_InterpolationDlg.h"
-/**
- * Constructor: Creates a CInterpolationDlg.
- *
- * @param parent Pointer to the parent of this dialog (defaults to NULL)
- */
-//==============================================================================
-CInterpolationDlg::CInterpolationDlg(QWidget *parent)
+CInterpolationDlg::CInterpolationDlg(float easeIn, float easeOut, QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::InterpolationDlg)
{
m_ui->setupUi(this);
window()->setFixedSize(size());
+
+ m_ui->easeInSlider->setValue(int(easeIn));
+ m_ui->easeOutSlider->setValue(int(easeOut));
}
CInterpolationDlg::~CInterpolationDlg()
@@ -51,22 +47,13 @@ CInterpolationDlg::~CInterpolationDlg()
m_ui = nullptr;
}
-void CInterpolationDlg::setEaseIn(uint value)
-{
- m_ui->easeInSlider->setValue(value);
-}
-
-void CInterpolationDlg::setEaseOut(uint value)
-{
- m_ui->easeOutSlider->setValue(value);
-}
-int CInterpolationDlg::easeIn() const
+float CInterpolationDlg::easeIn() const
{
return m_ui->easeInSlider->value();
}
-int CInterpolationDlg::easeOut() const
+float CInterpolationDlg::easeOut() const
{
return m_ui->easeOutSlider->value();
}
diff --git a/src/Authoring/Qt3DStudio/UI/InterpolationDlg.h b/src/Authoring/Qt3DStudio/UI/InterpolationDlg.h
index 0b324bd3..ebff86de 100644
--- a/src/Authoring/Qt3DStudio/UI/InterpolationDlg.h
+++ b/src/Authoring/Qt3DStudio/UI/InterpolationDlg.h
@@ -27,16 +27,10 @@
**
****************************************************************************/
-//==============================================================================
-// Prefix
-//==============================================================================
-
#ifndef INCLUDED_INTERPOLATION_DLG
-#define INCLUDED_INTERPOLATION_DLG 1
-
-#pragma once
+#define INCLUDED_INTERPOLATION_DLG
-#include <QDialog>
+#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
namespace Ui {
@@ -44,22 +38,19 @@ class InterpolationDlg;
}
QT_END_NAMESPACE
-//==============================================================================
/**
- * CInterpolationDlg: Dialog class for editing the ease-in/ease-out values of keyframes.
+ * CInterpolationDlg: Dialog class for editing keyframes interpolation
*/
-//==============================================================================
class CInterpolationDlg : public QDialog
{
Q_OBJECT
+
public:
- explicit CInterpolationDlg(QWidget *parent = nullptr); // standard constructor
+ explicit CInterpolationDlg(float easeIn, float easeOut, QWidget *parent = nullptr);
~CInterpolationDlg();
- void setEaseIn(uint value);
- void setEaseOut(uint value);
- int easeIn() const;
- int easeOut() const;
+ float easeIn() const;
+ float easeOut() const;
protected:
QT_PREPEND_NAMESPACE(Ui::InterpolationDlg) *m_ui = nullptr;
diff --git a/src/Authoring/Qt3DStudio/UI/InterpolationDlg.ui b/src/Authoring/Qt3DStudio/UI/InterpolationDlg.ui
index 0d27d777..710fee6b 100644
--- a/src/Authoring/Qt3DStudio/UI/InterpolationDlg.ui
+++ b/src/Authoring/Qt3DStudio/UI/InterpolationDlg.ui
@@ -1,311 +1,316 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>InterpolationDlg</class>
- <widget class="QDialog" name="InterpolationDlg">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>425</width>
- <height>195</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Set Keyframe Interpolation</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="2" column="1" colspan="2">
- <widget class="QSlider" name="easeOutSlider">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="tickPosition">
- <enum>QSlider::TicksBelow</enum>
- </property>
- <property name="tickInterval">
- <number>10</number>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Ease In:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QLabel" name="label_4">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Smooth</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="2">
- <widget class="QSlider" name="easeInSlider">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="tickPosition">
- <enum>QSlider::TicksBelow</enum>
- </property>
- <property name="tickInterval">
- <number>10</number>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_3">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Linear</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLabel" name="label_5">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Linear</string>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="QLabel" name="label_6">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Smooth</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Ease Out:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QSpinBox" name="easeInSpinBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="QSpinBox" name="easeOutSpinBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <tabstops>
- <tabstop>easeInSlider</tabstop>
- <tabstop>easeInSpinBox</tabstop>
- <tabstop>easeOutSlider</tabstop>
- <tabstop>easeOutSpinBox</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>InterpolationDlg</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>224</x>
- <y>272</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>InterpolationDlg</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>easeInSlider</sender>
- <signal>valueChanged(int)</signal>
- <receiver>easeInSpinBox</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>331</x>
- <y>21</y>
- </hint>
- <hint type="destinationlabel">
- <x>542</x>
- <y>35</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>easeOutSlider</sender>
- <signal>valueChanged(int)</signal>
- <receiver>easeOutSpinBox</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>210</x>
- <y>93</y>
- </hint>
- <hint type="destinationlabel">
- <x>545</x>
- <y>93</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>easeInSpinBox</sender>
- <signal>valueChanged(int)</signal>
- <receiver>easeInSlider</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>533</x>
- <y>24</y>
- </hint>
- <hint type="destinationlabel">
- <x>408</x>
- <y>18</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>easeOutSpinBox</sender>
- <signal>valueChanged(int)</signal>
- <receiver>easeOutSlider</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>546</x>
- <y>98</y>
- </hint>
- <hint type="destinationlabel">
- <x>338</x>
- <y>84</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <class>InterpolationDlg</class>
+ <widget class="QDialog" name="InterpolationDlg">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>425</width>
+ <height>195</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Set Keyframe Interpolation</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Ease In:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2">
+ <widget class="QSlider" name="easeInSlider">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksBelow</enum>
+ </property>
+ <property name="tickInterval">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QSpinBox" name="easeInSpinBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Linear</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Smooth</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Ease Out:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2">
+ <widget class="QSlider" name="easeOutSlider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksBelow</enum>
+ </property>
+ <property name="tickInterval">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QSpinBox" name="easeOutSpinBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Linear</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QLabel" name="label_6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Smooth</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>easeInSlider</tabstop>
+ <tabstop>easeInSpinBox</tabstop>
+ <tabstop>easeOutSlider</tabstop>
+ <tabstop>easeOutSpinBox</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>InterpolationDlg</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>233</x>
+ <y>211</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>InterpolationDlg</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>325</x>
+ <y>211</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>easeInSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>easeInSpinBox</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>108</x>
+ <y>58</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>406</x>
+ <y>72</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>easeOutSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>easeOutSpinBox</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>171</x>
+ <y>136</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>406</x>
+ <y>132</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>easeInSpinBox</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>easeInSlider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>406</x>
+ <y>72</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>108</x>
+ <y>55</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>easeOutSpinBox</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>easeOutSlider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>406</x>
+ <y>132</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>171</x>
+ <y>136</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
diff --git a/src/Authoring/Qt3DStudio/UI/RecentItems.cpp b/src/Authoring/Qt3DStudio/UI/RecentItems.cpp
index 681ae421..97665cb6 100644
--- a/src/Authoring/Qt3DStudio/UI/RecentItems.cpp
+++ b/src/Authoring/Qt3DStudio/UI/RecentItems.cpp
@@ -78,12 +78,12 @@ void CRecentItems::ReconstructList()
m_Menu->clear();
m_RecentItems.clear();
- int numRecentItems = CStudioPreferences::getNumRecentItems();
+ int numRecentItems = CStudioPreferences::numRecentItems();
if (numRecentItems > MAX_ITEMS)
numRecentItems = MAX_ITEMS;
for (int i = 0; i < numRecentItems; ++i) {
- QString theFile = CStudioPreferences::getRecentItem(i);
+ QString theFile = CStudioPreferences::recentItem(i);
if (!theFile.isEmpty() && QFileInfo(theFile).exists()) {
m_RecentItems.push_back(theFile);
QAction *act = m_Menu->addAction(theFile, this, &CRecentItems::onTriggerRecent);
@@ -97,19 +97,19 @@ void CRecentItems::RebuildList()
{
m_Menu->clear();
- CStudioPreferences::setNumRecentItems(GetItemCount());
+ CStudioPreferences::setNumRecentItems(int(GetItemCount()));
- for (int i = 0; i < m_RecentItems.size(); ++i) {
+ for (size_t i = 0; i < m_RecentItems.size(); ++i) {
const QString &item_i = m_RecentItems.at(i);
if (QFileInfo(item_i).exists()) {
QAction *act = m_Menu->addAction(item_i, this, &CRecentItems::onTriggerRecent);
- act->setData(i);
- CStudioPreferences::setRecentItem(i, item_i);
+ act->setData(int(i));
+ CStudioPreferences::setRecentItem(int(i), item_i);
}
}
}
-QString CRecentItems::GetItem(long inIndex) const
+QString CRecentItems::GetItem(size_t inIndex) const
{
return m_RecentItems.at(inIndex);
}
diff --git a/src/Authoring/Qt3DStudio/UI/RecentItems.h b/src/Authoring/Qt3DStudio/UI/RecentItems.h
index 9557353f..3d1cb6dd 100644
--- a/src/Authoring/Qt3DStudio/UI/RecentItems.h
+++ b/src/Authoring/Qt3DStudio/UI/RecentItems.h
@@ -53,8 +53,8 @@ public:
void AddRecentItem(const QString &inItem);
void RemoveRecentItem(const QString &inItem, bool rebuild = true);
- QString GetItem(long inIndex) const;
- long GetItemCount() const { return (long)m_RecentItems.size(); }
+ QString GetItem(size_t inIndex) const;
+ size_t GetItemCount() const { return m_RecentItems.size(); }
protected:
void ReconstructList();
diff --git a/src/Authoring/Qt3DStudio/UI/SceneView.cpp b/src/Authoring/Qt3DStudio/UI/SceneView.cpp
index 5e617d92..653fcd9b 100644
--- a/src/Authoring/Qt3DStudio/UI/SceneView.cpp
+++ b/src/Authoring/Qt3DStudio/UI/SceneView.cpp
@@ -81,7 +81,7 @@ CSceneView::~CSceneView()
QSize CSceneView::sizeHint() const
{
- return CStudioPreferences::GetDefaultClientSize();
+ return CStudioPreferences::defaultClientSize();
}
//==============================================================================
@@ -338,6 +338,10 @@ void CSceneView::setToolMode(long inMode)
*/
void CSceneView::onEditCameraChanged()
{
+ // Update the view mode accordingly
+ setViewMode(g_StudioApp.getRenderer().GetEditCamera() >= 0 ? CPlayerContainerWnd::VIEW_EDIT
+ : CPlayerContainerWnd::VIEW_SCENE);
+
// Reset any scrolling and recalculate the window position.
if (m_playerContainerWnd) {
m_playerContainerWnd->SetScrollRanges();
@@ -345,9 +349,6 @@ void CSceneView::onEditCameraChanged()
setPlayerWndPosition();
}
- // Update the view mode accordingly
- setViewMode(g_StudioApp.getRenderer().GetEditCamera() >= 0 ? CPlayerContainerWnd::VIEW_EDIT
- : CPlayerContainerWnd::VIEW_SCENE);
m_playerWnd->update();
}
diff --git a/src/Authoring/Qt3DStudio/UI/StartupDlg.cpp b/src/Authoring/Qt3DStudio/UI/StartupDlg.cpp
index c5cc4c47..40c2ba20 100644
--- a/src/Authoring/Qt3DStudio/UI/StartupDlg.cpp
+++ b/src/Authoring/Qt3DStudio/UI/StartupDlg.cpp
@@ -96,7 +96,7 @@ void CStartupDlg::OnInitDialog()
connect(m_ui->openDocument, &ClickableLabel::clicked, this, &CStartupDlg::OnOpenDocClicked);
// Load the product version
- m_ProductVersionStr = QStringLiteral("Qt 3D Studio v") + CStudioPreferences::GetVersionString();
+ m_ProductVersionStr = QStringLiteral("Qt 3D Studio v") + CStudioPreferences::versionString();
m_ui->versionStr->setText(m_ProductVersionStr);
// Populate the recent document list
diff --git a/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.cpp b/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.cpp
index 288cee86..bf0dc167 100644
--- a/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.cpp
+++ b/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.cpp
@@ -36,12 +36,12 @@
#include "StudioPreferences.h"
#include "StudioApp.h"
#include "StudioPreferences.h"
-#include "CommonConstants.h"
#include "Views.h"
#include "Qt3DSDMStudioSystem.h"
#include "ClientDataModelBridge.h"
#include "Core.h"
#include "IStudioRenderer.h"
+#include "MainFrm.h"
#include <QtWidgets/qmessagebox.h>
#include <QtWidgets/qlistview.h>
@@ -61,7 +61,7 @@ CStudioAppPrefsPage::CStudioAppPrefsPage(QWidget *parent)
, m_autosaveChanged(false)
, m_ui(new Ui::StudioAppPrefsPage)
{
- m_font = QFont(CStudioPreferences::GetFontFaceName());
+ m_font = QFont(CStudioPreferences::fontFaceName());
m_font.setPixelSize(CStudioPreferences::fontSize());
// Create a bold font for the group box text
@@ -90,7 +90,6 @@ void CStudioAppPrefsPage::onInitDialog()
// Add tool tips for controls
m_ui->m_DefaultInterpolation->setToolTip(tr("Set default keyframe interpolation type"));
m_ui->m_checkTimelineAbsoluteSnapping->setToolTip(tr("Enable timeline snapping grid"));
- m_ui->m_checkLegacyViewer->setToolTip(tr("Enable preview with Qt3D Runtime Viewer"));
m_ui->m_SnapRangeCombo->setToolTip(tr("Set resolution of timeline snapping grid"));
m_ui->m_buttonRestoreDefaults->setToolTip(tr("Click to restore default Studio settings"));
@@ -115,13 +114,19 @@ void CStudioAppPrefsPage::onInitDialog()
onApply(); // Save changed preferences before resetting, as it causes Studio to shut down
CStudioPreferencesPropPage::endDialog(PREFS_RESET_LAYOUT);
});
+ connect(m_ui->m_buttonResetPopupWarnings, &QPushButton::clicked, this,
+ &CStudioAppPrefsPage::onButtonResetPopupWarnings);
connect(m_ui->m_DefaultInterpolation, activated, this, [=](){ setModified(true); });
connect(m_ui->m_SnapRangeCombo, activated, this, [=](){ setModified(true); });
connect(m_ui->m_checkTimelineAbsoluteSnapping, &QCheckBox::clicked,
this, [=](){ setModified(true); enableOptions(); });
- connect(m_ui->m_checkLegacyViewer, &QCheckBox::clicked,
- this, [=](){ setModified(true); m_restartNeeded = true; });
connect(m_ui->m_EditViewStartupView, activated, this, [=](){ setModified(true); });
+ connect(m_ui->helperGridLinesSpinBox,
+ static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
+ this, [=](){ setModified(true); });
+ connect(m_ui->helperGridSpacingSpinBox,
+ static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
+ this, [=](){ setModified(true); });
connect(m_ui->selectorWidth,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, [=](){ setModified(true); m_restartNeeded = true; });
@@ -153,8 +158,8 @@ void CStudioAppPrefsPage::loadSettings()
m_ui->m_DefaultInterpolation->addItem(tr("Smooth"));
m_ui->m_DefaultInterpolation->addItem(tr("Linear"));
- long theInterpolationPref = 0;
- if (CStudioPreferences::GetInterpolation())
+ int theInterpolationPref = 0;
+ if (CStudioPreferences::isInterpolation())
theInterpolationPref = 0;
else
theInterpolationPref = 1;
@@ -162,25 +167,26 @@ void CStudioAppPrefsPage::loadSettings()
// Timeline snapping grid
m_ui->m_checkTimelineAbsoluteSnapping->setChecked(
- CStudioPreferences::IsTimelineSnappingGridActive());
+ CStudioPreferences::isTimelineSnappingGridActive());
- // Legacy viewer
- m_ui->m_checkLegacyViewer->setChecked(CStudioPreferences::IsLegacyViewerActive());
+ // Helper grid
+ m_ui->helperGridLinesSpinBox->setValue(CStudioPreferences::helperGridLines());
+ m_ui->helperGridSpacingSpinBox->setValue(CStudioPreferences::helperGridSpacing());
// Tool handles
- m_ui->selectorWidth->setValue(CStudioPreferences::getSelectorLineWidth());
- m_ui->selectorLength->setValue(CStudioPreferences::getSelectorLineLength());
+ m_ui->selectorWidth->setValue(double(CStudioPreferences::selectorLineWidth()));
+ m_ui->selectorLength->setValue(double(CStudioPreferences::selectorLineLength()));
// The scale mode
m_ui->m_SnapRangeCombo->addItem(tr("1 Second"));
m_ui->m_SnapRangeCombo->addItem(tr("0.5 Seconds"));
m_ui->m_SnapRangeCombo->addItem(tr("0.1 Seconds"));
- long theResolution = (long)CStudioPreferences::GetTimelineSnappingGridResolution();
+ int theResolution = CStudioPreferences::timelineSnappingGridResolution();
m_ui->m_SnapRangeCombo->setCurrentIndex(theResolution);
// Autosave options
- m_ui->autosaveEnabled->setChecked(CStudioPreferences::GetAutoSavePreference());
- m_ui->autosaveInterval->setValue(CStudioPreferences::GetAutoSaveDelay());
+ m_ui->autosaveEnabled->setChecked(CStudioPreferences::isAutoSavePreference());
+ m_ui->autosaveInterval->setValue(CStudioPreferences::autoSaveDelay());
initEditStartViewCombo();
@@ -203,25 +209,27 @@ void CStudioAppPrefsPage::saveSettings()
g_StudioApp.GetCore()->GetDoc()->SetDefaultKeyframeInterpolation(
m_ui->m_DefaultInterpolation->currentIndex() == 0);
+ // Timeline settings
// Timeline snapping grid
- CStudioPreferences::SetTimelineSnappingGridActive(
+ CStudioPreferences::setTimelineSnappingGridActive(
m_ui->m_checkTimelineAbsoluteSnapping->isChecked());
- long theCurrentSelection = m_ui->m_SnapRangeCombo->currentIndex();
- CStudioPreferences::SetTimelineSnappingGridResolution((ESnapGridResolution)theCurrentSelection);
-
- // Legacy viewer
- CStudioPreferences::SetLegacyViewerActive(m_ui->m_checkLegacyViewer->isChecked());
+ int theCurrentSelection = m_ui->m_SnapRangeCombo->currentIndex();
+ CStudioPreferences::setTimelineSnappingGridResolution(ESnapGridResolution(theCurrentSelection));
// Preferred Startup View
- CStudioPreferences::SetPreferredStartupView(m_ui->m_EditViewStartupView->currentIndex());
+ CStudioPreferences::setPreferredStartupView(m_ui->m_EditViewStartupView->currentIndex());
+ // VisualAids settings
+ // Helper grid
+ CStudioPreferences::setHelperGridLines(m_ui->helperGridLinesSpinBox->value());
+ CStudioPreferences::setHelperGridSpacing(m_ui->helperGridSpacingSpinBox->value());
// Tool handles
- CStudioPreferences::setSelectorLineWidth(m_ui->selectorWidth->value());
- CStudioPreferences::setSelectorLineLength(m_ui->selectorLength->value());
+ CStudioPreferences::setSelectorLineWidth(float(m_ui->selectorWidth->value()));
+ CStudioPreferences::setSelectorLineLength(float(m_ui->selectorLength->value()));
- // Autosave options
- CStudioPreferences::SetAutoSavePreference(m_ui->autosaveEnabled->isChecked());
- CStudioPreferences::SetAutoSaveDelay(m_ui->autosaveInterval->value());
+ // Autosave settings
+ CStudioPreferences::setAutoSavePreference(m_ui->autosaveEnabled->isChecked());
+ CStudioPreferences::setAutoSaveDelay(m_ui->autosaveInterval->value());
enableAutosave(m_ui->autosaveEnabled->isChecked());
setAutosaveInterval(m_ui->autosaveInterval->value());
m_autosaveChanged = false;
@@ -278,6 +286,12 @@ void CStudioAppPrefsPage::onButtonRestoreDefaults()
}
}
+void CStudioAppPrefsPage::onButtonResetPopupWarnings()
+{
+ // Setters per pop-up type
+ CStudioPreferences::setDoNotShowImportWarnings(false);
+}
+
//==============================================================================
/**
* EnableOptions: Enable/disable options.
@@ -309,8 +323,8 @@ void CStudioAppPrefsPage::initEditStartViewCombo()
// adding a 1px spacing, else the separator will disappear sometimes (QComboBox bug)
qobject_cast<QListView *>(m_ui->m_EditViewStartupView->view())->setSpacing(1);
- long thePreferredView = CStudioPreferences::GetPreferredStartupView();
- long theNumItems = m_ui->m_EditViewStartupView->count();
+ int thePreferredView = CStudioPreferences::preferredStartupView();
+ int theNumItems = m_ui->m_EditViewStartupView->count();
if (thePreferredView >= 0 && thePreferredView < theNumItems - 2)
m_ui->m_EditViewStartupView->setCurrentIndex(thePreferredView);
@@ -396,6 +410,7 @@ void CStudioAppPrefsPage::checkRestartCondition()
"Restart now?"));
if (retval == QMessageBox::Yes) {
+ g_StudioApp.GetViews()->getMainFrame()->handleGeometryAndState(true);
CStudioPreferences::savePreferences();
CStudioPreferencesPropPage::endDialog(PREFS_SETTINGS_RESTART);
}
@@ -481,7 +496,7 @@ void CStudioAppPrefsPage::loadBuildProperties()
void CStudioAppPrefsPage::SavePreviewSettings()
{
QString thePreviewApp = m_ui->m_PreviewSelector->currentText();
- CStudioPreferences::SetPreviewConfig(Q3DStudio::CString::fromQString(thePreviewApp));
+ CStudioPreferences::setPreviewConfig(Q3DStudio::CString::fromQString(thePreviewApp));
std::list<TBuildNameControlPair>::iterator theIter;
for (theIter = m_BuildProperties.begin(); theIter != m_BuildProperties.end(); ++theIter) {
@@ -490,7 +505,7 @@ void CStudioAppPrefsPage::SavePreviewSettings()
Q3DStudio::CBuildConfiguration::SConfigPropertyValue *thePropertyValue =
theCombo->itemData(theCombo->currentIndex())
.value<Q3DStudio::CBuildConfiguration::SConfigPropertyValue *>();
- CStudioPreferences::SetPreviewProperty(theName, thePropertyValue->GetName());
+ CStudioPreferences::setPreviewProperty(theName, thePropertyValue->GetName());
}
}
diff --git a/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.h b/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.h
index abea304b..d2aa18ca 100644
--- a/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.h
+++ b/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.h
@@ -76,6 +76,7 @@ protected:
#if 0 // Removed until we have some other Preview configurations that just Viewer
void onChangePreviewConfiguration();
#endif
+ void onButtonResetPopupWarnings();
void enableAutosave(bool enabled);
void setAutosaveInterval(int interval);
diff --git a/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.ui b/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.ui
index 7ebdc7e2..a49ceda4 100644
--- a/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.ui
+++ b/src/Authoring/Qt3DStudio/UI/StudioAppPrefsPage.ui
@@ -30,23 +30,23 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="m_DefaultInterpolation"/>
- </item>
<item row="1" column="1">
<widget class="QComboBox" name="m_SnapRangeCombo"/>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="m_checkTimelineAbsoluteSnapping">
- <property name="text">
- <string>Timeline Snapping Grid</string>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="m_DefaultInterpolation">
+ <property name="maximumSize">
+ <size>
+ <width>185</width>
+ <height>16777215</height>
+ </size>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="m_checkLegacyViewer">
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="m_checkTimelineAbsoluteSnapping">
<property name="text">
- <string>Qt3D Viewer</string>
+ <string>Timeline Snapping Grid</string>
</property>
</widget>
</item>
@@ -59,8 +59,90 @@
<string>Editing View</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="2" colspan="2">
- <widget class="QComboBox" name="m_EditViewStartupView"/>
+ <item row="1" column="2">
+ <widget class="QLabel" name="helperGridLineCountLabel">
+ <property name="text">
+ <string>Lines</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="6">
+ <widget class="QSpinBox" name="helperGridSpacingSpinBox">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Helper grid spacing</string>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhDigitsOnly</set>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>10000</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ <property name="stepType">
+ <enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QSpinBox" name="helperGridLinesSpinBox">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Lines in helper grid</string>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhDigitsOnly</set>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>1000</number>
+ </property>
+ <property name="stepType">
+ <enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="5">
+ <widget class="QLabel" name="helperGridSpacingLabel">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Spacing</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_4">
@@ -72,6 +154,36 @@
</property>
</widget>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="helperGridLabel">
+ <property name="text">
+ <string>Helper Grid</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="4" colspan="3">
+ <widget class="QComboBox" name="m_EditViewStartupView">
+ <property name="maximumSize">
+ <size>
+ <width>185</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -81,8 +193,40 @@
<string>Manipulator Tool Handles</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="3">
+ <widget class="QLabel" name="label_6">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Length</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
<item row="0" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Width</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
<widget class="QDoubleSpinBox" name="selectorWidth">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="toolTip">
<string>The width of the 3D view
manipulator tool handles</string>
@@ -104,22 +248,14 @@ manipulator tool handles</string>
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Width</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Length</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
+ <item row="0" column="4">
<widget class="QDoubleSpinBox" name="selectorLength">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="toolTip">
<string>The length of the 3D view
manipulator tool handles</string>
@@ -135,6 +271,19 @@ manipulator tool handles</string>
</property>
</widget>
</item>
+ <item row="0" column="0">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
@@ -151,18 +300,26 @@ manipulator tool handles</string>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="2">
<widget class="QLabel" name="intervalLabel">
<property name="text">
<string>Interval (seconds)</string>
</property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
</widget>
</item>
- <item row="0" column="2">
+ <item row="0" column="3">
<widget class="QSpinBox" name="autosaveInterval">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="toolTip">
- <string>The length of the 3D view
-manipulator tool handles.</string>
+ <string>The amount of time between autosaving.</string>
</property>
<property name="minimum">
<number>30</number>
@@ -178,7 +335,33 @@ manipulator tool handles.</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="0" column="1">
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <spacer name="horizontalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="2" colspan="2">
<widget class="QPushButton" name="clearAutosaveFiles">
<property name="toolTip">
<string>Clear all autosave files from project folder</string>
@@ -234,6 +417,16 @@ palette positions and visibilities</string>
</widget>
</item>
<item>
+ <widget class="QPushButton" name="m_buttonResetPopupWarnings">
+ <property name="toolTip">
+ <string>Click to clear &quot;Do not Show Again&quot; selections in all pop-ups.</string>
+ </property>
+ <property name="text">
+ <string>Reset Pop-up Warnings</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/Authoring/Qt3DStudio/UI/StudioPreferencesPropSheet.cpp b/src/Authoring/Qt3DStudio/UI/StudioPreferencesPropSheet.cpp
index 4510a9c2..027fe95e 100644
--- a/src/Authoring/Qt3DStudio/UI/StudioPreferencesPropSheet.cpp
+++ b/src/Authoring/Qt3DStudio/UI/StudioPreferencesPropSheet.cpp
@@ -99,7 +99,7 @@ void CStudioPreferencesPropSheet::onInitDialog()
m_ui->setupUi(this);
m_ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
- m_Font = QFont(CStudioPreferences::GetFontFaceName(), 8);
+ m_Font = QFont(CStudioPreferences::fontFaceName(), 8);
setFont(m_Font);
connect(m_ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
diff --git a/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.cpp b/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.cpp
index 36e344c3..030d1dac 100644
--- a/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.cpp
+++ b/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.cpp
@@ -32,10 +32,10 @@
#include "StudioProjectSettingsPage.h"
#include "StudioProjectSettings.h"
#include "StudioApp.h"
+#include "IDocumentBufferCache.h"
#include "Doc.h"
#include "Views.h"
#include "MainFrm.h"
-#include "CommonConstants.h"
#include "StudioPreferences.h"
#include "Core.h"
@@ -44,7 +44,7 @@ CStudioProjectSettingsPage::CStudioProjectSettingsPage(QWidget *parent)
, m_aspectRatio(0.0)
, m_ui(new Ui::StudioProjectSettingsPage)
{
- m_font = QFont(CStudioPreferences::GetFontFaceName());
+ m_font = QFont(CStudioPreferences::fontFaceName());
m_font.setPixelSize(CStudioPreferences::fontSize());
// Create a bold font for the group box text
@@ -101,6 +101,7 @@ void CStudioProjectSettingsPage::onInitDialog()
connect(m_ui->m_checkConstrainProportions, &QCheckBox::clicked,
this, &CStudioProjectSettingsPage::onCheckMaintainRatio);
connect(m_ui->m_checkUseKtx, &QCheckBox::clicked, [=](){ this->setModified(true); });
+ connect(m_ui->m_checkFlipTex, &QCheckBox::clicked, [=](){ this->setModified(true); });
connect(m_ui->m_Author, &QLineEdit::textEdited, [=](){ this->setModified(true); });
connect(m_ui->m_Company, &QLineEdit::textEdited, [=](){ this->setModified(true); });
}
@@ -131,6 +132,9 @@ void CStudioProjectSettingsPage::loadSettings()
// Prefer compressed textures
m_ui->m_checkUseKtx->setChecked(theProjectSettings->getPreferCompressedTextures());
+ // Automatically flip compressed textures
+ m_ui->m_checkFlipTex->setChecked(theProjectSettings->getFlipCompressedTextures());
+
// Author
m_ui->m_Author->setText(theProjectSettings->getAuthor());
@@ -170,6 +174,12 @@ void CStudioProjectSettingsPage::saveSettings()
// Prefer compressed textures
theProjectSettings->setPreferCompressedTextures(m_ui->m_checkUseKtx->isChecked());
+
+ // Automatically flip compressed textures. Trigger reloading if flip status changed.
+ bool updatedFlipTextures = m_ui->m_checkFlipTex->isChecked();
+ if (theProjectSettings->getFlipCompressedTextures() != updatedFlipTextures)
+ g_StudioApp.GetCore()->GetDoc()->GetBufferCache().reloadAll(updatedFlipTextures);
+ theProjectSettings->setFlipCompressedTextures(updatedFlipTextures);
}
// OnApply: Handler for the Apply button
diff --git a/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.ui b/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.ui
index 3ef4ccd2..e6c3d767 100644
--- a/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.ui
+++ b/src/Authoring/Qt3DStudio/UI/StudioProjectSettingsPage.ui
@@ -86,6 +86,16 @@ when ktx textures are present.</string>
</property>
</widget>
</item>
+ <item row="5" column="0">
+ <widget class="QCheckBox" name="m_checkFlipTex">
+ <property name="toolTip">
+ <string>Flip the y coordinate of compressed textures</string>
+ </property>
+ <property name="text">
+ <string>Flip compressed textures</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/Authoring/Qt3DStudio/Workspace/Dialogs.cpp b/src/Authoring/Qt3DStudio/Workspace/Dialogs.cpp
index 2a5a6780..93dc220c 100644
--- a/src/Authoring/Qt3DStudio/Workspace/Dialogs.cpp
+++ b/src/Authoring/Qt3DStudio/Workspace/Dialogs.cpp
@@ -78,11 +78,11 @@ struct SAllowedTypesEntry
};
const char *imgExts[] = {
- "png", "jpg", "jpeg", "dds", "bmp", "gif", "hdr", "ktx", nullptr,
+ "png", "jpg", "jpeg", "dds", "bmp", "gif", "hdr", "ktx", "astc", nullptr,
};
const wchar_t *wideImgExts[] = {
- L"png", L"jpg", L"jpeg", L"dds", L"bmp", L"gif", L"hdr", L"ktx", nullptr,
+ L"png", L"jpg", L"jpeg", L"dds", L"bmp", L"gif", L"hdr", L"ktx", L"astc", nullptr,
};
const char *modelExts[] = {
@@ -148,6 +148,10 @@ const char *materialExts[] = {
"material", "shader", "materialdef", nullptr,
};
+const char *shaderExts[] = {
+ "material", "shader", nullptr,
+};
+
const wchar_t *wideMaterialExts[] = {
L"material", L"shader", L"materialdef", nullptr,
};
@@ -229,27 +233,21 @@ CDialogs::~CDialogs()
*
* @param ioEaseIn value to be set as the ease in default - passes back the value chosen by the user
* @param ioEaseOut value to be set as the ease out default - passes back the value chosen by the
- * user
* @return true if the user clicked OK on the dialog (indicating that the values should be updated
* on the track)
*/
-bool CDialogs::PromptForKeyframeInterpolation(float &ioEaseIn, float &ioEaseOut)
+bool CDialogs::displayKeyframeInterpolation(float &ioEaseIn, float &ioEaseOut)
{
- bool theReturnValue = false;
-
- CInterpolationDlg theInterpolationDialog;
- theInterpolationDialog.setEaseIn(ioEaseIn);
- theInterpolationDialog.setEaseOut(ioEaseOut);
+ CInterpolationDlg interpolationDialog(ioEaseIn, ioEaseOut);
- // If the user presses the OK button
- if (theInterpolationDialog.exec() == QDialog::Accepted) {
+ if (interpolationDialog.exec() == QDialog::Accepted) {
// Retrieve the new interpolation values
- ioEaseIn = theInterpolationDialog.easeIn();
- ioEaseOut = theInterpolationDialog.easeOut();
- theReturnValue = true;
+ ioEaseIn = interpolationDialog.easeIn();
+ ioEaseOut = interpolationDialog.easeOut();
+ return true;
}
- return theReturnValue;
+ return false;
}
/**
@@ -366,9 +364,11 @@ void CDialogs::DisplayImportFailed(const QUrl &inURL, const QString &inDescripti
theMsgText += QStringLiteral("\n%1\n\n").arg(inURL.toDisplayString()) + theText;
// Display the failed import resource message.
- if (m_ShowGUI) {
- Qt3DSMessageBox::Show(theTitle, theMsgText, Qt3DSMessageBox::ICON_WARNING, false,
- g_StudioApp.m_pMainWnd);
+ if (m_ShowGUI && !CStudioPreferences::doNotShowImportWarnings()) {
+ bool doNotShowAgain = false;
+ Qt3DSMessageBox::Show(theTitle, theMsgText, Qt3DSMessageBox::ICON_WARNING, doNotShowAgain,
+ false, true, g_StudioApp.m_pMainWnd);
+ CStudioPreferences::setDoNotShowImportWarnings(doNotShowAgain);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theMsgText;
}
@@ -447,6 +447,16 @@ bool CDialogs::DisplayUndefinedDatainputDlg(
QString CDialogs::ConfirmRefreshModelFile(const QString &inFile)
{
+ QString prompt = QObject::tr("Refreshing an import is not undoable and resets the undo stack.\n"
+ "Are you sure you want to refresh '%1'?")
+ .arg(QFileInfo(inFile).fileName());
+
+ int choice = QMessageBox::warning(nullptr, QObject::tr("Refresh import"),
+ prompt, QMessageBox::Yes | QMessageBox::Cancel);
+
+ if (choice == QMessageBox::Cancel)
+ return {};
+
// this produces an extension string which contains all allowed formats specified in
// g_AllowedImportTypes
// currently DAE and FBX
@@ -1444,7 +1454,7 @@ void CDialogs::DisplayGLVersionDialog(const Q3DStudio::CString &inGLVersion,
theGLVersionDlg.exec();
if (theGLVersionDlg.GetDontShowAgain())
- CStudioPreferences::SetDontShowGLVersionDialog(true);
+ CStudioPreferences::setDontShowGLVersionDialog(true);
}
QStringList CDialogs::effectExtensions()
@@ -1495,6 +1505,18 @@ QStringList CDialogs::materialExtensions()
return exts;
}
+QStringList CDialogs::shaderExtensions()
+{
+ static QStringList exts;
+ if (exts.isEmpty()) {
+ for (const char *ext : shaderExts) {
+ if (ext)
+ exts << QString::fromLatin1(ext);
+ }
+ }
+ return exts;
+}
+
QStringList CDialogs::modelExtensions()
{
static QStringList exts;
diff --git a/src/Authoring/Qt3DStudio/Workspace/Dialogs.h b/src/Authoring/Qt3DStudio/Workspace/Dialogs.h
index 02f0b8d3..4d702ddf 100644
--- a/src/Authoring/Qt3DStudio/Workspace/Dialogs.h
+++ b/src/Authoring/Qt3DStudio/Workspace/Dialogs.h
@@ -68,6 +68,7 @@ public:
static QStringList fontExtensions();
static QStringList mapExtensions();
static QStringList materialExtensions();
+ static QStringList shaderExtensions();
static QStringList modelExtensions();
static QStringList behaviorExtensions();
static QStringList presentationExtensions();
@@ -145,7 +146,7 @@ public:
QColor displayColorDialog(const QColor &color, bool showAlpha = false) const;
ESavePromptResult PromptForSave();
- bool PromptForKeyframeInterpolation(float &ioEaseIn, float &ioEaseOut);
+ bool displayKeyframeInterpolation(float &ioEaseIn, float &ioEaseOut);
bool ConfirmRevert();
diff --git a/src/Authoring/Qt3DStudio/images.qrc b/src/Authoring/Qt3DStudio/images.qrc
index f97f0c63..9dfdee3b 100644
--- a/src/Authoring/Qt3DStudio/images.qrc
+++ b/src/Authoring/Qt3DStudio/images.qrc
@@ -319,6 +319,24 @@
<file>images/filter-disabled@2x.png</file>
<file>images/filter-colored.png</file>
<file>images/filter-colored@2x.png</file>
+ <file>images/helper_grid.png</file>
+ <file>images/helper_grid@2x.png</file>
+ <file>images/helper_grid_disabled.png</file>
+ <file>images/helper_grid_disabled@2x.png</file>
+ <file>images/maximize.png</file>
+ <file>images/maximize@2x.png</file>
+ <file>images/maximize_disabled.png</file>
+ <file>images/maximize_disabled@2x.png</file>
+ <file>images/gradient.png</file>
+ <file>images/gradient@2x.png</file>
+ <file>images/gradient_disabled.png</file>
+ <file>images/gradient_disabled@2x.png</file>
+ <file>images/Asset-Signal-Normal.png</file>
+ <file>images/Asset-Signal-Normal@2x.png</file>
+ <file>images/Objects-Signal-Normal.png</file>
+ <file>images/Objects-Signal-Normal@2x.png</file>
+ <file>images/Objects-Signal-Disabled.png</file>
+ <file>images/Objects-Signal-Disabled@2x.png</file>
</qresource>
<qresource prefix="/startup">
<file alias="open_dialog.png">images/open_dialog.png</file>
diff --git a/src/Authoring/Qt3DStudio/images/Asset-Signal-Normal.png b/src/Authoring/Qt3DStudio/images/Asset-Signal-Normal.png
new file mode 100644
index 00000000..dda0e2c3
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/Asset-Signal-Normal.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/Asset-Signal-Normal@2x.png b/src/Authoring/Qt3DStudio/images/Asset-Signal-Normal@2x.png
new file mode 100644
index 00000000..04f34fd1
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/Asset-Signal-Normal@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled.png b/src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled.png
new file mode 100644
index 00000000..e1301aa4
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled@2x.png b/src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled@2x.png
new file mode 100644
index 00000000..905e23a1
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/Objects-Signal-Disabled@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/Objects-Signal-Normal.png b/src/Authoring/Qt3DStudio/images/Objects-Signal-Normal.png
new file mode 100644
index 00000000..2463c2f1
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/Objects-Signal-Normal.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/Objects-Signal-Normal@2x.png b/src/Authoring/Qt3DStudio/images/Objects-Signal-Normal@2x.png
new file mode 100644
index 00000000..50932af4
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/Objects-Signal-Normal@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/gradient.png b/src/Authoring/Qt3DStudio/images/gradient.png
new file mode 100644
index 00000000..dda23252
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/gradient.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/gradient@2x.png b/src/Authoring/Qt3DStudio/images/gradient@2x.png
new file mode 100644
index 00000000..f0854021
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/gradient@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/gradient_disabled.png b/src/Authoring/Qt3DStudio/images/gradient_disabled.png
new file mode 100644
index 00000000..4313fa74
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/gradient_disabled.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/gradient_disabled@2x.png b/src/Authoring/Qt3DStudio/images/gradient_disabled@2x.png
new file mode 100644
index 00000000..76ac98b6
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/gradient_disabled@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/helper_grid.png b/src/Authoring/Qt3DStudio/images/helper_grid.png
new file mode 100644
index 00000000..60664b0d
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/helper_grid.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/helper_grid@2x.png b/src/Authoring/Qt3DStudio/images/helper_grid@2x.png
new file mode 100644
index 00000000..973c2e31
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/helper_grid@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/helper_grid_disabled.png b/src/Authoring/Qt3DStudio/images/helper_grid_disabled.png
new file mode 100644
index 00000000..33219d95
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/helper_grid_disabled.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/helper_grid_disabled@2x.png b/src/Authoring/Qt3DStudio/images/helper_grid_disabled@2x.png
new file mode 100644
index 00000000..9454f68c
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/helper_grid_disabled@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/maximize.png b/src/Authoring/Qt3DStudio/images/maximize.png
new file mode 100644
index 00000000..a5f63b03
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/maximize.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/maximize@2x.png b/src/Authoring/Qt3DStudio/images/maximize@2x.png
new file mode 100644
index 00000000..f5137285
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/maximize@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/maximize_disabled.png b/src/Authoring/Qt3DStudio/images/maximize_disabled.png
new file mode 100644
index 00000000..bc820172
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/maximize_disabled.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/images/maximize_disabled@2x.png b/src/Authoring/Qt3DStudio/images/maximize_disabled@2x.png
new file mode 100644
index 00000000..83db6756
--- /dev/null
+++ b/src/Authoring/Qt3DStudio/images/maximize_disabled@2x.png
Binary files differ
diff --git a/src/Authoring/Qt3DStudio/qml.qrc b/src/Authoring/Qt3DStudio/qml.qrc
index 09d5451f..2ab117aa 100644
--- a/src/Authoring/Qt3DStudio/qml.qrc
+++ b/src/Authoring/Qt3DStudio/qml.qrc
@@ -43,5 +43,7 @@
<file>Palettes/Action/HandlerGenericFloat.qml</file>
<file>Palettes/Inspector/MaterialDropDown.qml</file>
<file>Application/FilterVariantsDlg.qml</file>
+ <file>Palettes/Action/HandlerPropertyXYZW.qml</file>
+ <file>Palettes/Action/HandlerPropertyBaseXYZW.qml</file>
</qresource>
</RCC>
diff --git a/src/Authoring/Qt3DStudio/remotedeploymentsender.cpp b/src/Authoring/Qt3DStudio/remotedeploymentsender.cpp
index 5c66c682..342d1139 100644
--- a/src/Authoring/Qt3DStudio/remotedeploymentsender.cpp
+++ b/src/Authoring/Qt3DStudio/remotedeploymentsender.cpp
@@ -30,13 +30,13 @@
#include "remotedeploymentsender.h"
#include "StudioApp.h"
#include "Core.h"
+#include "StudioPreferences.h"
#include <QtCore/qpair.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdatastream.h>
#include <QtCore/qdiriterator.h>
-#include <QtCore/qsettings.h>
#include <QtWidgets/qinputdialog.h>
#include <QtWidgets/qmessagebox.h>
#include <QtWidgets/qdialog.h>
@@ -61,10 +61,8 @@ private:
ConnectionDialog::ConnectionDialog(QWidget *parent)
: QDialog(parent)
{
- QSettings settings;
- QString previousIPAddress = settings.value(QStringLiteral("lastRemoteDeploymentIP")).toString();
- QString previousPort = settings.value(QStringLiteral("lastRemoteDeploymentPort"),
- QStringLiteral("36000")).toString();
+ QString previousIPAddress = CStudioPreferences::remoteDeploymentIP();
+ QString previousPort = CStudioPreferences::remoteDeploymentPort();
m_hostLineEdit = new QLineEdit(this);
m_hostLineEdit->setText(previousIPAddress);
@@ -99,9 +97,8 @@ QPair<QString, int> ConnectionDialog::getInfo(QWidget *parent)
if (!dialog.exec())
return QPair<QString, int>();
- QSettings settings;
- settings.setValue(QStringLiteral("lastRemoteDeploymentIP"), dialog.m_hostLineEdit->text());
- settings.setValue(QStringLiteral("lastRemoteDeploymentPort"), dialog.m_portLineEdit->text());
+ CStudioPreferences::setRemoteDeploymentIP(dialog.m_hostLineEdit->text());
+ CStudioPreferences::setRemoteDeploymentPort(dialog.m_portLineEdit->text());
return qMakePair(dialog.m_hostLineEdit->text(),
dialog.m_portLineEdit->text().toInt());
diff --git a/src/Runtime/Runtime.pro b/src/Runtime/Runtime.pro
index eba449a2..8b07be9d 100644
--- a/src/Runtime/Runtime.pro
+++ b/src/Runtime/Runtime.pro
@@ -1,7 +1,6 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS += \
- ogl-runtime \
+SUBDIRS += ogl-runtime
# HACK to ensure syncqt is run for ogl-runtime if one is run for studio
# This is necessary because CI doesn't create dummy .git directories for submodules
@@ -13,20 +12,3 @@ if(!build_pass|!debug_and_release) {
$$system("$$MAKE_DIR_CMD")
}
}
-
-
-# Qt3D based runtime needs Qt 5.11 or later
-greaterThan(QT_MAJOR_VERSION, 5)|greaterThan(QT_MINOR_VERSION, 10) {
- SUBDIRS += qt3d-runtime
-
- # HACK to ensure syncqt is run for qt3d-runtime if one is run for studio
- # This is necessary because CI doesn't create dummy .git directories for submodules
- if(!build_pass|!debug_and_release) {
- # Pro file existence is checked to ensure we don't create dummy .git in empty submodule dir,
- # which happens when studio is cloned without --recursive option
- exists($$PWD/../../.git):!exists($$PWD/qt3d-runtime/.git):exists($$PWD/qt3d-runtime/qt3d-runtime.pro) {
- MAKE_DIR_CMD = $$sprintf($$QMAKE_MKDIR_CMD, $$shell_quote($$shell_path($$PWD/qt3d-runtime/.git)))
- $$system("$$MAKE_DIR_CMD")
- }
- }
-}
diff --git a/src/Runtime/ogl-runtime b/src/Runtime/ogl-runtime
-Subproject 2025912174c4cf99270b7439ec3b021e1d089ae
+Subproject 427fddb50d43aa21a90fc7356ee3cdd8a908df5
diff --git a/src/Runtime/qt3d-runtime b/src/Runtime/qt3d-runtime
deleted file mode 160000
-Subproject bd083f50691e35ac0ab572ebc92fe15dae2f298
diff --git a/src/commonplatform.pri b/src/commonplatform.pri
index 8c56d99d..6ee5eb6d 100644
--- a/src/commonplatform.pri
+++ b/src/commonplatform.pri
@@ -266,7 +266,7 @@ android {
}
win32 {
- DEFINES += QT3DS_OS_WINDOWS _WIN32 _PCPLATFORM \
+ DEFINES += QT3DS_OS_WINDOWS _PCPLATFORM \
WIDE_IS_DIFFERENT_TYPE_THAN_CHAR16_T KDWIN NOMINMAX
win32-msvc {
@@ -291,20 +291,20 @@ win32 {
contains(QT_ARCH, x86_64) {
DEFINES += _WIN64
+ } else {
+ DEFINES += _WIN32
}
}
BINDIR = $$MODULE_BASE_OUTDIR/bin
LIBDIR = $$MODULE_BASE_OUTDIR/lib
-!qtConfig(private_tests): {
- # Non-developer build
+
+exists($$MODULE_BASE_OUTDIR/src/Runtime/ogl-runtime/bin) {
RUNTIME_BINDIR = $$MODULE_BASE_OUTDIR/src/Runtime/ogl-runtime/bin
RUNTIME_LIBDIR = $$MODULE_BASE_OUTDIR/src/Runtime/ogl-runtime/lib
RUNTIME_INCLUDEDIR = $$MODULE_BASE_OUTDIR/src/Runtime/ogl-runtime/include
LIBS += -L"$$RUNTIME_LIBDIR"
-
} else {
- # Developer build
RUNTIME_BINDIR = $$BINDIR
RUNTIME_LIBDIR = $$LIBDIR
RUNTIME_INCLUDEDIR = $$MODULE_BASE_OUTDIR/include
diff --git a/src/shared/shared.pro b/src/shared/shared.pro
index eba654e5..1dece294 100644
--- a/src/shared/shared.pro
+++ b/src/shared/shared.pro
@@ -1,6 +1,8 @@
TEMPLATE = subdirs
-exists ($$(BREAKPAD_SOURCE_DIR)) {
+BREAKPAD_SOURCE_DIR = $$(BREAKPAD_SOURCE_DIR)
+
+!isEmpty(BREAKPAD_SOURCE_DIR):exists($$BREAKPAD_SOURCE_DIR) {
CONFIG += ordered
SUBDIRS += qt-breakpad
}
diff --git a/src/src.pro b/src/src.pro
index 279d386f..81532f12 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -2,7 +2,7 @@ TEMPLATE = subdirs
CONFIG += ordered
# When building the desktop authoring tool, skip embedded/mobile targets
-!cross_compile:!qnx:!mingw:!android:!ios:!integrity {
+!cross_compile:!qnx:!android:!ios:!integrity {
SUBDIRS += \
Runtime \
3rdparty \
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
deleted file mode 100644
index 61f50fd5..00000000
--- a/tests/auto/auto.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = subdirs
-CONFIG += ordered
-
-!macos:!win32: SUBDIRS += \
- qtextras
-
-# TODO: Re-enable these tests after fixing them
-# runtime \
-# viewer \
-# studio3d
diff --git a/tests/auto/qtextras/qt3dsqmlstream/qt3dsqmlstream.pro b/tests/auto/qtextras/qt3dsqmlstream/qt3dsqmlstream.pro
deleted file mode 100644
index 1ca4f737..00000000
--- a/tests/auto/qtextras/qt3dsqmlstream/qt3dsqmlstream.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = app
-CONFIG += testcase
-include($$PWD/../../../../src/commonplatform.pri)
-
-TARGET = tst_qt3dsqmlstream
-
-QT += testlib quick
-
-SOURCES += tst_qt3dsqmlstream.cpp
-
-INCLUDEPATH += \
- $$PWD/../../../../src/Runtime/ogl-runtime/src/qmlstreamer
-
-LIBS += \
- -lqt3dsqmlstreamer$$qtPlatformTargetSuffix()
-
-ANDROID_EXTRA_LIBS = \
- libqt3dsqmlstreamer.so
diff --git a/tests/auto/qtextras/qt3dsqmlstream/tst_qt3dsqmlstream.cpp b/tests/auto/qtextras/qt3dsqmlstream/tst_qt3dsqmlstream.cpp
deleted file mode 100644
index 71de525f..00000000
--- a/tests/auto/qtextras/qt3dsqmlstream/tst_qt3dsqmlstream.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QSignalSpy>
-#include <q3dsqmlstream.h>
-#include <QQuickItem>
-
-class tst_Qt3DSQmlStream : public QObject
-{
- Q_OBJECT
-public:
- tst_Qt3DSQmlStream()
- {
- qRegisterMetaType<QQuickItem*>();
- }
- ~tst_Qt3DSQmlStream() {}
-private slots:
-
- void checkInitialState()
- {
- // GIVEN
- Q3DSQmlStream qmlstream;
-
- // THEN
- QVERIFY(qmlstream.presentationId().isNull());
- QVERIFY(qmlstream.item() == nullptr);
- }
-
- void testSetPresentationId()
- {
- // GIVEN
- Q3DSQmlStream qmlstream;
- QString pid = "presentation0";
- QSignalSpy spy(&qmlstream, SIGNAL(presentationIdChanged(const QString&)));
-
- // WHEN
- qmlstream.setPresentationId(pid);
-
- // THEN
- QVERIFY(spy.isValid());
- QCOMPARE(qmlstream.presentationId(), pid);
- QCOMPARE(spy.count(), 1);
-
- // WHEN
- spy.clear();
- qmlstream.setPresentationId(pid);
-
- // THEN
- QVERIFY(spy.isValid());
- QCOMPARE(spy.count(), 0);
- }
-
- void testSetItem()
- {
- // GIVEN
- Q3DSQmlStream qmlstream;
- QScopedPointer<QQuickItem> item(new QQuickItem());
- QSignalSpy spy(&qmlstream, SIGNAL(itemChanged(QQuickItem *)));
-
- // WHEN
- qmlstream.setItem(item.data());
-
- // THEN
- QVERIFY(spy.isValid());
- QCOMPARE(qmlstream.item(), item.data());
- QCOMPARE(spy.count(), 1);
-
- // WHEN
- spy.clear();
- qmlstream.setItem(item.data());
-
- // THEN
- QVERIFY(spy.isValid());
- QCOMPARE(spy.count(), 0);
- }
-};
-
-QTEST_APPLESS_MAIN(tst_Qt3DSQmlStream)
-
-#include "tst_qt3dsqmlstream.moc"
diff --git a/tests/auto/qtextras/qtextras.pro b/tests/auto/qtextras/qtextras.pro
deleted file mode 100644
index 16a1ed80..00000000
--- a/tests/auto/qtextras/qtextras.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += \
- qt3dsqmlstream
diff --git a/tests/auto/runtime/Qt3DSRenderTestBase.cpp b/tests/auto/runtime/Qt3DSRenderTestBase.cpp
deleted file mode 100644
index f4ab0793..00000000
--- a/tests/auto/runtime/Qt3DSRenderTestBase.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestBase.h"
-
-#include "Qt3DSDMPrefix.h"
-#include "EASTL/allocator.h"
-
-namespace eastl
-{
-void AssertionFailure(const char* pExpression)
-{
- Q_UNUSED(pExpression);
-}
-EmptyString gEmptyString;
-void* gpEmptyBucketArray[2] = { nullptr, (void*)uintptr_t(~0) };
-}
-
-namespace qt3ds {
-
-void Qt3DSAssert(const char *exp, const char *file, int line, bool *ignore)
-{
- Q_UNUSED(ignore)
- qFatal("Assertion thrown %s(%d): %s", file, line, exp);
-}
-
-namespace render {
-SEndlType Endl;
-}
-}
-
-void *operator new[](size_t size, const char *, int, unsigned, const char *, int)
-{
- return malloc(size);
-}
-
-void *operator new[](size_t size, size_t, size_t, const char *, int, unsigned, const char *, int)
-{
- return malloc(size);
-}
-
-using namespace qt3ds::render;
-
-namespace qt3ds {
-namespace render {
-
-NVRenderTestBase::~NVRenderTestBase()
-{
- delete m_renderImpl;
-}
-
-bool NVRenderTestBase::initializeQt3DSRenderer(QSurfaceFormat format)
-{
- m_coreFactory = qt3ds::render::IQt3DSRenderFactoryCore::CreateRenderFactoryCore("", m_windowSystem,
- m_timeProvider);
- m_factory = m_coreFactory->CreateRenderFactory(format, false);
- m_rc = m_factory->GetQt3DSRenderContext();
- m_renderImpl = new qt3ds::render::Qt3DSRendererImpl(*m_rc);
-
- return true;
-}
-
-Qt3DSRendererImpl *NVRenderTestBase::qt3dsRenderer()
-{
- return m_renderImpl;
-}
-
-Q3DStudio::IRuntimeMetaData *NVRenderTestBase::metadata()
-{
- if (m_metaData.mPtr == NULL)
- m_metaData = &Q3DStudio::IRuntimeMetaData::Create(m_coreFactory->GetInputStreamFactory());
- return m_metaData.mPtr;
-}
-
-}
-}
diff --git a/tests/auto/runtime/Qt3DSRenderTestBase.h b/tests/auto/runtime/Qt3DSRenderTestBase.h
deleted file mode 100644
index bde0948f..00000000
--- a/tests/auto/runtime/Qt3DSRenderTestBase.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_BASE_H
-#define QT3DS_RENDER_TEST_BASE_H
-#include "foundation/Qt3DS.h"
-#include "foundation/Qt3DSAssert.h"
-#include "foundation/Qt3DSFoundation.h"
-#include "foundation/Qt3DSBroadcastingAllocator.h"
-#include "render/Qt3DSRenderBaseTypes.h"
-#include "render/Qt3DSRenderContext.h"
-#include "Qt3DSWindowSystem.h"
-#include "Qt3DSTypes.h"
-#include "Qt3DSTimer.h"
-#include "Qt3DSRenderRuntimeBinding.h"
-#include "Qt3DSRenderRuntimeBindingImpl.h"
-#include "Qt3DSRenderContextCore.h"
-#include "rendererimpl/Qt3DSRendererImpl.h"
-#include "Qt3DSMetadata.h"
-
-namespace qt3ds {
-namespace render {
-class IQt3DSRenderer;
-class Qt3DSRendererImpl;
-class IQt3DSRenderFactoryCore;
-class IQt3DSRenderFactory;
-}
-}
-
-namespace qt3ds {
-namespace render {
-
- class IQt3DSRenderFactoryCore;
- class IQt3DSRenderFactory;
- class Qt3DSRenderer;
-
- typedef struct SUSER_CONTEXT_DATA
- {
- unsigned int winWidth;
- unsigned int winHeight;
- } userContextData;
-
- struct SNullTimeProvider : public Q3DStudio::ITimeProvider
- {
- virtual Q3DStudio::INT64 GetCurrentTimeMicroSeconds() { return 0; }
- };
-
- struct SNullWindowSystem : public Q3DStudio::IWindowSystem
- {
- virtual QSize GetWindowDimensions() { return QSize(); }
-
- virtual void SetWindowDimensions(const QSize &) {}
- // For platforms that support it, we get the egl info for render plugins
- // Feel free to return NULL.
- virtual Q3DStudio::SEGLInfo *GetEGLInfo() { return NULL; }
-
- // on some systems we allow our default render target to be a offscreen buffer
- // otherwise return 0;
- virtual int GetDefaultRenderTargetID() { return 0; }
- // returns the depth buffer bit count for the render window
- // does not really matter here
- virtual int GetDepthBitCount() { return 16; }
- };
-
- /// this is the base class for all tests
- class NVRenderTestBase
- {
- public:
- /// constructor
- NVRenderTestBase(){}
- /// destructor
- virtual ~NVRenderTestBase();
-
- /// Checks if this test is supported
- ///
- /// @return true if supported
- virtual bool isSupported(NVRenderContext *context) = 0;
-
- /// This runs the test
- ///
- /// @param context (in) Pointer to a NVRenderContext context
- /// @param pUserData (in) Pointer to pUserData
- ///
- /// @return false if failed
- virtual bool run(NVRenderContext *context, userContextData *pUserData) = 0;
-
- /// This cleans up state after the test if needed
- ///
- /// @param context (in) Pointer to a NVRenderContext context
- /// @param pUserData (in) Pointer to pUserData
- ///
- /// @return false if failed
- virtual void cleanup(NVRenderContext *context, userContextData *pUserData) = 0;
-
- /// This runs the performance test
- ///
- /// @param context (in) Pointer to a NVRenderContext context
- /// @param pUserData (in) Pointer to pUserData
- ///
- /// @return false if failed
- virtual bool runPerformance(NVRenderContext *context, userContextData *pContextData) = 0;
-
- /// This is a query to determine if we run on a ES context
- ///
- /// @param context (in) Pointer to a NVRenderContext context
- ///
- /// @return false if failed
- virtual const bool isGLESContext(NVRenderContext *context)
- {
- NVRenderContextType ctxType = context->GetRenderContextType();
-
- // Need minimum of GL3 or GLES3
- if (ctxType == NVRenderContextValues::GLES2 || ctxType == NVRenderContextValues::GLES3
- || ctxType == NVRenderContextValues::GLES3PLUS) {
- return true;
- }
-
- return false;
- }
-
- bool initializeQt3DSRenderer(QSurfaceFormat format);
- qt3ds::render::Qt3DSRendererImpl *qt3dsRenderer();
- Q3DStudio::IRuntimeMetaData *metadata();
-
- private:
-
- NVScopedRefCounted<qt3ds::render::IQt3DSRenderFactoryCore> m_coreFactory;
- NVScopedRefCounted<qt3ds::render::IQt3DSRenderFactory> m_factory;
- NVScopedRefCounted<qt3ds::render::IQt3DSRenderContext> m_rc;
- qt3ds::foundation::NVScopedReleasable<Q3DStudio::IRuntimeMetaData> m_metaData;
- qt3ds::render::Qt3DSRendererImpl *m_renderImpl;
-
- SNullTimeProvider m_timeProvider;
- SNullWindowSystem m_windowSystem;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_BASE_H
diff --git a/tests/auto/runtime/Qt3DSRenderTestMathUtil.cpp b/tests/auto/runtime/Qt3DSRenderTestMathUtil.cpp
deleted file mode 100644
index f216faa2..00000000
--- a/tests/auto/runtime/Qt3DSRenderTestMathUtil.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestMathUtil.h"
-#include <math.h>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-#define QT3DS_RENDER_TEST_PI 3.14159265358979323846f
-
-inline float degreeToRad(float degree)
-{
- return (degree * QT3DS_RENDER_TEST_PI) / 180.0f;
-}
-
-void qt3ds::render::NvRenderTestMatrixFrustum(QT3DSMat44 *m, float l, float r, float b, float t, float n,
- float f)
-{
- float rightMinusLeftInv, topMinusBottomInv, farMinusNearInv, twoNear;
-
- rightMinusLeftInv = 1.0f / (r - l);
- topMinusBottomInv = 1.0f / (t - b);
- farMinusNearInv = 1.0f / (f - n);
- twoNear = 2.0f * n;
-
- m->column0 = QT3DSVec4(twoNear * rightMinusLeftInv, 0, 0, 0);
- m->column1 = QT3DSVec4(0, twoNear * topMinusBottomInv, 0, 0);
- m->column2 = QT3DSVec4((r + l) * rightMinusLeftInv, (t + b) * topMinusBottomInv,
- -(f + n) * farMinusNearInv, -1.0f);
- m->column3 = QT3DSVec4(0, 0, -(twoNear * f) * farMinusNearInv, 0.0f);
-}
-
-void qt3ds::render::NvGl2DemoMatrixOrtho(QT3DSMat44 *m, float l, float r, float b, float t, float n,
- float f)
-{
- float rightMinusLeftInv, topMinusBottomInv, farMinusNearInv;
-
- rightMinusLeftInv = 1.0f / (r - l);
- topMinusBottomInv = 1.0f / (t - b);
- farMinusNearInv = 1.0f / (f - n);
-
- m->column0 = QT3DSVec4(2.0f * rightMinusLeftInv, 0, 0, 0);
- m->column1 = QT3DSVec4(0, 2.0f * topMinusBottomInv, 0, 0);
- m->column2 = QT3DSVec4(0, 0, -2.0f * farMinusNearInv, 0);
- m->column3 = QT3DSVec4(-(r + l) * rightMinusLeftInv, -(t + b) * topMinusBottomInv,
- -(f + n) * farMinusNearInv, 1.0f);
-}
-
-void qt3ds::render::NvRenderTestMatrixRotX(QT3DSMat44 *m, float angle)
-{
- float rad = degreeToRad(angle);
- float cosPhi = cos(rad);
- float sinPhi = sin(rad);
-
- m->column0 = QT3DSVec4(1.0, 0.0, 0.0, 0.0);
- m->column1 = QT3DSVec4(0.0, cosPhi, -sinPhi, 0.0);
- m->column2 = QT3DSVec4(0.0, sinPhi, cosPhi, 0.0);
- m->column3 = QT3DSVec4(0.0, 0.0, 0.0, 1.0);
-}
-
-void qt3ds::render::NvRenderTestMatrixRotY(QT3DSMat44 *m, float angle)
-{
- float rad = degreeToRad(angle);
- float cosPhi = cos(rad);
- float sinPhi = sin(rad);
-
- m->column0 = QT3DSVec4(cosPhi, 0.0, sinPhi, 0.0);
- m->column1 = QT3DSVec4(0.0, 1.0, 0.0, 0.0);
- m->column2 = QT3DSVec4(-sinPhi, 0.0, cosPhi, 0.0);
- m->column3 = QT3DSVec4(0.0, 0.0, 0.0, 1.0);
-}
-
-void qt3ds::render::NvRenderTestMatrixRotZ(QT3DSMat44 *m, float angle)
-{
- float rad = degreeToRad(angle);
- float cosPhi = cos(rad);
- float sinPhi = sin(rad);
-
- m->column0 = QT3DSVec4(cosPhi, -sinPhi, 0.0, 0.0);
- m->column1 = QT3DSVec4(sinPhi, cosPhi, 0.0, 0.0);
- m->column2 = QT3DSVec4(0.0, 0.0, 1.0, 0.0);
- m->column3 = QT3DSVec4(0.0, 0.0, 0.0, 1.0);
-}
-
-void qt3ds::render::NvRenderTestMatrixTranslation(QT3DSMat44 *m, float x, float y, float z)
-{
- m->column0 = QT3DSVec4(1.0, 0.0, 0.0, 0.0);
- m->column1 = QT3DSVec4(0.0, 1.0, 0.0, 0.0);
- m->column2 = QT3DSVec4(0.0, 0.0, 1.0, 0.0);
- m->column3 = QT3DSVec4(x, y, z, 1.0);
-}
diff --git a/tests/auto/runtime/Qt3DSRenderTestMathUtil.h b/tests/auto/runtime/Qt3DSRenderTestMathUtil.h
deleted file mode 100644
index 739209e8..00000000
--- a/tests/auto/runtime/Qt3DSRenderTestMathUtil.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_MATH_UTIL_H
-#define QT3DS_RENDER_TEST_MATH_UTIL_H
-
-#include "foundation/Qt3DSMat44.h"
-
-namespace qt3ds {
-namespace render {
-
- void NvRenderTestMatrixFrustum(QT3DSMat44 *m, float l, float r, float b, float t, float n,
- float f);
-
- void NvGl2DemoMatrixOrtho(QT3DSMat44 *m, float l, float r, float b, float t, float n, float f);
-
- void NvRenderTestMatrixRotX(QT3DSMat44 *m, float angle);
- void NvRenderTestMatrixRotY(QT3DSMat44 *m, float angle);
- void NvRenderTestMatrixRotZ(QT3DSMat44 *m, float angle);
-
- void NvRenderTestMatrixTranslation(QT3DSMat44 *m, float x, float y, float z);
-}
-}
-
-#endif
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.cpp b/tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.cpp
deleted file mode 100644
index 9f81214f..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestAtomicCounterBuffer.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderAtomicCounterBuffer.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "layout(binding = 2, offset = 0) uniform atomic_uint ac_raster;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " uint counter = atomicCounterIncrement(ac_raster);\n"
- " float g = (float(counter)/255.0) / 255.0;\n"
- " fragColor = vec4(0.0, g, 0.0, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-NVRenderTestAtomicCounterBuffer::NVRenderTestAtomicCounterBuffer()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestAtomicCounterBuffer::~NVRenderTestAtomicCounterBuffer()
-{
-}
-
-bool NVRenderTestAtomicCounterBuffer::isSupported(NVRenderContext *context)
-{
- // This is currently only supported on GL 4 and GLES 3.1
- if (!context->IsAtomicCounterBufferSupported())
- return false;
-
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestAtomicCounterBuffer::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= rasterizerTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestAtomicCounterBuffer::rasterizerTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) },
- { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderAtomicCounterBuffer> mAtomicCounterBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create atomic counter buffer
- QT3DSU32 acCounter = 0;
- NVDataRef<QT3DSU8> acData((QT3DSU8 *)&acCounter, sizeof(QT3DSU32));
- mAtomicCounterBuffer = context->CreateAtomicCounterBuffer(
- "ac_buffer", NVRenderBufferUsageType::Static, sizeof(QT3DSU32), acData);
- if (!mAtomicCounterBuffer) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create atomic counter buffer";
- return false;
- }
- // add a parameter
- CRegisteredString theACName(context->GetStringTable().RegisterStr("ac_raster"));
- mAtomicCounterBuffer->AddParam(theACName, 0);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestAtomicCounterBuffer shader",
- toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderAtomicCounterBuffer *> atomicBuffer(
- "ac_buffer", *compResult.mShader);
- atomicBuffer.Set();
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestAtomicCounterBuffer::runPerformance(NVRenderContext *context,
- userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestAtomicCounterBuffer::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.h b/tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.h
deleted file mode 100644
index 87b0910a..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestAtomicCounterBuffer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_ATOMIC_COUNTER_BUFFER_H
-#define QT3DS_RENDER_TEST_ATOMIC_COUNTER_BUFFER_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestAtomicCounterBuffer : public NVRenderTestBase
- {
- public:
- NVRenderTestAtomicCounterBuffer();
- ~NVRenderTestAtomicCounterBuffer();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool rasterizerTest(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_ATOMIC_COUNTER_BUFFER_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.cpp b/tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.cpp
deleted file mode 100644
index 805782f7..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestAttribBuffers.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "in vec3 attr_col; // Vertex col\n"
- "out vec3 color; // output color\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- " color = attr_col;\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "in vec3 color; // input color\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4( color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-NVRenderTestAttribBuffers::NVRenderTestAttribBuffers()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestAttribBuffers::~NVRenderTestAttribBuffers()
-{
-}
-
-bool NVRenderTestAttribBuffers::isSupported(NVRenderContext *context)
-{
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestAttribBuffers::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= multiAttribBufferTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestAttribBuffers::multiAttribBufferTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) },
- { QT3DSVec3(0.0, 0.9, 0) } };
-
- static const Vertex vertexColors[] = { { QT3DSVec3(0.0, 1.0, 0.0) },
- { QT3DSVec3(0.0, 0.6, 0.0) },
- { QT3DSVec3(0.0, 0.2, 0.0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderVertexBuffer> mColorBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVRenderVertexBuffer *attribBuffers[2];
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestAttribBuffers shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0, 0),
- NVRenderVertexBufferEntry("attr_col", NVRenderComponentTypes::QT3DSF32, 3, 0, 1),
- };
-
- // position buffer
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create vertex buffer";
- return false;
- }
- // color buffer
- NVDataRef<QT3DSU8> colorData((QT3DSU8 *)vertexColors, bufSize);
- mColorBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), colorData);
- if (!mColorBuffer) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create color buffer";
- return false;
- }
-
- attribBuffers[0] = mVertexBuffer;
- attribBuffers[1] = mColorBuffer;
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 2));
- // create input Assembler
- QT3DSU32 strides[2];
- QT3DSU32 offsets[2];
- strides[0] = mVertexBuffer->GetStride();
- offsets[0] = 0;
- strides[1] = mColorBuffer->GetStride();
- offsets[1] = 0;
-
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, NVConstDataRef<NVRenderVertexBuffer *>(attribBuffers, 2), NULL,
- toConstDataRef(strides, 2), toConstDataRef(offsets, 2), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestAttribBuffers::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestAttribBuffers::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.h b/tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.h
deleted file mode 100644
index 47e898f2..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestAttribBuffers.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_ATTRIB_BUFFERS_H
-#define QT3DS_RENDER_TEST_ATTRIB_BUFFERS_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestAttribBuffers : public NVRenderTestBase
- {
- public:
- NVRenderTestAttribBuffers();
- ~NVRenderTestAttribBuffers();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool multiAttribBufferTest(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_ATTRIB_BUFFERS_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.cpp b/tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.cpp
deleted file mode 100644
index 30f26378..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestBackendQuery.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *PassthroughVertShader()
-{
- return "uniform mat4 mat_mvp;\n"
- "attribute vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-}
-
-static const char *SimpleFragShader()
-{
- return "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "uniform vec3 color;\n"
- "void main()\n"
- "{\n"
- "gl_FragColor = vec4( color, 1);\n"
- "}\n";
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
-NVRenderTestBackendQuery::NVRenderTestBackendQuery()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestBackendQuery::~NVRenderTestBackendQuery()
-{
-}
-
-bool NVRenderTestBackendQuery::isSupported(NVRenderContext *context)
-{
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestBackendQuery::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= depthBitsTest(context, pUserData);
- _curTest++;
- success &= depthBitsFBOTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestBackendQuery::renderQuad(NVRenderContext *context, userContextData *pUserData,
- QT3DSVec3 color)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestBackendQuery shader", toRef(PassthroughVertShader()),
- toRef(SimpleFragShader()));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestBackendQuery::depthBitsTest: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestBackendQuery::depthBitsTest: Failed to create input assembler";
- return false;
- }
-
- // check if default buffer bit size is in an acceptable size range
- // we accept a range from 16 to 32
- const QT3DSU32 bits = context->GetDepthBits();
- bool passed = (bits >= 16 && bits <= 32);
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return passed;
-}
-
-bool NVRenderTestBackendQuery::depthBitsTest(NVRenderContext *context, userContextData *pUserData)
-{
- QT3DSVec3 color(0.0, 0.0, 0.0);
- // check if default buffer bit size is in an acceptable size range
- // we accept a range from 16 to 32
- const QT3DSU32 bits = context->GetDepthBits();
- bool passed = (bits >= 16 && bits <= 32);
- if (passed)
- color.y = 1.0;
- else
- color.x = 1.0;
-
- passed &= renderQuad(context, pUserData, color);
-
- return passed;
-}
-
-bool NVRenderTestBackendQuery::depthBitsFBOTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- // depneding on the context we get different values
- NVRenderContextType theContextFlags(NVRenderContextValues::GLES2 | NVRenderContextValues::GL2);
- NVRenderContextType type = context->GetRenderContextType();
- bool depth16_Only = (type & theContextFlags);
- // create a FBO
- NVScopedRefCounted<NVRenderFrameBuffer> m_FBO;
- NVScopedRefCounted<NVRenderTexture2D> m_ColorTexture;
- NVScopedRefCounted<NVRenderTexture2D> m_Depth16Texture;
- NVScopedRefCounted<NVRenderTexture2D> m_Depth24Texture;
- NVScopedRefCounted<NVRenderTexture2D> m_Depth32Texture;
- NVScopedRefCounted<NVRenderTexture2D> m_Depth24Stencil8Texture;
-
- m_ColorTexture = context->CreateTexture2D();
- m_ColorTexture->SetTextureData(NVDataRef<QT3DSU8>(), 0, 256, 256, NVRenderTextureFormats::RGBA8);
- m_Depth16Texture = context->CreateTexture2D();
- m_Depth16Texture->SetTextureData(NVDataRef<QT3DSU8>(), 0, 256, 256,
- NVRenderTextureFormats::Depth16);
-
- m_FBO = context->CreateFrameBuffer();
- m_FBO->Attach(NVRenderFrameBufferAttachments::Color0,
- NVRenderTextureOrRenderBuffer(*m_ColorTexture));
- m_FBO->Attach(NVRenderFrameBufferAttachments::Depth,
- NVRenderTextureOrRenderBuffer(*m_Depth16Texture));
-
- if (!m_FBO->IsComplete()) {
- qWarning() << "NVRenderTestBackendQuery::depthBitsFBOTest: Failed to create FBO";
- return false;
- }
-
- context->SetRenderTarget(m_FBO);
-
- QT3DSVec3 color(0.0, 0.0, 0.0);
- // check depth bit count
- QT3DSU32 bits = context->GetDepthBits();
- QT3DSU32 bitsExpected = 16;
- bool passed = (bits == bitsExpected);
-
- // detach depth
- m_FBO->Attach(NVRenderFrameBufferAttachments::Depth, NVRenderTextureOrRenderBuffer());
-
- m_Depth24Texture = context->CreateTexture2D();
- m_Depth24Texture->SetTextureData(NVDataRef<QT3DSU8>(), 0, 256, 256,
- NVRenderTextureFormats::Depth24);
- m_FBO->Attach(NVRenderFrameBufferAttachments::Depth,
- NVRenderTextureOrRenderBuffer(*m_Depth24Texture));
- if (!m_FBO->IsComplete()) {
- qWarning() << "NVRenderTestBackendQuery::depthBitsFBOTest: Failed to create FBO";
- return false;
- }
- // check depth bit count
- bits = context->GetDepthBits();
- bitsExpected = (depth16_Only) ? 16 : 24;
- passed &= (bits == bitsExpected);
-
- // detach depth
- m_FBO->Attach(NVRenderFrameBufferAttachments::Depth, NVRenderTextureOrRenderBuffer());
-
- m_Depth32Texture = context->CreateTexture2D();
- m_Depth32Texture->SetTextureData(NVDataRef<QT3DSU8>(), 0, 256, 256,
- NVRenderTextureFormats::Depth32);
- m_FBO->Attach(NVRenderFrameBufferAttachments::Depth,
- NVRenderTextureOrRenderBuffer(*m_Depth32Texture));
- if (!m_FBO->IsComplete()) {
- qWarning() << "NVRenderTestBackendQuery::depthBitsFBOTest: Failed to create FBO";
- return false;
- }
- // check depth bit count
- bits = context->GetDepthBits();
- bitsExpected = (depth16_Only) ? 16 : 32;
- passed &= (bits == bitsExpected);
-
- // detach depth
- m_FBO->Attach(NVRenderFrameBufferAttachments::Depth, NVRenderTextureOrRenderBuffer());
-
- // only test depth stencil if supported
- if (context->IsDepthStencilSupported()) {
- m_Depth24Stencil8Texture = context->CreateTexture2D();
- m_Depth24Stencil8Texture->SetTextureData(NVDataRef<QT3DSU8>(), 0, 256, 256,
- NVRenderTextureFormats::Depth24Stencil8);
- m_FBO->Attach(NVRenderFrameBufferAttachments::DepthStencil,
- NVRenderTextureOrRenderBuffer(*m_Depth24Stencil8Texture));
- if (!m_FBO->IsComplete()) {
- qWarning() << "NVRenderTestBackendQuery::depthBitsFBOTest: Failed to create FBO";
- return false;
- }
- // check depth bit count
- bits = context->GetDepthBits();
- bitsExpected = (depth16_Only) ? 16 : 24;
- passed &= (bits == bitsExpected);
- }
-
- context->SetRenderTarget(NULL);
-
- if (passed)
- color.y = 1.0;
- else
- color.x = 1.0;
-
- passed &= renderQuad(context, pUserData, color);
-
- return passed;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestBackendQuery::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestBackendQuery::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.h b/tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.h
deleted file mode 100644
index e5fde648..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestBackendQuery.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_BACKEND_QUERY_H
-#define QT3DS_RENDER_TEST_BACKEND_QUERY_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestBackendQuery : public NVRenderTestBase
- {
- public:
- NVRenderTestBackendQuery();
- ~NVRenderTestBackendQuery();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool depthBitsTest(NVRenderContext *context, userContextData *pUserData);
- bool depthBitsFBOTest(NVRenderContext *context, userContextData *pUserData);
-
- bool renderQuad(NVRenderContext *context, userContextData *pUserData, QT3DSVec3 color);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_CONSTANT_BUFFER_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestClear.cpp b/tests/auto/runtime/base/Qt3DSRenderTestClear.cpp
deleted file mode 100644
index 8accb864..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestClear.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestClear.h"
-#include "foundation/Qt3DSVec4.h"
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-NVRenderTestClear::NVRenderTestClear()
-{
-}
-
-NVRenderTestClear::~NVRenderTestClear()
-{
-}
-
-bool NVRenderTestClear::isSupported(NVRenderContext *context)
-{
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-static bool checkColor(int width, int height, unsigned char *pixels, const QT3DSVec3 &color)
-{
- unsigned char *pSrc = pixels;
-
- for (int h = 0; h < height; h++) {
- for (int w = 0; w < width; w++) {
- if (pSrc[0] != (unsigned char)color.x || pSrc[1] != (unsigned char)color.y
- || pSrc[2] != (unsigned char)color.z) {
- return false;
- }
-
- pSrc += 3;
- }
- }
-
- return true;
-}
-
-bool NVRenderTestClear::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
-
- success &= testColorClear(context, pUserData);
-
- // if successfull draw green otherwise a red
- if (success) {
- // set clear color to green
- context->SetClearColor(QT3DSVec4(0.0f, 1.0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color));
- } else {
- // set clear color to green
- context->SetClearColor(QT3DSVec4(1.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color));
- }
-
- return success;
-}
-
-bool NVRenderTestClear::testColorClear(NVRenderContext *context, userContextData *pUserData)
-{
- // allocate buffer for readback
- NVAllocatorCallback &alloc(context->GetFoundation().getAllocator());
- QT3DSU32 size = pUserData->winHeight * pUserData->winHeight * 3 * sizeof(QT3DSU8);
- QT3DSU8 *pixels = (QT3DSU8 *)alloc.allocate(size, "testColorClear color clear", __FILE__, __LINE__);
-
- if (!pixels)
- return false;
-
- // set clear color to yellow
- context->SetClearColor(QT3DSVec4(1.0f, 1.0f, .0f, 0.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color));
-
- // read back pixels
- context->ReadPixels(NVRenderRect(0, 0, pUserData->winHeight, pUserData->winHeight),
- NVRenderReadPixelFormats::RGB8, NVDataRef<QT3DSU8>(pixels, size));
- // check color
- bool passed =
- checkColor(pUserData->winHeight, pUserData->winHeight, pixels, QT3DSVec3(255.0f, 255.0f, .0f));
-
- alloc.deallocate(pixels);
-
- return passed;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestClear::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestClear::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestClear.h b/tests/auto/runtime/base/Qt3DSRenderTestClear.h
deleted file mode 100644
index 6113b7bd..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestClear.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_CLEAR_H
-#define QT3DS_RENDER_TEST_CLEAR_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the render target clearing
- class NVRenderTestClear : public NVRenderTestBase
- {
- public:
- NVRenderTestClear();
- ~NVRenderTestClear();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextDat);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- /// subtests
- bool testColorClear(NVRenderContext *context, userContextData *pUserData);
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_CLEAR_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.cpp b/tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.cpp
deleted file mode 100644
index 8b6cb344..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.cpp
+++ /dev/null
@@ -1,847 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestConstantBuffer.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const char *scalarVertShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "layout (std140) uniform cbBuffer { \n"
- "float red;\n"
- "float green;\n"
- "mat4 mat_mvp;\n"
- "float blue;\n };\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *scalarFragShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "layout (std140) uniform cbBuffer { \n"
- "float red;\n"
- "float green;\n"
- "mat4 mat_mvp;\n"
- "float blue;\n };\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = vec4(red, green, blue, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *vectorVertShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "layout (std140) uniform cbBuffer { \n"
- "vec2 rg;\n"
- "mat4 mat_mvp;\n"
- "vec2 ba;\n };\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *vectorFragShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "layout (std140) uniform cbBuffer { \n"
- "vec2 rg;\n"
- "mat4 mat_mvp;\n"
- "vec2 ba;\n };\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = vec4(rg[0], rg[1], ba[0], ba[1]);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *structVertShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "struct sampleStruct {\n"
- "vec2 rg;\n"
- "mat4 mat_mvp;\n"
- "float blue;\n"
- "float alpha; };\n"
- "layout (std140) uniform cbBuffer { \n"
- "sampleStruct s[2]; };\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = s[0].mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *structFragShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "struct sampleStruct {\n"
- "vec2 rg;\n"
- "mat4 mat_mvp;\n"
- "float blue;\n"
- "float alpha; };\n"
- "layout (std140) uniform cbBuffer { \n"
- "sampleStruct s[2]; };\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = vec4(s[0].rg[0], s[0].rg[1], s[0].blue, s[0].alpha);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *multiCBVertShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "layout (std140) uniform cbBufferTrans { \n"
- "mat4 mat_mvp;\n };\n"
- "layout (std140) uniform cbBufferCol { \n"
- "float red;\n"
- "float green;\n"
- "float blue;\n };\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *multiCBFragShader(bool bESContext, std::string &prog)
-{
- if (bESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330 compatibility\n";
- }
-
- prog += "layout (std140) uniform cbBufferTrans { \n"
- "mat4 mat_mvp;\n };\n"
- "layout (std140) uniform cbBufferCol { \n"
- "float red;\n"
- "float green;\n"
- "float blue;\n };\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = vec4(red, green, blue, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-NVRenderTestConstantBuffer::NVRenderTestConstantBuffer()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestConstantBuffer::~NVRenderTestConstantBuffer()
-{
-}
-
-bool NVRenderTestConstantBuffer::isSupported(NVRenderContext *context)
-{
- NVRenderContextType ctxType = context->GetRenderContextType();
- NVRenderContextType nonSupportedFlags(NVRenderContextValues::GL2
- | NVRenderContextValues::GLES2);
-
- // This is currently only supported on GL(Es) >= 3
- if ((ctxType & nonSupportedFlags))
- return false;
-
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestConstantBuffer::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= scalarTest(context, pUserData);
- _curTest++;
- success &= vectorTest(context, pUserData);
- _curTest++;
- success &= structTest(context, pUserData);
- _curTest++;
- success &= rawTest(context, pUserData);
- _curTest++;
- success &= multiCBTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestConstantBuffer::scalarTest(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderConstantBuffer> mConstantBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create constant buffer referred in the program
- mConstantBuffer = context->CreateConstantBuffer("cbBuffer", NVRenderBufferUsageType::Static, 0,
- NVDataRef<QT3DSU8>());
- // buffer parameter. They must be in the order of appearance
- CRegisteredString theRedName(context->GetStringTable().RegisterStr("red"));
- mConstantBuffer->AddParam(theRedName, NVRenderShaderDataTypes::QT3DSF32, 1);
- CRegisteredString theGreenName(context->GetStringTable().RegisterStr("green"));
- mConstantBuffer->AddParam(theGreenName, NVRenderShaderDataTypes::QT3DSF32, 1);
- CRegisteredString theMatName(context->GetStringTable().RegisterStr("mat_mvp"));
- mConstantBuffer->AddParam(theMatName, NVRenderShaderDataTypes::QT3DSMat44, 1);
- CRegisteredString theBlueName(context->GetStringTable().RegisterStr("blue"));
- mConstantBuffer->AddParam(theBlueName, NVRenderShaderDataTypes::QT3DSF32, 1);
-
- // set values
- QT3DSF32 red = 0.0;
- mConstantBuffer->UpdateParam("red", NVDataRef<QT3DSU8>((QT3DSU8 *)&red, 1));
- QT3DSF32 green = 1.0;
- mConstantBuffer->UpdateParam("green", NVDataRef<QT3DSU8>((QT3DSU8 *)&green, 1));
- QT3DSF32 blue = 0.0;
- mConstantBuffer->UpdateParam("blue", NVDataRef<QT3DSU8>((QT3DSU8 *)&blue, 1));
- mConstantBuffer->UpdateParam("mat_mvp", NVDataRef<QT3DSU8>((QT3DSU8 *)mvp.front(), 1));
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestConstantBuffer::scalarTest",
- toRef(scalarVertShader(isGLESContext(context), vtxProg)),
- toRef(scalarFragShader(isGLESContext(context), frgProg)));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestConstantBuffer::scalarTest: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestConstantBuffer::scalarTest: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderConstantBuffer *> cb("cbBuffer",
- *compResult.mShader);
- mConstantBuffer->Update();
- cb.Set();
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestConstantBuffer::vectorTest(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderConstantBuffer> mConstantBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create constant buffer referred in the program
- mConstantBuffer = context->CreateConstantBuffer("cbBuffer", NVRenderBufferUsageType::Static, 0,
- NVDataRef<QT3DSU8>());
- // buffer parameter. They must be in the order of appearance
- CRegisteredString theRGName(context->GetStringTable().RegisterStr("rg"));
- mConstantBuffer->AddParam(theRGName, NVRenderShaderDataTypes::QT3DSVec2, 1);
- CRegisteredString theMatName(context->GetStringTable().RegisterStr("mat_mvp"));
- mConstantBuffer->AddParam(theMatName, NVRenderShaderDataTypes::QT3DSMat44, 1);
- CRegisteredString theBAName(context->GetStringTable().RegisterStr("ba"));
- mConstantBuffer->AddParam(theBAName, NVRenderShaderDataTypes::QT3DSVec2, 1);
-
- // set values
- QT3DSVec2 rg;
- rg[0] = 0.0;
- rg[1] = 1.0;
- mConstantBuffer->UpdateParam("rg", NVDataRef<QT3DSU8>((QT3DSU8 *)&rg, 1));
- QT3DSVec2 ba;
- ba[0] = 0.0;
- ba[1] = 1.0;
- mConstantBuffer->UpdateParam("ba", NVDataRef<QT3DSU8>((QT3DSU8 *)&ba, 1));
- mConstantBuffer->UpdateParam("mat_mvp", NVDataRef<QT3DSU8>((QT3DSU8 *)mvp.front(), 1));
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestConstantBuffer::vectorTest",
- toRef(vectorVertShader(isGLESContext(context), vtxProg)),
- toRef(vectorFragShader(isGLESContext(context), frgProg)));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestConstantBuffer::vectorTest: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestConstantBuffer::vectorTest: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderConstantBuffer *> cb("cbBuffer",
- *compResult.mShader);
- cb.Set();
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestConstantBuffer::structTest(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderConstantBuffer> mConstantBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create constant buffer referred in the program
- mConstantBuffer = context->CreateConstantBuffer("cbBuffer", NVRenderBufferUsageType::Static, 0,
- NVDataRef<QT3DSU8>());
- // buffer parameter. They must be in the order of appearance
- CRegisteredString theRGName(context->GetStringTable().RegisterStr("s[0].rg"));
- mConstantBuffer->AddParam(theRGName, NVRenderShaderDataTypes::QT3DSVec2, 1);
- CRegisteredString theMatName(context->GetStringTable().RegisterStr("s[0].mat_mvp"));
- mConstantBuffer->AddParam(theMatName, NVRenderShaderDataTypes::QT3DSMat44, 1);
- CRegisteredString theBlueName(context->GetStringTable().RegisterStr("s[0].blue"));
- mConstantBuffer->AddParam(theBlueName, NVRenderShaderDataTypes::QT3DSF32, 1);
- CRegisteredString theAlphaName(context->GetStringTable().RegisterStr("s[0].alpha"));
- mConstantBuffer->AddParam(theAlphaName, NVRenderShaderDataTypes::QT3DSF32, 1);
-
- // set values
- QT3DSVec2 rg;
- rg[0] = 0.0;
- rg[1] = 1.0;
- mConstantBuffer->UpdateParam("s[0].rg", NVDataRef<QT3DSU8>((QT3DSU8 *)&rg, 1));
- QT3DSF32 blue, alpha;
- blue = 0.0;
- alpha = 1.0;
- mConstantBuffer->UpdateParam("s[0].blue", NVDataRef<QT3DSU8>((QT3DSU8 *)&blue, 1));
- mConstantBuffer->UpdateParam("s[0].alpha", NVDataRef<QT3DSU8>((QT3DSU8 *)&alpha, 1));
- mConstantBuffer->UpdateParam("s[0].mat_mvp", NVDataRef<QT3DSU8>((QT3DSU8 *)mvp.front(), 1));
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestConstantBuffer::structTest",
- toRef(structVertShader(isGLESContext(context), vtxProg)),
- toRef(structFragShader(isGLESContext(context), frgProg)));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestConstantBuffer::structTest: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestConstantBuffer::structTest: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderConstantBuffer *> cb("cbBuffer",
- *compResult.mShader);
- cb.Set();
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestConstantBuffer::rawTest(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- struct sampleStruct
- {
- float rg[2];
- float padding[2];
- QT3DSMat44 mat_mvp; // matrices start on 16 byte boundaries
- float blue;
- float alpha;
- } s;
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderConstantBuffer> mConstantBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- NVDataRef<QT3DSU8> cBuffer((QT3DSU8 *)&s, sizeof(sampleStruct));
- // create constant buffer referred in the program
- mConstantBuffer = context->CreateConstantBuffer("cbBuffer", NVRenderBufferUsageType::Static,
- sizeof(sampleStruct), cBuffer);
- // set values
- s.rg[0] = 0.0;
- s.rg[1] = 1.0;
- s.mat_mvp = mvp;
- s.blue = 0.0;
- s.alpha = 0.0;
- mConstantBuffer->UpdateRaw(0, cBuffer);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestConstantBuffer::rawTest",
- toRef(structVertShader(isGLESContext(context), vtxProg)),
- toRef(structFragShader(isGLESContext(context), frgProg)));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestConstantBuffer::rawTest: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestConstantBuffer::rawTest: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderConstantBuffer *> cb("cbBuffer",
- *compResult.mShader);
- cb.Set();
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-///< test of multiple constant buffers
-bool NVRenderTestConstantBuffer::multiCBTest(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderConstantBuffer> mConstantBufferTrans;
- NVScopedRefCounted<NVRenderConstantBuffer> mConstantBufferCol;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create constant buffer referred in the program
- mConstantBufferTrans = context->CreateConstantBuffer(
- "cbBufferTrans", NVRenderBufferUsageType::Static, 0, NVDataRef<QT3DSU8>());
- // buffer parameter. They must be in the order of appearance
- CRegisteredString theMatName(context->GetStringTable().RegisterStr("mat_mvp"));
- mConstantBufferTrans->AddParam(theMatName, NVRenderShaderDataTypes::QT3DSMat44, 1);
-
- // create constant buffer referred in the program
- mConstantBufferCol = context->CreateConstantBuffer(
- "cbBufferCol", NVRenderBufferUsageType::Static, 0, NVDataRef<QT3DSU8>());
- CRegisteredString theRedName(context->GetStringTable().RegisterStr("red"));
- mConstantBufferCol->AddParam(theRedName, NVRenderShaderDataTypes::QT3DSF32, 1);
- CRegisteredString theGreenName(context->GetStringTable().RegisterStr("green"));
- mConstantBufferCol->AddParam(theGreenName, NVRenderShaderDataTypes::QT3DSF32, 1);
- CRegisteredString theBlueName(context->GetStringTable().RegisterStr("blue"));
- mConstantBufferCol->AddParam(theBlueName, NVRenderShaderDataTypes::QT3DSF32, 1);
-
- // set values
- mConstantBufferTrans->UpdateParam("mat_mvp", NVDataRef<QT3DSU8>((QT3DSU8 *)mvp.front(), 1));
-
- QT3DSF32 red = 0.0;
- mConstantBufferCol->UpdateParam("red", NVDataRef<QT3DSU8>((QT3DSU8 *)&red, 1));
- QT3DSF32 green = 1.0;
- mConstantBufferCol->UpdateParam("green", NVDataRef<QT3DSU8>((QT3DSU8 *)&green, 1));
- QT3DSF32 blue = 0.0;
- mConstantBufferCol->UpdateParam("blue", NVDataRef<QT3DSU8>((QT3DSU8 *)&blue, 1));
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestConstantBuffer::multiCBTest",
- toRef(multiCBVertShader(isGLESContext(context), vtxProg)),
- toRef(multiCBFragShader(isGLESContext(context), frgProg)));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestConstantBuffer::scalarTest: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestConstantBuffer::scalarTest: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderConstantBuffer *> cbTrans(
- "cbBufferTrans", *compResult.mShader);
- mConstantBufferTrans->Update();
- cbTrans.Set();
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderConstantBuffer *> cbCol(
- "cbBufferCol", *compResult.mShader);
- mConstantBufferCol->Update();
- cbCol.Set();
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestConstantBuffer::runPerformance(NVRenderContext *context,
- userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestConstantBuffer::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.h b/tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.h
deleted file mode 100644
index 417e4bb3..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestConstantBuffer.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_CONSTANT_BUFFER_H
-#define QT3DS_RENDER_TEST_CONSTANT_BUFFER_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestConstantBuffer : public NVRenderTestBase
- {
- public:
- NVRenderTestConstantBuffer();
- ~NVRenderTestConstantBuffer();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool scalarTest(NVRenderContext *context, userContextData *pUserData);
- bool vectorTest(NVRenderContext *context, userContextData *pUserData);
- bool structTest(NVRenderContext *context, userContextData *pUserData);
- bool rawTest(NVRenderContext *context, userContextData *pUserData);
- bool multiCBTest(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_CONSTANT_BUFFER_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.cpp b/tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.cpp
deleted file mode 100644
index 4b8044d3..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestDrawIndirectBuffer.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderDrawIndirectBuffer.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-NVRenderTestDrawIndirectBuffer::NVRenderTestDrawIndirectBuffer()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestDrawIndirectBuffer::~NVRenderTestDrawIndirectBuffer()
-{
-}
-
-bool NVRenderTestDrawIndirectBuffer::isSupported(NVRenderContext *context)
-{
- // This is currently only supported on GL 4 and GLES 3.1
- // we have no direct check for this but this is the same version
- if (!context->IsAtomicCounterBufferSupported())
- return false;
-
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestDrawIndirectBuffer::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= drawArrayIndirect(context, pUserData);
- _curTest++;
- success &= drawElementsIndirect(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestDrawIndirectBuffer::drawArrayIndirect(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) },
- { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderDrawIndirectBuffer> mDrawIndirectBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestDrawIndirectBuffer shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), NULL, toConstDataRef(&strides, 1),
- toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create input assembler";
- return false;
- }
-
- // create draw indirect buffer
- DrawArraysIndirectCommand command;
- command.baseInstance = 0;
- command.count = 6;
- command.first = 0;
- command.primCount = 1;
- QT3DSU32 commandBufSize = sizeof(DrawArraysIndirectCommand);
- NVDataRef<QT3DSU8> commandData((QT3DSU8 *)&command, commandBufSize);
- mDrawIndirectBuffer = context->CreateDrawIndirectBuffer(NVRenderBufferUsageType::Dynamic,
- commandBufSize, commandData);
-
- if (!mDrawIndirectBuffer) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create vertex buffer";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- mDrawIndirectBuffer->Bind();
- context->DrawIndirect(mInputAssembler->GetPrimitiveType(), 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestDrawIndirectBuffer::drawElementsIndirect(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) },
- { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- const unsigned short indices[] = { 0, 1, 2, 3, 4, 5 };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderDrawIndirectBuffer> mDrawIndirectBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestDrawIndirectBuffer shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create vertex buffer";
- return false;
- }
-
- // index buffer
- bufSize = 6 * sizeof(unsigned short);
- NVDataRef<QT3DSU8> idxData((QT3DSU8 *)indices, bufSize);
- mIndexBuffer = context->CreateIndexBuffer(
- NVRenderBufferUsageType::Static, NVRenderComponentTypes::QT3DSU16, bufSize,
- NVConstDataRef<QT3DSU8>(reinterpret_cast<const QT3DSU8 *>(indices), bufSize));
- if (!mIndexBuffer) {
- qWarning() << "NVRenderTestPrimitives::Triangles: Failed to create index buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create input assembler";
- return false;
- }
-
- // create draw indirect buffer
- DrawElementsIndirectCommand command;
- command.baseInstance = 0;
- command.count = 6;
- command.firstIndex = 0;
- command.baseVertex = 0;
- command.primCount = 1;
- QT3DSU32 commandBufSize = sizeof(DrawElementsIndirectCommand);
- NVDataRef<QT3DSU8> commandData((QT3DSU8 *)&command, commandBufSize);
- mDrawIndirectBuffer = context->CreateDrawIndirectBuffer(NVRenderBufferUsageType::Dynamic,
- commandBufSize, commandData);
-
- if (!mDrawIndirectBuffer) {
- qWarning() << "NVRenderTestAtomicCounterBuffer: Failed to create vertex buffer";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- mDrawIndirectBuffer->Bind();
- context->DrawIndirect(mInputAssembler->GetPrimitiveType(), 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestDrawIndirectBuffer::runPerformance(NVRenderContext *context,
- userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestDrawIndirectBuffer::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.h b/tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.h
deleted file mode 100644
index ee37a133..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestDrawIndirectBuffer.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_DRAW_INDIRECT_BUFFER_H
-#define QT3DS_RENDER_TEST_DRAW_INDIRECT_BUFFER_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestDrawIndirectBuffer : public NVRenderTestBase
- {
- public:
- NVRenderTestDrawIndirectBuffer();
- ~NVRenderTestDrawIndirectBuffer();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool drawArrayIndirect(NVRenderContext *context, userContextData *pUserData);
- bool drawElementsIndirect(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_ATOMIC_COUNTER_BUFFER_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestPrimitives.cpp b/tests/auto/runtime/base/Qt3DSRenderTestPrimitives.cpp
deleted file mode 100644
index d3c2423b..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestPrimitives.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestPrimitives.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *PassthroughVertShader()
-{
- return "uniform mat4 mat_mvp;\n"
- "attribute vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-}
-
-static const char *SimpleFragShader()
-{
- return "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "void main()\n"
- "{\n"
- "gl_FragColor = vec4(0, 1, 0, 1);\n"
- "}\n";
-}
-
-NVRenderTestPrimitives::NVRenderTestPrimitives()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestPrimitives::~NVRenderTestPrimitives()
-{
-}
-
-bool NVRenderTestPrimitives::isSupported(NVRenderContext *context)
-{
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestPrimitives::renderPrimitive(NVRenderContext *context,
- userContextData *pContextData,
- const Vertex *pVertexData, unsigned int vertexCount,
- const unsigned short *pIndexData,
- unsigned int indexCount,
- NVRenderDrawMode::Enum primType)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestPrimitives shader", toRef(PassthroughVertShader()), toRef(SimpleFragShader()));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = vertexCount * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)pVertexData, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestPrimitives::Triangles: Failed to create vertex buffer";
- return false;
- }
-
- // index buffer
- if (pIndexData && indexCount) {
- bufSize = indexCount * sizeof(unsigned short);
- NVDataRef<QT3DSU8> idxData((QT3DSU8 *)pIndexData, bufSize);
- mIndexBuffer = context->CreateIndexBuffer(
- NVRenderBufferUsageType::Static, NVRenderComponentTypes::QT3DSU16, bufSize,
- NVConstDataRef<QT3DSU8>(reinterpret_cast<const QT3DSU8 *>(pIndexData), bufSize));
- if (!mIndexBuffer) {
- qWarning() << "NVRenderTestPrimitives::Triangles: Failed to create index buffer";
- return false;
- }
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestPrimitives::Triangles: Failed to create inout assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- QT3DSU32 count = (mIndexBuffer.mPtr) ? indexCount : vertexCount;
- context->Draw(primType, count, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestPrimitives::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= triangles(context, pUserData);
- _curTest++;
- success &= triangleStrip(context, pUserData);
- _curTest++;
- success &= lines(context, pUserData);
- _curTest++;
- success &= lineStrip(context, pUserData);
- _curTest++;
- success &= trianglesIndexed(context, pUserData);
- _curTest++;
- success &= triangleStripIndexed(context, pUserData);
- _curTest++;
- success &= linesIndexed(context, pUserData);
- _curTest++;
- success &= lineStripIndexed(context, pUserData);
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestPrimitives::triangles(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.85, -0.9, 0) }, { QT3DSVec3(-0.85, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- return renderPrimitive(context, pUserData, vertexPositions, 6, NULL, 0,
- NVRenderDrawMode::Triangles);
-}
-
-bool NVRenderTestPrimitives::triangleStrip(NVRenderContext *context, userContextData *pUserData)
-{
- const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0.0) },
- { QT3DSVec3(-0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.9f, 0.9f, 0.0f) },
- { QT3DSVec3(0.9f, -0.9f, 0.0f) } };
-
- return renderPrimitive(context, pUserData, vertexPositions, 4, NULL, 0,
- NVRenderDrawMode::TriangleStrip);
-}
-
-bool NVRenderTestPrimitives::lines(NVRenderContext *context, userContextData *pUserData)
-{
- const Vertex vertexPositions[] = {
- { QT3DSVec3(0.9f, 0.9f, 0.0f) }, { QT3DSVec3(0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.9f, -0.9f, 0.0f) }, { QT3DSVec3(-0.85f, -0.9f, 0.0f) },
- { QT3DSVec3(-0.85f, -0.9f, 0.0f) }, { QT3DSVec3(0.9f, 0.9f, 0.0f) },
- { QT3DSVec3(-0.9f, -0.9f, 0.0f) }, { QT3DSVec3(0.85f, 0.9f, 0.0f) },
- { QT3DSVec3(0.85f, 0.9f, 0.0f) }, { QT3DSVec3(-0.9f, 0.9f, 0.0f) },
- { QT3DSVec3(-0.9f, 0.9f, 0.0f) }, { QT3DSVec3(-0.9f, -0.9f, 0.0f) }
- };
-
- return renderPrimitive(context, pUserData, vertexPositions, 12, NULL, 0,
- NVRenderDrawMode::Lines);
-}
-
-bool NVRenderTestPrimitives::lineStrip(NVRenderContext *context, userContextData *pUserData)
-{
- const Vertex vertexPositions[] = {
- { QT3DSVec3(-0.9f, 0.9f, 0.0f) }, { QT3DSVec3(-0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.9f, -0.9f, 0.0f) }, { QT3DSVec3(0.9f, 0.9f, 0.0f) },
- { QT3DSVec3(-0.9f, 0.9f, 0.0f) },
- };
-
- return renderPrimitive(context, pUserData, vertexPositions, 5, NULL, 0,
- NVRenderDrawMode::LineStrip);
-}
-
-bool NVRenderTestPrimitives::trianglesIndexed(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.85, -0.9, 0) }, { QT3DSVec3(-0.85, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
- const unsigned short indices[] = { 0, 1, 2, 3, 4, 5 };
-
- return renderPrimitive(context, pUserData, vertexPositions, 6, indices, 6,
- NVRenderDrawMode::Triangles);
-}
-
-bool NVRenderTestPrimitives::triangleStripIndexed(NVRenderContext *context,
- userContextData *pUserData)
-{
- const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0.0) },
- { QT3DSVec3(-0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.9f, 0.9f, 0.0f) },
- { QT3DSVec3(0.9f, -0.9f, 0.0f) } };
-
- const unsigned short indices[] = { 0, 1, 2, 3 };
-
- return renderPrimitive(context, pUserData, vertexPositions, 4, indices, 4,
- NVRenderDrawMode::TriangleStrip);
-}
-
-bool NVRenderTestPrimitives::linesIndexed(NVRenderContext *context, userContextData *pUserData)
-{
- const Vertex vertexPositions[] = {
- { QT3DSVec3(0.9f, 0.9f, 0.0f) }, { QT3DSVec3(0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(-0.85f, -0.9f, 0.0f) }, { QT3DSVec3(-0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.85f, 0.9f, 0.0f) }, { QT3DSVec3(-0.9f, 0.9f, 0.0f) },
- };
-
- const unsigned short indices[] = { 0, 1, 1, 2, 2, 0, 3, 4, 4, 5, 5, 3 };
-
- return renderPrimitive(context, pUserData, vertexPositions, 6, indices, 12,
- NVRenderDrawMode::Lines);
-}
-
-bool NVRenderTestPrimitives::lineStripIndexed(NVRenderContext *context, userContextData *pUserData)
-{
- const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0.0) },
- { QT3DSVec3(-0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.9f, -0.9f, 0.0f) },
- { QT3DSVec3(0.9f, 0.9f, 0.0f) } };
-
- const unsigned short indices[] = { 0, 1, 2, 3, 0 };
-
- return renderPrimitive(context, pUserData, vertexPositions, 4, indices, 5,
- NVRenderDrawMode::LineStrip);
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestPrimitives::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestPrimitives::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestPrimitives.h b/tests/auto/runtime/base/Qt3DSRenderTestPrimitives.h
deleted file mode 100644
index 4b6128e2..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestPrimitives.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_PRIMITIVES_H
-#define QT3DS_RENDER_TEST_PRIMITIVES_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- struct Vertex
- {
- QT3DSVec3 positions;
- };
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestPrimitives : public NVRenderTestBase
- {
- public:
- NVRenderTestPrimitives();
- ~NVRenderTestPrimitives();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool triangles(NVRenderContext *context, userContextData *pUserData);
- bool triangleStrip(NVRenderContext *context, userContextData *pUserData);
- bool lines(NVRenderContext *context, userContextData *pUserData);
- bool lineStrip(NVRenderContext *context, userContextData *pContextData);
-
- bool trianglesIndexed(NVRenderContext *context, userContextData *pUserData);
- bool triangleStripIndexed(NVRenderContext *context, userContextData *pUserData);
- bool linesIndexed(NVRenderContext *context, userContextData *pUserData);
- bool lineStripIndexed(NVRenderContext *context, userContextData *pContextData);
-
- bool renderPrimitive(NVRenderContext *context, userContextData *pContextData,
- const Vertex *pVertexData, unsigned int vertexCount,
- const unsigned short *pIndexData, unsigned int indexCount,
- NVRenderDrawMode::Enum primType);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_PRIMITIVES_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.cpp b/tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.cpp
deleted file mode 100644
index a76bfa05..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestProgramPipeline.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderProgramPipeline.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
-
- prog += "out gl_PerVertex\n"
- "{\n"
- "\tvec4 gl_Position;\n"
- "\tfloat gl_PointSize;\n"
- "\tfloat gl_ClipDistance[];\n"
- "};\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "in vec3 attr_col; // Vertex col\n"
- "out vec3 color; // output color\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- " color = attr_col;\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- prog += "in vec3 color; // input color\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4( color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-NVRenderTestProgramPipeline::NVRenderTestProgramPipeline()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestProgramPipeline::~NVRenderTestProgramPipeline()
-{
-}
-
-bool NVRenderTestProgramPipeline::isSupported(NVRenderContext *context)
-{
- return context->IsProgramPipelineSupported();
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestProgramPipeline::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= vertFragSeparateTest(context, pUserData);
- _curTest++;
- success &= vertFragCombinedTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestProgramPipeline::vertFragSeparateTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) },
- { QT3DSVec3(0.0, 0.9, 0) } };
-
- static const Vertex vertexColors[] = { { QT3DSVec3(0.0, 1.0, 0.0) },
- { QT3DSVec3(0.0, 1.0, 0.0) },
- { QT3DSVec3(0.0, 1.0, 0.0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderVertexBuffer> mColorBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderProgramPipeline> mProgramPipeline;
- NVRenderVertexBuffer *attribBuffers[2];
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult vtxResult = context->CompileSource(
- "NVRenderTestProgramPipeline vertex shader",
- toRef(vertShader(vtxProg, isGLESContext(context))), NVConstDataRef<QT3DSI8>(),
- NVConstDataRef<QT3DSI8>(), NVConstDataRef<QT3DSI8>(), NVConstDataRef<QT3DSI8>(), true);
- if (!vtxResult.mShader) {
- return false;
- }
-
- NVRenderVertFragCompilationResult fragResult = context->CompileSource(
- "NVRenderTestProgramPipeline fragment shader", NVConstDataRef<QT3DSI8>(),
- toRef(fragShader(frgProg, isGLESContext(context))), NVConstDataRef<QT3DSI8>(),
- NVConstDataRef<QT3DSI8>(), NVConstDataRef<QT3DSI8>(), true);
-
- if (!fragResult.mShader) {
- return false;
- }
-
- // setup program pipeline
- mProgramPipeline = context->CreateProgramPipeline();
- if (!mProgramPipeline) {
- qWarning() << "NVRenderTestProgramPipeline: Failed to create program pipeline";
- return false;
- }
-
- mProgramPipeline->SetProgramStages(vtxResult.mShader,
- NVRenderShaderTypeFlags(NVRenderShaderTypeValue::Vertex));
- mProgramPipeline->SetProgramStages(fragResult.mShader,
- NVRenderShaderTypeFlags(NVRenderShaderTypeValue::Fragment));
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0, 0),
- NVRenderVertexBufferEntry("attr_col", NVRenderComponentTypes::QT3DSF32, 3, 0, 1),
- };
-
- // position buffer
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create vertex buffer";
- return false;
- }
- // color buffer
- NVDataRef<QT3DSU8> colorData((QT3DSU8 *)vertexColors, bufSize);
- mColorBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), colorData);
- if (!mColorBuffer) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create color buffer";
- return false;
- }
-
- attribBuffers[0] = mVertexBuffer;
- attribBuffers[1] = mColorBuffer;
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 2));
- // create input Assembler
- QT3DSU32 strides[2];
- QT3DSU32 offsets[2];
- strides[0] = mVertexBuffer->GetStride();
- offsets[0] = 0;
- strides[1] = mColorBuffer->GetStride();
- offsets[1] = 0;
-
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, NVConstDataRef<NVRenderVertexBuffer *>(attribBuffers, 2), NULL,
- toConstDataRef(strides, 2), toConstDataRef(offsets, 2), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveProgramPipeline(mProgramPipeline);
- vtxResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- vtxResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveProgramPipeline(0);
- return true;
-}
-
-bool NVRenderTestProgramPipeline::vertFragCombinedTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) },
- { QT3DSVec3(0.0, 0.9, 0) } };
-
- static const Vertex vertexColors[] = { { QT3DSVec3(0.0, 1.0, 0.0) },
- { QT3DSVec3(0.0, 1.0, 0.0) },
- { QT3DSVec3(0.0, 1.0, 0.0) } };
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderVertexBuffer> mColorBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderProgramPipeline> mProgramPipeline;
- NVRenderVertexBuffer *attribBuffers[2];
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestProgramPipeline vertex shader",
- toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))), NVConstDataRef<QT3DSI8>(),
- NVConstDataRef<QT3DSI8>(), NVConstDataRef<QT3DSI8>(), true);
- if (!compResult.mShader) {
- return false;
- }
-
- // setup program pipeline
- mProgramPipeline = context->CreateProgramPipeline();
- if (!mProgramPipeline) {
- qWarning() << "NVRenderTestProgramPipeline: Failed to create program pipeline";
- return false;
- }
-
- mProgramPipeline->SetProgramStages(
- compResult.mShader, NVRenderShaderTypeFlags(NVRenderShaderTypeValue::Vertex
- | NVRenderShaderTypeValue::Fragment));
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0, 0),
- NVRenderVertexBufferEntry("attr_col", NVRenderComponentTypes::QT3DSF32, 3, 0, 1),
- };
-
- // position buffer
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create vertex buffer";
- return false;
- }
- // color buffer
- NVDataRef<QT3DSU8> colorData((QT3DSU8 *)vertexColors, bufSize);
- mColorBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), colorData);
- if (!mColorBuffer) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create color buffer";
- return false;
- }
-
- attribBuffers[0] = mVertexBuffer;
- attribBuffers[1] = mColorBuffer;
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 2));
- // create input Assembler
- QT3DSU32 strides[2];
- QT3DSU32 offsets[2];
- strides[0] = mVertexBuffer->GetStride();
- offsets[0] = 0;
- strides[1] = mColorBuffer->GetStride();
- offsets[1] = 0;
-
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, NVConstDataRef<NVRenderVertexBuffer *>(attribBuffers, 2), NULL,
- toConstDataRef(strides, 2), toConstDataRef(offsets, 2), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestAttribBuffers: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveProgramPipeline(mProgramPipeline);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveProgramPipeline(0);
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestProgramPipeline::runPerformance(NVRenderContext *context,
- userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestProgramPipeline::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.h b/tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.h
deleted file mode 100644
index eeec086d..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestProgramPipeline.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_PROGRAM_PIPELINE_H
-#define QT3DS_RENDER_TEST_PROGRAM_PIPELINE_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestProgramPipeline : public NVRenderTestBase
- {
- public:
- NVRenderTestProgramPipeline();
- ~NVRenderTestProgramPipeline();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool vertFragSeparateTest(NVRenderContext *context, userContextData *pUserData);
- bool vertFragCombinedTest(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_PROGRAM_PIPELINE_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestTexture2D.cpp b/tests/auto/runtime/base/Qt3DSRenderTestTexture2D.cpp
deleted file mode 100644
index 6904955f..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestTexture2D.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestTexture2D.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderTexture2D.h"
-#include "render/Qt3DSRenderTexture2DArray.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "in vec3 attr_uv; // texture coord\n"
- "out vec3 varTexCoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- " varTexCoord = attr_uv;\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330\n";
- }
-
- prog += "uniform sampler2DArray inTex;\n"
- "in vec3 varTexCoord;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = texture(inTex, varTexCoord);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
- QT3DSVec3 texCoord;
-};
-
-static const Vertex vertexPositionsL0[] = {
- { QT3DSVec3(-0.9, 0.0, 0), QT3DSVec3(0, 0, 0) }, { QT3DSVec3(0.0, 0.9, 0), QT3DSVec3(1, 1, 0) },
- { QT3DSVec3(-0.9, 0.9, 0), QT3DSVec3(0, 1, 0) }, { QT3DSVec3(-0.9, 0.0, 0), QT3DSVec3(0, 0, 0) },
- { QT3DSVec3(0.0, 0.0, 0), QT3DSVec3(1, 0, 0) }, { QT3DSVec3(0.0, 0.9, 0), QT3DSVec3(1, 1, 0) }
-};
-
-static const Vertex vertexPositionsL1[] = {
- { QT3DSVec3(0.0, -0.9, 0), QT3DSVec3(0, 0, 1) }, { QT3DSVec3(0.9, 0.0, 0), QT3DSVec3(1, 1, 1) },
- { QT3DSVec3(0.0, 0.0, 0), QT3DSVec3(0, 1, 1) }, { QT3DSVec3(0.0, -0.9, 0), QT3DSVec3(0, 0, 1) },
- { QT3DSVec3(0.9, -0.9, 0), QT3DSVec3(1, 0, 1) }, { QT3DSVec3(0.9, 0.0, 0), QT3DSVec3(1, 1, 1) }
-};
-
-#define TEXTURE_LAYER_SIZE 2
-#define TEXTURE_SIZE 64
-#define PATTERN_SIZE 0x8
-
-NVRenderTestTexture2D::NVRenderTestTexture2D()
-{
- _curTest = 0;
- _maxColumn = 4;
- _pTextureData = NULL;
-}
-
-NVRenderTestTexture2D::~NVRenderTestTexture2D()
-{
-}
-
-bool NVRenderTestTexture2D::isSupported(NVRenderContext *context)
-{
- return context->IsTextureArraySupported();
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestTexture2D::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- // alloc data
- _pTextureData = new unsigned char[TEXTURE_SIZE * TEXTURE_SIZE * 4 * TEXTURE_LAYER_SIZE];
- CreateTexData(_pTextureData);
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= texArray2DTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- if (_pTextureData)
- delete _pTextureData;
-
- return success;
-}
-
-void NVRenderTestTexture2D::CreateTexData(unsigned char *_pOutData)
-{
- if (!_pOutData)
- return;
-
- unsigned char *_pData = _pOutData;
-
- // Create a checkerboard pattern
- for (int i = 0; i < TEXTURE_LAYER_SIZE; i++) {
- for (int j = 0; j < TEXTURE_SIZE; j++) {
- for (int k = 0; k < TEXTURE_SIZE; k++) {
- unsigned char c = (((j & PATTERN_SIZE) == 0) ^ ((k & PATTERN_SIZE) == 0)) * 255;
- *_pData++ = 0x0;
- *_pData++ = c >> i;
- *_pData++ = 0x0;
- *_pData++ = 0xFF;
- }
- }
- }
-}
-
-bool NVRenderTestTexture2D::renderTexArrayQuad(NVRenderContext *context, userContextData *pUserData,
- NVRenderTexture2DArray *pTex, QT3DSU8 *vertexPositions)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestTexture2D shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- NVRenderVertexBufferEntry("attr_uv", NVRenderComponentTypes::QT3DSF32, 3, 12),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData(vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 6 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestTexture2D: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 2));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler =
- context->CreateInputAssembler(mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), NULL,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestTexture2D: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- NVRenderCachedShaderProperty<NVRenderTexture2DArray *> mArrayTexture("inTex",
- *compResult.mShader);
- mArrayTexture.Set(pTex);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestTexture2D::texArray2DTest(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // create texture
- NVScopedRefCounted<NVRenderTexture2DArray> mArrayTexture;
- mArrayTexture = context->CreateTexture2DArray();
- mArrayTexture->SetTextureData(
- NVDataRef<QT3DSU8>(_pTextureData, TEXTURE_SIZE * TEXTURE_SIZE * 4 * TEXTURE_LAYER_SIZE), 0,
- TEXTURE_SIZE, TEXTURE_SIZE, TEXTURE_LAYER_SIZE, NVRenderTextureFormats::RGBA8);
-
- success &= renderTexArrayQuad(context, pUserData, mArrayTexture, (QT3DSU8 *)vertexPositionsL0);
- success &= renderTexArrayQuad(context, pUserData, mArrayTexture, (QT3DSU8 *)vertexPositionsL1);
-
- return success;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestTexture2D::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestTexture2D::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestTexture2D.h b/tests/auto/runtime/base/Qt3DSRenderTestTexture2D.h
deleted file mode 100644
index 5c5de114..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestTexture2D.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_TEXTURE_2D_H
-#define QT3DS_RENDER_TEST_TEXTURE_2D_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- class NVRenderTexture2D;
- class NVRenderTexture2DArray;
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestTexture2D : public NVRenderTestBase
- {
- public:
- NVRenderTestTexture2D();
- ~NVRenderTestTexture2D();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool texArray2DTest(NVRenderContext *context, userContextData *pUserData);
-
- bool renderTexArrayQuad(NVRenderContext *context, userContextData *pUserData,
- NVRenderTexture2DArray *pTex, QT3DSU8 *vertexPositions);
- void CreateTexData(unsigned char *_pOutData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- unsigned char *_pTextureData;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_TEXTURE_2D_H
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.cpp b/tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.cpp
deleted file mode 100644
index bf8ff0e3..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestTimerQuery.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderTimerQuery.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330\n";
- }
-
- prog += "uniform vec3 color;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
-NVRenderTestTimerQuery::NVRenderTestTimerQuery()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestTimerQuery::~NVRenderTestTimerQuery()
-{
-}
-
-bool NVRenderTestTimerQuery::isSupported(NVRenderContext *context)
-{
- return context->IsTimerQuerySupported();
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestTimerQuery::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= timerTest(context, pUserData);
- _curTest++;
- success &= absoluteTimerTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestTimerQuery::renderQuad(NVRenderContext *context, userContextData *pUserData,
- QT3DSVec3 color)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestTimerQuery shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestTimerQuery: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler =
- context->CreateInputAssembler(mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), NULL,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestTimerQuery: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestTimerQuery::timerTest(NVRenderContext *context, userContextData *pUserData)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- QT3DSMat44 proj = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&proj, -1, 1, -1, 1, -10, 10);
- QT3DSVec3 color(1.0, 1.0, 0.0);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestTimerQuery shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestTimerQuery: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler =
- context->CreateInputAssembler(mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), NULL,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestTimerQuery: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
-
- // setup translation
- QT3DSMat44 transZ;
- NvRenderTestMatrixTranslation(&transZ, 0.0, 0.0, 0.2);
- mvp = transZ * proj;
-
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- NVScopedRefCounted<NVRenderTimerQuery> pQuery = context->CreateTimerQuery();
-
- // render 1000 quads this should take at least some amount of time
- pQuery->Begin();
- for (QT3DSI32 i = 0; i < 1000; i++) {
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
- }
- pQuery->End();
-
- // get elapsed time in nano seconds
- QT3DSU64 result = 0;
- pQuery->GetResult(&result);
- // convert to milli second
- QT3DSF64 elapsed = double(result) / 1e06;
-
- /// it should take at least a fraction of a milli second
- if (elapsed > 0.0)
- color.x = 0.0; // right
- else
- color.y = 0.0; // wrong
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- renderQuad(context, pUserData, color);
-
- return (elapsed > 0.0);
-}
-
-bool NVRenderTestTimerQuery::absoluteTimerTest(NVRenderContext *context, userContextData *pUserData)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- QT3DSMat44 proj = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&proj, -1, 1, -1, 1, -10, 10);
- QT3DSVec3 color(1.0, 1.0, 0.0);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestTimerQuery shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestTimerQuery: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler =
- context->CreateInputAssembler(mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), NULL,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestTimerQuery: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
-
- // setup translation
- QT3DSMat44 transZ;
- NvRenderTestMatrixTranslation(&transZ, 0.0, 0.0, 0.2);
- mvp = transZ * proj;
-
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- NVScopedRefCounted<NVRenderTimerQuery> pQueryStart = context->CreateTimerQuery();
- NVScopedRefCounted<NVRenderTimerQuery> pQueryEnd = context->CreateTimerQuery();
-
- // render 1000 quads this should take at least some amount of time
- pQueryStart->SetTimerQuery();
- for (QT3DSI32 i = 0; i < 1000; i++) {
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
- }
- pQueryEnd->SetTimerQuery();
-
- // get absolute time in nano seconds
- QT3DSU64 start = 0;
- pQueryStart->GetResult(&start);
- QT3DSU64 end = 0;
- pQueryEnd->GetResult(&end);
-
- // convert to milli second
- QT3DSF64 elapsed = double(end - start) / 1e06;
-
- // it should take at least a fraction of a milli second
- if (elapsed > 0.0)
- color.x = 0.0; // right
- else
- color.y = 0.0; // wrong
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- renderQuad(context, pUserData, color);
-
- return (elapsed > 0.0);
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestTimerQuery::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestTimerQuery::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.h b/tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.h
deleted file mode 100644
index 127c25fc..00000000
--- a/tests/auto/runtime/base/Qt3DSRenderTestTimerQuery.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_TIMER_QUERY_H
-#define QT3DS_RENDER_TEST_TIMER_QUERY_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- class NVRenderTimerQuery;
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestTimerQuery : public NVRenderTestBase
- {
- public:
- NVRenderTestTimerQuery();
- ~NVRenderTestTimerQuery();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool timerTest(NVRenderContext *context, userContextData *pUserData);
- bool absoluteTimerTest(NVRenderContext *context, userContextData *pUserData);
-
- bool renderQuad(NVRenderContext *context, userContextData *pUserData, QT3DSVec3 color);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_TIMER_QUERY_H
diff --git a/tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.cpp b/tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.cpp
deleted file mode 100644
index 15035b43..00000000
--- a/tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.cpp
+++ /dev/null
@@ -1,636 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestComputeShader.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderImageTexture.h"
-#include "render/Qt3DSRenderStorageBuffer.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *vertTexShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "in vec2 attr_uv; // texture coord\n"
- "out vec2 varTexCoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- " varTexCoord = attr_uv;\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform vec3 color;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragTexShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform sampler2D inTex;\n"
- "in vec2 varTexCoord;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = texture(inTex, varTexCoord);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *computeShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_ARB_compute_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n"
- "#extension GL_ARB_compute_shader : enable\n";
- }
-
- prog += "// Set workgroup layout;\n"
- "layout (local_size_x =16, local_size_y = 16) in;\n\n"
- "void main()\n"
- "{\n"
- " // do nothing\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *computeWorkShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_ARB_compute_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n"
- "precision mediump image2D;\n";
- } else {
- prog += "#version 430\n"
- "#extension GL_ARB_compute_shader : enable\n";
- }
-
- prog += "// Set workgroup layout;\n"
- "layout (local_size_x = 32, local_size_y = 32) in;\n\n"
- "layout (rgba8, binding = 2) uniform image2D outputImage;\n\n"
- "void main()\n"
- "{\n"
- " imageStore( outputImage, ivec2(gl_GlobalInvocationID.xy), vec4( "
- "vec2(gl_LocalInvocationID.xy) / vec2(gl_WorkGroupSize.xy), 0.0, 1.0 ) );\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *computeStorageShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_ARB_compute_shader : enable\n"
- "#extension GL_ARB_shader_storage_buffer_object : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n"
- "#extension GL_ARB_compute_shader : enable\n"
- "#extension GL_ARB_shader_storage_buffer_object : enable\n";
- }
-
- prog += "layout( std140, binding=4 ) buffer Pos\n"
- "{\n"
- " vec4 Positions[ ]; // array of positions\n"
- "};\n"
- "// Set workgroup layout;\n"
- "layout (local_size_x = 32, local_size_y = 1) in;\n\n"
- "void main()\n"
- "{\n"
- " uint gid = gl_GlobalInvocationID.x;\n"
- " if ( gid < uint(1000) ) {\n"
- " Positions[gid].x = float(gl_GlobalInvocationID.x);\n"
- " }\n"
- "}\n";
-
- return prog.c_str();
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
- QT3DSVec2 texCoord;
-};
-
-NVRenderTestComputeShader::NVRenderTestComputeShader()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestComputeShader::~NVRenderTestComputeShader()
-{
-}
-
-bool NVRenderTestComputeShader::isSupported(NVRenderContext *context)
-{
- return context->IsComputeSupported();
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestComputeShader::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
-
- context->SetRenderTarget(NULL);
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= computeCompile(context, pUserData);
- _curTest++;
- success &= computeWorkgroup(context, pUserData);
- _curTest++;
- success &= computeStorage(context, pUserData);
- _curTest++;
-
- return success;
-}
-
-bool NVRenderTestComputeShader::computeCompile(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.0, 0.9, 0), QT3DSVec2(0, 0) } };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestComputeShader shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 5 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestComputeShader: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestComputeShader: Failed to create input assembler";
- return false;
- }
-
- // create a compute shader which does nothing just as a compile check
- std::string computeProg;
- NVRenderVertFragCompilationResult computeResult = context->CompileComputeSource(
- "Compute nothing shader", toRef(computeShader(computeProg, isGLESContext(context))));
-
- if (!computeResult.mShader) {
- color.x = 1.0;
- color.y = 0.0;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
- if (computeResult.mShader)
- computeResult.mShader->release();
-
- return true;
-}
-
-#define WORKGROUP_SIZE 32
-
-bool NVRenderTestComputeShader::computeWorkgroup(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = {
- { QT3DSVec3(-0.9, -0.9, 0), QT3DSVec2(0, 0) }, { QT3DSVec3(0.9, 0.9, 0), QT3DSVec2(1, 1) },
- { QT3DSVec3(-0.9, 0.9, 0), QT3DSVec2(0, 1) }, { QT3DSVec3(-0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.9, -0.9, 0), QT3DSVec2(1, 0) }, { QT3DSVec3(0.9, 0.9, 0), QT3DSVec2(1, 1) }
- };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- // create texture
- NVScopedRefCounted<NVRenderTexture2D> mColorTexture;
- mColorTexture = context->CreateTexture2D();
- mColorTexture->SetTextureStorage(1, pUserData->winWidth, pUserData->winHeight,
- NVRenderTextureFormats::RGBA8);
- // create a image buffer wrapper
- NVScopedRefCounted<NVRenderImage2D> mColorImage;
- mColorImage = context->CreateImage2D(mColorTexture, NVRenderImageAccessType::Write);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestComputeShader shader", toRef(vertTexShader(vtxProg, isGLESContext(context))),
- toRef(fragTexShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- NVRenderVertexBufferEntry("attr_uv", NVRenderComponentTypes::QT3DSF32, 2, 12),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 5 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestComputeShader: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 2));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestComputeShader: Failed to create input assembler";
- return false;
- }
-
- // create a compute shader which outputs the workgroups as color codes
- std::string computeProg;
- NVRenderVertFragCompilationResult computeResult = context->CompileComputeSource(
- "Compute workgroup shader", toRef(computeWorkShader(computeProg, isGLESContext(context))));
-
- if (!computeResult.mShader) {
- qWarning() << "NVRenderTestComputeShader: Failed to create compute shader";
- return false;
- }
-
- // set program
- context->SetActiveShader(computeResult.mShader);
- NVRenderCachedShaderProperty<NVRenderImage2D *> mOutputImage("outputImage",
- *computeResult.mShader);
- mOutputImage.Set(mColorImage);
- // run compute shader
- context->DispatchCompute(computeResult.mShader, pUserData->winWidth / WORKGROUP_SIZE,
- pUserData->winHeight / WORKGROUP_SIZE, 1);
- NVRenderBufferBarrierFlags flags(NVRenderBufferBarrierValues::ShaderImageAccess);
- // sync
- context->SetMemoryBarrier(flags);
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
- // set texture
- NVRenderCachedShaderProperty<NVRenderTexture2D *> mInputImage("inTex", *compResult.mShader);
- mInputImage.Set(mColorTexture);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 6, 0);
-
- context->SetActiveShader(0);
-
- compResult.mShader->release();
- if (computeResult.mShader)
- computeResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestComputeShader::computeStorage(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.0, 0.9, 0), QT3DSVec2(0, 0) } };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create vertex buffer for compute shader usage
- NVScopedRefCounted<NVRenderVertexBuffer> mComputeVertexBuffer;
- QT3DSF32 *storageData = new QT3DSF32[1000 * 4]; // vec 4 in shader program
- NVDataRef<QT3DSU8> storData((QT3DSU8 *)storageData, 1000 * sizeof(QT3DSF32) * 4);
- mComputeVertexBuffer = context->CreateVertexBuffer(
- NVRenderBufferUsageType::Static, 1000 * sizeof(QT3DSF32) * 4, sizeof(QT3DSF32), storData);
- if (!mComputeVertexBuffer) {
- qWarning() << "NVRenderTestComputeShader: Failed to create compute vertex buffer";
- return false;
- }
- // create storage wrapper for vertex buffer
- NVScopedRefCounted<NVRenderStorageBuffer> mComputeStorageBuffer;
- mComputeStorageBuffer =
- context->CreateStorageBuffer("Pos", NVRenderBufferUsageType::Static,
- 1000 * sizeof(QT3DSF32) * 4, storData, mComputeVertexBuffer.mPtr);
- if (!mComputeStorageBuffer) {
- qWarning() << "NVRenderTestComputeShader: Failed to create compute storage buffer";
- return false;
- }
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestComputeShader shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 5 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestComputeShader: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestComputeShader: Failed to create input assembler";
- return false;
- }
-
- // create a compute shader which places id's into the buffer
- std::string computeProg;
- NVRenderVertFragCompilationResult computeResult = context->CompileComputeSource(
- "Compute storage shader", toRef(computeStorageShader(computeProg, isGLESContext(context))));
-
- if (!computeResult.mShader) {
- qWarning() << "NVRenderTestComputeShader: Failed to create compute shader";
- return false;
- }
-
- // set and run compute program
- context->SetActiveShader(computeResult.mShader);
- qt3ds::render::NVRenderCachedShaderBuffer<NVRenderShaderStorageBuffer *> storageBuffer(
- "Pos", *computeResult.mShader);
- storageBuffer.Set();
- // run compute shader
- context->DispatchCompute(computeResult.mShader, 1024 / WORKGROUP_SIZE, 1, 1);
- NVRenderBufferBarrierFlags flags(NVRenderBufferBarrierValues::ShaderStorage
- | NVRenderBufferBarrierValues::VertexAttribArray);
- // sync
- context->SetMemoryBarrier(flags);
-
- // check content
- bool contentOK = true;
- mComputeVertexBuffer->Bind();
- NVDataRef<QT3DSU8> pData = mComputeVertexBuffer->MapBuffer();
- QT3DSF32 *fData = (QT3DSF32 *)pData.begin();
- QT3DSU32 size = pData.size() / 4;
- for (QT3DSU32 i = 0, k = 0; i < size; i += 4, k++) {
- if (fData[i] != (float)k)
- contentOK = false;
- }
-
- mComputeVertexBuffer->UnmapBuffer();
-
- if (!contentOK) {
- color.x = 1.0;
- color.y = 0.0;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
- if (computeResult.mShader)
- computeResult.mShader->release();
-
- delete storageData;
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestComputeShader::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestComputeShader::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.h b/tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.h
deleted file mode 100644
index 826fb9c7..00000000
--- a/tests/auto/runtime/compute/Qt3DSRenderTestComputeShader.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_COMPUTE_SHADER_H
-#define QT3DS_RENDER_TEST_COMPUTE_SHADER_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestComputeShader : public NVRenderTestBase
- {
- public:
- NVRenderTestComputeShader();
- ~NVRenderTestComputeShader();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool computeCompile(NVRenderContext *context, userContextData *pUserData);
- bool computeWorkgroup(NVRenderContext *context, userContextData *pUserData);
- bool computeStorage(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif
diff --git a/tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.cpp b/tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.cpp
deleted file mode 100644
index 400cfc51..00000000
--- a/tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestFboMsaa.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *PassthroughVertShader()
-{
- return "uniform mat4 mat_mvp;\n"
- "attribute vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-}
-
-static const char *SimpleFragShader()
-{
- return "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "uniform vec3 color;\n"
- "void main()\n"
- "{\n"
- "gl_FragColor = vec4( color, 1.0);\n"
- "}\n";
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) },
- { QT3DSVec3(0.0, 0.9, 0) } };
-
-NVRenderTestFboMsaa::NVRenderTestFboMsaa()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestFboMsaa::~NVRenderTestFboMsaa()
-{
-}
-
-bool NVRenderTestFboMsaa::isSupported(NVRenderContext *context)
-{
- NVRenderContextType ctxType = context->GetRenderContextType();
- NVRenderContextType nonSupportedFlags(NVRenderContextValues::GL2 | NVRenderContextValues::GLES2
- | NVRenderContextValues::GLES3);
-
- // This is currently only supported on >= GL3 && >= GLES 3.1
- if ((ctxType & nonSupportedFlags))
- return false;
-
- return true;
-}
-
-bool NVRenderTestFboMsaa::run(NVRenderContext *context, userContextData *pUserData)
-{
- if (!setupResolveFbo(context, pUserData))
- return false;
-
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetRenderTarget(NULL);
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= simpleMsaaTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestFboMsaa::renderTriangle(NVRenderContext *context, QT3DSVec3 color)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- NVRenderVertFragCompilationResult compResult =
- context->CompileSource("NVRenderTestBackendQuery shader", toRef(PassthroughVertShader()),
- toRef(SimpleFragShader()));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestFboMsaa: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestFboMsaa: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestFboMsaa::setupResolveFbo(NVRenderContext *context, userContextData *pUserData)
-{
- // color texture
- m_ResolveColorTexture = context->CreateTexture2D();
- m_ResolveColorTexture->SetTextureData(NVDataRef<QT3DSU8>(), 0, pUserData->winWidth,
- pUserData->winHeight, NVRenderTextureFormats::RGBA8);
- // depth texture
- m_ResolveDepthTexture = context->CreateTexture2D();
- m_ResolveDepthTexture->SetTextureData(NVDataRef<QT3DSU8>(), 0, pUserData->winWidth,
- pUserData->winHeight, NVRenderTextureFormats::Depth24);
- // create resolve FBO
- m_ResolveFbo = context->CreateFrameBuffer();
- m_ResolveFbo->Attach(NVRenderFrameBufferAttachments::Color0,
- NVRenderTextureOrRenderBuffer(*m_ResolveColorTexture));
- m_ResolveFbo->Attach(NVRenderFrameBufferAttachments::Depth,
- NVRenderTextureOrRenderBuffer(*m_ResolveDepthTexture));
-
- return m_ResolveFbo->IsComplete();
-}
-
-bool NVRenderTestFboMsaa::simpleMsaaTest(NVRenderContext *context, userContextData *pUserData)
-{
- // create a multisampled FBO
- NVScopedRefCounted<NVRenderFrameBuffer> msFBO;
- NVScopedRefCounted<NVRenderTexture2D> msColorTexture;
- NVScopedRefCounted<NVRenderTexture2D> msDepth24Texture;
-
- msColorTexture = context->CreateTexture2D();
- msColorTexture->SetTextureDataMultisample(4, pUserData->winWidth, pUserData->winHeight,
- NVRenderTextureFormats::RGBA8);
- msDepth24Texture = context->CreateTexture2D();
- msDepth24Texture->SetTextureDataMultisample(4, pUserData->winWidth, pUserData->winHeight,
- NVRenderTextureFormats::Depth24);
-
- msFBO = context->CreateFrameBuffer();
- msFBO->Attach(NVRenderFrameBufferAttachments::Color0,
- NVRenderTextureOrRenderBuffer(*msColorTexture),
- NVRenderTextureTargetType::Texture2D_MS);
- msFBO->Attach(NVRenderFrameBufferAttachments::Depth,
- NVRenderTextureOrRenderBuffer(*msDepth24Texture),
- NVRenderTextureTargetType::Texture2D_MS);
-
- if (!msFBO->IsComplete())
- return false;
-
- // clear and draw to multisampled buffer
- context->SetRenderTarget(msFBO);
- context->SetMultisampleEnabled(true);
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
- renderTriangle(context, qt3ds::QT3DSVec3(0.0, 1.0, 0.0));
- context->SetMultisampleEnabled(false);
-
- // do resolve blit
- // first we must setup the render target
- context->SetRenderTarget(m_ResolveFbo);
- // second setup read target
- context->SetReadTarget(msFBO);
- context->SetReadBuffer(NVReadFaces::Color0);
-
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- context->BlitFramebuffer(0, 0, pUserData->winWidth, pUserData->winHeight, 0, 0,
- pUserData->winWidth, pUserData->winHeight, NVRenderClearValues::Color,
- NVRenderTextureMagnifyingOp::Nearest);
-
- // copy to default buffer
- // first we must setup the render target
- context->SetRenderTarget(NULL);
- // second setup read target
- context->SetReadTarget(m_ResolveFbo);
- context->SetReadBuffer(NVReadFaces::Color0);
-
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- context->BlitFramebuffer(0, 0, pUserData->winWidth, pUserData->winHeight, 0, 0,
- pUserData->winWidth, pUserData->winHeight, NVRenderClearValues::Color,
- NVRenderTextureMagnifyingOp::Nearest);
-
- context->SetReadTarget(NULL);
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestFboMsaa::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestFboMsaa::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- m_ResolveColorTexture->release();
- m_ResolveDepthTexture->release();
- m_ResolveFbo->release();
-
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- context->SetRenderTarget(NULL);
-}
diff --git a/tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.h b/tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.h
deleted file mode 100644
index bf9ed842..00000000
--- a/tests/auto/runtime/fbo/Qt3DSRenderTestFboMsaa.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_FBO_MSAA_H
-#define QT3DS_RENDER_TEST_FBO_MSAA_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestFboMsaa : public NVRenderTestBase
- {
- public:
- NVRenderTestFboMsaa();
- ~NVRenderTestFboMsaa();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool setupResolveFbo(NVRenderContext *context, userContextData *pUserData);
- bool renderTriangle(NVRenderContext *context, QT3DSVec3 color);
-
- // tests
- bool simpleMsaaTest(NVRenderContext *context, userContextData *pUserData);
-
- NVScopedRefCounted<NVRenderFrameBuffer> m_ResolveFbo;
- NVScopedRefCounted<NVRenderTexture2D> m_ResolveColorTexture;
- NVScopedRefCounted<NVRenderTexture2D> m_ResolveDepthTexture;
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_FBO_MSAA_H
diff --git a/tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.cpp b/tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.cpp
deleted file mode 100644
index 1a1c34c5..00000000
--- a/tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.cpp
+++ /dev/null
@@ -1,390 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestGeometryShader.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderImageTexture.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform vec3 color;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *geometryShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_EXT_geometry_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- // pass through shader
- prog += "layout (triangles) in;\n"
- "layout (triangle_strip, max_vertices = 3) out;\n"
- "void main()\n"
- "{\n"
- " int i;\n"
- " for(i=0; i<gl_in.length(); i++)\n"
- " {\n"
- " gl_Position = gl_in[i].gl_Position;\n"
- " EmitVertex();\n"
- " }\n"
- " EndPrimitive();\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *wireframeShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_EXT_geometry_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 430\n";
- }
-
- // convert to wireframe
- prog += "layout (triangles) in;\n"
- "layout (line_strip, max_vertices = 4) out;\n"
- "void main()\n"
- "{\n"
- " int i;\n"
- " for(i=0; i<gl_in.length(); i++)\n"
- " {\n"
- " gl_Position = gl_in[i].gl_Position;\n"
- " EmitVertex();\n"
- " }\n"
- " gl_Position = gl_in[0].gl_Position;\n"
- " EmitVertex();\n"
- " EndPrimitive();\n"
- "}\n";
-
- return prog.c_str();
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
- QT3DSVec2 texCoord;
-};
-
-NVRenderTestGeometryShader::NVRenderTestGeometryShader()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestGeometryShader::~NVRenderTestGeometryShader()
-{
-}
-
-bool NVRenderTestGeometryShader::isSupported(NVRenderContext *context)
-{
- return context->IsGeometryStageSupported();
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestGeometryShader::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
-
- context->SetRenderTarget(NULL);
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= geometryCompile(context, pUserData);
- _curTest++;
- success &= wireframe(context, pUserData);
- _curTest++;
-
- return success;
-}
-
-bool NVRenderTestGeometryShader::geometryCompile(NVRenderContext *context,
- userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.0, 0.9, 0), QT3DSVec2(0, 0) } };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestGeometryShader shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 5 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestGeometryShader: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestGeometryShader: Failed to create input assembler";
- return false;
- }
-
- // create a geometry shader which does nothing just as a compile check
- std::string geomProg;
- std::string vtxProgDummy;
- std::string frgProgDummy;
- NVRenderVertFragCompilationResult geomResult = context->CompileSource(
- "NVRenderTestGeometryShader shader",
- toRef(vertShader(vtxProgDummy, isGLESContext(context))),
- toRef(fragShader(frgProgDummy, isGLESContext(context))), NVConstDataRef<QT3DSI8>(),
- NVConstDataRef<QT3DSI8>(), toRef(geometryShader(geomProg, isGLESContext(context))));
-
- if (!geomResult.mShader) {
- color.x = 1.0;
- color.y = 0.0;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
- if (geomResult.mShader)
- geomResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestGeometryShader::wireframe(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.9, -0.9, 0), QT3DSVec2(0, 0) },
- { QT3DSVec3(0.0, 0.9, 0), QT3DSVec2(0, 0) } };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- // geometry shader converts primitives from triangles to lines
- std::string vtxProg;
- std::string frgProg;
- std::string geomProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestGeometryShader shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))), NVConstDataRef<QT3DSI8>(),
- NVConstDataRef<QT3DSI8>(), toRef(wireframeShader(geomProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 5 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestGeometryShader: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Triangles);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestGeometryShader: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestGeometryShader::runPerformance(NVRenderContext *context,
- userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestGeometryShader::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.h b/tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.h
deleted file mode 100644
index 139a7e26..00000000
--- a/tests/auto/runtime/geometry/Qt3DSRenderTestGeometryShader.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_GEOMETRY_SHADER_H
-#define QT3DS_RENDER_TEST_GEOMETRY_SHADER_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestGeometryShader : public NVRenderTestBase
- {
- public:
- NVRenderTestGeometryShader();
- ~NVRenderTestGeometryShader();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool geometryCompile(NVRenderContext *context, userContextData *pUserData);
- bool wireframe(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif
diff --git a/tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.cpp b/tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.cpp
deleted file mode 100644
index 1bb0b160..00000000
--- a/tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.cpp
+++ /dev/null
@@ -1,367 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestOcclusionQuery.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderOcclusionQuery.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = mat_mvp * vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 300 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 330\n";
- }
-
- prog += "uniform vec3 color;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
-};
-
-static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, 0.9, 0) }, { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(-0.9, 0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) }, { QT3DSVec3(0.9, 0.9, 0) } };
-
-static const Vertex largeQuadPositions[] = { { QT3DSVec3(-0.7, 0.7, 0) }, { QT3DSVec3(-0.7, -0.7, 0) },
- { QT3DSVec3(0.7, -0.7, 0) }, { QT3DSVec3(-0.7, 0.7, 0) },
- { QT3DSVec3(0.7, -0.7, 0) }, { QT3DSVec3(0.7, 0.7, 0) } };
-
-static const Vertex smallQuadPositions[] = { { QT3DSVec3(-0.5, 0.5, 0) }, { QT3DSVec3(-0.5, -0.5, 0) },
- { QT3DSVec3(0.5, -0.5, 0) }, { QT3DSVec3(-0.5, 0.5, 0) },
- { QT3DSVec3(0.5, -0.5, 0) }, { QT3DSVec3(0.5, 0.5, 0) } };
-
-NVRenderTestOcclusionQuery::NVRenderTestOcclusionQuery()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestOcclusionQuery::~NVRenderTestOcclusionQuery()
-{
-}
-
-bool NVRenderTestOcclusionQuery::isSupported(NVRenderContext *context)
-{
- return context->IsSampleQuerySupported();
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestOcclusionQuery::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= occlusionPassTest(context, pUserData);
- _curTest++;
- success &= occlusionFailTest(context, pUserData);
- _curTest++;
-
- // cleanup
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-
- return success;
-}
-
-bool NVRenderTestOcclusionQuery::renderQuad(NVRenderContext *context, userContextData *pUserData,
- QT3DSVec3 color)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestOcclusionQuery shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 3 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestOcclusionQuery: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler =
- context->CreateInputAssembler(mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), NULL,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestOcclusionQuery: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-void NVRenderTestOcclusionQuery::renderPrim(NVRenderContext *context, userContextData *pUserData,
- void *pData, float zOffset, QT3DSVec3 color,
- NVRenderOcclusionQuery *pQuery)
-{
- NVScopedRefCounted<NVRenderVertexBuffer> mVB;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mIA;
- Vertex *pVtxData = (Vertex *)pData;
- QT3DSMat44 proj = QT3DSMat44::createIdentity();
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&proj, -1, 1, -1, 1, -10, 10);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestOcclusionQuery shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 6 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertDataSmall((QT3DSU8 *)pVtxData, bufSize);
- mVB = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize, 3 * sizeof(QT3DSF32),
- vertDataSmall);
- if (!mVB)
- qWarning() << "NVRenderTestOcclusionQuery: Failed to create vertex buffer";
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVB->GetStride();
- QT3DSU32 offsets = 0;
- mIA = context->CreateInputAssembler(mAttribLayout, toConstDataRef(&mVB.mPtr, 1), NULL,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1));
- if (!mVB) {
- qWarning() << "NVRenderTestOcclusionQuery: Failed to create input assembler";
- return;
- }
-
- // make input assembler active
- context->SetInputAssembler(mIA);
- // setup translation
- QT3DSMat44 transZ;
- NvRenderTestMatrixTranslation(&transZ, 0.0, 0.0, zOffset);
- mvp = transZ * proj;
-
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
-
- // start query
- if (pQuery)
- pQuery->Begin();
-
- context->Draw(NVRenderDrawMode::Triangles, 6, 0);
-
- // end query
- if (pQuery)
- pQuery->End();
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-}
-
-bool NVRenderTestOcclusionQuery::occlusionPassTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- NVScopedRefCounted<NVRenderOcclusionQuery> pQuery = context->CreateOcclusionQuery();
-
- renderPrim(context, pUserData, (void *)largeQuadPositions, 0.1, QT3DSVec3(0.0, 0.0, 1.0), NULL);
- // this quad should be covered by the previous one
- renderPrim(context, pUserData, (void *)smallQuadPositions, 0.2, QT3DSVec3(1.0, 1.0, 0.0), pQuery);
- // check visibility
- QT3DSU32 result = 0;
- pQuery->GetResult(&result);
-
- QT3DSVec3 color(0.0, 0.0, 0.0);
- if (result)
- color.x = 1.0; // wrong
- else
- color.y = 1.0; // right
-
- renderQuad(context, pUserData, color);
-
- return (result == 0);
-}
-
-bool NVRenderTestOcclusionQuery::occlusionFailTest(NVRenderContext *context,
- userContextData *pUserData)
-{
- NVScopedRefCounted<NVRenderOcclusionQuery> pQuery = context->CreateOcclusionQuery();
-
- renderPrim(context, pUserData, (void *)largeQuadPositions, 0.2, QT3DSVec3(0.0, 0.0, 1.0), NULL);
- // this quad should be visible by the previous one
- renderPrim(context, pUserData, (void *)smallQuadPositions, 0.1, QT3DSVec3(1.0, 1.0, 0.0), pQuery);
- // check visibility
- QT3DSU32 result = 0;
- pQuery->GetResult(&result);
-
- QT3DSVec3 color(0.0, 0.0, 0.0);
- if (result == 0)
- color.x = 1.0; // wrong
- else
- color.y = 1.0; // right
-
- renderQuad(context, pUserData, color);
-
- return (result == 1);
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestOcclusionQuery::runPerformance(NVRenderContext *context,
- userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestOcclusionQuery::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(0.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.h b/tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.h
deleted file mode 100644
index d540dadf..00000000
--- a/tests/auto/runtime/geometry/Qt3DSRenderTestOcclusionQuery.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_OCCLUSION_QUERY_H
-#define QT3DS_RENDER_TEST_OCCLUSION_QUERY_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- class NVRenderOcclusionQuery;
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestOcclusionQuery : public NVRenderTestBase
- {
- public:
- NVRenderTestOcclusionQuery();
- ~NVRenderTestOcclusionQuery();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool occlusionPassTest(NVRenderContext *context, userContextData *pUserData);
- bool occlusionFailTest(NVRenderContext *context, userContextData *pUserData);
-
- bool renderQuad(NVRenderContext *context, userContextData *pUserData, QT3DSVec3 color);
- void renderPrim(NVRenderContext *context, userContextData *pUserData, void *pData, float z,
- QT3DSVec3 color, NVRenderOcclusionQuery *pQuery);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_OCCLUSION_QUERY_H
diff --git a/tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.cpp b/tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.cpp
deleted file mode 100644
index f2724a4a..00000000
--- a/tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.cpp
+++ /dev/null
@@ -1,560 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "Qt3DSRenderTestTessellation.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/backends/gl/Qt3DSOpenGLUtil.h"
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-static const char *vertShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "void main()\n"
- "{\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *vertPhongShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform mat4 mat_mvp;\n"
- "in vec3 attr_pos; // Vertex pos\n"
- "in vec3 attr_norm; // normal pos\n"
- "out vec3 ctNorm; // output normal control patch\n"
- "void main()\n"
- "{\n"
- " ctNorm = attr_norm;\n"
- " gl_Position = vec4(attr_pos, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform vec3 color;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *fragPhongShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "uniform vec3 color;\n"
- "in vec3 normWorld;\n"
- "out vec4 fragColor;\n"
- "void main()\n"
- "{\n"
- " fragColor = vec4(color, 1.0);\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *tessControlShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "// number of CPs in patch\n"
- "layout (vertices = 3) out;\n"
- "uniform float tessLevelInner; // controlled by keyboard buttons\n"
- "uniform float tessLevelOuter; // controlled by keyboard buttons\n"
- "void main () {\n"
- "gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
- "// Calculate the tessellation levels\n"
- "gl_TessLevelInner[0] = tessLevelInner; // number of nested primitives to generate\n"
- "gl_TessLevelOuter[0] = tessLevelOuter; // times to subdivide first side\n"
- "gl_TessLevelOuter[1] = tessLevelOuter; // times to subdivide second side\n"
- "gl_TessLevelOuter[2] = tessLevelOuter; // times to subdivide third side\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *tessPhongControlShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog +=
- "// number of CPs in patch\n"
- "layout (vertices = 3) out;\n"
- "// phong tessellation per patch data\n"
- "struct PhongTessPatch {\n"
- " float projIJ;\n"
- " float projJK;\n"
- " float projIK;\n"
- "};\n"
- "in vec3 ctNorm[]; // control point normal\n"
- "out vec3 normObj[]; // output normal pos\n"
- "uniform float tessLevels;\n"
- "uniform float tessBlend;\n"
- "out PhongTessPatch tcTessPatch[3];\n"
- "float PIi(int i, vec3 q)\n"
- "{\n"
- " vec3 q_minus_p = q - gl_in[i].gl_Position.xyz;\n"
- " return q[gl_InvocationID] - dot(q_minus_p, ctNorm[i]) * ctNorm[i][gl_InvocationID];\n"
- "}\n"
- "void main () {\n"
- " // path through data\n"
- " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
- " normObj[gl_InvocationID] = ctNorm[gl_InvocationID];\n"
- " // compute projections separate for each xyz component\n"
- " tcTessPatch[gl_InvocationID].projIJ = PIi(0, gl_in[1].gl_Position.xyz) + PIi(1, "
- "gl_in[0].gl_Position.xyz);\n"
- " tcTessPatch[gl_InvocationID].projJK = PIi(1, gl_in[2].gl_Position.xyz) + PIi(2, "
- "gl_in[1].gl_Position.xyz);\n"
- " tcTessPatch[gl_InvocationID].projIK = PIi(2, gl_in[0].gl_Position.xyz) + PIi(0, "
- "gl_in[2].gl_Position.xyz);\n"
- " // set the tessellation levels\n"
- " gl_TessLevelInner[0] = tessLevels; // number of nested primitives to generate\n"
- " gl_TessLevelOuter[gl_InvocationID] = tessLevels; // times to subdivide first side\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *tessEvaluationShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "// triangles, quads, or isolines\n"
- "layout (triangles, equal_spacing, ccw) in;\n"
- "uniform mat4 mat_mvp;\n"
- "// gl_TessCoord is location within the patch\n"
- "// (barycentric for triangles, UV for quads)\n"
- "void main () {\n"
- "vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position; // x is one corner\n"
- "vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position; // y is the 2nd corner\n"
- "vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position; // z is the 3rd corner (ignore when "
- "using quads)\n"
- "vec4 pos = p0 + p1 + p2;\n"
- "gl_Position = mat_mvp * pos;\n"
- "}\n";
-
- return prog.c_str();
-}
-
-static const char *tessPhongEvaluationShader(std::string &prog, bool binESContext)
-{
- if (binESContext) {
- prog += "#version 310 es\n"
- "#extension GL_EXT_tessellation_shader : enable\n"
- "precision highp float;\n"
- "precision highp int;\n";
- } else {
- prog += "#version 400\n";
- }
-
- prog += "// triangles, quads, or isolines\n"
- "layout (triangles, fractional_odd_spacing, ccw) in;\n"
- "struct PhongTessPatch {\n"
- " float projIJ;\n"
- " float projJK;\n"
- " float projIK;\n"
- "};\n"
- "in vec3 normObj[]; // control point normal\n"
- "out vec3 normWorld; // output normal pos\n"
- "in PhongTessPatch tcTessPatch[];\n"
- "uniform mat4 mat_mvp;\n"
- "uniform float tessBlend;\n"
- "// gl_TessCoord is location within the patch\n"
- "// (barycentric for triangles, UV for quads)\n"
- "void main () {\n"
- " // output normal\n"
- " // pre compute square tesselation coord\n"
- " vec3 tessSquared = gl_TessCoord * gl_TessCoord;\n"
- " vec3 norm = gl_TessCoord.x * normObj[0]\n"
- " + gl_TessCoord.y * normObj[1]\n"
- " + gl_TessCoord.z * normObj[2]; // z is the 3rd corner (ignore when "
- "using quads)\n"
- " // barycentric linear position\n"
- " vec3 linearPos = gl_TessCoord.x * gl_in[0].gl_Position.xyz\n"
- " + gl_TessCoord.y * gl_in[1].gl_Position.xyz\n"
- " + gl_TessCoord.z * gl_in[2].gl_Position.xyz;\n"
- " // projective terms\n"
- " vec3 projJI = vec3(tcTessPatch[0].projIJ, tcTessPatch[1].projIJ, "
- "tcTessPatch[2].projIJ);\n"
- " vec3 projKJ = vec3(tcTessPatch[0].projJK, tcTessPatch[1].projJK, "
- "tcTessPatch[2].projJK);\n"
- " vec3 projIK = vec3(tcTessPatch[0].projIK, tcTessPatch[1].projIK, "
- "tcTessPatch[2].projIK);\n"
- " // phong interpolated position\n"
- " vec3 phongPos = tessSquared.x * gl_in[0].gl_Position.xyz\n"
- " + tessSquared.y * gl_in[1].gl_Position.xyz\n"
- " + tessSquared.z * gl_in[2].gl_Position.xyz\n"
- " + gl_TessCoord.x * gl_TessCoord.y * projJI\n"
- " + gl_TessCoord.y * gl_TessCoord.z * projKJ\n"
- " + gl_TessCoord.z * gl_TessCoord.x * projIK;\n"
- " // final position\n"
- " vec3 finalPos = (1.0-tessBlend)*linearPos + tessBlend*phongPos;\n"
- " gl_Position = mat_mvp * vec4(finalPos, 1.0);\n"
- " normWorld = norm;\n"
- "}\n";
-
- return prog.c_str();
-}
-
-struct Vertex
-{
- QT3DSVec3 positions;
- QT3DSVec3 normals;
-};
-
-NVRenderTestTessellation::NVRenderTestTessellation()
-{
- _curTest = 0;
- _maxColumn = 4;
-}
-
-NVRenderTestTessellation::~NVRenderTestTessellation()
-{
-}
-
-bool NVRenderTestTessellation::isSupported(NVRenderContext *context)
-{
- NVRenderContextType ctxType = context->GetRenderContextType();
- NVRenderContextType nonSupportedFlags(
- NVRenderContextValues::GL2 | NVRenderContextValues::GLES2 | NVRenderContextValues::GL3
- | NVRenderContextValues::GLES3 | NVRenderContextValues::GLES3PLUS);
-
- // This is currently only supported on >= GL4 && >= GLES 3.1
- if ((ctxType & nonSupportedFlags))
- return false;
-
- return true;
-}
-
-////////////////////////////////
-// test for functionality
-////////////////////////////////
-
-inline NVConstDataRef<QT3DSI8> toRef(const char *data)
-{
- size_t len = strlen(data) + 1;
- return NVConstDataRef<QT3DSI8>((const QT3DSI8 *)data, (QT3DSU32)len);
-}
-
-bool NVRenderTestTessellation::run(NVRenderContext *context, userContextData *pUserData)
-{
- bool success = true;
-
- context->SetRenderTarget(NULL);
- // conpute cell width
- _cellSize = pUserData->winWidth / _maxColumn;
-
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 1.f));
- context->Clear(NVRenderClearFlags(NVRenderClearValues::Color | NVRenderClearValues::Depth));
-
- success &= trianglePatches(context, pUserData);
- _curTest++;
- success &= phongPatches(context, pUserData);
- _curTest++;
-
- return success;
-}
-
-bool NVRenderTestTessellation::trianglePatches(NVRenderContext *context, userContextData *pUserData)
-{
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0) },
- { QT3DSVec3(0.9, -0.9, 0) },
- { QT3DSVec3(0.0, 0.9, 0) } };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&mvp, -1, 1, -1, 1, -10, 10);
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- std::string tcProg;
- std::string teProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestTessellation shader", toRef(vertShader(vtxProg, isGLESContext(context))),
- toRef(fragShader(frgProg, isGLESContext(context))),
- toRef(tessControlShader(tcProg, isGLESContext(context))),
- toRef(tessEvaluationShader(teProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 6 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestFboMsaa: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 1));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Patches, 3);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestFboMsaa: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
- // set tessellation values
- float tessLevelInner = 4.0;
- compResult.mShader->SetPropertyValue("tessLevelInner", tessLevelInner);
- float tessLevelOuter = 4.0;
- compResult.mShader->SetPropertyValue("tessLevelOuter", tessLevelOuter);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-bool NVRenderTestTessellation::phongPatches(NVRenderContext *context, userContextData *pUserData)
-{
- QT3DSVec3 n1(-1.0, 0.5, 1.0);
- n1.normalize();
- QT3DSVec3 n2(1.0, 0.5, 1.0);
- n2.normalize();
- QT3DSVec3 n3(0.0, 1.0, 1.0);
- n3.normalize();
- static const Vertex vertexPositions[] = { { QT3DSVec3(-0.9, -0.9, 0.0), n1 },
- { QT3DSVec3(0.9, -0.9, 0.0), n2 },
- { QT3DSVec3(0.0, 0.9, -0.0), n3 } };
-
- qt3ds::QT3DSVec3 color(0.0, 1.0, 0.0);
-
- NVScopedRefCounted<NVRenderVertexBuffer> mVertexBuffer;
- NVScopedRefCounted<NVRenderAttribLayout> mAttribLayout;
- NVScopedRefCounted<NVRenderInputAssembler> mInputAssembler;
- NVScopedRefCounted<NVRenderIndexBuffer> mIndexBuffer;
- QT3DSMat44 p = QT3DSMat44::createIdentity();
- QT3DSMat44 rotX = QT3DSMat44::createIdentity();
- QT3DSMat44 rotY = QT3DSMat44::createIdentity();
- QT3DSMat44 mv = QT3DSMat44::createIdentity();
- QT3DSMat44 mvp = QT3DSMat44::createIdentity();
- NvGl2DemoMatrixOrtho(&p, -1, 1, -1, 1, -10, 10);
- // NvRenderTestMatrixRotY( &rotY, 45.0 );
- // NvRenderTestMatrixRotX( &rotX, 90.0 );
- mv = rotY * rotX;
- mvp = mv * p;
-
- // create shaders
- std::string vtxProg;
- std::string frgProg;
- std::string tcProg;
- std::string teProg;
- NVRenderVertFragCompilationResult compResult = context->CompileSource(
- "NVRenderTestTessellation shader", toRef(vertPhongShader(vtxProg, isGLESContext(context))),
- toRef(fragPhongShader(frgProg, isGLESContext(context))),
- toRef(tessPhongControlShader(tcProg, isGLESContext(context))),
- toRef(tessPhongEvaluationShader(teProg, isGLESContext(context))));
- if (!compResult.mShader) {
- return false;
- }
-
- unsigned int curY = 0;
- unsigned int curX = _curTest;
- if (_curTest >= _maxColumn) {
- curY = (_curTest / _maxColumn);
- curX = (_curTest % _maxColumn);
- }
-
- // set viewport
- context->SetViewport(NVRenderRect(curX * _cellSize, curY * _cellSize, _cellSize, _cellSize));
-
- // this is the layout
- NVRenderVertexBufferEntry entries[] = {
- NVRenderVertexBufferEntry("attr_pos", NVRenderComponentTypes::QT3DSF32, 3, 0),
- NVRenderVertexBufferEntry("attr_norm", NVRenderComponentTypes::QT3DSF32, 3, 12),
- };
-
- QT3DSU32 bufSize = 3 * sizeof(Vertex);
- NVDataRef<QT3DSU8> vertData((QT3DSU8 *)vertexPositions, bufSize);
- mVertexBuffer = context->CreateVertexBuffer(NVRenderBufferUsageType::Static, bufSize,
- 6 * sizeof(QT3DSF32), vertData);
- if (!mVertexBuffer) {
- qWarning() << "NVRenderTestFboMsaa: Failed to create vertex buffer";
- return false;
- }
-
- // create our attribute layout
- mAttribLayout = context->CreateAttributeLayout(toConstDataRef(entries, 2));
- // create input Assembler
- QT3DSU32 strides = mVertexBuffer->GetStride();
- QT3DSU32 offsets = 0;
- mInputAssembler = context->CreateInputAssembler(
- mAttribLayout, toConstDataRef(&mVertexBuffer.mPtr, 1), mIndexBuffer.mPtr,
- toConstDataRef(&strides, 1), toConstDataRef(&offsets, 1), NVRenderDrawMode::Patches, 3);
- if (!mInputAssembler) {
- qWarning() << "NVRenderTestFboMsaa: Failed to create input assembler";
- return false;
- }
-
- // make input assembler active
- context->SetInputAssembler(mInputAssembler);
- // set program
- context->SetActiveShader(compResult.mShader);
- compResult.mShader->SetPropertyValue("mat_mvp", mvp);
- // set color
- compResult.mShader->SetPropertyValue("color", color);
- // set tessellation values
- float tessLevels = 8.0;
- compResult.mShader->SetPropertyValue("tessLevels", tessLevels);
- float tessBlend = 1.0;
- compResult.mShader->SetPropertyValue("tessBlend", tessBlend);
-
- context->SetDepthTestEnabled(true);
- context->SetDepthWriteEnabled(true);
-
- // draw
- context->Draw(mInputAssembler->GetPrimitiveType(), 3, 0);
-
- context->SetActiveShader(0);
- compResult.mShader->release();
-
- return true;
-}
-
-////////////////////////////////
-// performance test
-////////////////////////////////
-bool NVRenderTestTessellation::runPerformance(NVRenderContext *context, userContextData *pUserData)
-{
- return true;
-}
-
-////////////////////////////////
-// test cleanup
-////////////////////////////////
-void NVRenderTestTessellation::cleanup(NVRenderContext *context, userContextData *pUserData)
-{
- context->SetClearColor(QT3DSVec4(.0f, .0f, .0f, 0.f));
- // dummy
- context->SetViewport(NVRenderRect(0, 0, pUserData->winWidth, pUserData->winHeight));
-}
diff --git a/tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.h b/tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.h
deleted file mode 100644
index 74036969..00000000
--- a/tests/auto/runtime/geometry/Qt3DSRenderTestTessellation.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT3DS_RENDER_TEST_TESSELLATION_H
-#define QT3DS_RENDER_TEST_TESSELLATION_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
- /// This class tests the creation of all kinds of primitives
- class NVRenderTestTessellation : public NVRenderTestBase
- {
- public:
- NVRenderTestTessellation();
- ~NVRenderTestTessellation();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
- private:
- bool trianglePatches(NVRenderContext *context, userContextData *pUserData);
- bool phongPatches(NVRenderContext *context, userContextData *pUserData);
-
- unsigned int _curTest;
- unsigned int _cellSize;
- unsigned int _maxColumn;
- };
-}
-}
-
-#endif // QT3DS_RENDER_TEST_TESSELLATION_H
diff --git a/tests/auto/runtime/images/NVRenderTestAttribBuffers.png b/tests/auto/runtime/images/NVRenderTestAttribBuffers.png
deleted file mode 100644
index e0fe9463..00000000
--- a/tests/auto/runtime/images/NVRenderTestAttribBuffers.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestBackendQuery.png b/tests/auto/runtime/images/NVRenderTestBackendQuery.png
deleted file mode 100644
index 76592360..00000000
--- a/tests/auto/runtime/images/NVRenderTestBackendQuery.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestClear.png b/tests/auto/runtime/images/NVRenderTestClear.png
deleted file mode 100644
index 6e4c3191..00000000
--- a/tests/auto/runtime/images/NVRenderTestClear.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestComputeShader.png b/tests/auto/runtime/images/NVRenderTestComputeShader.png
deleted file mode 100644
index 6f08814a..00000000
--- a/tests/auto/runtime/images/NVRenderTestComputeShader.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestDrawIndirectBuffer.png b/tests/auto/runtime/images/NVRenderTestDrawIndirectBuffer.png
deleted file mode 100644
index 76592360..00000000
--- a/tests/auto/runtime/images/NVRenderTestDrawIndirectBuffer.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestFboMsaa.png b/tests/auto/runtime/images/NVRenderTestFboMsaa.png
deleted file mode 100644
index 8eab95ce..00000000
--- a/tests/auto/runtime/images/NVRenderTestFboMsaa.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestGeometryShader.png b/tests/auto/runtime/images/NVRenderTestGeometryShader.png
deleted file mode 100644
index 820534e0..00000000
--- a/tests/auto/runtime/images/NVRenderTestGeometryShader.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestOcclusionQuery.png b/tests/auto/runtime/images/NVRenderTestOcclusionQuery.png
deleted file mode 100644
index 76592360..00000000
--- a/tests/auto/runtime/images/NVRenderTestOcclusionQuery.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestProgramPipeline.png b/tests/auto/runtime/images/NVRenderTestProgramPipeline.png
deleted file mode 100644
index f868b2d7..00000000
--- a/tests/auto/runtime/images/NVRenderTestProgramPipeline.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/images/NVRenderTestTexture2D.png b/tests/auto/runtime/images/NVRenderTestTexture2D.png
deleted file mode 100644
index afde59f3..00000000
--- a/tests/auto/runtime/images/NVRenderTestTexture2D.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/runtime/runtime.pro b/tests/auto/runtime/runtime.pro
deleted file mode 100644
index 146a243f..00000000
--- a/tests/auto/runtime/runtime.pro
+++ /dev/null
@@ -1,83 +0,0 @@
-TEMPLATE = app
-CONFIG += testcase
-include($$PWD/../../../src/Runtime/ogl-runtime/commoninclude.pri)
-
-TARGET = tst_qt3dsruntime
-QT += testlib gui
-QT += quick-private
-
-RESOURCES += \
- runtime.qrc \
- $$PWD/../../../src/Runtime/ogl-runtime/testres.qrc
-
-INCLUDEPATH += \
- $$PWD/../../../src/Runtime/ogl-runtime/src/Qt3DSRuntimeRender/RendererImpl
-
-HEADERS += \
- base/Qt3DSRenderTestAtomicCounterBuffer.h \
- base/Qt3DSRenderTestAttribBuffers.h \
- base/Qt3DSRenderTestBackendQuery.h \
- base/Qt3DSRenderTestClear.h \
- base/Qt3DSRenderTestConstantBuffer.h \
- base/Qt3DSRenderTestDrawIndirectBuffer.h \
- base/Qt3DSRenderTestPrimitives.h \
- base/Qt3DSRenderTestProgramPipeline.h \
- base/Qt3DSRenderTestTexture2D.h \
- base/Qt3DSRenderTestTimerQuery.h \
- compute/Qt3DSRenderTestComputeShader.h \
- fbo/Qt3DSRenderTestFboMsaa.h \
- geometry/Qt3DSRenderTestGeometryShader.h \
- geometry/Qt3DSRenderTestOcclusionQuery.h \
- geometry/Qt3DSRenderTestTessellation.h \
- Qt3DSRenderTestBase.h \
- Qt3DSRenderTestMathUtil.h \
- tst_qt3dsruntime.h \
- shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.h \
- shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.h \
- shadergenerator/Qt3DSRenderTestEffectGenerator.h
-
-SOURCES += \
- base/Qt3DSRenderTestAtomicCounterBuffer.cpp \
- base/Qt3DSRenderTestAttribBuffers.cpp \
- base/Qt3DSRenderTestBackendQuery.cpp \
- base/Qt3DSRenderTestClear.cpp \
- base/Qt3DSRenderTestConstantBuffer.cpp \
- base/Qt3DSRenderTestDrawIndirectBuffer.cpp \
- base/Qt3DSRenderTestPrimitives.cpp \
- base/Qt3DSRenderTestProgramPipeline.cpp \
- base/Qt3DSRenderTestTexture2D.cpp \
- base/Qt3DSRenderTestTimerQuery.cpp \
- compute/Qt3DSRenderTestComputeShader.cpp \
- fbo/Qt3DSRenderTestFboMsaa.cpp \
- geometry/Qt3DSRenderTestGeometryShader.cpp \
- geometry/Qt3DSRenderTestOcclusionQuery.cpp \
- geometry/Qt3DSRenderTestTessellation.cpp \
- Qt3DSRenderTestMathUtil.cpp \
- tst_qt3dsruntime.cpp \
- Qt3DSRenderTestBase.cpp \
- shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.cpp \
- shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.cpp \
- shadergenerator/Qt3DSRenderTestEffectGenerator.cpp
-
-linux {
- BEGIN_ARCHIVE = -Wl,--whole-archive
- END_ARCHIVE = -Wl,--no-whole-archive
-}
-
-LIBS += \
- -lqt3dsopengl$$qtPlatformTargetSuffix() \
- -lqt3dsqmlstreamer$$qtPlatformTargetSuffix()
-
-ANDROID_EXTRA_LIBS = \
- libqt3dsqmlstreamer.so
-
-win32 {
- LIBS += \
- -lws2_32
-}
-
-linux {
- LIBS += \
- -ldl \
- -lEGL
-}
diff --git a/tests/auto/runtime/runtime.qrc b/tests/auto/runtime/runtime.qrc
deleted file mode 100644
index f4318f5a..00000000
--- a/tests/auto/runtime/runtime.qrc
+++ /dev/null
@@ -1,14 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>images/NVRenderTestTexture2D.png</file>
- <file>images/NVRenderTestProgramPipeline.png</file>
- <file>images/NVRenderTestAttribBuffers.png</file>
- <file>images/NVRenderTestBackendQuery.png</file>
- <file>images/NVRenderTestClear.png</file>
- <file>images/NVRenderTestComputeShader.png</file>
- <file>images/NVRenderTestDrawIndirectBuffer.png</file>
- <file>images/NVRenderTestFboMsaa.png</file>
- <file>images/NVRenderTestGeometryShader.png</file>
- <file>images/NVRenderTestOcclusionQuery.png</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.cpp b/tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.cpp
deleted file mode 100644
index 244065a3..00000000
--- a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.cpp
+++ /dev/null
@@ -1,469 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "Qt3DSRenderTestCustomMaterialGenerator.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderContext.h"
-#include "Qt3DSRenderCustomMaterialSystem.h"
-#include "Qt3DSRenderCustomMaterialRenderContext.h"
-#include "Qt3DSRenderCustomMaterialShaderGenerator.h"
-#include "Qt3DSRenderDynamicObjectSystem.h"
-#include "Qt3DSRenderDynamicObjectSystemCommands.h"
-#include "Qt3DSRenderContextCore.h"
-#include "Qt3DSTypes.h"
-#include "Qt3DSRenderRuntimeBinding.h"
-#include "Qt3DSApplication.h"
-#include "Qt3DSInputEngine.h"
-#include "foundation/FileTools.h"
-#include "Qt3DSWindowSystem.h"
-#include "Qt3DSRenderShaderCache.h"
-#include "rendererimpl/Qt3DSRendererImpl.h"
-#include "Qt3DSRenderLight.h"
-#include "Qt3DSRenderUIPLoader.h"
-#include "Qt3DSDMMetaDataTypes.h"
-
-#include <QTime>
-#include <QString>
-#include <QTextStream>
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-
-
-namespace qt3ds {
-namespace render {
-
-Qt3DSRenderTestCustomMaterialGenerator::Qt3DSRenderTestCustomMaterialGenerator()
-{
-
-}
-
-Qt3DSRenderTestCustomMaterialGenerator::~Qt3DSRenderTestCustomMaterialGenerator()
-{
-
-}
-
-
-bool Qt3DSRenderTestCustomMaterialGenerator::isSupported(NVRenderContext *context)
-{
- Q_UNUSED(context);
- return true;
-}
-
-bool Qt3DSRenderTestCustomMaterialGenerator::runPerformance(NVRenderContext *context,
- userContextData *pContextData)
-{
- Q_UNUSED(context);
- Q_UNUSED(pContextData);
- return false;
-}
-
-void Qt3DSRenderTestCustomMaterialGenerator::cleanup(NVRenderContext *context,
- userContextData *pUserData)
-{
- Q_UNUSED(context);
- Q_UNUSED(pUserData);
-}
-
-struct CustomTestParams
-{
- SRenderableObjectFlags flags;
- dynamic::SDynamicShaderProgramFlags dynamicFlags;
- QT3DSF32 opacity;
- SLayer layer;
- SLayerRenderData layerData;
- SRenderableImage *images;
- SLight light[QT3DS_MAX_NUM_LIGHTS];
- SModel model;
- SRenderSubset subset;
- SShaderDefaultMaterialKey shaderkey;
- SCustomMaterial *material;
- eastl::vector<SShaderPreprocessorFeature> features;
- Option<qt3dsdm::SMetaDataCustomMaterial> metaMaterial;
- SImage dummyImages[SShaderDefaultMaterialKeyProperties::ImageMapCount];
- eastl::vector<SRenderableImage*> renderableImages;
- qt3ds::render::Qt3DSRendererImpl *render;
- SImage iblLightProbe;
- NVRenderTexture2D *texture;
-
- CustomTestParams(Qt3DSRendererImpl &impl)
- : layerData(layer, impl)
- , images(NULL)
- , subset(impl.GetContext().GetAllocator())
- , material(NULL)
- , render(&impl)
- , texture(NULL)
- {
- }
- ~CustomTestParams()
- {
- if (texture)
- texture->release();
- }
-
- void addRenderableImage(ImageMapTypes::Enum type,
- SShaderDefaultMaterialKeyProperties::ImageMapNames name)
- {
- renderableImages.push_back(new SRenderableImage(type, dummyImages[name]));
- render->DefaultMaterialShaderKeyProperties().m_ImageMaps[name].SetEnabled(shaderkey, true);
- }
- void prepare()
- {
- for (unsigned int i = 0; i < renderableImages.size(); i++) {
- if (i == 0)
- images = renderableImages[0];
- else
- renderableImages[i-1]->m_NextImage = renderableImages[i];
- }
- }
-};
-
-struct CustomTestKey
-{
- unsigned int tessellation : 2;
- unsigned int wireframe : 1;
- unsigned int lighting: 1;
- unsigned int indirectLightmap: 1;
- unsigned int radiosityLightmap: 1;
- unsigned int shadowLightmap: 1;
- unsigned int transparency : 1;
- unsigned int refraction : 1;
- unsigned int iblprobe : 1;
- unsigned int emissiveMap : 1;
- unsigned int displacementMap : 1;
- unsigned int diffuse = 1;
- unsigned int specular = 1;
- unsigned int glossy = 1;
- unsigned int cutout = 1;
- unsigned int transmissive : 1;
- unsigned int ssao : 1;
- unsigned int ssdo : 1;
- unsigned int ssm : 1;
-
- CustomTestKey(TessModeValues::Enum tess = TessModeValues::NoTess, bool wire = false,
- bool lights = false, bool indirect = false, bool radiosity = false,
- bool shadow = false, bool trans = false, bool refract = false, bool ibl = false,
- bool emissive = false, bool disp = false, bool diff = false,
- bool spec = false, bool glo = false, bool cut = false, bool transm = false,
- bool ao = false, bool direct = false, bool shadowssm = false)
- : tessellation(tess), wireframe(wire), lighting(lights), indirectLightmap(indirect)
- , radiosityLightmap(radiosity), shadowLightmap(shadow), transparency(trans)
- , refraction(refract), iblprobe(ibl), emissiveMap(emissive), displacementMap(disp)
- , diffuse(diff), specular(spec), glossy(glo), cutout(cut), transmissive(transm)
- , ssao(ao), ssdo(direct), ssm(shadowssm)
- {
-
- }
-
- bool operator == (const CustomTestKey &other) const
- {
- uint64_t a = *(uint64_t *)this;
- uint64_t b = *(uint64_t *)&other;
- return a == b;
- }
-
- QString toString()
- {
- QString str;
- QTextStream stream(&str);
- stream << "Custom Key tessellation: " << int(tessellation);
- stream << " wireframe: " << (wireframe ? "true" : "false");
- stream << " lighting: " << (lighting ? "true" : "false");
- stream << " indirectLightmap: " << (indirectLightmap ? "true" : "false");
- stream << " radiosityLightmap: " << (radiosityLightmap ? "true" : "false");
- stream << " shadowLightmap: " << (shadowLightmap ? "true" : "false");
- stream << " transparency: " << (transparency ? "true" : "false");
- stream << " refraction: " << (refraction ? "true" : "false");
- stream << " iblprobe: " << (iblprobe ? "true" : "false");
- stream << " emissiveMap: " << (emissiveMap ? "true" : "false");
- stream << " displacementMap: " << (displacementMap ? "true" : "false");
- stream << " diffuse: " << (diffuse ? "true" : "false");
- stream << " specular: " << (specular ? "true" : "false");
- stream << " glossy: " << (glossy ? "true" : "false");
- stream << " cutout: " << (cutout ? "true" : "false");
- stream << " transmissive: " << (transmissive ? "true" : "false");
- stream << " ssao: " << (ssao ? "true" : "false");
- stream << " ssdo: " << (ssdo ? "true" : "false");
- stream << " ssm: " << (ssm ? "true" : "false");
- return str;
- }
-};
-
-#define MAX_TEST_KEY ((1llu<<20)-1)
-
-static CustomTestKey randomizeTestKey()
-{
- uint64_t v = (uint64_t(qrand()))%MAX_TEST_KEY;
- return *reinterpret_cast<CustomTestKey*>(&v);
-}
-
-CustomTestParams *generateTest(qt3ds::render::Qt3DSRendererImpl *renderImpl,
- NVRenderContext *context, CustomTestKey key, SCustomMaterial *material)
-{
- CustomTestParams *params = new CustomTestParams(*renderImpl);
- params->material = material;
- params->material->m_ShaderKeyValues = (SCustomMaterialShaderKeyFlags)0;
- params->material->m_Lightmaps = SLightmaps();
- params->material->m_DisplacementMap = NULL;
- params->material->m_EmissiveMap2 = NULL;
- params->material->m_hasTransparency = false;
- params->material->m_IblProbe = NULL;
- params->material->m_hasRefraction = false;
- switch (key.tessellation) {
- case 1:
- params->model.m_TessellationMode = TessModeValues::TessLinear;
- break;
- case 2:
- params->model.m_TessellationMode = TessModeValues::TessPhong;
- break;
- case 3:
- params->model.m_TessellationMode = TessModeValues::TessNPatch;
- break;
- default:
- params->model.m_TessellationMode = TessModeValues::NoTess;
- break;
- }
-
- renderImpl->DefaultMaterialShaderKeyProperties()
- .m_TessellationMode.SetValue(params->shaderkey, params->model.m_TessellationMode);
-
- if (key.wireframe && key.tessellation > 0) {
- params->subset.m_WireframeMode = true;
- renderImpl->DefaultMaterialShaderKeyProperties().m_WireframeMode.SetValue(
- params->shaderkey, true);
- }
-
- CRegisteredString lighting =
- renderImpl->GetContext().GetStringTable().RegisterStr("QT3DS_ENABLE_CG_LIGHTING");
- params->features.push_back(SShaderPreprocessorFeature(lighting, key.lighting));
-
- if (key.indirectLightmap) {
- params->material->m_Lightmaps.m_LightmapIndirect
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::LightmapIndirect];
- params->addRenderableImage(ImageMapTypes::LightmapIndirect,
- SShaderDefaultMaterialKeyProperties::LightmapIndirect);
- }
- if (key.radiosityLightmap) {
- params->material->m_Lightmaps.m_LightmapRadiosity
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::LightmapRadiosity];
- params->addRenderableImage(ImageMapTypes::LightmapRadiosity,
- SShaderDefaultMaterialKeyProperties::LightmapRadiosity);
- }
- if (key.shadowLightmap) {
- params->material->m_Lightmaps.m_LightmapShadow
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::LightmapShadow];
- params->addRenderableImage(ImageMapTypes::LightmapRadiosity,
- SShaderDefaultMaterialKeyProperties::LightmapShadow);
- }
-
- if (key.diffuse)
- params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::diffuse;
-
- // TODO: emissive mask doesn't work
-// if (key.emissiveMap >= 1) {
-// params->material->m_EmissiveMap2
-// = &params->dummyImages[SShaderDefaultMaterialKeyProperties::EmissiveMap];
-// params->addRenderableImage(ImageMapTypes::Emissive,
-// SShaderDefaultMaterialKeyProperties::EmissiveMap);
-// }
-
- if (key.specular)
- params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::specular;
-
- if (key.displacementMap) {
- params->material->m_DisplacementMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::DisplacementMap];
- params->material->m_DisplacementMap->m_ImageShaderName
- = renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("DisplacementMap");
- params->material->m_DisplaceAmount = 1.0f;
- params->addRenderableImage(ImageMapTypes::Displacement,
- SShaderDefaultMaterialKeyProperties::DisplacementMap);
-
- params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::displace;
- }
-
- if (key.iblprobe) {
- renderImpl->DefaultMaterialShaderKeyProperties().m_HasIbl.SetValue(
- params->shaderkey, true);
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_LIGHT_PROBE"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
-
- params->material->m_IblProbe = &params->iblLightProbe;
- params->texture = context->CreateTexture2D();
- NVRenderTextureFormats::Enum format = NVRenderTextureFormats::RGBA8;
- unsigned int data = 0;
- NVDataRef<QT3DSU8> buffer = toU8DataRef<unsigned int>(data);
- params->texture->SetTextureData(buffer, 0, 1, 1, format);
- params->iblLightProbe.m_TextureData.m_Texture = params->texture;
- } else {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_LIGHT_PROBE"));
- params->features.push_back(SShaderPreprocessorFeature(str, false));
- }
-
- // these requires calculateGlass function in material
-// if (key.transparency) {
-// params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::transparent;
-// params->material->m_hasTransparency = true;
-// }
-// if (key.refraction) {
-// params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::refraction;
-// params->material->m_hasRefraction = true;
-// }
- if (key.glossy)
- params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::glossy;
-
- if (key.cutout)
- params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::cutout;
-
- if (key.transmissive)
- params->material->m_ShaderKeyValues &= SCustomMaterialShaderKeyValues::transmissive;
-
- if (key.ssm) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_SSM"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
- if (key.ssao) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_SSAO"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
- if (key.ssdo) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_SSDO"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
-
- params->prepare();
- return params;
-}
-
-bool GenShader(IQt3DSRenderContext &qt3dsContext, CustomTestParams &params)
-{
- bool success = true;
- ICustomMaterialShaderGenerator &theMaterialGenerator(qt3dsContext.GetCustomMaterialShaderGenerator());
-
- SCustomMaterialVertexPipeline thePipeline(&qt3dsContext,
- params.model.m_TessellationMode);
-
- for (int i = 0; i < params.metaMaterial->m_CustomMaterialCommands.size(); i++) {
- dynamic::SCommand &command = *params.metaMaterial->m_CustomMaterialCommands[i];
- if (command.m_Type == dynamic::CommandTypes::Enum::BindShader) {
- dynamic::SBindShader *bindShader = static_cast<dynamic::SBindShader *>(&command);
- NVRenderShaderProgram *theProgram = theMaterialGenerator.GenerateShader(
- *params.material, params.shaderkey, thePipeline,
- toConstDataRef(params.features.data(), (QT3DSU32)params.features.size()),
- params.layerData.m_Lights, params.images,
- (params.material->m_hasTransparency || params.material->m_hasRefraction),
- "custom material pipeline-- ", bindShader->m_ShaderPath);
- if (!theProgram) {
- success = false;
- break;
- }
- }
- }
-
- return success;
-}
-
-bool Qt3DSRenderTestCustomMaterialGenerator::run(NVRenderContext *context,
- userContextData *pUserData)
-{
- Q_UNUSED(pUserData);
- bool success = true;
-
- QVector<CustomTestKey> testKeys;
- testKeys.push_back(CustomTestKey());
- testKeys.push_back(CustomTestKey(TessModeValues::TessLinear));
- testKeys.push_back(CustomTestKey(TessModeValues::TessNPatch));
- testKeys.push_back(CustomTestKey(TessModeValues::TessPhong));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true));
- testKeys.push_back(CustomTestKey(TessModeValues::NoTess, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true));
-
- while (testKeys.size() < 100) {
- CustomTestKey key = randomizeTestKey();
- if (!testKeys.contains(key))
- testKeys.push_back(key);
- }
-
- if (success) {
- CRegisteredString name = context->GetStringTable().RegisterStr("qrc:/copper.shader");
-
- metadata()->LoadMaterialXMLFile("CustomMaterial", "", "copper", "qrc:/copper.shader");
- Option<qt3dsdm::SMetaDataCustomMaterial> metaMaterial =
- metadata()->GetMaterialMetaDataBySourcePath("qrc:/copper.shader");
-
- if (metaMaterial.hasValue()) {
- qt3ds::render::IUIPLoader::CreateMaterialClassFromMetaMaterial(
- name, context->GetFoundation(),
- qt3dsRenderer()->GetQt3DSContext().GetCustomMaterialSystem(), *metaMaterial,
- context->GetStringTable());
- SCustomMaterial *material = qt3dsRenderer()->GetQt3DSContext().GetCustomMaterialSystem()
- .CreateCustomMaterial(name, qt3dsRenderer()->GetContext().GetAllocator());
-
- for (CustomTestKey key : testKeys) {
- CustomTestParams *params = generateTest(qt3dsRenderer(), context, key, material);
- params->metaMaterial = metaMaterial;
- success &= GenShader(qt3dsRenderer()->GetQt3DSContext(), *params);
- if (!success)
- qDebug () << "failing key: " << key.toString();
- delete params;
- }
- delete material;
- }
- }
-
- return success;
-}
-
-} // render
-} // qt3ds
diff --git a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.h b/tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.h
deleted file mode 100644
index 621d20f6..00000000
--- a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT3DS_RENDER_TEST_CUSTOM_MATERIAL_GENERATOR_H
-#define QT3DS_RENDER_TEST_CUSTOM_MATERIAL_GENERATOR_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
-class Qt3DSRenderTestCustomMaterialGenerator : public NVRenderTestBase
-{
-public:
- Qt3DSRenderTestCustomMaterialGenerator();
- ~Qt3DSRenderTestCustomMaterialGenerator();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
-private:
-
-};
-
-} // render
-} // qt3ds
-
-#endif
diff --git a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.cpp b/tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.cpp
deleted file mode 100644
index 1e2c07e8..00000000
--- a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "Qt3DSRenderTestDefaultMaterialGenerator.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderContext.h"
-#include "Qt3DSTypes.h"
-#include "Qt3DSRenderRuntimeBinding.h"
-#include "Qt3DSApplication.h"
-#include "Qt3DSInputEngine.h"
-#include "foundation/FileTools.h"
-#include "Qt3DSWindowSystem.h"
-#include "Qt3DSRenderContextCore.h"
-#include "Qt3DSRenderShaderCache.h"
-#include "rendererimpl/Qt3DSRendererImpl.h"
-#include "Qt3DSRenderLight.h"
-
-#include <QTime>
-
-#include <string>
-
-using namespace qt3ds;
-using namespace qt3ds::render;
-
-
-
-namespace qt3ds {
-namespace render {
-
-Qt3DSRenderTestDefaultMaterialGenerator::Qt3DSRenderTestDefaultMaterialGenerator()
-{
-
-}
-
-Qt3DSRenderTestDefaultMaterialGenerator::~Qt3DSRenderTestDefaultMaterialGenerator()
-{
-
-}
-
-
-bool Qt3DSRenderTestDefaultMaterialGenerator::isSupported(NVRenderContext *context)
-{
- Q_UNUSED(context);
- return true;
-}
-
-bool Qt3DSRenderTestDefaultMaterialGenerator::runPerformance(NVRenderContext *context,
- userContextData *pContextData)
-{
- Q_UNUSED(context);
- Q_UNUSED(pContextData);
- return false;
-}
-
-void Qt3DSRenderTestDefaultMaterialGenerator::cleanup(NVRenderContext *context,
- userContextData *pUserData)
-{
- Q_UNUSED(context);
- Q_UNUSED(pUserData);
-}
-
-
-#define MAX_TEST_KEY ((1llu<<32)-1)
-
-struct TestKey
-{
- unsigned int tessellation: 2;
- unsigned int wireframe: 1;
- unsigned int lighting: 2;
- unsigned int lights: 4;
- unsigned int indirectLightmap: 1;
- unsigned int radiosityLightmap: 1;
- unsigned int lightProbe: 2;
- unsigned int iblLightProbe: 1;
- unsigned int iblfow: 1;
- unsigned int diffuseMap: 2;
- unsigned int emissiveMap: 2;
- unsigned int specularModel: 2;
- unsigned int specularMap: 1;
- unsigned int specularReflection: 1;
- unsigned int fresnel: 1;
- unsigned int bumpmapping: 2;
- unsigned int displacementMap: 1;
- unsigned int opacityMap: 1;
- unsigned int translucencyMap: 1;
- unsigned int ssm: 1;
- unsigned int ssdo: 1;
- unsigned int ssao: 1;
-
- TestKey(TessModeValues::Enum tess = TessModeValues::NoTess, bool wire = false,
- DefaultMaterialLighting::Enum lmode = DefaultMaterialLighting::NoLighting,
- int lightCount = 0, bool indirect = false, bool radio = false, int lprobe = 0,
- bool iblProbe = false, bool iblf = false, int diffuse = 0, int emissive = 0,
- DefaultMaterialSpecularModel::Enum sModel = DefaultMaterialSpecularModel::Default,
- bool sMap = false, bool sRef = false, bool fre = false, int bump = 0,
- bool disp = false, bool opac = false, bool trans = false, bool shadow = false,
- bool ao = false, bool directOcc = false)
- : tessellation(tess), wireframe(wire), lighting(lmode), lights(lightCount)
- , indirectLightmap(indirect), radiosityLightmap(radio), lightProbe(lprobe)
- , iblLightProbe(iblProbe), iblfow(iblf), diffuseMap(diffuse), emissiveMap(emissive)
- , specularModel(sModel), specularMap(sMap), specularReflection(sRef)
- , fresnel(fre), bumpmapping(bump), displacementMap(disp), opacityMap(opac)
- , translucencyMap(trans), ssm(shadow), ssao(ao), ssdo(directOcc)
- {
-
- }
-
- bool operator == (const TestKey &other) const
- {
- return toInt() == other.toInt();
- }
-
- QString toString()
- {
- QString str;
- QTextStream stream(&str);
-
- stream << " tessellation: " << tessellation;
- stream << " wireframe: " << (wireframe ? "true" : "false");
- stream << " lighting: " << lighting;
- stream << " lights: " << lights;
- stream << " indirectLightmap: " << (indirectLightmap ? "true" : "false");
- stream << " radiosityLightmap: " << (radiosityLightmap ? "true" : "false");
- stream << " lightProbe: " << lightProbe;
- stream << " iblLightProbe: " << (iblLightProbe ? "true" : "false");
- stream << " iblfow: " << (iblfow ? "true" : "false");
- stream << " diffuseMap: " << diffuseMap;
- stream << " emissiveMap: " << emissiveMap;
- stream << " specularModel: " << specularModel;
- stream << " specularMap: " << (specularMap ? "true" : "false");
- stream << " specularReflection: " << (specularReflection ? "true" : "false");
- stream << " fresnel: " << (fresnel ? "true" : "false");
- stream << " bumpmapping: " << bumpmapping;
- stream << " displacementMap: " << (displacementMap ? "true" : "false");
- stream << " opacityMap: " << (opacityMap ? "true" : "false");
- stream << " translucencyMap: " << (translucencyMap ? "true" : "false");
- stream << " ssm: " << (ssm ? "true" : "false");
- stream << " ssdo: " << (ssdo ? "true" : "false");
- stream << " ssao: " << (ssao ? "true" : "false");
-
- return str;
- }
-
- void clampValues()
- {
- lighting = qMin(lighting, 2u);
- if (lighting == 1)
- lighting = 2;
- emissiveMap = qMin(emissiveMap, 2u);
- specularModel = qMin(specularModel, 2u);
- bumpmapping = qMin(bumpmapping, 2u);
- lightProbe = 0;
- if (!iblLightProbe)
- iblfow = 0;
- if (!tessellation)
- wireframe = 0;
- }
-
- uint64_t toInt() const
- {
- return (*(uint64_t *)this)&MAX_TEST_KEY;
- }
-};
-
-struct TestParams
-{
- SRenderableObjectFlags flags;
- NVConstDataRef<QT3DSMat44> boneGlobals;
- SRenderSubset subset;
- SDefaultMaterial material;
- SModel model;
- QT3DSMat44 viewProjection;
- SModelContext modelContext;
- SRenderableImage *images;
- SShaderDefaultMaterialKey shaderkey;
- SSubsetRenderable renderable;
- eastl::vector<SShaderPreprocessorFeature> features;
- SLight light[QT3DS_MAX_NUM_LIGHTS];
- SLayer layer;
- SLayerRenderData layerData;
- SImage dummyImages[SShaderDefaultMaterialKeyProperties::ImageMapCount];
- NVRenderTexture2D *textures[4];
- eastl::vector<SRenderableImage*> renderableImages;
- qt3ds::render::Qt3DSRendererImpl *render;
-
- TestParams(NVRenderContext *context, qt3ds::render::Qt3DSRendererImpl *renderImpl)
- : subset(context->GetAllocator())
- , modelContext(model, viewProjection)
- , images(NULL)
- , renderable(flags, QT3DSVec3(), *renderImpl, subset, material, modelContext, 1.0f, images,
- shaderkey, boneGlobals)
- , layerData(layer, *renderImpl)
- , render(renderImpl)
- {
- for (int i = 0; i < 4; ++i) {
- textures[i] = context->CreateTexture2D();
- NVRenderTextureFormats::Enum format = NVRenderTextureFormats::RGBA8;
- unsigned int data = 0;
- NVDataRef<QT3DSU8> buffer = toU8DataRef<unsigned int>(data);
- textures[i]->SetTextureData(buffer, 0, 1, 1, format);
- }
- for (int i = 0; i < SShaderDefaultMaterialKeyProperties::ImageMapCount; ++i)
- dummyImages[i].m_TextureData.m_Texture = textures[i%4];
- dummyImages[SShaderDefaultMaterialKeyProperties::DiffuseMap1].m_TextureData.
- m_TextureFlags.SetPreMultiplied(true);
- dummyImages[SShaderDefaultMaterialKeyProperties::EmissiveMap2].m_TextureData.
- m_TextureFlags.SetInvertUVCoords(true);
- }
- ~TestParams()
- {
- for (NVRenderTexture2D *tex : textures)
- tex->release();
- for (SRenderableImage *img : renderableImages)
- delete img;
- }
- void addRenderableImage(ImageMapTypes::Enum type,
- SShaderDefaultMaterialKeyProperties::ImageMapNames name)
- {
- renderableImages.push_back(new SRenderableImage(type, dummyImages[name]));
- render->DefaultMaterialShaderKeyProperties().m_ImageMaps[name].SetEnabled(shaderkey, true);
- }
- void prepare()
- {
- for (unsigned int i = 0; i < renderableImages.size(); i++) {
- if (i == 0)
- images = renderableImages[0];
- else {
- renderableImages[i-1]->m_NextImage = renderableImages[i];
- }
-
- }
- renderable.m_ShaderDescription = shaderkey;
- renderable.m_FirstImage = images;
- }
-};
-
-TestKey randomizeTestKey()
-{
- uint64_t v = (uint64_t(qrand()) << 32 | uint64_t(qrand()))&MAX_TEST_KEY;
- TestKey key = *reinterpret_cast<TestKey*>(&v);
- key.clampValues();
- return key;
-}
-
-
-TestParams *generateTest(qt3ds::render::Qt3DSRendererImpl *renderImpl,
- NVRenderContext *context, TestKey key)
-{
- // TODO: light probes
- TestParams *params = new TestParams(context, renderImpl);
-
- switch (key.tessellation) {
- case 1:
- params->model.m_TessellationMode = TessModeValues::TessLinear;
- break;
- case 2:
- params->model.m_TessellationMode = TessModeValues::TessPhong;
- break;
- case 3:
- params->model.m_TessellationMode = TessModeValues::TessNPatch;
- break;
- default:
- params->model.m_TessellationMode = TessModeValues::NoTess;
- break;
- }
-
- renderImpl->DefaultMaterialShaderKeyProperties()
- .m_TessellationMode.SetValue(params->shaderkey, params->model.m_TessellationMode);
-
- switch (key.lighting) {
- case 1:
- params->material.m_Lighting = DefaultMaterialLighting::VertexLighting;
- break;
- case 2:
- params->material.m_Lighting = DefaultMaterialLighting::FragmentLighting;
- break;
- default:
- params->material.m_Lighting = DefaultMaterialLighting::NoLighting;
- break;
- }
- if (key.lighting != 0) {
- renderImpl->DefaultMaterialShaderKeyProperties()
- .m_HasLighting.SetValue(params->shaderkey, true);
- }
-
- if (key.wireframe && key.tessellation > 0) {
- params->subset.m_WireframeMode = true;
- renderImpl->DefaultMaterialShaderKeyProperties().m_WireframeMode.SetValue(
- params->shaderkey, true);
- }
- bool castShadow = false;
- key.lights = qMin(int(key.lights), int(QT3DS_MAX_NUM_LIGHTS));
- for (unsigned int i = 0; i < key.lights; ++i) {
- params->light[i].m_LightType = static_cast<RenderLightTypes::Enum>((i%3)+1);
- if (params->light[i].m_LightType != RenderLightTypes::Directional) {
- renderImpl->DefaultMaterialShaderKeyProperties().m_LightFlags[i].SetValue(
- params->shaderkey, true);
- }
- if (params->light[i].m_LightType == RenderLightTypes::Area) {
- renderImpl->DefaultMaterialShaderKeyProperties()
- .m_LightAreaFlags[i]
- .SetValue(params->shaderkey, true);
- }
- if (params->light[i].m_LightType != RenderLightTypes::Point) {
- renderImpl->DefaultMaterialShaderKeyProperties()
- .m_LightShadowFlags[i]
- .SetValue(params->shaderkey, castShadow);
- castShadow = !castShadow;
- }
- params->layerData.m_Lights.push_back(&params->light[i]);
- }
-
- renderImpl->DefaultMaterialShaderKeyProperties().m_LightCount.SetValue(params->shaderkey,
- key.lights);
-
- // shadow lightmap is not used
- if (key.indirectLightmap) {
- params->material.m_Lightmaps.m_LightmapIndirect
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::LightmapIndirect];
- params->addRenderableImage(ImageMapTypes::LightmapIndirect,
- SShaderDefaultMaterialKeyProperties::LightmapIndirect);
- }
- if (key.radiosityLightmap) {
- params->material.m_Lightmaps.m_LightmapRadiosity
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::LightmapRadiosity];
- params->addRenderableImage(ImageMapTypes::LightmapRadiosity,
- SShaderDefaultMaterialKeyProperties::LightmapRadiosity);
- }
-
- for (unsigned int i = 0; i < key.diffuseMap; ++i) {
- params->material.m_DiffuseMaps[i]
- = &params->dummyImages[static_cast<SShaderDefaultMaterialKeyProperties::ImageMapNames>
- (SShaderDefaultMaterialKeyProperties::DiffuseMap0 + i)];
- params->addRenderableImage(ImageMapTypes::Diffuse,
- static_cast<SShaderDefaultMaterialKeyProperties::ImageMapNames>
- (SShaderDefaultMaterialKeyProperties::DiffuseMap0 + i));
- }
-
- if (key.emissiveMap >= 1) {
- params->material.m_EmissiveMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::EmissiveMap];
- params->addRenderableImage(ImageMapTypes::Emissive,
- SShaderDefaultMaterialKeyProperties::EmissiveMap);
- }
- if (key.emissiveMap == 2) {
- params->material.m_EmissiveMap2
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::EmissiveMap2];
- params->addRenderableImage(ImageMapTypes::Emissive,
- SShaderDefaultMaterialKeyProperties::EmissiveMap2);
- }
-
- switch (key.specularModel) {
- case 1:
- params->material.m_SpecularModel = DefaultMaterialSpecularModel::KGGX;
- break;
- case 2:
- params->material.m_SpecularModel = DefaultMaterialSpecularModel::KWard;
- break;
- default:
- params->material.m_SpecularModel = DefaultMaterialSpecularModel::Default;
- break;
- }
-
- if (key.specularMap) {
- params->material.m_SpecularMap =
- &params->dummyImages[SShaderDefaultMaterialKeyProperties::SpecularAmountMap];
- params->material.m_SpecularAmount = 1.0f;
- params->addRenderableImage(ImageMapTypes::SpecularAmountMap,
- SShaderDefaultMaterialKeyProperties::SpecularAmountMap);
- }
- if (key.specularReflection) {
- params->dummyImages[SShaderDefaultMaterialKeyProperties::SpecularMap].m_MappingMode
- = ImageMappingModes::Environment;
- params->material.m_SpecularAmount = 1.0f;
- params->material.m_SpecularReflection
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::SpecularMap];
- params->addRenderableImage(ImageMapTypes::Specular,
- SShaderDefaultMaterialKeyProperties::SpecularMap);
- }
- if (key.fresnel)
- params->material.m_FresnelPower = 1.0f;
-
- if (key.bumpmapping == 1) {
- params->material.m_BumpMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::BumpMap];
- params->material.m_BumpAmount = 1.0f;
- params->addRenderableImage(ImageMapTypes::Bump, SShaderDefaultMaterialKeyProperties::BumpMap);
- }
- if (key.bumpmapping == 2) {
- params->material.m_NormalMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::NormalMap];
- params->addRenderableImage(ImageMapTypes::Normal, SShaderDefaultMaterialKeyProperties::NormalMap);
- }
-
- if (key.displacementMap) {
- params->material.m_DisplacementMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::DisplacementMap];
- params->material.m_DisplaceAmount = 1.0f;
- params->addRenderableImage(ImageMapTypes::Displacement,
- SShaderDefaultMaterialKeyProperties::DisplacementMap);
- }
-
- if (key.opacityMap) {
- params->material.m_OpacityMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::OpacityMap];
- params->material.m_Opacity = 0.5f;
- params->addRenderableImage(ImageMapTypes::Opacity,
- SShaderDefaultMaterialKeyProperties::OpacityMap);
- }
-
- if (key.translucencyMap) {
- params->material.m_TranslucencyMap
- = &params->dummyImages[SShaderDefaultMaterialKeyProperties::TranslucencyMap];
- params->material.m_TranslucentFalloff = 0.1f;
- params->addRenderableImage(ImageMapTypes::Translucency,
- SShaderDefaultMaterialKeyProperties::TranslucencyMap);
- }
-
- if (key.ssm) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_SSM"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
- if (key.ssao) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_SSAO"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
- if (key.ssdo) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_SSDO"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
-
- if (key.iblLightProbe) {
- renderImpl->DefaultMaterialShaderKeyProperties().m_HasIbl.SetValue(
- params->shaderkey, true);
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_LIGHT_PROBE"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- if (key.iblfow) {
- CRegisteredString str(renderImpl->GetQt3DSContext().GetStringTable()
- .RegisterStr("QT3DS_ENABLE_IBL_FOV"));
- params->features.push_back(SShaderPreprocessorFeature(str, true));
- }
- }
-
- if (params->material.IsSpecularEnabled()) {
- renderImpl->DefaultMaterialShaderKeyProperties().m_SpecularEnabled.SetValue(
- params->shaderkey, true);
- renderImpl->DefaultMaterialShaderKeyProperties().m_SpecularModel.SetSpecularModel(
- params->shaderkey, params->material.m_SpecularModel);
- }
- if (params->material.IsFresnelEnabled()) {
- renderImpl->DefaultMaterialShaderKeyProperties().m_FresnelEnabled.SetValue(
- params->shaderkey, true);
- }
-
- params->prepare();
- return params;
-}
-
-
-
-bool Qt3DSRenderTestDefaultMaterialGenerator::run(NVRenderContext *context,
- userContextData *pUserData)
-{
- Q_UNUSED(pUserData);
- bool success = true;
-
- qsrand(QTime::currentTime().msec());
-
- QVector<TestKey> testKeys;
-
- testKeys.push_back(TestKey());
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 1));
- testKeys.push_back(TestKey(TessModeValues::TessLinear, false, DefaultMaterialLighting::FragmentLighting, 1));
- testKeys.push_back(TestKey(TessModeValues::TessNPatch, false, DefaultMaterialLighting::FragmentLighting, 1));
- testKeys.push_back(TestKey(TessModeValues::TessPhong, false, DefaultMaterialLighting::FragmentLighting, 1));
- testKeys.push_back(TestKey(TessModeValues::TessLinear, true, DefaultMaterialLighting::FragmentLighting, 1));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 6));
- // vertex lighting is not supported?
- //testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::VertexLighting, 6));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 1, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 1, true, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 2));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 3, true, true, 0, false, false, 3));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 3, true, true, 0, false, false, 1, 1));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 4, true, true, 0, false, false, 1, 2));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 4, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::KGGX, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 5, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::KWard, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 5, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 6, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 6, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 1));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 2));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 0, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 0, true, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 0, true, true, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 0, true, true, true, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 0, true, true, true, false, true));
- testKeys.push_back(TestKey(TessModeValues::NoTess, false, DefaultMaterialLighting::FragmentLighting, 2, true, true, 0, false, false, 1, 1, DefaultMaterialSpecularModel::Default, true, true, true, 0, true, true, true, true, false, true));
-
- while (testKeys.size() < 100) {
- TestKey key = randomizeTestKey();
- if (!testKeys.contains(key))
- testKeys.push_back(key);
- }
- // generated programs must be unique
- QVector<NVRenderShaderProgram *> programs;
- success = initializeQt3DSRenderer(context->format());
- if (success) {
- for (TestKey key : testKeys) {
- qDebug () << "testing key: " << key.toInt();
- TestParams *params = generateTest(qt3dsRenderer(), context, key);
-
- qt3dsRenderer()->BeginLayerRender(params->layerData);
- NVRenderShaderProgram *program
- = qt3dsRenderer()->GenerateShader(params->renderable,
- toConstDataRef(params->features.data(),
- (QT3DSU32)params->features.size()));
- if (!program) {
- success = false;
- } else {
- if (programs.contains(program)) {
- qDebug () << "Generated program is not unique vs " << testKeys[programs.indexOf(program)].toString();
- success = false;
- }
- else {
- programs.push_back(program);
- }
- }
-
- if (!success)
- qDebug () << "failing test key: " << key.toString();
-
- qt3dsRenderer()->EndLayerRender();
- delete params;
- }
- }
-
- return success;
-}
-
-} // render
-} // qt3ds
diff --git a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.h b/tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.h
deleted file mode 100644
index c1464a30..00000000
--- a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT3DS_RENDER_TEST_DEFAULT_MATERIAL_GENERATOR_H
-#define QT3DS_RENDER_TEST_DEFAULT_MATERIAL_GENERATOR_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-
-namespace qt3ds {
-namespace render {
-
-class Qt3DSRenderTestDefaultMaterialGenerator : public NVRenderTestBase
-{
-public:
- Qt3DSRenderTestDefaultMaterialGenerator();
- ~Qt3DSRenderTestDefaultMaterialGenerator();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
-private:
-
-};
-
-} // render
-} // qt3ds
-
-#endif
diff --git a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.cpp b/tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.cpp
deleted file mode 100644
index 48346e68..00000000
--- a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "Qt3DSRenderTestEffectGenerator.h"
-#include "../Qt3DSRenderTestMathUtil.h"
-#include "render/Qt3DSRenderShaderProgram.h"
-#include "render/Qt3DSRenderContext.h"
-#include "Qt3DSRenderCustomMaterialSystem.h"
-#include "Qt3DSRenderCustomMaterialRenderContext.h"
-#include "Qt3DSRenderCustomMaterialShaderGenerator.h"
-#include "Qt3DSRenderDynamicObjectSystem.h"
-#include "Qt3DSRenderDynamicObjectSystemCommands.h"
-#include "Qt3DSRenderContextCore.h"
-#include "Qt3DSTypes.h"
-#include "Qt3DSRenderRuntimeBinding.h"
-#include "Qt3DSApplication.h"
-#include "Qt3DSInputEngine.h"
-#include "foundation/FileTools.h"
-#include "Qt3DSWindowSystem.h"
-#include "Qt3DSRenderShaderCache.h"
-#include "rendererimpl/Qt3DSRendererImpl.h"
-#include "Qt3DSRenderLight.h"
-#include "Qt3DSRenderUIPLoader.h"
-#include "Qt3DSDMMetaDataTypes.h"
-
-#include <QTime>
-#include <QString>
-#include <QStringList>
-
-#include <string>
-
-using namespace qt3ds::render;
-
-namespace qt3ds {
-namespace render {
-
-Qt3DSRenderTestEffectGenerator::Qt3DSRenderTestEffectGenerator()
-{
-
-}
-
-Qt3DSRenderTestEffectGenerator::~Qt3DSRenderTestEffectGenerator()
-{
-
-}
-
-bool Qt3DSRenderTestEffectGenerator::isSupported(NVRenderContext *context)
-{
- Q_UNUSED(context);
- return true;
-}
-
-bool Qt3DSRenderTestEffectGenerator::runPerformance(NVRenderContext *context,
- userContextData *pContextData)
-{
- Q_UNUSED(context);
- Q_UNUSED(pContextData);
- return false;
-}
-
-void Qt3DSRenderTestEffectGenerator::cleanup(NVRenderContext *context,
- userContextData *pUserData)
-{
- Q_UNUSED(context);
- Q_UNUSED(pUserData);
-}
-
-bool GenShader(IQt3DSRenderContext &qt3dsContext, SEffect &effect, qt3dsdm::SMetaDataEffect *metaEffect)
-{
- bool success = true;
- for (int i = 0; i < metaEffect->m_EffectCommands.size(); i++) {
- dynamic::SCommand &command = *metaEffect->m_EffectCommands[i];
- if (command.m_Type == dynamic::CommandTypes::Enum::BindShader) {
- dynamic::SBindShader *bindShader = static_cast<dynamic::SBindShader *>(&command);
- NVRenderShaderProgram *theProgram =
- qt3dsContext.GetDynamicObjectSystem()
- .GetShaderProgram(bindShader->m_ShaderPath, bindShader->m_ShaderDefine,
- TShaderFeatureSet(), dynamic::SDynamicShaderProgramFlags())
- .first;
- if (!theProgram)
- success = false;
- }
- }
- return success;
-}
-
-bool Qt3DSRenderTestEffectGenerator::run(NVRenderContext *context, userContextData *pUserData)
-{
- Q_UNUSED(pUserData);
- bool success = true;
-
- QStringList effectFiles;
- effectFiles.append("Desaturate.effect");
- effectFiles.append("Gaussian Blur.effect");
- effectFiles.append("Sepia.effect");
- effectFiles.append("Bloom.effect");
-
- for (QString effectName : effectFiles) {
- QString qfile = "qrc:/";
- qfile.append(effectName);
- QByteArray data = qfile.toLatin1();
- const char *cname = data.data();
- CRegisteredString name = context->GetStringTable().RegisterStr(cname);
-
- metadata()->LoadEffectXMLFile("Effect", "", effectName.toLatin1().data(), cname);
- Option<qt3dsdm::SMetaDataEffect> metaEffect =
- metadata()->GetEffectMetaDataBySourcePath(cname);
-
- if (metaEffect.hasValue()) {
- qt3ds::render::IUIPLoader::CreateEffectClassFromMetaEffect(
- name, context->GetFoundation(),
- qt3dsRenderer()->GetQt3DSContext().GetEffectSystem(), *metaEffect,
- context->GetStringTable());
-
- SEffect *effect = qt3dsRenderer()->GetQt3DSContext().GetEffectSystem()
- .CreateEffectInstance(name, qt3dsRenderer()->GetContext().GetAllocator());
-
- success &= GenShader(qt3dsRenderer()->GetQt3DSContext(), *effect, &metaEffect.getValue());
- if (!success)
- qDebug () << "failed effect: " << effectName;
- delete effect;
- }
- }
-
- return success;
-}
-
-} // render
-} // qt3ds
diff --git a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.h b/tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.h
deleted file mode 100644
index 4e26cf3c..00000000
--- a/tests/auto/runtime/shadergenerator/Qt3DSRenderTestEffectGenerator.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT3DS_RENDER_TEST_EFFECT_GENERATOR_H
-#define QT3DS_RENDER_TEST_EFFECT_GENERATOR_H
-
-#include "../Qt3DSRenderTestBase.h"
-
-namespace qt3ds {
-namespace render {
-
-class Qt3DSRenderTestEffectGenerator : public NVRenderTestBase
-{
-public:
- Qt3DSRenderTestEffectGenerator();
- ~Qt3DSRenderTestEffectGenerator();
-
- bool isSupported(NVRenderContext *context);
- bool run(NVRenderContext *context, userContextData *pUserData);
- bool runPerformance(NVRenderContext *context, userContextData *pContextData);
- void cleanup(NVRenderContext *context, userContextData *pUserData);
-
-private:
-
-};
-
-} // render
-} // qt3ds
-
-#endif
diff --git a/tests/auto/runtime/tst_qt3dsruntime.cpp b/tests/auto/runtime/tst_qt3dsruntime.cpp
deleted file mode 100644
index 763529cb..00000000
--- a/tests/auto/runtime/tst_qt3dsruntime.cpp
+++ /dev/null
@@ -1,727 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "tst_qt3dsruntime.h"
-
-#include "render/Qt3DSRenderContext.h"
-#include "foundation/TrackingAllocator.h"
-#include "foundation/Qt3DSFoundation.h"
-#include "foundation/StringTable.h"
-#include "foundation/Qt3DSMat44.h"
-
-#include "base/Qt3DSRenderTestClear.h"
-#include "base/Qt3DSRenderTestPrimitives.h"
-#include "base/Qt3DSRenderTestConstantBuffer.h"
-#include "base/Qt3DSRenderTestBackendQuery.h"
-#include "base/Qt3DSRenderTestTimerQuery.h"
-#include "base/Qt3DSRenderTestTexture2D.h"
-#include "base/Qt3DSRenderTestAtomicCounterBuffer.h"
-#include "base/Qt3DSRenderTestDrawIndirectBuffer.h"
-#include "base/Qt3DSRenderTestAttribBuffers.h"
-#include "base/Qt3DSRenderTestProgramPipeline.h"
-#include "fbo/Qt3DSRenderTestFboMsaa.h"
-#include "geometry/Qt3DSRenderTestTessellation.h"
-#include "geometry/Qt3DSRenderTestGeometryShader.h"
-#include "geometry/Qt3DSRenderTestOcclusionQuery.h"
-#include "compute/Qt3DSRenderTestComputeShader.h"
-#include "shadergenerator/Qt3DSRenderTestDefaultMaterialGenerator.h"
-#include "shadergenerator/Qt3DSRenderTestCustomMaterialGenerator.h"
-#include "shadergenerator/Qt3DSRenderTestEffectGenerator.h"
-
-#include <QImage>
-#include <QOpenGLContext>
-#include <QOffscreenSurface>
-#include <QOpenGLFramebufferObject>
-#include <QOpenGLFramebufferObjectFormat>
-
-using namespace std;
-using namespace qt3ds;
-using namespace qt3ds::render;
-using namespace qt3ds::foundation;
-
-extern "C" {
-bool InitializeGL();
-}
-
-// Enable this to dump the test output into a log.txt file
-//#define DUMP_LOGFILE
-
-#ifndef EA_PLATFORM_WINDOWS
-
-#ifndef EASTL_DEBUG_BREAK
-void EASTL_DEBUG_BREAK()
-{
- return;
-}
-#endif
-
-namespace qt3ds {
-void NVAssert(const char *exp, const char *file, int line, bool *ignore)
-{
- *ignore = true;
- QString message = QString("failed: %1, file %2, line %3\n")
- .arg(exp).arg(file).arg(line);
- QFAIL(message.toLatin1().constData());
-}
-}
-#endif
-
-void messageOutput(QtMsgType type, const QMessageLogContext &context,
- const QString &msg)
-{
- Q_UNUSED(context);
- switch (type) {
- case QtDebugMsg:
- case QtInfoMsg:
- case QtWarningMsg:
- case QtCriticalMsg: {
-#ifdef DUMP_LOGFILE
- QFile file("log.txt");
- if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
- QTextStream stream(&file);
- stream << msg;
- }
- file.close();
-#endif
- } break; // swallow
- case QtFatalMsg:
- QFAIL(msg.toLocal8Bit().constData());
- }
-}
-
-void tst_qt3dsruntime::initTestCase()
-{
- qInstallMessageHandler(messageOutput);
-#ifdef DUMP_LOGFILE
- QFile file("log.txt");
- if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
- QTextStream stream(&file);
- stream << "Log file: " << QTime::currentTime().toString() << "\n";
- }
- file.close();
-#endif
-}
-
-QSurfaceFormat makeFormat(int major, int minor, bool gles = false, bool coreProfile = true)
-{
- QSurfaceFormat format;
- format.setDepthBufferSize(32);
- format.setVersion(major, minor);
- if (coreProfile)
- format.setProfile(QSurfaceFormat::CoreProfile);
- else
- format.setProfile(QSurfaceFormat::CompatibilityProfile);
- if (gles)
- format.setRenderableType(QSurfaceFormat::OpenGLES);
- return format;
-}
-
-bool tst_qt3dsruntime::init(QSurfaceFormat format)
-{
- m_glContext = new QT_PREPEND_NAMESPACE(QOpenGLContext)(this);
- m_glContext->setFormat(format);
- bool success = m_glContext->create();
- if (!success)
- return false;
-
- m_glSurface = new QOffscreenSurface;
- m_glSurface->setFormat(format);
- m_glSurface->create();
- m_glContext->makeCurrent(m_glSurface);
-
- m_allocator = new CAllocator;
- m_foundation = NVCreateFoundation(QT3DS_FOUNDATION_VERSION, *m_allocator);
- m_stringTable = &IStringTable::CreateStringTable(*m_allocator);
- m_renderContext = &NVRenderContext::CreateGL(*m_foundation, *m_stringTable, format);
- return true;
-}
-
-bool tst_qt3dsruntime::init()
-{
-#if defined(QT_OPENGL_ES_2)
- return init(makeFormat(2, 0, true, false));
-#elif defined(Q_OS_ANDROID) || defined(QT_OPENGL_ES_3)
- return init(makeFormat(3, 2, true, false));
-#else
- return init(makeFormat(4, 3));
-#endif
-}
-
-bool tst_qt3dsruntime::executeTest(NVRenderTestBase *curTest,
- const QString &testName,
- bool performPixelTest)
-{
- bool success = true;
- int width = 640;
- int height = 480;
- userContextData userData = { (unsigned int)width, (unsigned int)height };
-
- QOpenGLFramebufferObjectFormat fboFormat;
- fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
- QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(QSize(width, height), fboFormat);
-
- m_renderContext->SetDefaultRenderTarget(fbo->handle());
- m_renderContext->SetDefaultDepthBufferBitCount(m_glContext->format().depthBufferSize());
- m_renderContext->SetViewport(NVRenderRect(0, 0, userData.winWidth, userData.winHeight));
-
- success = curTest->run(m_renderContext, &userData);
-
- if (performPixelTest) {
- QImage image = fbo->toImage();
- QImage refImage(QString(":/images/%1.png").arg(testName));
- refImage = refImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- if (!refImage.isNull()) {
- bool pixelTest = image == refImage;
- success &= pixelTest;
- if (!pixelTest)
- image.save(QString("%1_failed.png").arg(testName));
- }
- }
-
- curTest->cleanup(m_renderContext, &userData);
-
- return success;
-}
-
-void tst_qt3dsruntime::testNVRenderTestClear()
-{
- init();
- NVRenderTestClear *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestClear);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestClear");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestPrimitives()
-{
- init();
- NVRenderTestPrimitives *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestPrimitives);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestPrimitives");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestConstantBuffer()
-{
- init();
- NVRenderTestConstantBuffer *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestConstantBuffer);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestConstantBuffer");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestBackendQuery()
-{
- init();
- NVRenderTestBackendQuery *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestBackendQuery);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestBackendQuery", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestTimerQuery()
-{
- init();
- NVRenderTestTimerQuery *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestTimerQuery);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestTimerQuery");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestFboMsaa()
-{
- init();
- NVRenderTestFboMsaa *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestFboMsaa);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestFboMsaa", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestTessellation()
-{
- init();
- NVRenderTestTessellation *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestTessellation);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestTessellation");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestGeometryShader()
-{
- init();
- NVRenderTestGeometryShader *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestGeometryShader);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestGeometryShader");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestComputeShader()
-{
- init();
- NVRenderTestComputeShader *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestComputeShader);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestComputeShader", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestOcclusionQuery()
-{
- init();
- NVRenderTestOcclusionQuery *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestOcclusionQuery);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestOcclusionQuery", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestTexture2D()
-{
- init();
- NVRenderTestTexture2D *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestTexture2D);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestTexture2D", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestAtomicCounterBuffer()
-{
- init();
- NVRenderTestAtomicCounterBuffer *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestAtomicCounterBuffer);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- bool success = executeTest(test, "NVRenderTestAtomicCounterBuffer");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestDrawIndirectBuffer()
-{
- init();
- NVRenderTestDrawIndirectBuffer *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestDrawIndirectBuffer);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestDrawIndirectBuffer", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestAttribBuffers()
-{
- init();
- NVRenderTestAttribBuffers *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestAttribBuffers);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestAttribBuffers", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testNVRenderTestProgramPipeline()
-{
- init();
- NVRenderTestProgramPipeline *test =
- QT3DS_NEW(m_foundation->getAllocator(), NVRenderTestProgramPipeline);
- if (!test->isSupported(m_renderContext)) {
- QT3DS_FREE(m_foundation->getAllocator(), test);
- QSKIP("not supported");
- }
- // TODO: Fix BOUL-332 to re-enable this pixel test
- bool success = executeTest(test, "NVRenderTestProgramPipeline", false);
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-#if defined(QT_OPENGL_ES_2)
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_200es()
-{
- if (init(makeFormat(2, 0, true, false))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_200es()
-{
- runCustomShaderGeneratorTest(makeFormat(2, 0, true, false));
- cleanup();
-}
-#endif
-
-#if defined(QT_OPENGL_ES_3)
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_300es()
-{
- if (init(makeFormat(3, 0, true, false))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_300es()
-{
- runCustomShaderGeneratorTest(makeFormat(3, 0, true, false));
- cleanup();
-}
-
-#if defined(QT_FEATURE_opengles31)
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_310es()
-{
- if (init(makeFormat(3, 1, true, false))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_310es()
-{
- runCustomShaderGeneratorTest(makeFormat(3, 1, true, false));
- cleanup();
-}
-#endif
-#if defined(QT_FEATURE_opengles32)
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_320es()
-{
- if (init(makeFormat(3, 1, true, false))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_320es()
-{
- runCustomShaderGeneratorTest(makeFormat(3, 1, true, false));
- cleanup();
-}
-
-#endif
-#endif
-
-#if defined(QT_OPENGL_DYNAMIC)
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_300()
-{
- QSKIP("OpenGL 3.0 is not supported");
- if (init(makeFormat(3, 0))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_310()
-{
- if (init(makeFormat(3, 1))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_320()
-{
- if (init(makeFormat(3, 2))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_330()
-{
- if (init(makeFormat(3, 3))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_400()
-{
- if (init(makeFormat(4, 0))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_410()
-{
- if (init(makeFormat(4, 1))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_420()
-{
- if (init(makeFormat(4, 2))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderDefaultShaderGenerator_430()
-{
- if (init(makeFormat(4, 3))) {
- runDefaultShaderGeneratorTest();
- cleanup();
- }
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_300()
-{
- QSKIP("OpenGL 3.0 is not supported");
- runCustomShaderGeneratorTest(makeFormat(3, 0));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_310()
-{
- runCustomShaderGeneratorTest(makeFormat(3, 1));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_320()
-{
- runCustomShaderGeneratorTest(makeFormat(3, 2));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_330()
-{
- runCustomShaderGeneratorTest(makeFormat(3, 3));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_400()
-{
- runCustomShaderGeneratorTest(makeFormat(4, 0));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_410()
-{
- runCustomShaderGeneratorTest(makeFormat(4, 1));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_420()
-{
- runCustomShaderGeneratorTest(makeFormat(4, 2));
-}
-
-void tst_qt3dsruntime::testRenderCustomShaderGenerator_430()
-{
- runCustomShaderGeneratorTest(makeFormat(4, 3));
-}
-
-#endif
-
-void tst_qt3dsruntime::runDefaultShaderGeneratorTest()
-{
- Qt3DSRenderTestDefaultMaterialGenerator *test =
- QT3DS_NEW(m_foundation->getAllocator(), Qt3DSRenderTestDefaultMaterialGenerator);
- if (!test->isSupported(m_renderContext))
- QSKIP("not supported");
- bool success = executeTest(test, "Qt3DSRenderTestDefaultMaterialGenerator");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
-}
-
-void tst_qt3dsruntime::runCustomShaderGeneratorTest(QSurfaceFormat format)
-{
- m_glContext = new QT_PREPEND_NAMESPACE(QOpenGLContext)(this);
- m_glContext->setFormat(format);
- bool success = m_glContext->create();
- if (!success)
- return;
-
- m_glSurface = new QOffscreenSurface;
- m_glSurface->setFormat(format);
- m_glSurface->create();
- m_glContext->makeCurrent(m_glSurface);
-
- m_allocator = new CAllocator;
- m_foundation = NVCreateFoundation(QT3DS_FOUNDATION_VERSION, *m_allocator);
-
- Qt3DSRenderTestCustomMaterialGenerator *test =
- QT3DS_NEW(m_foundation->getAllocator(), Qt3DSRenderTestCustomMaterialGenerator);
-
- test->initializeQt3DSRenderer(format);
- m_renderContext = &NVRenderContext::CreateGL(*m_foundation, test->qt3dsRenderer()->GetContext()
- .GetStringTable(), format);
-
- if (!test->isSupported(m_renderContext))
- QSKIP("not supported");
- success = executeTest(test, "Qt3DSRenderTestCusromMaterialGenerator");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::testRenderEffectGenerator()
-{
- QSurfaceFormat format = makeFormat(4, 3);
- m_glContext = new QT_PREPEND_NAMESPACE(QOpenGLContext)(this);
- m_glContext->setFormat(format);
- bool success = m_glContext->create();
- if (!success)
- return;
-
- m_glSurface = new QOffscreenSurface;
- m_glSurface->setFormat(format);
- m_glSurface->create();
- m_glContext->makeCurrent(m_glSurface);
-
- m_allocator = new CAllocator;
- m_foundation = NVCreateFoundation(QT3DS_FOUNDATION_VERSION, *m_allocator);
-
- Qt3DSRenderTestEffectGenerator *test =
- QT3DS_NEW(m_foundation->getAllocator(), Qt3DSRenderTestEffectGenerator);
-
- test->initializeQt3DSRenderer(format);
- m_renderContext = &NVRenderContext::CreateGL(*m_foundation, test->qt3dsRenderer()->GetContext()
- .GetStringTable(), format);
-
- if (!test->isSupported(m_renderContext))
- QSKIP("not supported");
- success = executeTest(test, "Qt3DSRenderTestEffectGenerator");
- QT3DS_FREE(m_foundation->getAllocator(), test);
- test = 0;
- QVERIFY(success);
- cleanup();
-}
-
-void tst_qt3dsruntime::cleanup()
-{
- if (m_renderContext)
- m_renderContext->release();
- if (m_foundation)
- m_foundation->release();
-
- m_renderContext = 0;
- m_stringTable = 0;
- m_foundation = 0;
-
- delete m_allocator;
- m_allocator = 0;
-
- m_glSurface->destroy();
- delete m_glSurface;
- m_glSurface = 0;
-
- delete m_glContext;
- m_glContext = 0;
-}
-
-QTEST_MAIN(tst_qt3dsruntime)
diff --git a/tests/auto/runtime/tst_qt3dsruntime.h b/tests/auto/runtime/tst_qt3dsruntime.h
deleted file mode 100644
index 1f5b943e..00000000
--- a/tests/auto/runtime/tst_qt3dsruntime.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TST_QT3DSRUNTIME
-#define TST_QT3DSRUNTIME
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-
-namespace qt3ds {
-class NVFoundation;
-namespace foundation {
-class CAllocator;
-class IStringTable;
-}
-namespace render {
-class NVRenderContext;
-class NVRenderTestBase;
-}
-}
-
-QT_BEGIN_NAMESPACE
-class QOpenGLContext;
-class QOffscreenSurface;
-QT_END_NAMESPACE
-
-class tst_qt3dsruntime : public QObject
-{
- Q_OBJECT
-public:
- tst_qt3dsruntime()
- : m_allocator(0)
- , m_foundation(0)
- , m_stringTable(0)
- , m_renderContext(0)
- , m_glContext(0)
- , m_glSurface(0)
- {
- }
-
-private Q_SLOTS:
- void initTestCase();
-
- void testNVRenderTestClear();
- void testNVRenderTestPrimitives();
- void testNVRenderTestConstantBuffer();
- void testNVRenderTestBackendQuery();
- void testNVRenderTestTimerQuery();
- void testNVRenderTestFboMsaa();
- void testNVRenderTestTessellation();
- void testNVRenderTestGeometryShader();
- void testNVRenderTestComputeShader();
- void testNVRenderTestOcclusionQuery();
- void testNVRenderTestTexture2D();
- void testNVRenderTestAtomicCounterBuffer();
- void testNVRenderTestDrawIndirectBuffer();
- void testNVRenderTestAttribBuffers();
- void testNVRenderTestProgramPipeline();
-
- void testRenderEffectGenerator();
-
-#if defined(QT_OPENGL_ES_2)
- void testRenderDefaultShaderGenerator_200es();
- void testRenderCustomShaderGenerator_200es();
-#endif
-#if defined(QT_OPENGL_ES_3)
- void testRenderDefaultShaderGenerator_300es();
- void testRenderCustomShaderGenerator_300es();
-#if defined(QT_FEATURE_opengles31)
- void testRenderDefaultShaderGenerator_310es();
- void testRenderCustomShaderGenerator_310es();
-#endif
-#if defined(QT_FEATURE_opengles32)
- void testRenderDefaultShaderGenerator_320es();
- void testRenderCustomShaderGenerator_320es();
-#endif
-#endif
-
-#if defined(QT_OPENGL_DYNAMIC)
- void testRenderDefaultShaderGenerator_300();
- void testRenderDefaultShaderGenerator_310();
- void testRenderDefaultShaderGenerator_320();
- void testRenderDefaultShaderGenerator_330();
- void testRenderDefaultShaderGenerator_400();
- void testRenderDefaultShaderGenerator_410();
- void testRenderDefaultShaderGenerator_420();
- void testRenderDefaultShaderGenerator_430();
-
- void testRenderCustomShaderGenerator_300();
- void testRenderCustomShaderGenerator_310();
- void testRenderCustomShaderGenerator_320();
- void testRenderCustomShaderGenerator_330();
- void testRenderCustomShaderGenerator_400();
- void testRenderCustomShaderGenerator_410();
- void testRenderCustomShaderGenerator_420();
- void testRenderCustomShaderGenerator_430();
-#endif
-
-
-
-private:
- bool executeTest(qt3ds::render::NVRenderTestBase *curTest,
- const QString &testName, bool peformPixelTest = true);
- bool init(QSurfaceFormat format);
- bool init();
- void runDefaultShaderGeneratorTest();
- void runCustomShaderGeneratorTest(QSurfaceFormat format);
- void cleanup();
-
- qt3ds::foundation::CAllocator *m_allocator;
- qt3ds::NVFoundation *m_foundation;
- qt3ds::foundation::IStringTable *m_stringTable;
- qt3ds::render::NVRenderContext *m_renderContext;
- QOpenGLContext *m_glContext;
- QOffscreenSurface *m_glSurface;
-};
-
-#endif // TST_QT3DSRUNTIME
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/q3dssurfaceviewer.pro b/tests/auto/studio3d/q3dssurfaceviewer/q3dssurfaceviewer.pro
deleted file mode 100644
index 7da6bf77..00000000
--- a/tests/auto/studio3d/q3dssurfaceviewer/q3dssurfaceviewer.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = app
-CONFIG += testcase
-
-TARGET = tst_q3dssurfaceviewer
-
-QT += testlib studio3d
-
-SOURCES += tst_q3dssurfaceviewer.cpp
-
-RESOURCES += ../shared/shared_presentations.qrc
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
deleted file mode 100644
index 786ef3a3..00000000
--- a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
+++ /dev/null
@@ -1,1516 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtStudio3D/q3dssurfaceviewer.h>
-#include <QtStudio3D/q3dsviewersettings.h>
-#include <QtStudio3D/q3dspresentation.h>
-#include <QtStudio3D/q3dssceneelement.h>
-#include <QtStudio3D/q3dselement.h>
-#include <QtStudio3D/q3dsdatainput.h>
-#include <QtGui/qwindow.h>
-#include <QtGui/qopenglcontext.h>
-#include <QtGui/qoffscreensurface.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qimage.h>
-#include <QtGui/qscreen.h>
-#include <QtGui/qopenglframebufferobject.h>
-#include <QtGui/qevent.h>
-#include <QtCore/qurl.h>
-#include <QtCore/qfile.h>
-#include "../shared/shared_presentations.h"
-
-class tst_Q3DSSurfaceViewer : public QObject
-{
- Q_OBJECT
-public:
- tst_Q3DSSurfaceViewer();
- ~tst_Q3DSSurfaceViewer() {}
-
-private slots:
- void initTestCase();
- void init();
- void cleanup();
-
- void testBasics_data();
- void testBasics();
- void testSourceChange_data();
- void testSourceChange();
- void testSizeChange_data();
- void testSizeChange();
- void testUpdateInterval_data();
- void testUpdateInterval();
- void testMultiple_data();
- void testMultiple();
- void testGrab_data();
- void testGrab();
- void testReset_data();
- void testReset();
- void testSettings_data();
- void testSettings();
- void testPresentation_data();
- void testPresentation();
- void testPresentationActivation_data();
- void testPresentationActivation();
- void testSceneElement_data();
- void testSceneElement();
- void testElement_data();
- void testElement();
- void testMouseInput_data();
- void testMouseInput();
- void testDataInput_data();
- void testDataInput();
-
-private:
- QWindow *createWindow(const QSize &size);
- QOffscreenSurface *createOffscreen();
- QOpenGLFramebufferObject *createFbo(const QSize &size);
-
- // Created viewers are returned via *&viewer parameter rather than return value, so that we can
- // use QCOMPARE and QVERIFY inside these functions (they require void return value).
- void createViewer(Q3DSSurfaceViewer *&viewer, QSurface *surface, const QUrl &url,
- bool autoSize, const QSize &size, int updateInterval, int fboId);
- void createWindowAndViewer(Q3DSSurfaceViewer *&viewer, const QUrl &url = RED,
- bool autoSize = true, const QSize &size = QSize(),
- int updateInterval = 0);
- void createOffscreenAndViewer(Q3DSSurfaceViewer *&viewer, const QUrl &url = RED,
- const QSize &size = QSize(), int updateInterval = 0);
- void checkPixel(Q3DSSurfaceViewer *viewer, const QColor &color,
- const QPoint &pixel = QPoint(50, 50));
-
- QWindow *m_window;
- QOffscreenSurface *m_surface;
- Q3DSSurfaceViewer *m_viewer;
- QSurfaceFormat m_format;
- QOpenGLContext *m_context;
- QOpenGLFramebufferObject *m_fbo;
-};
-
-tst_Q3DSSurfaceViewer::tst_Q3DSSurfaceViewer()
- : m_window(nullptr)
- , m_surface(nullptr)
- , m_viewer(nullptr)
- , m_context(nullptr)
- , m_fbo(nullptr)
-{
-}
-
-//#define DUMP_LOGFILE // Uncomment log Qt 3D Studio internal messages to log.txt file
-void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
-{
- Q_UNUSED(context);
- switch (type) {
- // case QtDebugMsg:
- case QtInfoMsg:
- case QtWarningMsg:
- case QtCriticalMsg: {
-#ifdef DUMP_LOGFILE
- QFile file("log.txt");
- if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
- QTextStream stream(&file);
- stream << msg << "\n";
- }
- file.close();
-#endif
- } break; // swallow
- case QtFatalMsg:
- QFAIL(msg.toLocal8Bit().constData());
- }
-}
-
-void tst_Q3DSSurfaceViewer::initTestCase()
-{
- qInstallMessageHandler(messageOutput);
-#ifdef DUMP_LOGFILE
- QFile file("log.txt");
- if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
- QTextStream stream(&file);
- stream << "Log file: " << QTime::currentTime().toString() << "\n";
- }
- file.close();
-#endif
-
- QWindow *dummy = createWindow(QSize(100, 100));
- m_format = dummy->format();
- qDebug() << m_format;
- delete dummy;
-}
-
-void tst_Q3DSSurfaceViewer::init()
-{
- m_context = new QOpenGLContext();
- m_context->setFormat(m_format);
- m_context->create();
-}
-
-void tst_Q3DSSurfaceViewer::cleanup()
-{
- if (m_window)
- m_window->close();
-
- delete m_viewer;
- m_viewer = nullptr;
-
- delete m_window;
- m_window = nullptr;
-
- delete m_surface;
- m_surface = nullptr;
-
- delete m_fbo;
- m_fbo = nullptr;
-
- delete m_context;
- m_context = nullptr;
-}
-
-QWindow *tst_Q3DSSurfaceViewer::createWindow(const QSize &size)
-{
- QWindow *window = new QWindow();
-
- window->resize(size);
- window->setSurfaceType(QSurface::OpenGLSurface);
- window->setFormat(m_format);
- window->setTitle(QStringLiteral("Q3DSSurfaceViewer test window"));
- window->create();
-
- return window;
-}
-
-QOffscreenSurface *tst_Q3DSSurfaceViewer::createOffscreen()
-{
- QOffscreenSurface *surface = new QOffscreenSurface();
- surface->setFormat(m_format);
- surface->create();
-
- return surface;
-}
-
-QOpenGLFramebufferObject *tst_Q3DSSurfaceViewer::createFbo(const QSize &size)
-{
- QOpenGLFramebufferObjectFormat fboFormat;
- fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
- return new QOpenGLFramebufferObject(size, fboFormat);
-}
-
-void tst_Q3DSSurfaceViewer::createViewer(Q3DSSurfaceViewer *&viewer, QSurface *surface,
- const QUrl &url, bool autoSize, const QSize &size,
- int updateInterval, int fboId)
-{
- viewer = new Q3DSSurfaceViewer();
- QSignalSpy spy(viewer, &Q3DSSurfaceViewer::runningChanged);
-
- viewer->presentation()->setSource(url);
- QCOMPARE(viewer->presentation()->source(), url);
-
- QVERIFY(spy.isValid());
- QCOMPARE(spy.count(), 0);
-
- viewer->setAutoSize(autoSize);
- if (!autoSize)
- viewer->setSize(size);
- viewer->setUpdateInterval(updateInterval);
-
- QVERIFY(viewer->create(surface, m_context, fboId));
-
- QCOMPARE(spy.count(), 1);
- QVERIFY(viewer->isRunning());
-
- QVERIFY(viewer->fboId() == fboId);
- QVERIFY(viewer->surface() == surface);
- QVERIFY(viewer->context() == m_context);
-}
-
-void tst_Q3DSSurfaceViewer::createWindowAndViewer(Q3DSSurfaceViewer *&viewer,
- const QUrl &url, bool autoSize,
- const QSize &size, int updateInterval)
-{
- QSize actualSize = size;
- if (actualSize.isEmpty())
- actualSize = QSize(300, 200);
-
- m_window = createWindow(actualSize);
-
- createViewer(viewer, m_window, url, autoSize, actualSize, updateInterval, 0);
-
- m_window->show();
- QGuiApplication::processEvents();
-}
-
-void tst_Q3DSSurfaceViewer::createOffscreenAndViewer(Q3DSSurfaceViewer *&viewer,
- const QUrl &url, const QSize &size,
- int updateInterval)
-{
- QSize actualSize = size;
- if (actualSize.isEmpty())
- actualSize = QSize(300, 200);
-
- m_surface = createOffscreen();
- m_context->makeCurrent(m_surface);
- m_fbo = createFbo(actualSize);
-
- createViewer(viewer, m_surface, url, false, actualSize, updateInterval, m_fbo->handle());
-}
-
-void tst_Q3DSSurfaceViewer::checkPixel(Q3DSSurfaceViewer *viewer, const QColor &color,
- const QPoint &pixel)
-{
- // Grab operation is potentially costly, so retry only every second instead of using
- // QTRY_COMPARE which would try it every 50ms. We also want to wait first as it takes some time
- // for the presentation to be displayed.
- QColor grabColor;
- for (int i = 0; i < 20; i++) {
- // Note: If checkpixel is ever changed to not have this wait, some
- // QGuiApplication::processEvents() calls may be necessary in various test cases to
- // ensure expected signaling order.
- QTest::qWait(1000);
- QImage image = viewer->grab(QRect(pixel, QSize(1, 1)));
- grabColor = QColor(image.pixel(0, 0));
- if (grabColor == color)
- break;
- }
- QCOMPARE(grabColor, color);
-}
-
-void tst_Q3DSSurfaceViewer::testBasics_data()
-{
- QTest::addColumn<bool>("isWindow");
- QTest::newRow("window") << true;
- QTest::newRow("offscreen") << false;
-}
-
-void tst_Q3DSSurfaceViewer::testBasics()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, RED);
- else
- createOffscreenAndViewer(m_viewer, RED);
-
- QSignalSpy spy(m_viewer, &Q3DSSurfaceViewer::runningChanged);
- QVERIFY(spy.isValid());
-
- checkPixel(m_viewer, Qt::red);
-
- m_viewer->destroy();
-
- QCOMPARE(spy.count(), 1);
- QVERIFY(!m_viewer->isRunning());
-}
-
-void tst_Q3DSSurfaceViewer::testSourceChange_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testSourceChange()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, RED);
- else
- createOffscreenAndViewer(m_viewer, RED);
-
- QSignalSpy spy(m_viewer->presentation(), &Q3DSPresentation::sourceChanged);
- QVERIFY(spy.isValid());
- QVERIFY(m_viewer->presentation()->source() == RED);
-
- checkPixel(m_viewer, Qt::red);
-
- // Different source
- m_viewer->presentation()->setSource(BLUE);
- QCOMPARE(spy.count(), 1);
- QVERIFY(m_viewer->presentation()->source() == BLUE);
-
- checkPixel(m_viewer, Qt::blue);
-
- // Reset same source
- m_viewer->presentation()->setSource(BLUE);
- QCOMPARE(spy.count(), 1);
- QVERIFY(m_viewer->presentation()->source() == BLUE);
-
- checkPixel(m_viewer, Qt::blue);
-
- // Different source again
- m_viewer->presentation()->setSource(RED);
- QCOMPARE(spy.count(), 2);
- QVERIFY(m_viewer->presentation()->source() == RED);
-
- checkPixel(m_viewer, Qt::red);
-}
-
-void tst_Q3DSSurfaceViewer::testSizeChange_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testSizeChange()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow) {
- createWindowAndViewer(m_viewer, MIXED, true, QSize(600, 600));
- } else {
- // Changing size for offscreen surface means recreating the fbo. There's no guarantee
- // we can get the same fbo id if we do that, so we would have to reinitialize anyway
- QSKIP("Skipping size change testing for offscreen surfaces");
- }
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QSignalSpy spy1(m_viewer, &Q3DSSurfaceViewer::sizeChanged);
- QVERIFY(spy1.isValid());
- QSignalSpy spy2(m_viewer, &Q3DSSurfaceViewer::autoSizeChanged);
- QVERIFY(spy2.isValid());
-
- QPoint leftPoint(m_viewer->size().width() * 11 / 24, m_viewer->size().height() / 2);
- QPoint rightPoint(m_viewer->size().width() * 13 / 24, m_viewer->size().height() / 2);
-
- // MIXED presentation has left side blue, right side red
- checkPixel(m_viewer, Qt::blue, leftPoint);
- checkPixel(m_viewer, Qt::red, rightPoint);
-
- m_window->resize(QSize(800, 800));
- QGuiApplication::processEvents();
- QCOMPARE(spy1.count(), 1);
-
- checkPixel(m_viewer, Qt::blue, leftPoint);
- checkPixel(m_viewer, Qt::blue, rightPoint);
-
- m_window->resize(QSize(400, 400));
- QGuiApplication::processEvents();
- QCOMPARE(spy1.count(), 2);
-
- checkPixel(m_viewer, Qt::red, leftPoint);
- checkPixel(m_viewer, Qt::red, rightPoint);
-
- m_viewer->setAutoSize(false);
- QCOMPARE(spy2.count(), 1);
-
- // Size should not change since autosize is no longer on
- m_window->resize(QSize(600, 600));
- QGuiApplication::processEvents();
- QCOMPARE(spy1.count(), 2);
-
- checkPixel(m_viewer, Qt::red, leftPoint);
- checkPixel(m_viewer, Qt::red, rightPoint);
-
- m_viewer->setSize(QSize(700, 700));
- QCOMPARE(spy1.count(), 3);
-
- checkPixel(m_viewer, Qt::blue, leftPoint);
- checkPixel(m_viewer, Qt::blue, rightPoint);
-}
-
-void tst_Q3DSSurfaceViewer::testUpdateInterval_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testUpdateInterval()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, ANIMATION);
- else
- createOffscreenAndViewer(m_viewer, ANIMATION);
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QSignalSpy spy(m_viewer, &Q3DSSurfaceViewer::updateIntervalChanged);
- QVERIFY(spy.isValid());
- QVERIFY(m_viewer->updateInterval() == 0);
-
- checkPixel(m_viewer, Qt::black);
- {
- // Grab two images two seconds apart to verify animation is happening
- QImage image1 = m_viewer->grab();
- QTest::qWait(2000);
- QImage image2 = m_viewer->grab();
- QVERIFY(image1 != image2);
-
- }
- {
- m_viewer->setUpdateInterval(100000);
- QVERIFY(m_viewer->updateInterval() == 100000);
- QCOMPARE(spy.count(), 1);
- // Can't test if animation actually stopped, as grabbing the viewer forces update on it
- }
- {
- m_viewer->setUpdateInterval(20);
- QCOMPARE(spy.count(), 2);
- QVERIFY(m_viewer->updateInterval() == 20);
-
- // Non-zero interval short enough to see animation
- QImage image1 = m_viewer->grab();
- QTest::qWait(2000);
- QImage image2 = m_viewer->grab();
- QVERIFY(image1 != image2);
- }
- {
- m_viewer->setUpdateInterval(-1);
- QCOMPARE(spy.count(), 3);
- QVERIFY(m_viewer->updateInterval() == -1);
- // Can't test if animation actually stopped, as grabbing the viewer forces update on it
- }
-}
-
-void tst_Q3DSSurfaceViewer::testMultiple_data()
-{
- QTest::addColumn<int>("windowCount");
- QTest::addColumn<int>("offscreenCount");
- QTest::newRow("windows") << 2 << 0;
- QTest::newRow("offscreens") << 0 << 2;
- QTest::newRow("mixed") << 1 << 1;
-}
-
-void tst_Q3DSSurfaceViewer::testMultiple()
-{
- QFETCH(int, windowCount);
- QFETCH(int, offscreenCount);
-
- QVector<QWindow *> windows;
- QVector<QOffscreenSurface *> surfaces;
- QVector<Q3DSSurfaceViewer *> viewers;
- QVector<QOpenGLFramebufferObject *> fbos;
-
- int viewerCount = windowCount + offscreenCount;
- windows.resize(windowCount);
- surfaces.resize(offscreenCount);
- fbos.resize(offscreenCount);
- viewers.resize(viewerCount);
-
- QSize size(200, 150);
- QUrl url;
- for (int i = 0; i < windowCount; i++) {
- windows[i] = createWindow(size);
- if (i % 2)
- url = RED;
- else
- url = BLUE;
- createViewer(viewers[i], windows[i], url, true, size, 0, 0);
- windows[i]->setPosition(10 + i * 50, 10 + i * 50);
- windows[i]->show();
- QGuiApplication::processEvents();
- }
- for (int i = 0; i < offscreenCount; i++) {
- surfaces[i] = createOffscreen();
- m_context->makeCurrent(surfaces[i]);
- fbos[i] = createFbo(size);
- if ((i + windowCount) % 2)
- url = RED;
- else
- url = BLUE;
- createViewer(viewers[i + windowCount], surfaces[i], url, false, size, 0,
- fbos[i]->handle());
- }
-
- for (int i = 0; i < viewerCount; i++) {
- if (i % 2)
- checkPixel(viewers[i], Qt::red);
- else
- checkPixel(viewers[i], Qt::blue);
- }
-
- for (QWindow *w : windows) {
- w->close();
- delete w;
- }
- windows.clear();
-
- for (QOffscreenSurface *s : surfaces)
- delete s;
- surfaces.clear();
-
- for (Q3DSSurfaceViewer *v : viewers)
- delete v;
- viewers.clear();
-
- for (QOpenGLFramebufferObject *f : fbos)
- delete f;
- fbos.clear();
-}
-
-void tst_Q3DSSurfaceViewer::testGrab_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testGrab()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, MIXED_VERTICAL);
- else
- createOffscreenAndViewer(m_viewer, MIXED_VERTICAL);
-
- // Single pixels
- int w = m_viewer->size().width();
- int h = m_viewer->size().height();
-
- checkPixel(m_viewer, Qt::blue, QPoint(w / 2, h / 4));
- checkPixel(m_viewer, Qt::red, QPoint(w / 2, 3 * h / 4));
-
- checkPixel(m_viewer, Qt::blue, QPoint(0, 0));
- checkPixel(m_viewer, Qt::blue, QPoint(w - 1, 0));
- checkPixel(m_viewer, Qt::red, QPoint(0, h - 1));
- checkPixel(m_viewer, Qt::red, QPoint(w - 1, h - 1));
-
- // Full buffer
- QImage img = m_viewer->grab();
- QColor grabColor1 = img.pixel(w / 2, h / 4);
- QColor grabColor2 = img.pixel(w / 2, 3 * h / 4);
- QCOMPARE(grabColor1, QColor(Qt::blue));
- QCOMPARE(grabColor2, QColor(Qt::red));
-
- // Partial buffer
- img = m_viewer->grab(QRect(w / 3, h / 3, w / 2, h / 2));
- grabColor1 = img.pixel(0, 0);
- grabColor2 = img.pixel(w / 2 - 1, h / 2 - 1);
- QCOMPARE(grabColor1, QColor(Qt::blue));
- QCOMPARE(grabColor2, QColor(Qt::red));
-}
-
-void tst_Q3DSSurfaceViewer::testReset_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testReset()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, RED);
- else
- createOffscreenAndViewer(m_viewer, RED);
-
- checkPixel(m_viewer, Qt::red);
-
- m_viewer->presentation()->setAttribute(QStringLiteral("Scene.Layer.Rectangle.Material"),
- QStringLiteral("diffuse.r"), QVariant(0.0));
- m_viewer->presentation()->setAttribute(QStringLiteral("Scene.Layer.Rectangle.Material"),
- QStringLiteral("diffuse.b"), QVariant(1.0));
- checkPixel(m_viewer, Qt::blue);
-
- // Note: reset() is private method now, instead can reload presentation by switching sources
- // m_viewer->reset();
- m_viewer->presentation()->setSource(ANIMATION);
- m_viewer->presentation()->setSource(RED);
-
- checkPixel(m_viewer, Qt::red);
-}
-
-void tst_Q3DSSurfaceViewer::testSettings_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testSettings()
-{
- QFETCH(bool, isWindow);
-
- int width = 500;
- int height = 500;
-
- if (isWindow)
- createWindowAndViewer(m_viewer, SETTINGS, false, QSize(width, height));
- else
- createOffscreenAndViewer(m_viewer, SETTINGS, QSize(width, height));
-
- Q3DSViewerSettings *s = m_viewer->settings();
-
- QSignalSpy spy1(s, &Q3DSViewerSettings::matteColorChanged);
- QSignalSpy spy2(s, &Q3DSViewerSettings::showRenderStatsChanged);
- QSignalSpy spy4(s, &Q3DSViewerSettings::scaleModeChanged);
- QVERIFY(spy1.isValid());
- QVERIFY(spy2.isValid());
- QVERIFY(spy4.isValid());
-
- // Check defaults
- QCOMPARE(s->matteColor(), QColor(Qt::black));
- QCOMPARE(s->isShowRenderStats(), false);
- QCOMPARE(s->scaleMode(), Q3DSViewerSettings::ScaleModeCenter);
-
- // Matte
- checkPixel(m_viewer, Qt::black);
-
- s->setMatteColor(Qt::cyan);
- QCOMPARE(s->matteColor(), QColor(Qt::cyan));
-
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 0);
- QCOMPARE(spy4.count(), 0);
-
- checkPixel(m_viewer, Qt::cyan);
-
- // Render stats
- QImage image1 = m_viewer->grab();
-
- s->setShowRenderStats(true);
- QCOMPARE(s->isShowRenderStats(), true);
-
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy4.count(), 0);
-
- QImage image2 = m_viewer->grab();
- QVERIFY(image1 != image2);
-
- s->setShowRenderStats(false);
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy4.count(), 0);
-
- // ScaleMode
- checkPixel(m_viewer, Qt::cyan);
- checkPixel(m_viewer, Qt::cyan, QPoint(50, height / 2));
- s->setScaleMode(Q3DSViewerSettings::ScaleModeFit);
- QCOMPARE(s->scaleMode(), Q3DSViewerSettings::ScaleModeFit);
-
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy4.count(), 1);
-
- checkPixel(m_viewer, Qt::cyan);
- checkPixel(m_viewer, Qt::red, QPoint(50, height / 2));
-
- s->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
- QCOMPARE(s->scaleMode(), Q3DSViewerSettings::ScaleModeFill);
-
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy4.count(), 2);
-
- checkPixel(m_viewer, Qt::blue);
- checkPixel(m_viewer, Qt::red, QPoint(50, height / 2));
-
- // Saving & loading settings
- s->save(QStringLiteral("testViewer"), QStringLiteral("The Qt Company"),
- QStringLiteral("tst_q3dsurfaceviewer"));
-
- image1 = m_viewer->grab();
-
- s->setMatteColor(Qt::yellow);
- s->setShowRenderStats(true);
- s->setScaleMode(Q3DSViewerSettings::ScaleModeFit);
-
- QCOMPARE(s->matteColor(), QColor(Qt::yellow));
- QCOMPARE(s->isShowRenderStats(), true);
- QCOMPARE(s->scaleMode(), Q3DSViewerSettings::ScaleModeFit);
-
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy2.count(), 3);
- QCOMPARE(spy4.count(), 3);
-
- image2 = m_viewer->grab();
-
- s->load(QStringLiteral("testViewer"), QStringLiteral("The Qt Company"),
- QStringLiteral("tst_q3dsurfaceviewer"));
-
- QCOMPARE(s->matteColor(), QColor(Qt::cyan));
- QCOMPARE(s->isShowRenderStats(), false);
- QCOMPARE(s->scaleMode(), Q3DSViewerSettings::ScaleModeFill);
-
- QCOMPARE(spy1.count(), 3);
- QCOMPARE(spy2.count(), 4);
- QCOMPARE(spy4.count(), 4);
-
- QImage image3 = m_viewer->grab();
- QVERIFY(image1 != image2);
- QVERIFY(image3 != image2);
- QVERIFY(image1 == image3);
-
- // Clean up the settings so they don't pollute the system (and we have clean slate next time)
- QSettings(QStringLiteral("The Qt Company"), QStringLiteral("tst_q3dsurfaceviewer")).clear();
-}
-
-void tst_Q3DSSurfaceViewer::testPresentation_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testPresentation()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, MULTISLIDE);
- else
- createOffscreenAndViewer(m_viewer, MULTISLIDE);
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QList<QVariant> args;
- Q3DSPresentation *p = m_viewer->presentation();
- QSignalSpy spy1(p, &Q3DSPresentation::slideEntered);
- QSignalSpy spy2(p, &Q3DSPresentation::slideExited);
- QVERIFY(spy1.isValid());
- QVERIFY(spy2.isValid());
-
- // There are three different "scenes":
- // The main Scene, three slides: S1, S2, S3
- // Two components on Scene.Layer:
- // Scene.Layer.Component1, two slides: C1S1, C1S2
- // Scene.Layer.Component2, two slides: C2S1, C2S2
- // The component slides also get enter when parent slide is entered, but they do not get
- // the corresponding exit if parent slide is exited.
- QString path = QStringLiteral("Scene");
- QString pathC1 = QStringLiteral("Scene.Layer.Component1");
- QString pathC2 = QStringLiteral("Scene.Layer.Component2");
- QPoint mainPoint(m_viewer->size().width() * 2 / 8, m_viewer->size().height() / 2);
- QPoint bgPoint(m_viewer->size().width() * 2 / 8, m_viewer->size().height() / 32);
- QPoint c1Point(m_viewer->size().width() * 5 / 8, m_viewer->size().height() / 2);
- QPoint c2Point(m_viewer->size().width() * 7 / 8, m_viewer->size().height() / 2);
-
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
-
- QCOMPARE(spy1.count(), 3);
- QCOMPARE(spy2.count(), 0);
-
- // String Attribute
- QImage image1 = m_viewer->grab();
- p->setAttribute(QStringLiteral("Scene.Layer.Text"),
- QStringLiteral("textstring"), QStringLiteral("Test!"));
- QImage image2 = m_viewer->grab();
- QTRY_VERIFY(image1 != image2);
-
- // Float Attribute
- p->setAttribute(QStringLiteral("Scene.Layer.Rect.Material"),
- QStringLiteral("diffuse.r"), 0.0);
- p->setAttribute(QStringLiteral("Scene.Layer.Rect.Material"),
- QStringLiteral("diffuse.g"), 1.0);
- p->setAttribute(QStringLiteral("Scene.Layer.Rect.Material"),
- QStringLiteral("diffuse.b"), 1.0);
-
- checkPixel(m_viewer, Qt::cyan, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
-
- p->setAttribute(QStringLiteral("Scene.Layer.Rect.Material"),
- QStringLiteral("diffuse.r"), 1.0);
- p->setAttribute(QStringLiteral("Scene.Layer.Rect.Material"),
- QStringLiteral("diffuse.g"), 0.0);
- p->setAttribute(QStringLiteral("Scene.Layer.Rect.Material"),
- QStringLiteral("diffuse.b"), 0.0);
-
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
-
- // Bool Attribute
- checkPixel(m_viewer, Qt::yellow, bgPoint);
- p->setAttribute(QStringLiteral("Scene"), QStringLiteral("bgcolorenable"), false);
- checkPixel(m_viewer, Qt::black, bgPoint);
-
- // Slide changes
- p->goToSlide(path, 2);
- checkPixel(m_viewer, Qt::blue, mainPoint);
- checkPixel(m_viewer, Qt::blue, c1Point);
- checkPixel(m_viewer, Qt::blue, c2Point);
-
- QCOMPARE(spy1.count(), 4);
- QCOMPARE(spy2.count(), 1);
- args = spy1.last();
- QCOMPARE(args.at(0).toString(), path);
- QCOMPARE(args.at(1).toInt(), 2);
- QCOMPARE(args.at(2).toString(), QStringLiteral("S2"));
- args = spy2.last();
- QCOMPARE(args.at(0).toString(), path);
- QCOMPARE(args.at(1).toInt(), 1);
- QCOMPARE(args.at(2).toString(), QStringLiteral("S1"));
-
- // Time change
- p->goToTime(path, 7.0f);
- checkPixel(m_viewer, Qt::black, mainPoint);
- QCOMPARE(spy1.count(), 4);
- QCOMPARE(spy2.count(), 1);
-
- // More complex slide changes
- // Changing slide that is not visible should not trigger enter signals
- // The slides should still change, though, and become visible later when we switch back to S1
- p->goToSlide(pathC1, QStringLiteral("C1S2"));
- p->goToSlide(pathC2, QStringLiteral("C2S2"));
- QCOMPARE(spy1.count(), 4);
- QCOMPARE(spy2.count(), 1);
-
- p->goToSlide(path, QStringLiteral("S1"));
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::cyan, c1Point);
- checkPixel(m_viewer, Qt::magenta, c2Point);
- QCOMPARE(spy1.count(), 7);
- QCOMPARE(spy2.count(), 2);
-
- p->goToSlide(pathC1, QStringLiteral("C1S1"));
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::magenta, c2Point);
- QCOMPARE(spy1.count(), 8);
- QCOMPARE(spy2.count(), 3);
-
- args = spy1.last();
- QCOMPARE(args.at(0).toString(), pathC1);
- QCOMPARE(args.at(1).toInt(), 1);
- QCOMPARE(args.at(2).toString(), QStringLiteral("C1S1"));
- args = spy2.last();
- QCOMPARE(args.at(0).toString(), pathC1);
- QCOMPARE(args.at(1).toInt(), 2);
- QCOMPARE(args.at(2).toString(), QStringLiteral("C1S2"));
-
- p->goToSlide(pathC2, QStringLiteral("C2S1"));
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
- QCOMPARE(spy1.count(), 9);
- QCOMPARE(spy2.count(), 4);
-
- args = spy1.last();
- QCOMPARE(args.at(0).toString(), pathC2);
- QCOMPARE(args.at(1).toInt(), 1);
- QCOMPARE(args.at(2).toString(), QStringLiteral("C2S1"));
- args = spy2.last();
- QCOMPARE(args.at(0).toString(), pathC2);
- QCOMPARE(args.at(1).toInt(), 2);
- QCOMPARE(args.at(2).toString(), QStringLiteral("C2S2"));
-
- p->goToSlide(path, true, true);
- checkPixel(m_viewer, Qt::blue, mainPoint);
- checkPixel(m_viewer, Qt::blue, c1Point);
- checkPixel(m_viewer, Qt::blue, c2Point);
- QCOMPARE(spy1.count(), 10);
- QCOMPARE(spy2.count(), 5);
-
- args = spy1.last();
- QCOMPARE(args.at(0).toString(), path);
- QCOMPARE(args.at(1).toInt(), 2);
- QCOMPARE(args.at(2).toString(), QStringLiteral("S2"));
- args = spy2.last();
- QCOMPARE(args.at(0).toString(), path);
- QCOMPARE(args.at(1).toInt(), 1);
- QCOMPARE(args.at(2).toString(), QStringLiteral("S1"));
-
- p->goToSlide(path, false, true);
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
- QCOMPARE(spy1.count(), 13);
- QCOMPARE(spy2.count(), 6);
-
- // No wrap, should not change
- p->goToSlide(path, false, false);
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
- QCOMPARE(spy1.count(), 13);
- QCOMPARE(spy2.count(), 6);
-
- // Should wrap
- p->goToSlide(path, false, true);
- checkPixel(m_viewer, Qt::green, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::green, c2Point);
- QCOMPARE(spy1.count(), 14);
- QCOMPARE(spy2.count(), 7);
-
- // No wrap, should not change
- p->goToSlide(path, true, false);
- checkPixel(m_viewer, Qt::green, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::green, c2Point);
- QCOMPARE(spy1.count(), 14);
- QCOMPARE(spy2.count(), 7);
-
- // Should wrap
- p->goToSlide(path, true, true);
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
- QCOMPARE(spy1.count(), 17);
- QCOMPARE(spy2.count(), 8);
-}
-
-void tst_Q3DSSurfaceViewer::testPresentationActivation_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testPresentationActivation()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, ANIMATION);
- else
- createOffscreenAndViewer(m_viewer, ANIMATION);
-
- // Note: Presentation filename isn't default ID anymore, need to set manually.
- m_viewer->setPresentationId(QStringLiteral("animation"));
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- {
- // Grab two images two seconds apart to verify animation is happening
- QImage image1 = m_viewer->grab();
- QTest::qWait(2000);
- QImage image2 = m_viewer->grab();
- QVERIFY(image1 != image2);
- }
-
- m_viewer->presentation()->setPresentationActive(QStringLiteral("animation"), false);
-
- {
- // Grab two images two seconds apart to verify animation has stopped
- QImage image1 = m_viewer->grab();
- QTest::qWait(2000);
- QImage image2 = m_viewer->grab();
- QVERIFY(image1 == image2);
- }
-
- m_viewer->presentation()->setPresentationActive(QStringLiteral("animation"), true);
-
- {
- // Grab two images two seconds apart to verify animation is happening
- QImage image1 = m_viewer->grab();
- QTest::qWait(2000);
- QImage image2 = m_viewer->grab();
- QVERIFY(image1 != image2);
- }
-}
-
-void tst_Q3DSSurfaceViewer::testSceneElement_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testSceneElement()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, MULTISLIDE);
- else
- createOffscreenAndViewer(m_viewer, MULTISLIDE);
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QString path = QStringLiteral("Scene");
- QString pathC1 = QStringLiteral("Scene.Layer.Component1");
- QString pathC2 = QStringLiteral("Scene.Layer.Component2");
-
- Q3DSPresentation *p = m_viewer->presentation();
- Q3DSSceneElement *scene = new Q3DSSceneElement(path);
- Q3DSSceneElement *sceneC1 = new Q3DSSceneElement(pathC1);
- Q3DSSceneElement *sceneC2 = new Q3DSSceneElement(pathC2);
- QSignalSpy spy1(scene, &Q3DSSceneElement::currentSlideIndexChanged);
- QSignalSpy spy2(scene, &Q3DSSceneElement::previousSlideIndexChanged);
- QSignalSpy spy3(scene, &Q3DSSceneElement::currentSlideNameChanged);
- QSignalSpy spy4(scene, &Q3DSSceneElement::previousSlideNameChanged);
- QSignalSpy spy5(scene, &Q3DSSceneElement::elementPathChanged);
- QSignalSpy spy6(sceneC1, &Q3DSSceneElement::currentSlideIndexChanged);
- QSignalSpy spy7(sceneC1, &Q3DSSceneElement::previousSlideIndexChanged);
- QSignalSpy spy8(sceneC1, &Q3DSSceneElement::currentSlideNameChanged);
- QSignalSpy spy9(sceneC1, &Q3DSSceneElement::previousSlideNameChanged);
- QSignalSpy spy10(sceneC1, &Q3DSSceneElement::elementPathChanged);
- QSignalSpy spy11(sceneC2, &Q3DSSceneElement::currentSlideIndexChanged);
- QSignalSpy spy12(sceneC2, &Q3DSSceneElement::previousSlideIndexChanged);
- QSignalSpy spy13(sceneC2, &Q3DSSceneElement::currentSlideNameChanged);
- QSignalSpy spy14(sceneC2, &Q3DSSceneElement::previousSlideNameChanged);
- QSignalSpy spy15(sceneC2, &Q3DSSceneElement::elementPathChanged);
- QVERIFY(spy1.isValid());
- QVERIFY(spy2.isValid());
- QVERIFY(spy3.isValid());
- QVERIFY(spy4.isValid());
- QVERIFY(spy5.isValid());
- QVERIFY(spy6.isValid());
- QVERIFY(spy7.isValid());
- QVERIFY(spy8.isValid());
- QVERIFY(spy9.isValid());
- QVERIFY(spy10.isValid());
- QVERIFY(spy11.isValid());
- QVERIFY(spy12.isValid());
- QVERIFY(spy13.isValid());
- QVERIFY(spy14.isValid());
- QVERIFY(spy15.isValid());
-
- // Defaults
- QCOMPARE(scene->currentSlideIndex(), 0);
- QCOMPARE(scene->previousSlideIndex(), 0);
- QCOMPARE(scene->currentSlideName(), QStringLiteral(""));
- QCOMPARE(scene->previousSlideName(), QStringLiteral(""));
- QCOMPARE(scene->elementPath(), path);
-
- checkPixel(m_viewer, Qt::red);
-
- // Ensure we have no pending events to confuse spy counts
- QGuiApplication::processEvents();
-
- p->registerElement(scene);
- p->registerElement(sceneC1);
- p->registerElement(sceneC2);
-
- QCOMPARE(scene->currentSlideIndex(), 1);
- QCOMPARE(scene->previousSlideIndex(), 0);
- QCOMPARE(scene->currentSlideName(), QStringLiteral("S1"));
- QCOMPARE(scene->previousSlideName(), QStringLiteral(""));
- QCOMPARE(scene->elementPath(), path);
-
- p->goToSlide(path, QStringLiteral("S2"));
- checkPixel(m_viewer, Qt::blue);
-
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy3.count(), 1);
- QCOMPARE(spy4.count(), 1);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 0);
- QCOMPARE(spy7.count(), 0);
- QCOMPARE(spy8.count(), 0);
- QCOMPARE(spy9.count(), 0);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 0);
- QCOMPARE(spy12.count(), 0);
- QCOMPARE(spy13.count(), 0);
- QCOMPARE(spy14.count(), 0);
- QCOMPARE(spy15.count(), 0);
-
- p->goToSlide(path, QStringLiteral("S1"));
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 0);
- // Getting previous slide change without getting current slide change seems illogical here,
- // but that's how the internal viewer logic for previous slide works. It makes sense when
- // you consider the fact that we always get enter events for child slides when parent slide
- // is entered.
- QCOMPARE(spy7.count(), 1);
- QCOMPARE(spy8.count(), 0);
- QCOMPARE(spy9.count(), 1);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 0);
- QCOMPARE(spy12.count(), 1);
- QCOMPARE(spy13.count(), 0);
- QCOMPARE(spy14.count(), 1);
- QCOMPARE(spy15.count(), 0);
-
- p->goToSlide(pathC1, QStringLiteral("C1S2"));
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 1);
- QCOMPARE(spy7.count(), 1);
- QCOMPARE(spy8.count(), 1);
- QCOMPARE(spy9.count(), 1);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 0);
- QCOMPARE(spy12.count(), 1);
- QCOMPARE(spy13.count(), 0);
- QCOMPARE(spy14.count(), 1);
- QCOMPARE(spy15.count(), 0);
-
- p->goToSlide(pathC2, QStringLiteral("C2S2"));
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 1);
- QCOMPARE(spy7.count(), 1);
- QCOMPARE(spy8.count(), 1);
- QCOMPARE(spy9.count(), 1);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 1);
- QCOMPARE(spy12.count(), 1);
- QCOMPARE(spy13.count(), 1);
- QCOMPARE(spy14.count(), 1);
- QCOMPARE(spy15.count(), 0);
-
- // Subscenes revert to original slides when parent is re-entered
- p->goToSlide(path, QStringLiteral("S2"));
- checkPixel(m_viewer, Qt::blue);
-
- QCOMPARE(spy1.count(), 3);
- QCOMPARE(spy2.count(), 3);
- QCOMPARE(spy3.count(), 3);
- QCOMPARE(spy4.count(), 3);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 1);
- QCOMPARE(spy7.count(), 1);
- QCOMPARE(spy8.count(), 1);
- QCOMPARE(spy9.count(), 1);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 1);
- QCOMPARE(spy12.count(), 1);
- QCOMPARE(spy13.count(), 1);
- QCOMPARE(spy14.count(), 1);
- QCOMPARE(spy15.count(), 0);
-
- p->goToSlide(path, QStringLiteral("S1"));
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 4);
- QCOMPARE(spy2.count(), 4);
- QCOMPARE(spy3.count(), 4);
- QCOMPARE(spy4.count(), 4);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 2);
- QCOMPARE(spy7.count(), 2);
- QCOMPARE(spy8.count(), 2);
- QCOMPARE(spy9.count(), 2);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 2);
- QCOMPARE(spy12.count(), 2);
- QCOMPARE(spy13.count(), 2);
- QCOMPARE(spy14.count(), 2);
- QCOMPARE(spy15.count(), 0);
-
- p->unregisterElement(scene);
- p->unregisterElement(sceneC1);
- p->unregisterElement(sceneC2);
-
- // No more signals after unregistering
- p->goToSlide(path, QStringLiteral("S2"));
- checkPixel(m_viewer, Qt::blue);
-
- QCOMPARE(spy1.count(), 4);
- QCOMPARE(spy2.count(), 4);
- QCOMPARE(spy3.count(), 4);
- QCOMPARE(spy4.count(), 4);
- QCOMPARE(spy5.count(), 0);
- QCOMPARE(spy6.count(), 2);
- QCOMPARE(spy7.count(), 2);
- QCOMPARE(spy8.count(), 2);
- QCOMPARE(spy9.count(), 2);
- QCOMPARE(spy10.count(), 0);
- QCOMPARE(spy11.count(), 2);
- QCOMPARE(spy12.count(), 2);
- QCOMPARE(spy13.count(), 2);
- QCOMPARE(spy14.count(), 2);
- QCOMPARE(spy15.count(), 0);
-
- // Reregister
- p->registerElement(scene);
- p->goToSlide(path, QStringLiteral("S1"));
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 5);
- QCOMPARE(spy2.count(), 5);
- QCOMPARE(spy3.count(), 5);
- QCOMPARE(spy4.count(), 5);
- QCOMPARE(spy5.count(), 0);
-
- QCOMPARE(scene->currentSlideIndex(), 1);
- QCOMPARE(scene->previousSlideIndex(), 2);
- QCOMPARE(scene->currentSlideName(), QStringLiteral("S1"));
- QCOMPARE(scene->previousSlideName(), QStringLiteral("S2"));
- QCOMPARE(scene->elementPath(), path);
-
- scene->setCurrentSlideName(QStringLiteral("S2"));
- checkPixel(m_viewer, Qt::blue);
-
- QCOMPARE(spy1.count(), 6);
- QCOMPARE(spy2.count(), 6);
-
- scene->setCurrentSlideIndex(0);
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 7);
- QCOMPARE(spy2.count(), 7);
-
- // Go to next slide, wrap parameter doesn't matter
- scene->goToSlide(true, true);
- checkPixel(m_viewer, Qt::blue);
-
- QCOMPARE(spy1.count(), 8);
- QCOMPARE(spy2.count(), 8);
-
- // Go to next slide, wrap parameter doesn't matter
- scene->goToSlide(true, false);
- checkPixel(m_viewer, Qt::green);
-
- QCOMPARE(spy1.count(), 9);
- QCOMPARE(spy2.count(), 9);
-
- // No wrap, should not change
- scene->goToSlide(true, false);
- checkPixel(m_viewer, Qt::green);
-
- QCOMPARE(spy1.count(), 9);
- QCOMPARE(spy2.count(), 9);
-
- // Should wrap
- scene->goToSlide(true, true);
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 10);
- QCOMPARE(spy2.count(), 10);
-
- // No wrap, should not change
- scene->goToSlide(false, false);
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 10);
- QCOMPARE(spy2.count(), 10);
-
- // Should wrap
- scene->goToSlide(false, true);
- checkPixel(m_viewer, Qt::green);
-
- QCOMPARE(spy1.count(), 11);
- QCOMPARE(spy2.count(), 11);
-
- // Time change
- scene->goToTime(7.0f);
- checkPixel(m_viewer, Qt::yellow);
-
- QCOMPARE(spy1.count(), 11);
- QCOMPARE(spy2.count(), 11);
-
- // Back to first slide for further tests
- scene->setCurrentSlideIndex(0);
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 12);
- QCOMPARE(spy2.count(), 12);
-
- // Change element path
- scene->setElementPath(pathC1);
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 12);
- QCOMPARE(spy2.count(), 12);
- QCOMPARE(spy3.count(), 12);
- QCOMPARE(spy4.count(), 12);
- QCOMPARE(spy5.count(), 1);
-
- QCOMPARE(scene->currentSlideIndex(), 1);
- QCOMPARE(scene->previousSlideIndex(), 1);
- // Having current and previous slides the same seems weird, but that's how the slide
- // logic works internally.
- QCOMPARE(scene->currentSlideName(), QStringLiteral("C1S1"));
- QCOMPARE(scene->previousSlideName(), QStringLiteral("C1S1"));
- QCOMPARE(scene->elementPath(), pathC1);
-
- p->goToSlide(pathC1, QStringLiteral("C1S2"));
- checkPixel(m_viewer, Qt::red);
-
- QCOMPARE(spy1.count(), 13);
- QCOMPARE(spy2.count(), 12);
- QCOMPARE(spy3.count(), 13);
- QCOMPARE(spy4.count(), 12);
- QCOMPARE(spy5.count(), 1);
-}
-
-void tst_Q3DSSurfaceViewer::testElement_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testElement()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, MULTISLIDE);
- else
- createOffscreenAndViewer(m_viewer, MULTISLIDE);
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QString path1 = QStringLiteral("Scene.Layer.Rect.Material"); // Red
- QString path2 = QStringLiteral("Scene.Layer.Component1.Rectangle4.Material"); // Green
- QString path3 = QStringLiteral("Scene.Layer.Component2.Rectangle6.Material"); // Yellow
-
- QPoint mainPoint(m_viewer->size().width() * 2 / 8, m_viewer->size().height() / 2);
- QPoint c1Point(m_viewer->size().width() * 5 / 8, m_viewer->size().height() / 2);
- QPoint c2Point(m_viewer->size().width() * 7 / 8, m_viewer->size().height() / 2);
-
- Q3DSPresentation *p = m_viewer->presentation();
- Q3DSElement *element1 = new Q3DSElement(p, path1);
- Q3DSElement *element2 = new Q3DSElement(p, path2);
- QSignalSpy spy2(element2, &Q3DSSceneElement::elementPathChanged);
- QVERIFY(spy2.isValid());
-
- checkPixel(m_viewer, Qt::red, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
-
- element1->setAttribute(QStringLiteral("diffuse.r"), 0.0);
- element1->setAttribute(QStringLiteral("diffuse.g"), 0.0);
- element1->setAttribute(QStringLiteral("diffuse.b"), 1.0);
- checkPixel(m_viewer, Qt::blue, mainPoint);
- checkPixel(m_viewer, Qt::green, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
-
- element2->setAttribute(QStringLiteral("diffuse.r"), 1.0);
- element2->setAttribute(QStringLiteral("diffuse.g"), 0.0);
- element2->setAttribute(QStringLiteral("diffuse.b"), 1.0);
- checkPixel(m_viewer, Qt::blue, mainPoint);
- checkPixel(m_viewer, Qt::magenta, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
-
- // Change elementpath, nothing changes visually
- element2->setElementPath(path3);
- checkPixel(m_viewer, Qt::blue, mainPoint);
- checkPixel(m_viewer, Qt::magenta, c1Point);
- checkPixel(m_viewer, Qt::yellow, c2Point);
- QCOMPARE(spy2.count(), 1);
-
- element2->setAttribute(QStringLiteral("diffuse.r"), 0.0);
- element2->setAttribute(QStringLiteral("diffuse.g"), 1.0);
- element2->setAttribute(QStringLiteral("diffuse.b"), 1.0);
- checkPixel(m_viewer, Qt::blue, mainPoint);
- checkPixel(m_viewer, Qt::magenta, c1Point);
- checkPixel(m_viewer, Qt::cyan, c2Point);
-}
-
-void tst_Q3DSSurfaceViewer::testMouseInput_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testMouseInput()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, MOUSE);
- else
- createOffscreenAndViewer(m_viewer, MOUSE);
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QPoint point1(m_viewer->size().width() * 1 / 4, m_viewer->size().height() / 2);
- QPoint point2(m_viewer->size().width() * 3 / 4, m_viewer->size().height() / 2);
-
- checkPixel(m_viewer, Qt::blue, point1);
- checkPixel(m_viewer, Qt::red, point2);
-
- QMouseEvent e1(QEvent::MouseButtonPress, point1, Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- m_viewer->presentation()->mousePressEvent(&e1);
-
- checkPixel(m_viewer, Qt::green, point1);
- checkPixel(m_viewer, Qt::red, point2);
-
- QMouseEvent e2(QEvent::MouseButtonRelease, point1, Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- m_viewer->presentation()->mouseReleaseEvent(&e2);
-
- checkPixel(m_viewer, Qt::blue, point1);
- checkPixel(m_viewer, Qt::red, point2);
-
- QMouseEvent e3(QEvent::MouseButtonPress, point2, Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- m_viewer->presentation()->mousePressEvent(&e3);
-
- checkPixel(m_viewer, Qt::blue, point1);
- checkPixel(m_viewer, Qt::blue, point2);
-
- QMouseEvent e4(QEvent::MouseButtonRelease, point2, Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- m_viewer->presentation()->mouseReleaseEvent(&e4);
-
- checkPixel(m_viewer, Qt::blue, point1);
- checkPixel(m_viewer, Qt::red, point2);
-
- // Note: No way yet to hook mouse move into anything in the presentation
-}
-
-void tst_Q3DSSurfaceViewer::testDataInput_data()
-{
- testBasics_data();
-}
-
-void tst_Q3DSSurfaceViewer::testDataInput()
-{
- QFETCH(bool, isWindow);
-
- if (isWindow)
- createWindowAndViewer(m_viewer, DATAINPUT);
- else
- createOffscreenAndViewer(m_viewer, DATAINPUT);
-
- m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QPoint point1(m_viewer->size().width() / 4, m_viewer->size().height() / 4);
-
- const QString animationName = QStringLiteral("animationInput");
- const QString slideName = QStringLiteral("slideInput");
-
- checkPixel(m_viewer, Qt::red, point1);
- m_viewer->presentation()->setDataInputValue(animationName, 90);
- checkPixel(m_viewer, Qt::blue, point1);
- m_viewer->presentation()->setDataInputValue(animationName, 10);
- checkPixel(m_viewer, Qt::red, point1);
-
- Q3DSDataInput *animationInput = new Q3DSDataInput();
- animationInput->setName(animationName);
-
- m_viewer->presentation()->registerDataInput(animationInput);
- QVERIFY(m_viewer->presentation()->registeredDataInput(animationInput->name()));
-
- Q3DSDataInput *slideInput = new Q3DSDataInput(m_viewer->presentation(), slideName);
- QVERIFY(m_viewer->presentation()->registeredDataInput(slideInput->name()));
-
- animationInput->setValue(90);
- checkPixel(m_viewer, Qt::blue, point1);
- animationInput->setValue(10);
- checkPixel(m_viewer, Qt::red, point1);
-
- slideInput->setValue(QStringLiteral("Slide2"));
- checkPixel(m_viewer, Qt::green, point1);
- slideInput->setValue(QStringLiteral("Slide1"));
- checkPixel(m_viewer, Qt::red, point1);
-
- m_viewer->presentation()->unregisterDataInput(animationInput);
- m_viewer->presentation()->unregisterDataInput(slideInput);
- QVERIFY(!m_viewer->presentation()->registeredDataInput(animationInput->name()));
- QVERIFY(!m_viewer->presentation()->registeredDataInput(slideInput->name()));
- delete animationInput;
- delete slideInput;
-}
-
-
-QTEST_MAIN(tst_Q3DSSurfaceViewer)
-
-#include "tst_q3dssurfaceviewer.moc"
diff --git a/tests/auto/studio3d/shared/presentation/animation.uip b/tests/auto/studio3d/shared/presentation/animation.uip
deleted file mode 100644
index bd78b515..00000000
--- a/tests/auto/studio3d/shared/presentation/animation.uip
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Cube" >
- <Material id="Material" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="29690" />
- <Set ref="#Camera" endtime="29690" />
- <Set ref="#Light" endtime="29690" />
- <Add ref="#Cube" name="Cube" endtime="29690" position="5.7735 -14.4338 0" sourcepath="#Cube" >
- <AnimationTrack property="position.x" type="EaseInOut" >0 -457.55 100 100 4.832 -8.66028 100 100 11.174 440.23 100 100 20.037 -64.9519 100 100 29.69 -401.258 100 100</AnimationTrack>
- <AnimationTrack property="position.y" type="EaseInOut" >0 -1.52588e-05 100 100 4.832 -220.837 100 100 11.174 -18.7639 100 100 20.037 225.167 100 100 29.69 -14.4337 100 100</AnimationTrack>
- <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 4.832 0 100 100 11.174 0 100 100 20.037 0 100 100 29.69 0 100 100</AnimationTrack>
- </Add>
- <Add ref="#Material" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/blue.uip b/tests/auto/studio3d/shared/presentation/blue.uip
deleted file mode 100644
index a6eefa7e..00000000
--- a/tests/auto/studio3d/shared/presentation/blue.uip
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle" >
- <Material id="Material" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle" name="Rectangle" endtime="8000" position="0 -15.8771 0" scale="13.3333 9.5252 1" sourcepath="#Rectangle" />
- <Add ref="#Material" diffuse="0 0 1" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/datainput.uia b/tests/auto/studio3d/shared/presentation/datainput.uia
deleted file mode 100644
index fbfa55b6..00000000
--- a/tests/auto/studio3d/shared/presentation/datainput.uia
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<application>
- <assets initial="datainput">
- <dataInput name="animationInput" type="Ranged Number" min="0" max="100"/>
- <dataInput name="slideInput" type="String" />
- <presentation id="datainput" src="datainput.uip"/>
- <presentation id="subpres" src="datainput_sub.uip"/>
- </assets>
- <statemachine ref="#logic">
- <visual-states>
- <state ref="Initial">
- <enter>
- <goto-slide element="main:Scene" rel="next"/>
- </enter>
- </state>
- </visual-states>
- </statemachine>
-</application>
diff --git a/tests/auto/studio3d/shared/presentation/datainput.uip b/tests/auto/studio3d/shared/presentation/datainput.uip
deleted file mode 100644
index 3807cec2..00000000
--- a/tests/auto/studio3d/shared/presentation/datainput.uip
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="600" maintainAspect="False" >
- <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
- </ProjectSettings>
- <Graph >
- <Scene id="Scene" backgroundcolor="0 1 0" controlledproperty="$animationInput @timeline $slideInput @slide" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Component id="Component" >
- <Text id="Text" />
- </Component>
- <Model id="Rectangle" >
- <Material id="Default" name="Default" >
- <Image id="Default_diffusemap" />
- </Material>
- </Model>
- <Text id="Text_001" />
- <Model id="Rectangle2" >
- <Material id="Default_001" name="Default" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" background="Transparent" sourcepath="" />
- <Add ref="#Camera" />
- <Add ref="#Light" />
- <Add ref="#Rectangle" name="Rectangle" sourcepath="#Rectangle" >
- <AnimationTrack property="position.x" type="EaseInOut" >0 -327.165 100 100 10 351.542 100 100</AnimationTrack>
- <AnimationTrack property="position.y" type="EaseInOut" >0 -6.41502 100 100 10 -17.962 100 100</AnimationTrack>
- <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
- </Add>
- <Add ref="#Default" diffusemap="#Default_diffusemap" />
- <Add ref="#Default_diffusemap" sourcepath="maps/QT-symbol.png" subpresentation="subpres" />
- <State id="Scene-Slide1" name="Slide1" initialplaystate="Pause" >
- <Add ref="#Component" name="Component" controlledproperty="$animationInput @timeline" />
- <Add ref="#Rectangle2" name="Rectangle2" position="0 0 100" scale="9999 9999 99999" sourcepath="#Rectangle" />
- <Add ref="#Default_001" >
- <AnimationTrack property="diffuse.x" type="EaseInOut" >0 1 100 100 4.487 1 100 100 5.5 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="diffuse.y" type="EaseInOut" >0 0 100 100 4.487 0 100 100 5.5 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="diffuse.z" type="EaseInOut" >0 0 100 100 4.487 0 100 100 5.5 1 100 100 10 1 100 100</AnimationTrack>
- </Add>
- </State>
- <State id="Scene-Slide2" name="Slide2" initialplaystate="Play" playmode="Stop at end" playthroughto="Previous" >
- <Add ref="#Text_001" name="Text" font="TitilliumWeb-Regular" position="-442.635 -193.733 0" textstring="Second slide" />
- </State>
- </State>
- <State name="Master Slide" component="#Component" >
- <State id="Component-Slide1" name="Slide1" initialplaystate="Pause" >
- <Add ref="#Text" name="Text" controlledproperty="$animationInput textstring" font="TitilliumWeb-Regular" position="-5.132 137.281 0" >
- <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 10 -360 100 100</AnimationTrack>
- </Add>
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/datainput_sub.uip b/tests/auto/studio3d/shared/presentation/datainput_sub.uip
deleted file mode 100644
index c007eaba..00000000
--- a/tests/auto/studio3d/shared/presentation/datainput_sub.uip
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="400" presentationHeight="200" maintainAspect="False" >
- <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
- </ProjectSettings>
- <Graph >
- <Scene id="Scene" controlledproperty="$animationInput @timeline" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Text id="Text" controlledproperty="$slideInput textstring" />
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" />
- <State id="Scene-Slide1" name="Slide1" initialplaystate="Pause" >
- <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" opacity="99" size="96" >
- <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 10 -360 100 100</AnimationTrack>
- </Add>
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/fonts/TitilliumWeb-Regular.ttf b/tests/auto/studio3d/shared/presentation/fonts/TitilliumWeb-Regular.ttf
deleted file mode 100644
index 6da82193..00000000
--- a/tests/auto/studio3d/shared/presentation/fonts/TitilliumWeb-Regular.ttf
+++ /dev/null
Binary files differ
diff --git a/tests/auto/studio3d/shared/presentation/mixed.uip b/tests/auto/studio3d/shared/presentation/mixed.uip
deleted file mode 100644
index 16fea006..00000000
--- a/tests/auto/studio3d/shared/presentation/mixed.uip
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle" >
- <Material id="Material" />
- </Model>
- <Model id="Rectangle2" >
- <Material id="Material_001" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle" name="Rectangle" endtime="8000" position="401.651 25 0" scale="8 16 1" sourcepath="#Rectangle" />
- <Add ref="#Material" diffuse="1 0 0" emissivecolor="1 1 1" emissivepower="1" />
- <Add ref="#Rectangle2" name="Rectangle2" endtime="8000" position="-378.164 25 0" scale="8 16 1" sourcepath="#Rectangle" />
- <Add ref="#Material_001" diffuse="0 0 1" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/mixed_vertical.uip b/tests/auto/studio3d/shared/presentation/mixed_vertical.uip
deleted file mode 100644
index 7914b119..00000000
--- a/tests/auto/studio3d/shared/presentation/mixed_vertical.uip
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle" >
- <Material id="Material" />
- </Model>
- <Model id="Rectangle2" >
- <Material id="Material_001" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle" name="Rectangle" endtime="8000" position="0 -400 0" scale="16 8 1" sourcepath="#Rectangle" />
- <Add ref="#Material" diffuse="1 0 0" emissivecolor="1 1 1" emissivepower="1" />
- <Add ref="#Rectangle2" name="Rectangle2" endtime="8000" position="0 400 0" scale="16 8 1" sourcepath="#Rectangle" />
- <Add ref="#Material_001" diffuse="0 0 1" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/mouse.uip b/tests/auto/studio3d/shared/presentation/mouse.uip
deleted file mode 100644
index edd9f95f..00000000
--- a/tests/auto/studio3d/shared/presentation/mouse.uip
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle" >
- <Material id="Material" />
- </Model>
- <Model id="Rectangle2" >
- <Material id="Material_001" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle" name="Rectangle" endtime="8000" position="668.283 7.21691 0" scale="13.3333 9.5252 1" sourcepath="#Rectangle" >
- <Action id="Rectangle-Action" eyeball="True" triggerObject="#Rectangle" event="onPressureDown" targetObject="#Material" handler="Set Property" >
- <HandlerArgument name="Property Name" type="String" argtype="Property" value="diffuse" />
- <HandlerArgument name="Property Value" type="Float3" argtype="Dependent" value="0 0 1" />
- </Action>
- <Action id="Rectangle-Action_001" eyeball="True" triggerObject="#Rectangle" event="onPressureUp" targetObject="#Material" handler="Set Property" >
- <HandlerArgument name="Property Name" type="String" argtype="Property" value="diffuse" />
- <HandlerArgument name="Property Value" type="Float3" argtype="Dependent" value="1 0 0" />
- </Action>
- </Add>
- <Add ref="#Material" diffuse="1 0 0" emissivecolor="1 1 1" emissivepower="1" />
- <Add ref="#Rectangle2" name="Rectangle2" endtime="8000" position="-528.276 -19.6247 0" scale="10.6053 8.67004 1" sourcepath="#Rectangle" >
- <Action id="Rectangle2-Action" eyeball="True" triggerObject="#Rectangle2" event="onPressureDown" targetObject="#Material_001" handler="Set Property" >
- <HandlerArgument name="Property Name" type="String" argtype="Property" value="diffuse" />
- <HandlerArgument name="Property Value" type="Float3" argtype="Dependent" value="0 1 0" />
- </Action>
- <Action id="Rectangle2-Action_001" eyeball="True" triggerObject="#Rectangle2" event="onPressureUp" targetObject="#Material_001" handler="Set Property" >
- <HandlerArgument name="Property Name" type="String" argtype="Property" value="diffuse" />
- <HandlerArgument name="Property Value" type="Float3" argtype="Dependent" value="0 0 1" />
- </Action>
- </Add>
- <Add ref="#Material_001" diffuse="0 0 1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/multislide.uip b/tests/auto/studio3d/shared/presentation/multislide.uip
deleted file mode 100644
index e17db1db..00000000
--- a/tests/auto/studio3d/shared/presentation/multislide.uip
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" backgroundcolor="1 1 0" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle1" >
- <Material id="Material" />
- </Model>
- <Model id="Rectangle2" >
- <Material id="Material_001" />
- </Model>
- <Model id="Rectangle2_003" >
- <Material id="Material_006" />
- </Model>
- <Component id="Component" >
- <Model id="Rectangle" >
- <Material id="Material_002" />
- </Model>
- <Model id="Rectangle2_001" >
- <Material id="Material_003" />
- </Model>
- </Component>
- <Component id="Component2" >
- <Model id="Rectangle_001" >
- <Material id="Material_004" />
- </Model>
- <Model id="Rectangle2_002" >
- <Material id="Material_005" />
- </Model>
- </Component>
- <Text id="Text" />
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-S1" name="S1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle1" name="Rect" position="0 0 0" scale="13.3333 5 1" sourcepath="#Rectangle" />
- <Add ref="#Material" diffuse="1 0 0" emissivecolor="1 1 1" emissivepower="1" opacity="100" />
- <Add ref="#Component" name="Component1" endtime="8000" position="400 0 -1" scale="4 3 1" />
- <Add ref="#Component2" name="Component2" endtime="8000" position="461.548 -5.72538 -5" />
- <Add ref="#Text" name="Text" endtime="8000" font="TitilliumWeb-Regular" position="-304.552 -193.631 0" size="36" />
- </State>
- <State id="Scene-S2" name="S2" initialplaystate="Pause" playmode="Looping" playthroughto="Previous" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle2" name="Rectangle2" position="0 -15.8771 0" scale="13.3333 9.5252 1" sourcepath="#Rectangle" >
- <AnimationTrack property="scale.x" type="EaseInOut" >0 11.6 100 100 8 1 100 100</AnimationTrack>
- <AnimationTrack property="scale.y" type="EaseInOut" >0 9.5252 100 100 8 1 100 100</AnimationTrack>
- <AnimationTrack property="scale.z" type="EaseInOut" >0 1 100 100 8 1 100 100</AnimationTrack>
- </Add>
- <Add ref="#Material_001" diffuse="0 0 1" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- <State id="Scene-S3" name="S3" initialplaystate="Pause" playmode="Looping" playthroughto="Previous" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle2_003" name="Rectangle3" position="0 -15.8771 0" scale="13.3333 9.5252 1" sourcepath="#Rectangle" >
- <AnimationTrack property="scale.x" type="EaseInOut" >0 11.6 100 100 8 1 100 100</AnimationTrack>
- <AnimationTrack property="scale.y" type="EaseInOut" >0 9.5252 100 100 8 1 100 100</AnimationTrack>
- <AnimationTrack property="scale.z" type="EaseInOut" >0 1 100 100 8 1 100 100</AnimationTrack>
- </Add>
- <Add ref="#Material_006" diffuse="0 1 0" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- </State>
- <State name="Master Slide" component="#Component" >
- <State id="Component1-C1S1" name="C1S1" >
- <Add ref="#Rectangle" name="Rectangle4" position="0 0 -1" scale="2 3 1" sourcepath="#Rectangle" />
- <Add ref="#Material_002" diffuse="0 1 0" />
- </State>
- <State id="Component1-C1S2" name="C1S2" playthroughto="Previous" >
- <Add ref="#Rectangle2_001" name="Rectangle5" position="0 0 -1" scale="2 3 1" sourcepath="#Rectangle" />
- <Add ref="#Material_003" diffuse="0 1 1" />
- </State>
- </State>
- <State name="Master Slide" component="#Component2" >
- <State id="Component2-C2S1" name="C2S1" >
- <Add ref="#Rectangle_001" name="Rectangle6" scale="3.5 7 3.03591" sourcepath="#Rectangle" />
- <Add ref="#Material_004" diffuse="1 1 0" />
- </State>
- <State id="Component2-C2S2" name="C2S2" playthroughto="Previous" >
- <Add ref="#Rectangle2_002" name="Rectangle7" scale="3.5 7 3.03591" sourcepath="#Rectangle" />
- <Add ref="#Material_005" diffuse="1 0 1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/red.uip b/tests/auto/studio3d/shared/presentation/red.uip
deleted file mode 100644
index a04d2f8a..00000000
--- a/tests/auto/studio3d/shared/presentation/red.uip
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle" >
- <Material id="Material" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle" name="Rectangle" endtime="8000" position="0 -15.8771 0" scale="13.3333 9.5252 1" sourcepath="#Rectangle" />
- <Add ref="#Material" diffuse="1 0 0" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/presentation/settings.uip b/tests/auto/studio3d/shared/presentation/settings.uip
deleted file mode 100644
index acd580ab..00000000
--- a/tests/auto/studio3d/shared/presentation/settings.uip
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="3" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="300" presentationHeight="200" maintainAspect="False" />
- <Graph >
- <Scene id="Scene" backgroundcolor="0 0 1" >
- <Layer id="Layer" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Rectangle" >
- <Material id="Material" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" />
- <Add ref="#Camera" />
- <Add ref="#Light" lighttype="Directional" position="0 0 -500" rotation="0 0 0" />
- <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
- <Set ref="#Layer" endtime="8000" />
- <Set ref="#Camera" endtime="8000" />
- <Set ref="#Light" endtime="8000" />
- <Add ref="#Rectangle" name="Rectangle" edgetess="1" endtime="8000" innertess="1" position="0 -15.8771 0" scale="11 2.375 1" sourcepath="#Rectangle" tessellation="Linear" />
- <Add ref="#Material" diffuse="1 0 0" emissivecolor="1 1 1" emissivepower="1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/auto/studio3d/shared/shared_presentations.h b/tests/auto/studio3d/shared/shared_presentations.h
deleted file mode 100644
index 6d382738..00000000
--- a/tests/auto/studio3d/shared/shared_presentations.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qurl.h>
-
-const QUrl RED = QUrl(QStringLiteral("qrc:/red.uip"));
-const QUrl BLUE = QUrl(QStringLiteral("qrc:/blue.uip"));
-const QUrl MIXED = QUrl(QStringLiteral("qrc:/mixed.uip"));
-const QUrl MIXED_VERTICAL = QUrl(QStringLiteral("qrc:/mixed_vertical.uip"));
-const QUrl ANIMATION = QUrl(QStringLiteral("qrc:/animation.uip"));
-const QUrl SETTINGS = QUrl(QStringLiteral("qrc:/settings.uip"));
-const QUrl MULTISLIDE = QUrl(QStringLiteral("qrc:/multislide.uip"));
-const QUrl MOUSE = QUrl(QStringLiteral("qrc:/mouse.uip"));
-const QUrl DATAINPUT = QUrl(QStringLiteral("qrc:/datainput.uia"));
diff --git a/tests/auto/studio3d/shared/shared_presentations.qrc b/tests/auto/studio3d/shared/shared_presentations.qrc
deleted file mode 100644
index d4bb668f..00000000
--- a/tests/auto/studio3d/shared/shared_presentations.qrc
+++ /dev/null
@@ -1,15 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="blue.uip">presentation/blue.uip</file>
- <file alias="red.uip">presentation/red.uip</file>
- <file alias="mixed.uip">presentation/mixed.uip</file>
- <file alias="animation.uip">presentation/animation.uip</file>
- <file alias="mixed_vertical.uip">presentation/mixed_vertical.uip</file>
- <file alias="settings.uip">presentation/settings.uip</file>
- <file alias="multislide.uip">presentation/multislide.uip</file>
- <file alias="mouse.uip">presentation/mouse.uip</file>
- <file alias="datainput.uip">presentation/datainput.uip</file>
- <file alias="datainput.uia">presentation/datainput.uia</file>
- <file alias="datainput_sub.uip">presentation/datainput_sub.uip</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/studio3d/studio3d.pro b/tests/auto/studio3d/studio3d.pro
deleted file mode 100644
index e92019f0..00000000
--- a/tests/auto/studio3d/studio3d.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += \
- q3dssurfaceviewer
diff --git a/tests/auto/viewer/tst_qt3dsviewer.cpp b/tests/auto/viewer/tst_qt3dsviewer.cpp
deleted file mode 100644
index c9787fdb..00000000
--- a/tests/auto/viewer/tst_qt3dsviewer.cpp
+++ /dev/null
@@ -1,762 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "tst_qt3dsviewer.h"
-
-#include <QtQuick/QQuickItem>
-#include <QtGui/QSurfaceFormat>
-#include <QtStudio3D/Q3DSPresentation>
-#include <QtStudio3D/Q3DSElement>
-#include <QtStudio3D/Q3DSViewerSettings>
-#include <QtStudio3D/Q3DSGeometry>
-#include <QtCore/QRandomGenerator>
-#include <QtCore/QFile>
-#include <QtCore/QTextStream>
-#include <QtCore/QRegularExpression>
-
-void messageOutput(QtMsgType type, const QMessageLogContext &context,
- const QString &msg)
-{
- Q_UNUSED(context);
- switch (type) {
- case QtDebugMsg:
- case QtInfoMsg:
- case QtWarningMsg:
- case QtCriticalMsg:
- break; // swallow
- case QtFatalMsg:
- QFAIL(msg.toLocal8Bit().constData());
- }
-}
-
-void tst_qt3dsviewer::initTestCase()
-{
- qInstallMessageHandler(messageOutput);
-}
-
-void tst_qt3dsviewer::cleanupTestCase()
-{
-}
-
-void tst_qt3dsviewer::init()
-{
-#if defined(Q_OS_ANDROID)
- QSurfaceFormat format;
- format.setDepthBufferSize(32);
- format.setVersion(3, 2);
- format.setProfile(QSurfaceFormat::CompatibilityProfile);
- format.setRenderableType(QSurfaceFormat::OpenGLES);
-#else
- QSurfaceFormat format;
- format.setDepthBufferSize(32);
- format.setVersion(4, 3);
- format.setProfile(QSurfaceFormat::CoreProfile);
- QSurfaceFormat::setDefaultFormat(format);
-#endif
-
- m_viewer = new QQuickView;
- m_viewer->setTitle(QStringLiteral("tst_qt3dsviewer"));
- m_viewer->setSource(QUrl("qrc:/tst_qt3dsviewer.qml"));
- m_studio3DItem = m_viewer->rootObject();
- m_presentation = nullptr;
- m_settings = nullptr;
- m_ignoreError = false;
-
- QVERIFY(m_studio3DItem);
-
- const auto children = m_studio3DItem->children();
- for (auto &child : children) {
- if (!m_presentation)
- m_presentation = qobject_cast<Q3DSPresentation *>(child);
- if (!m_settings)
- m_settings = qobject_cast<Q3DSViewerSettings *>(child);
- }
-
- QVERIFY(m_presentation);
- QVERIFY(m_settings);
-}
-
-void tst_qt3dsviewer::cleanup()
-{
- deleteCreated();
- if (!m_ignoreError)
- QCOMPARE(m_studio3DItem->property("error").toString(), {});
- m_studio3DItem = nullptr;
- m_viewer->hide();
- m_viewer->deleteLater();
- m_viewer = nullptr;
-}
-
-void tst_qt3dsviewer::testEmpty()
-{
- m_presentation->setProperty("source", QUrl());
- m_viewer->show();
- QTest::qWait(1000);
- QCOMPARE(m_studio3DItem->property("running").toBool(), false);
- QVERIFY(!m_studio3DItem->property("error").toString().isEmpty());
- m_ignoreError = true; // To avoid triggering cleanup() fail as we are expecting an error
-}
-
-void tst_qt3dsviewer::testLoading()
-{
- QCOMPARE(m_studio3DItem->property("running").toBool(), false);
- m_viewer->show();
- QTest::qWait(1000);
- QCOMPARE(m_studio3DItem->property("running").toBool(), true);
-}
-
-
-void tst_qt3dsviewer::testSlides()
-{
- QSignalSpy spyEntered(m_presentation,
- SIGNAL(slideEntered(const QString &, unsigned int, const QString &)));
- QSignalSpy spyExited(m_presentation,
- SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
- QCOMPARE(spyEntered.count(), 0);
- QCOMPARE(spyExited.count(), 0);
-
- m_viewer->show();
- QTest::qWait(1000);
-
- QCOMPARE(spyEntered.count(), 1);
- QCOMPARE(spyExited.count(), 0);
-
- QVERIFY(spyExited.wait(12000));
- QCOMPARE(spyEntered.count(), 2);
- QCOMPARE(spyExited.count(), 1);
-}
-
-void tst_qt3dsviewer::testFrameUpdates()
-{
- QSignalSpy spyFrames(m_studio3DItem, SIGNAL(frameUpdate()));
- QSignalSpy spyExited(m_presentation,
- SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
- m_viewer->show();
- QVERIFY(spyExited.wait(12000));
- // Just ensure we get some frames, exact count will vary a lot due to external factors
- QVERIFY(spyFrames.count() > 10);
-}
-
-void tst_qt3dsviewer::testSettings()
-{
- m_viewer->show();
- m_settings->setMatteColor(QColor("#0000ff"));
- QVERIFY(m_settings->matteColor() == QColor("#0000ff"));
-
- // Save and change matte color
- m_settings->save("", "tst_qt3dsviewer", "tst_qt3dsviewer");
- m_settings->setMatteColor(QColor("#00ff00"));
- QVERIFY(m_settings->matteColor() == QColor("#00ff00"));
- // Load and previous matte color should be back
- m_settings->load("", "tst_qt3dsviewer", "tst_qt3dsviewer");
- QVERIFY(m_settings->matteColor() == QColor("#0000ff"));
-}
-
-void tst_qt3dsviewer::testCreateElement()
-{
- m_viewer->show();
-
- m_settings->setShowRenderStats(true);
- m_settings->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QSignalSpy spyExited(m_presentation,
- SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
- QSignalSpy spyElemCreated(m_presentation, SIGNAL(elementsCreated(const QStringList &,
- const QString &)));
-
- QObject::connect(m_presentation, &Q3DSPresentation::elementsCreated,
- [this](const QStringList &elementNames, const QString &error) {
- QCOMPARE(error, QString());
- for (const auto &elementName : elementNames)
- QVERIFY(m_createdElements.contains(elementName));
- });
-
- auto loadMatDefFile = [&](const QString &fileName) -> QString {
- QFile matDefFile(fileName);
- if (!matDefFile.open(QIODevice::ReadOnly | QIODevice::Text))
- return {};
-
- QTextStream in(&matDefFile);
- return in.readAll();
- };
-
- int animValue = 0;
-
- QString md = loadMatDefFile(QStringLiteral(
- ":/scenes/simple_cube_animation/materials/Basic Red.materialdef"));
- m_presentation->createMaterial(md);
- m_createdMaterials << QStringLiteral("materials/Basic Red");
- md = loadMatDefFile(QStringLiteral(
- ":/scenes/simple_cube_animation/materials/Basic Green.materialdef"));
- m_presentation->createMaterial(md);
- m_createdMaterials << QStringLiteral("materials/Basic Green");
-
-
- QHash<QString, QVariant> data;
- data.insert(QStringLiteral("name"), QStringLiteral("New Cylinder"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cylinder"));
- data.insert(QStringLiteral("material"), QString());
- data.insert(QStringLiteral("starttime"), 0);
- data.insert(QStringLiteral("endtime"), 4500);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(200, 300, 200)));
- data.insert(QStringLiteral("opacity"), 20.0);
- data.insert(QStringLiteral("controlledproperty"), QStringLiteral("@newDataInput opacity"));
-
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
-
- // Elements can be registered before they are created
- Q3DSElement newCylinder(m_presentation, QStringLiteral("Scene.Layer.New Cylinder"));
- Q3DSElement newCylinder2(m_presentation,
- QStringLiteral("Scene.Layer.New Cylinder.New Cylinder 2"));
- Q3DSElement newGroup(m_presentation, QStringLiteral("Scene.Layer.New Group"));
- Q3DSElement newSphere(m_presentation, QStringLiteral("Scene.Layer.Cube2.New Sphere"));
-
- QTimer animationTimer;
- animationTimer.setInterval(10);
- int animDir = 1;
- QObject::connect(&animationTimer, &QTimer::timeout, [&]() {
- if (qAbs(animValue) > 100)
- animDir = -animDir;
- animValue += animDir;
- newCylinder.setAttribute(QStringLiteral("rotation.x"), animValue * 4);
- newCylinder2.setAttribute(QStringLiteral("position.y"), animValue * 3);
- newSphere.setAttribute(QStringLiteral("position.x"), 50 + animValue * 2);
- newGroup.setAttribute(QStringLiteral("opacity"), qAbs(animValue));
- m_presentation->setDataInputValue(QStringLiteral("newDataInput"), qAbs(animValue / 2));
- });
-
- // Create objects to slides 1 & 2 while slide 1 is executing
- QTimer::singleShot(1000, [&]() {
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("New Cylinder 2"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cylinder"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Red"));
- data.insert(QStringLiteral("starttime"), 500);
- data.insert(QStringLiteral("endtime"), 5000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(50, animValue, 50)));
-
- createElement(QStringLiteral("Scene.Layer.New Cylinder"),
- QStringLiteral("Slide1"), data);
-
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("New Sphere"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Sphere"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Green"));
- data.insert(QStringLiteral("starttime"), 1000);
- data.insert(QStringLiteral("endtime"), 4000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(animValue, 75, 0)));
-
- createElement(QStringLiteral("Scene.Layer.Cube2"), QStringLiteral("Slide2"), data);
-
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("Sphere To Delete"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Sphere"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Red"));
- data.insert(QStringLiteral("starttime"), 0);
- data.insert(QStringLiteral("endtime"), 10000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(-100, -100, 0)));
-
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide2"), data);
-
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("New Group"));
- data.insert(QStringLiteral("type"), QStringLiteral("group"));
- data.insert(QStringLiteral("starttime"), 0);
- data.insert(QStringLiteral("endtime"), 10000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(50, -100, 0)));
-
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
-
- QVector<QHash<QString, QVariant>> groupElemProps;
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("Child 1 of Group"));
- data.insert(QStringLiteral("type"), QStringLiteral("model"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cylinder"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Green"));
- data.insert(QStringLiteral("starttime"), 1000);
- data.insert(QStringLiteral("endtime"), 4000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(0, 0, 0)));
- groupElemProps << data;
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("Child 2 of Group"));
- data.insert(QStringLiteral("type"), QStringLiteral("model"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cylinder"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Green"));
- data.insert(QStringLiteral("starttime"), 2000);
- data.insert(QStringLiteral("endtime"), 4000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(100, 0, 0)));
- groupElemProps << data;
-
- m_createdElements << QStringLiteral("Scene.Layer.New Group.Child 1 of Group")
- << QStringLiteral("Scene.Layer.New Group.Child 2 of Group");
-
- m_presentation->createElements(QStringLiteral("Scene.Layer.New Group"),
- QStringLiteral("Slide1"), groupElemProps);
-
- animationTimer.start();
- });
-
- // Switch to slide 2
- QVERIFY(spyExited.wait(20000));
-
- // Remove dynamically added object
- QTimer::singleShot(3000, [&]() {
- m_presentation->deleteElement(QStringLiteral("Scene.Layer.Sphere To Delete"));
- m_createdElements.removeOne(QStringLiteral("Scene.Layer.Sphere To Delete"));
- });
-
- // Create objects to slides 1 and 2 while slide 2 is executing
- QTimer::singleShot(2000, [&]() {
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("New Cylinder 3"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cylinder"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Green"));
- data.insert(QStringLiteral("starttime"), 0);
- data.insert(QStringLiteral("endtime"), 3000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(-100, -100, 0)));
-
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
-
- data.clear();
- data.insert(QStringLiteral("name"), QStringLiteral("New Sphere 2"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Sphere"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Green"));
- data.insert(QStringLiteral("starttime"), 0);
- data.insert(QStringLiteral("endtime"), 5000);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(-100, 100, 0)));
-
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide2"), data);
- });
-
- // Switch to slide 1
- QVERIFY(spyExited.wait(20000));
-
- QRandomGenerator rnd;
- QVector<QHash<QString, QVariant>> massProps;
- for (int i = 0; i < 1000; ++i) {
- data.clear();
- QString elementName = QStringLiteral("MassElement_%1").arg(i);
- data.insert(QStringLiteral("name"), elementName);
- data.insert(QStringLiteral("sourcepath"),
- i % 2 ? QStringLiteral("#Cube") : QStringLiteral("#Cone"));
- data.insert(QStringLiteral("material"),
- i % 2 ? QStringLiteral("Basic Green") : QStringLiteral("Basic Red"));
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(rnd.bounded(-600, 600),
- rnd.bounded(-600, 600),
- rnd.bounded(800, 1200))));
- massProps << data;
- m_createdElements << QStringLiteral("Scene.Layer.") + elementName;
- }
- m_presentation->createElements(QStringLiteral("Scene.Layer"), QStringLiteral("Slide2"),
- massProps);
-
- // Switch to slide 2
- QVERIFY(spyExited.wait(20000));
-
- QTest::qWait(500);
- QCOMPARE(spyElemCreated.count(), 9);
- const QStringList createdElements = m_presentation->createdElements();
- QCOMPARE(createdElements.size(), m_createdElements.size());
- for (const auto &elementName : createdElements)
- QVERIFY(m_createdElements.contains(elementName));
- deleteCreated();
-
- // Switch to slide 1
- QVERIFY(spyExited.wait(20000));
- QTest::qWait(1000);
-}
-
-void tst_qt3dsviewer::testCreateMaterial()
-{
- m_viewer->show();
-
- m_settings->setShowRenderStats(true);
- m_settings->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QSignalSpy spyExited(m_presentation,
- SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
- QSignalSpy spyMatCreated(m_presentation, SIGNAL(materialsCreated(const QStringList &,
- const QString &)));
- QSignalSpy spyElemCreated(m_presentation, SIGNAL(elementsCreated(const QStringList &,
- const QString &)));
-
- QStringList materialDefinitions;
- // Create material via .materialdef file in resources
- materialDefinitions
- << QStringLiteral(":/scenes/simple_cube_animation/materials/Basic Blue.materialdef")
- << QStringLiteral(":/scenes/simple_cube_animation/materials/Basic Texture.materialdef");
-
- // Create material directly from materialdef content
- auto loadMatDefFile = [&](const QString &fileName) -> QString {
- QFile matDefFile(fileName);
- if (!matDefFile.open(QIODevice::ReadOnly | QIODevice::Text))
- return {};
-
- QTextStream in(&matDefFile);
- return in.readAll();
- };
- QString matDef = loadMatDefFile(
- QStringLiteral(":/scenes/simple_cube_animation/materials/Copper.materialdef"));
- QVERIFY(!matDef.isEmpty());
- materialDefinitions << matDef;
-
- m_presentation->createMaterials(materialDefinitions);
- m_createdMaterials << QStringLiteral("materials/Basic Blue")
- << QStringLiteral("materials/Basic Texture")
- << QStringLiteral("materials/Copper");
-
- QObject::connect(m_presentation, &Q3DSPresentation::materialsCreated,
- [this](const QStringList &materialNames, const QString &error) {
- QCOMPARE(error, QString());
- for (auto &name : materialNames) {
- QVERIFY(m_createdMaterials.contains(name));
- QHash<QString, QVariant> data;
- if (name == QLatin1String("materials/Basic Blue")) {
- data.insert(QStringLiteral("name"), QStringLiteral("Blue Cylinder"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cylinder"));
- data.insert(QStringLiteral("material"), name);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(200, 300, 200)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- } else if (name == QLatin1String("materials/Basic Texture")) {
- data.insert(QStringLiteral("name"), QStringLiteral("Textured Cone"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cone"));
- data.insert(QStringLiteral("material"), name);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(-200, -300, 200)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- } else if (name == QLatin1String("materials/Copper")) {
- data.insert(QStringLiteral("name"), QStringLiteral("Copper Sphere"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Sphere"));
- data.insert(QStringLiteral("material"), name);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(-200, 300, 200)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- } else if (name == QLatin1String("materials/Just Yellow")) {
- QHash<QString, QVariant> data;
- data.insert(QStringLiteral("name"), QStringLiteral("Yellow Cube"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cube"));
- data.insert(QStringLiteral("material"), name);
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(200, -300, 200)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- } else {
- QVERIFY(false);
- }
- }
- });
-
- // Create material after start
- QTimer::singleShot(1000, [&]() {
- QString md = loadMatDefFile(QStringLiteral(
- ":/scenes/simple_cube_animation/materials/Basic Blue.materialdef"));
- // Modify the diffuse color and material name so that we can be sure it is a new one
- md.replace(QStringLiteral("Basic Blue"), QStringLiteral("Just Yellow"));
- md.replace(QRegularExpression(QStringLiteral("\"diffuse\">.*<")),
- QStringLiteral("\"diffuse\">1 1 0 1<"));
- m_presentation->createMaterial(md);
- m_createdMaterials << QStringLiteral("materials/Just Yellow");
- });
-
- // Delete material
- QTimer::singleShot(2500, [&]() {
- m_presentation->deleteElement(QStringLiteral("Scene.Layer.Textured Cone"));
- m_presentation->deleteMaterial("materials/Basic Texture");
- m_createdMaterials.removeOne(QStringLiteral("materials/Basic Texture"));
-
- // Try to use the deleted material - should find a fallback material
- QHash<QString, QVariant> data;
- data.insert(QStringLiteral("name"), QStringLiteral("Textured Cone 2"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("#Cone"));
- data.insert(QStringLiteral("material"), QStringLiteral("materials/Basic Texture"));
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(-100, -300, 200)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- });
-
- QVERIFY(spyExited.wait(20000));
- QCOMPARE(spyMatCreated.count(), 2);
- QCOMPARE(spyElemCreated.count(), 5);
- const QStringList createdMaterials = m_presentation->createdMaterials();
- QCOMPARE(createdMaterials.size(), m_createdMaterials.size());
- for (const auto &name : createdMaterials)
- QVERIFY(m_createdMaterials.contains(name));
- deleteCreated();
- QTest::qWait(200); // Extra wait to verify slide change visually
-}
-
-void tst_qt3dsviewer::testCreateMesh()
-{
- m_viewer->show();
-
- m_settings->setShowRenderStats(true);
- m_settings->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
-
- QSignalSpy spyExited(m_presentation,
- SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
- QSignalSpy spyMeshCreated(m_presentation, SIGNAL(meshesCreated(const QStringList &,
- const QString &)));
- QSignalSpy spyElemCreated(m_presentation, SIGNAL(elementsCreated(const QStringList &,
- const QString &)));
- Q3DSGeometry pyramid;
- Q3DSGeometry star;
- createGeometries(pyramid, star);
-
- Q3DSElement pyramidElem(m_presentation, QStringLiteral("Scene.Layer.Pyramid"));
- Q3DSElement starElem(m_presentation, QStringLiteral("Scene.Layer.Star"));
-
- int animValue = 0;
- QTimer animationTimer;
- animationTimer.setInterval(10);
- QObject::connect(&animationTimer, &QTimer::timeout, [&]() {
- animValue++;
- pyramidElem.setAttribute(QStringLiteral("rotation.x"), animValue * 2);
- pyramidElem.setAttribute(QStringLiteral("rotation.y"), animValue);
- starElem.setAttribute(QStringLiteral("rotation.x"), -animValue * 2);
- starElem.setAttribute(QStringLiteral("rotation.y"), -animValue);
- });
-
- m_presentation->createMaterial(
- QStringLiteral(":/scenes/simple_cube_animation/materials/Basic Texture.materialdef"));
- m_createdMaterials << QStringLiteral("materials/Basic Texture");
- m_presentation->createMesh(QStringLiteral("Pyramid"), pyramid);
- m_createdMeshes << QStringLiteral("Pyramid");
-
- QObject::connect(m_presentation, &Q3DSPresentation::meshesCreated,
- [&](const QStringList &meshNames, const QString &error) {
- QCOMPARE(error, QString());
- for (auto &name : meshNames) {
- QVERIFY(m_createdMeshes.contains(name));
- QHash<QString, QVariant> data;
- if (name == QLatin1String("Pyramid")) {
- data.insert(QStringLiteral("name"), QStringLiteral("Pyramid"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("Pyramid"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Texture"));
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(100, 150, 500)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- animationTimer.start();
- } else if (name == QLatin1String("Star")) {
- data.insert(QStringLiteral("name"), QStringLiteral("Star"));
- data.insert(QStringLiteral("sourcepath"), QStringLiteral("Star"));
- data.insert(QStringLiteral("material"), QStringLiteral("Basic Texture"));
- data.insert(QStringLiteral("position"),
- QVariant::fromValue<QVector3D>(QVector3D(100, -150, 500)));
- createElement(QStringLiteral("Scene.Layer"), QStringLiteral("Slide1"), data);
- } else {
- QVERIFY(false);
- }
- }
- });
-
- // Create mesh after start
- QTimer::singleShot(1000, [&]() {
- m_presentation->createMesh(QStringLiteral("Star"), star);
- m_createdMeshes << QStringLiteral("Star");
- });
-
- QTimer::singleShot(3000, [&]() {
- m_presentation->deleteElement(QStringLiteral("Scene.Layer.Star"));
- m_presentation->deleteMesh(QStringLiteral("Star"));
- m_createdMeshes.removeOne(QStringLiteral("Star"));
- });
-
- QVERIFY(spyExited.wait(20000));
- QCOMPARE(spyMeshCreated.count(), 2);
- QCOMPARE(spyElemCreated.count(), 2);
- const QStringList createdMeshes = m_presentation->createdMeshes();
- QCOMPARE(createdMeshes.size(), m_createdMeshes.size());
- for (const auto &name : createdMeshes)
- QVERIFY(m_createdMeshes.contains(name));
- deleteCreated();
- QTest::qWait(200); // Extra wait to verify slide change visually
-}
-
-void tst_qt3dsviewer::testMouseEvents()
-{
- m_viewer->show();
- QTest::qWait(1000);
-
- QSignalSpy spyEvents(m_studio3DItem,
- SIGNAL(ignoredEventsChanged()));
- QSignalSpy spyExited(m_presentation,
- SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
-
- QCOMPARE(spyEvents.count(), 0);
- QCOMPARE(spyExited.count(), 0);
-
- // Ignore mouse, so slide doesn't change
- m_studio3DItem->setProperty("ignoredEvents", 1);
- QTest::mousePress(m_viewer, Qt::LeftButton);
- QTest::qWait(1000);
- QTest::mouseRelease(m_viewer, Qt::LeftButton);
- QCOMPARE(spyEvents.count(), 1);
- QCOMPARE(spyExited.count(), 0);
-
- // Enable mouse, clicking switches slide
- m_studio3DItem->setProperty("ignoredEvents", 0);
- QTest::mousePress(m_viewer, Qt::LeftButton);
- QTest::qWait(1000);
- QTest::mouseRelease(m_viewer, Qt::LeftButton);
- QCOMPARE(spyEvents.count(), 2);
- QCOMPARE(spyExited.count(), 1);
-}
-
-void tst_qt3dsviewer::deleteCreated()
-{
- m_presentation->deleteElements(m_createdElements);
- m_presentation->deleteMaterials(m_createdMaterials);
- m_presentation->deleteMeshes(m_createdMeshes);
- m_createdElements.clear();
- m_createdMaterials.clear();
- m_createdMeshes.clear();
- QVERIFY(m_presentation->createdElements().size() == 0);
- QVERIFY(m_presentation->createdMaterials().size() == 0);
- QVERIFY(m_presentation->createdMeshes().size() == 0);
-}
-
-void tst_qt3dsviewer::createElement(const QString &parentElementPath, const QString &slideName,
- const QHash<QString, QVariant> &properties)
-{
- m_createdElements << parentElementPath + QLatin1Char('.')
- + properties[QStringLiteral("name")].toString();
- m_presentation->createElement(parentElementPath, slideName, properties);
-}
-
-void tst_qt3dsviewer::createGeometries(Q3DSGeometry &pyramid, Q3DSGeometry &star)
-{
- struct Vertex {
- QVector3D position;
- QVector3D normal;
- QVector2D uv;
- };
-
- QVector<Vertex> vertices;
-
- auto createVertex = [&](const QVector3D &xyz, const QVector3D &n, const QVector2D &uv) {
- Vertex newVertex;
- newVertex.position = xyz;
- if (n.isNull())
- newVertex.normal = xyz; // This is almost never the correct normal
- else
- newVertex.normal = n.normalized();
- newVertex.uv = uv;
- vertices.append(newVertex);
- };
-
- auto createTriangle = [&](const QVector3D &xyz1, const QVector2D &uv1,
- const QVector3D &xyz2, const QVector2D &uv2,
- const QVector3D &xyz3, const QVector2D &uv3) {
- QVector3D n;
- n = QVector3D::crossProduct(xyz2 - xyz1, xyz3 - xyz1).normalized();
-
- createVertex(xyz1, n, uv1);
- createVertex(xyz2, n, uv2);
- createVertex(xyz3, n, uv3);
- };
-
- // Pyramid (no index buffer)
- {
- QVector3D xyz[5] = {{0, 0, 50}, {50, 50, -50}, {50, -50, -50}, {-50, -50, -50},
- {-50, 50, -50}};
- QVector2D uv[4] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}};
- createTriangle(xyz[0], uv[0], xyz[1], uv[1], xyz[2], uv[2]);
- createTriangle(xyz[0], uv[0], xyz[2], uv[1], xyz[3], uv[2]);
- createTriangle(xyz[0], uv[0], xyz[3], uv[1], xyz[4], uv[2]);
- createTriangle(xyz[0], uv[0], xyz[4], uv[1], xyz[1], uv[2]);
- createTriangle(xyz[1], uv[0], xyz[4], uv[2], xyz[3], uv[1]);
- createTriangle(xyz[1], uv[0], xyz[3], uv[3], xyz[2], uv[2]);
-
- QByteArray vertexBuffer(reinterpret_cast<const char *>(vertices.constData()),
- vertices.size() * int(sizeof(Vertex)));
-
- pyramid.clear();
- pyramid.setVertexData(vertexBuffer);
- pyramid.addAttribute(Q3DSGeometry::Attribute::PositionSemantic);
- pyramid.addAttribute(Q3DSGeometry::Attribute::NormalSemantic);
- pyramid.addAttribute(Q3DSGeometry::Attribute::TexCoordSemantic);
- }
-
- vertices.clear();
-
- // Star (using index buffer)
- {
- // Note: Since faces share vertices, the normals on the vertices are not correct
- // for any face, leading to weird lighting behavior
- createVertex({0, 150, 0}, {}, {0.5f, 1});
- createVertex({50, 50, -50}, {}, {0.66f, 0.66f});
- createVertex({150, 0, 0}, {}, {1, 0.5f});
- createVertex({50, -50, -50}, {}, {0.66f, 0.33f});
- createVertex({0, -150, 0}, {}, {0.5f, 0});
- createVertex({-50, -50, -50}, {}, {0.33f, 0.33f});
- createVertex({-150, 0, 0}, {}, {0, 0.5f});
- createVertex({-50, 50, -50}, {}, {0.33f, 0.66f});
- createVertex({50, 50, 50}, {}, {0.66f, 0.66f});
- createVertex({50, -50, 50}, {}, {0.66f, 0.33f});
- createVertex({-50, -50, 50}, {}, {0.33f, 0.33f});
- createVertex({-50, 50, 50}, {}, {0.33f, 0.66f});
-
- QVector<quint16> indices = {
- 0, 1, 8, 0, 7, 1, 0, 11, 7, 0, 8, 11, // Top pyramid
- 2, 1, 3, 2, 3, 9, 2, 9, 8, 2, 8, 1, // Right pyramid
- 4, 3, 5, 4, 5, 10, 4, 10, 9, 4, 9, 3, // Bottom pyramid
- 6, 5, 7, 6, 7, 11, 6, 11, 10, 6, 10, 5, // Left pyramid
- 1, 7, 5, 1, 5, 3, // Front center rect
- 8, 10, 11, 8, 9, 10 // Back center rect
- };
-
- QByteArray vertexBuffer(reinterpret_cast<const char *>(vertices.constData()),
- vertices.size() * int(sizeof(Vertex)));
- QByteArray indexBuffer(reinterpret_cast<const char *>(indices.constData()),
- indices.size() * int(sizeof(quint16)));
-
- Q3DSGeometry::Attribute indexAtt;
- indexAtt.semantic = Q3DSGeometry::Attribute::IndexSemantic;
- indexAtt.componentType = Q3DSGeometry::Attribute::ComponentType::U16Type;
-
- star.clear();
- star.setVertexData(vertexBuffer);
- star.setIndexData(indexBuffer);
- star.addAttribute(Q3DSGeometry::Attribute::PositionSemantic);
- star.addAttribute(Q3DSGeometry::Attribute::NormalSemantic);
- star.addAttribute(Q3DSGeometry::Attribute::TexCoordSemantic);
- star.addAttribute(indexAtt);
- }
-}
-
-QTEST_MAIN(tst_qt3dsviewer)
diff --git a/tests/auto/viewer/tst_qt3dsviewer.h b/tests/auto/viewer/tst_qt3dsviewer.h
deleted file mode 100644
index 3d1f9473..00000000
--- a/tests/auto/viewer/tst_qt3dsviewer.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2012 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TST_QT3DSVIEWER
-#define TST_QT3DSVIEWER
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/QQuickView>
-#include <QtStudio3D/q3dspresentation.h>
-#include <QtStudio3D/q3dsviewersettings.h>
-
-class tst_qt3dsviewer : public QObject
-{
- Q_OBJECT
-public:
- tst_qt3dsviewer()
- {
- }
-
-private Q_SLOTS:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
- void testEmpty();
- void testLoading();
- void testSlides();
- void testFrameUpdates();
- void testSettings();
- void testCreateElement();
- void testCreateMaterial();
- void testCreateMesh();
- void testMouseEvents();
-
-private:
- void deleteCreated();
- void createElement(const QString &parentElementPath, const QString &slideName,
- const QHash<QString, QVariant> &properties);
- void createGeometries(Q3DSGeometry &pyramid, Q3DSGeometry &star);
-
- QQuickView *m_viewer = nullptr;
- QObject *m_studio3DItem = nullptr;
- Q3DSPresentation *m_presentation = nullptr;
- Q3DSViewerSettings *m_settings = nullptr;
- QStringList m_createdElements;
- QStringList m_createdMaterials;
- QStringList m_createdMeshes;
- bool m_ignoreError = false;
-
-};
-
-#endif // TST_QT3DSVIEWER
diff --git a/tests/auto/viewer/tst_qt3dsviewer.qml b/tests/auto/viewer/tst_qt3dsviewer.qml
deleted file mode 100644
index e65a49db..00000000
--- a/tests/auto/viewer/tst_qt3dsviewer.qml
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtStudio3D.OpenGL 2.4
-
-Studio3D {
- id: studio3D
- width: 800
- height: 800
- Presentation {
- source: "qrc:/scenes/simple_cube_animation/simple_cube_animation.uia"
- }
- ViewerSettings {
- }
-}
diff --git a/tests/auto/viewer/viewer.pro b/tests/auto/viewer/viewer.pro
deleted file mode 100644
index 9e06c2ca..00000000
--- a/tests/auto/viewer/viewer.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-TEMPLATE = app
-CONFIG += testcase
-include($$PWD/../../../src/Runtime/ogl-runtime/commoninclude.pri)
-
-TARGET = tst_qt3dsviewer
-QT += testlib gui quick studio3d
-RESOURCES += viewer.qrc
-
-HEADERS += \
- tst_qt3dsviewer.h
-
-SOURCES += \
- tst_qt3dsviewer.cpp
-
-LIBS += \
- -lqt3dsopengl$$qtPlatformTargetSuffix() \
- -lqt3dsqmlstreamer$$qtPlatformTargetSuffix()
-
-ANDROID_EXTRA_LIBS = \
- libqt3dsopengl.so \
- libqt3dsqmlstreamer.so
diff --git a/tests/auto/viewer/viewer.qrc b/tests/auto/viewer/viewer.qrc
deleted file mode 100644
index dcdddbea..00000000
--- a/tests/auto/viewer/viewer.qrc
+++ /dev/null
@@ -1,16 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>../../scenes/simple_cube_animation/simple_cube_animation.uia</file>
- <file>../../scenes/simple_cube_animation/presentations/simple_cube_animation.uip</file>
- <file>../../scenes/simple_cube_animation/materials/Basic Green.materialdef</file>
- <file>../../scenes/simple_cube_animation/materials/Basic Red.materialdef</file>
- <file>../../scenes/simple_cube_animation/materials/Basic Blue.materialdef</file>
- <file>../../scenes/simple_cube_animation/materials/Basic Texture.materialdef</file>
- <file>../../scenes/simple_cube_animation/materials/Copper.materialdef</file>
- <file>../../scenes/simple_cube_animation/materials/copper.shader</file>
- <file>../../scenes/simple_cube_animation/maps/materials/shadow.png</file>
- <file>../../scenes/simple_cube_animation/maps/materials/spherical_checker.png</file>
- <file>../../scenes/simple_cube_animation/maps/QT-symbol.png</file>
- <file>tst_qt3dsviewer.qml</file>
- </qresource>
-</RCC>
diff --git a/tests/scenes/customvertex/customvertex.uia b/tests/scenes/customvertex/customvertex.uia
deleted file mode 100644
index 84488102..00000000
--- a/tests/scenes/customvertex/customvertex.uia
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<application xmlns="http://qt.io/qt3dstudio/uia">
- <assets initial="customvertex">
- <presentation id="customvertex" src="presentations/customvertex.uip"/>
- </assets>
- <statemachine ref="#logic">
- <visual-states>
- <state ref="Initial">
- <enter>
- <goto-slide rel="next" element="main:Scene"/>
- </enter>
- </state>
- </visual-states>
- </statemachine>
-</application>
diff --git a/tests/scenes/customvertex/materials/simple.shader b/tests/scenes/customvertex/materials/simple.shader
deleted file mode 100644
index bdbd21e9..00000000
--- a/tests/scenes/customvertex/materials/simple.shader
+++ /dev/null
@@ -1,29 +0,0 @@
-<Material name="simple" version="1.0">
- <MetaData>
- <Property formalName="Scale" name="scale" type="Vector" default="1 1 1" stage="vertex" category="Material" />
- <Property formalName="Color" name="color" type="Color" default="1 1 1" stage="fragment" category="Material" />
- </MetaData>
- <Shaders type="GLSL" version="330">
- <Shader>
- <VertexShader>
- attribute vec3 attr_pos;
- uniform mat4 modelViewProjection;
-
- void main() {
- gl_Position = modelViewProjection * vec4(attr_pos * scale, 1.0);
- }
- </VertexShader>
- <FragmentShader>
- out vec4 fragColor;
- void main() {
- fragColor = vec4(color.rgb, 1.0);
- }
- </FragmentShader>
- </Shader>
- </Shaders>
-<Passes>
- <Pass>
- </Pass>
-</Passes>
-</Material>
-
diff --git a/tests/scenes/customvertex/presentations/customvertex.uip b/tests/scenes/customvertex/presentations/customvertex.uip
deleted file mode 100644
index eba06daa..00000000
--- a/tests/scenes/customvertex/presentations/customvertex.uip
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="5" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="1920" presentationHeight="1080" maintainAspect="False" preferKtx="False" >
- <CustomColors count="16" >#7391ff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
- </ProjectSettings>
- <Classes >
- <CustomMaterial id="simple" name="simple" sourcepath="../materials/simple.shader" />
- </Classes>
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" variants="" >
- <Camera id="Camera" />
- <Light id="Light" />
- <Model id="Sphere" >
- <CustomMaterial id="simple_001" class="#simple" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" disabledepthprepass="True" />
- <Add ref="#Camera" />
- <Add ref="#Light" />
- <State id="Scene-Slide1" name="Slide1" >
- <Add ref="#Sphere" name="Sphere" position="0 0 0" sourcepath="#Sphere" />
- <Add ref="#simple_001" name="Material" color="0.333333 0.666667 0" scale="1 2 1" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/scenes/simple_cube_animation/maps/QT-symbol.png b/tests/scenes/simple_cube_animation/maps/QT-symbol.png
deleted file mode 100644
index 752a2e2f..00000000
--- a/tests/scenes/simple_cube_animation/maps/QT-symbol.png
+++ /dev/null
Binary files differ
diff --git a/tests/scenes/simple_cube_animation/maps/materials/shadow.png b/tests/scenes/simple_cube_animation/maps/materials/shadow.png
deleted file mode 100644
index 599b1ccc..00000000
--- a/tests/scenes/simple_cube_animation/maps/materials/shadow.png
+++ /dev/null
Binary files differ
diff --git a/tests/scenes/simple_cube_animation/maps/materials/spherical_checker.png b/tests/scenes/simple_cube_animation/maps/materials/spherical_checker.png
deleted file mode 100644
index e42394dd..00000000
--- a/tests/scenes/simple_cube_animation/maps/materials/spherical_checker.png
+++ /dev/null
Binary files differ
diff --git a/tests/scenes/simple_cube_animation/materials/Basic Blue.materialdef b/tests/scenes/simple_cube_animation/materials/Basic Blue.materialdef
deleted file mode 100644
index c35d47b8..00000000
--- a/tests/scenes/simple_cube_animation/materials/Basic Blue.materialdef
+++ /dev/null
@@ -1,25 +0,0 @@
-<MaterialData version="1.0">
- <Property name="shaderlighting">Pixel</Property>
- <Property name="blendmode">Normal</Property>
- <Property name="diffuse">0 0.482353 1 1</Property>
- <Property name="specularamount">0</Property>
- <Property name="specularroughness">0</Property>
- <Property name="opacity">100</Property>
- <Property name="emissivecolor">1 1 1 1</Property>
- <Property name="emissivepower">0</Property>
- <Property name="bumpamount">0.5</Property>
- <Property name="displaceamount">20</Property>
- <Property name="translucentfalloff">1</Property>
- <Property name="diffuselightwrap">0</Property>
- <Property name="specularmodel">Default</Property>
- <Property name="speculartint">1 1 1 1</Property>
- <Property name="ior">1.5</Property>
- <Property name="fresnelPower">0</Property>
- <Property name="vertexcolors">False</Property>
- <Property name="sourcepath"></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">Material</Property>
- <Property name="name"><![CDATA[materials/Basic Blue]]></Property>
- <Property name="path"><![CDATA[C:/dev/q3dstudio/qt3dstudio/tests/scenes/simple_cube_animation/materials/Basic Blue.materialdef]]></Property>
-</MaterialData> \ No newline at end of file
diff --git a/tests/scenes/simple_cube_animation/materials/Basic Green.materialdef b/tests/scenes/simple_cube_animation/materials/Basic Green.materialdef
deleted file mode 100644
index 273a348c..00000000
--- a/tests/scenes/simple_cube_animation/materials/Basic Green.materialdef
+++ /dev/null
@@ -1,25 +0,0 @@
-<MaterialData version="1.0">
- <Property name="shaderlighting">Pixel</Property>
- <Property name="blendmode">Normal</Property>
- <Property name="diffuse">0.180392 1 0 1</Property>
- <Property name="specularamount">0</Property>
- <Property name="specularroughness">0</Property>
- <Property name="opacity">100</Property>
- <Property name="emissivecolor">1 1 1 1</Property>
- <Property name="emissivepower">0</Property>
- <Property name="bumpamount">0.5</Property>
- <Property name="displaceamount">20</Property>
- <Property name="translucentfalloff">1</Property>
- <Property name="diffuselightwrap">0</Property>
- <Property name="specularmodel">Default</Property>
- <Property name="speculartint">1 1 1 1</Property>
- <Property name="ior">1.5</Property>
- <Property name="fresnelPower">0</Property>
- <Property name="vertexcolors">False</Property>
- <Property name="sourcepath"></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">Material</Property>
- <Property name="name"><![CDATA[materials/Basic Green]]></Property>
- <Property name="path"><![CDATA[C:/dev/q3dstudio/qt3dstudio/tests/scenes/simple_cube_animation/materials/Basic Green.materialdef]]></Property>
-</MaterialData> \ No newline at end of file
diff --git a/tests/scenes/simple_cube_animation/materials/Basic Red.materialdef b/tests/scenes/simple_cube_animation/materials/Basic Red.materialdef
deleted file mode 100644
index 38b8eb7b..00000000
--- a/tests/scenes/simple_cube_animation/materials/Basic Red.materialdef
+++ /dev/null
@@ -1,25 +0,0 @@
-<MaterialData version="1.0">
- <Property name="shaderlighting">Pixel</Property>
- <Property name="blendmode">Normal</Property>
- <Property name="diffuse">1 0 0.0156863 1</Property>
- <Property name="specularamount">0</Property>
- <Property name="specularroughness">0</Property>
- <Property name="opacity">100</Property>
- <Property name="emissivecolor">1 1 1 1</Property>
- <Property name="emissivepower">0</Property>
- <Property name="bumpamount">0.5</Property>
- <Property name="displaceamount">20</Property>
- <Property name="translucentfalloff">1</Property>
- <Property name="diffuselightwrap">0</Property>
- <Property name="specularmodel">Default</Property>
- <Property name="speculartint">1 1 1 1</Property>
- <Property name="ior">1.5</Property>
- <Property name="fresnelPower">0</Property>
- <Property name="vertexcolors">False</Property>
- <Property name="sourcepath"></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">Material</Property>
- <Property name="name"><![CDATA[materials/Basic Red]]></Property>
- <Property name="path"><![CDATA[C:/dev/q3dstudio/qt3dstudio/tests/scenes/simple_cube_animation/materials/Basic Red.materialdef]]></Property>
-</MaterialData> \ No newline at end of file
diff --git a/tests/scenes/simple_cube_animation/materials/Basic Texture.materialdef b/tests/scenes/simple_cube_animation/materials/Basic Texture.materialdef
deleted file mode 100644
index 4defa98f..00000000
--- a/tests/scenes/simple_cube_animation/materials/Basic Texture.materialdef
+++ /dev/null
@@ -1,63 +0,0 @@
-<MaterialData version="1.0">
- <Property name="shaderlighting">Pixel</Property>
- <Property name="blendmode">Normal</Property>
- <Property name="diffuse">0.752941 0.756863 1 1</Property>
- <Property name="diffusemap"><![CDATA[./maps/materials/spherical_checker.png]]></Property>
- <Property name="diffusemap2"><![CDATA[./maps/QT-symbol.png]]></Property>
- <Property name="specularamount">0</Property>
- <Property name="specularroughness">0</Property>
- <Property name="opacity">100</Property>
- <Property name="emissivecolor">1 1 1 1</Property>
- <Property name="emissivepower">0</Property>
- <Property name="bumpamount">0.5</Property>
- <Property name="displaceamount">20</Property>
- <Property name="translucentfalloff">1</Property>
- <Property name="diffuselightwrap">0</Property>
- <Property name="specularmodel">Default</Property>
- <Property name="speculartint">1 1 1 1</Property>
- <Property name="ior">1.5</Property>
- <Property name="fresnelPower">0</Property>
- <Property name="vertexcolors">False</Property>
- <Property name="sourcepath"></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">Material</Property>
- <Property name="name"><![CDATA[materials/Basic Texture]]></Property>
- <Property name="path"><![CDATA[C:/dev/qt/NDD/qt3ds2/tests/scenes/simple_cube_animation/materials/Basic Texture.materialdef]]></Property>
- <TextureData name="diffusemap">
- <Property name="scaleu">1</Property>
- <Property name="scalev">1</Property>
- <Property name="mappingmode">UV Mapping</Property>
- <Property name="tilingmodehorz">Tiled</Property>
- <Property name="tilingmodevert">Tiled</Property>
- <Property name="rotationuv">0</Property>
- <Property name="positionu">0</Property>
- <Property name="positionv">0</Property>
- <Property name="pivotu">0</Property>
- <Property name="pivotv">0</Property>
- <Property name="subpresentation"></Property>
- <Property name="sourcepath"><![CDATA[./maps/materials/spherical_checker.png]]></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">Image</Property>
- <Property name="name"><![CDATA[Image]]></Property>
- </TextureData>
- <TextureData name="diffusemap2">
- <Property name="scaleu">2</Property>
- <Property name="scalev">3</Property>
- <Property name="mappingmode">UV Mapping</Property>
- <Property name="tilingmodehorz">Tiled</Property>
- <Property name="tilingmodevert">Tiled</Property>
- <Property name="rotationuv">0</Property>
- <Property name="positionu">0</Property>
- <Property name="positionv">0</Property>
- <Property name="pivotu">0</Property>
- <Property name="pivotv">0</Property>
- <Property name="subpresentation"></Property>
- <Property name="sourcepath"><![CDATA[./maps/QT-symbol.png]]></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">Image</Property>
- <Property name="name"><![CDATA[Image]]></Property>
- </TextureData>
-</MaterialData> \ No newline at end of file
diff --git a/tests/scenes/simple_cube_animation/materials/Copper.materialdef b/tests/scenes/simple_cube_animation/materials/Copper.materialdef
deleted file mode 100644
index 76880986..00000000
--- a/tests/scenes/simple_cube_animation/materials/Copper.materialdef
+++ /dev/null
@@ -1,14 +0,0 @@
-<MaterialData version="1.0">
- <Property name="uEnvironmentTexture" type="Texture"><![CDATA[./maps/materials/spherical_checker.png]]></Property>
- <Property name="uEnvironmentMappingEnabled">True</Property>
- <Property name="uBakedShadowTexture" type="Texture"><![CDATA[./maps/materials/shadow.png]]></Property>
- <Property name="uShadowMappingEnabled">False</Property>
- <Property name="roughness">0</Property>
- <Property name="metal_color">0.807843 0.45098 0.211765 1</Property>
- <Property name="sourcepath"><![CDATA[./materials/copper.shader]]></Property>
- <Property name="importid"></Property>
- <Property name="importfile"></Property>
- <Property name="type">CustomMaterial</Property>
- <Property name="name"><![CDATA[materials/Copper]]></Property>
- <Property name="path"><![CDATA[C:/dev/qt/NDD/qt3ds2/tests/scenes/simple_cube_animation/materials/Copper.materialdef]]></Property>
-</MaterialData> \ No newline at end of file
diff --git a/tests/scenes/simple_cube_animation/materials/copper.shader b/tests/scenes/simple_cube_animation/materials/copper.shader
deleted file mode 100644
index cf9e1ad4..00000000
--- a/tests/scenes/simple_cube_animation/materials/copper.shader
+++ /dev/null
@@ -1,178 +0,0 @@
-<Material name="copper" version="1.0">
- <MetaData >
- <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/>
- <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/>
- <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/>
- <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/>
- <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/>
- <Property formalName="Metal Color" name="metal_color" type="Color" default="0.805 0.395 0.305" description="Color of the material" category="Material"/>
- </MetaData>
- <Shaders type="GLSL" version="330">
- <Shader>
- <Shared> </Shared>
-<VertexShader>
- </VertexShader>
- <FragmentShader>
-
-// add enum defines
-#define scatter_reflect 0
-#define scatter_transmit 1
-#define scatter_reflect_transmit 2
-
-#define QT3DS_ENABLE_UV0 1
-#define QT3DS_ENABLE_WORLD_POSITION 1
-#define QT3DS_ENABLE_TEXTAN 1
-#define QT3DS_ENABLE_BINORMAL 0
-
-#include "vertexFragmentBase.glsllib"
-
-// set shader output
-out vec4 fragColor;
-
-// add structure defines
-struct layer_result
-{
- vec4 base;
- vec4 layer;
- mat3 tanFrame;
-};
-
-
-// temporary declarations
- vec4 tmpShadowTerm;
-
-layer_result layers[1];
-
-#include "SSAOCustomMaterial.glsllib"
-#include "sampleLight.glsllib"
-#include "sampleProbe.glsllib"
-#include "sampleArea.glsllib"
-#include "square.glsllib"
-#include "calculateRoughness.glsllib"
-#include "evalBakedShadowMap.glsllib"
-#include "evalEnvironmentMap.glsllib"
-#include "luminance.glsllib"
-#include "microfacetBSDF.glsllib"
-#include "physGlossyBSDF.glsllib"
-#include "simpleGlossyBSDF.glsllib"
-#include "fresnelLayer.glsllib"
-
-bool evalTwoSided()
-{
- return( false );
-}
-
-vec3 computeFrontMaterialEmissive()
-{
- return( vec3( 0, 0, 0 ) );
-}
-
-void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
-{
-#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
-
-#endif
-}
-
-void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular )
-{
-#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness );
-
-#endif
-}
-
-void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor )
-{
-#if !QT3DS_ENABLE_LIGHT_PROBE
- layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect );
-
-#else
- layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
-
-#endif
-}
-
-vec3 computeBackMaterialEmissive()
-{
- return( vec3(0, 0, 0) );
-}
-
-void computeBackLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
-{
-#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
-#endif
-}
-
-void computeBackAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular )
-{
-#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
-#endif
-}
-
-void computeBackLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor )
-{
-#if !QT3DS_ENABLE_LIGHT_PROBE
- layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
-#else
- layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
-#endif
-}
-
-float computeIOR()
-{
- return( false ? 1.0 : luminance( vec3( 1, 1, 1 ) ) );
-}
-
-float evalCutout()
-{
- return( 1.000000 );
-}
-
-vec3 computeNormal()
-{
- return( normal );
-}
-
-void computeTemporaries()
-{
- tmpShadowTerm = evalBakedShadowMap( texCoord0 );
-}
-
-vec4 computeLayerWeights( in float alpha )
-{
- vec4 color;
- color = fresnelLayer( normal, vec3( 25.65, 25.65, 25.65 ), 1.000000, metal_color.rgb, layers[0].layer, layers[0].base, alpha );
- return color;
-}
-
-
-void initializeLayerVariables(void)
-{
- // clear layers
- layers[0].base = vec4(0.0, 0.0, 0.0, 1.0);
- layers[0].layer = vec4(0.0, 0.0, 0.0, 1.0);
- layers[0].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) );
-}
-
- </FragmentShader>
- </Shader>
- </Shaders>
-<Passes >
- <ShaderKey value="4"/>
- <LayerKey count="1"/>
- <Pass >
- </Pass>
-</Passes>
-</Material>
diff --git a/tests/scenes/simple_cube_animation/presentations/simple_cube_animation.uip b/tests/scenes/simple_cube_animation/presentations/simple_cube_animation.uip
deleted file mode 100644
index f8fae907..00000000
--- a/tests/scenes/simple_cube_animation/presentations/simple_cube_animation.uip
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<UIP version="6" >
- <Project >
- <ProjectSettings author="" company="" presentationWidth="600" presentationHeight="600" maintainAspect="False" preferKtx="False" >
- <CustomColors count="16" >#7391ff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
- </ProjectSettings>
- <Graph >
- <Scene id="Scene" >
- <Layer id="Layer" variants="" >
- <Camera id="Camera" />
- <Light id="Light" >
- <Model id="Sphere" variants="" >
- <Material id="Default_animatable" />
- </Model>
- </Light>
- <Model id="Cube" variants="" >
- <Material id="Basic Green_animatable" />
- </Model>
- <Model id="Cube2" variants="" >
- <Material id="Basic Red_animatable" />
- </Model>
- </Layer>
- </Scene>
- </Graph>
- <Logic >
- <State name="Master Slide" component="#Scene" >
- <Add ref="#Layer" background="SolidColor" backgroundcolor="0.584314 0.0941176 0.34902 1" />
- <Add ref="#Camera" />
- <Add ref="#Light" brightness="400" lighttype="Point" >
- <AnimationTrack property="position.x" type="EaseInOut" >0 -341.785 100 100 5 269.972 100 100</AnimationTrack>
- <AnimationTrack property="position.y" type="EaseInOut" >0 0 100 100 5 0 100 100</AnimationTrack>
- <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 5 0 100 100</AnimationTrack>
- </Add>
- <State id="Scene-Slide1" name="Slide1" playmode="Play Through To..." >
- <Set ref="#Layer" endtime="5000" >
- <Action id="Layer-Action" eyeball="True" triggerObject="#Scene" event="onPressureDown" targetObject="#Scene" handler="Next Slide" />
- </Set>
- <Set ref="#Camera" endtime="5000" />
- <Set ref="#Light" endtime="5000" />
- <Add ref="#Sphere" name="Sphere" endtime="5000" scale="0.1 0.1 0.1" sourcepath="#Sphere" />
- <Add ref="#Default_animatable" name="Default_animatable" blendmode="Normal" bumpamount="0.5" diffuse="1 1 0 1" diffuselightwrap="0" displaceamount="20" emissivecolor="1 1 1 1" emissivepower="0" fresnelPower="0" importfile="" importid="" ior="1.5" opacity="100" shaderlighting="None" sourcepath="" specularamount="0" specularmodel="Default" specularroughness="0" speculartint="1 1 1 1" translucentfalloff="1" type="Material" vertexcolors="False" />
- <Add ref="#Cube" name="Cube" endtime="5000" position="-458.877 -70.3589 600" sourcepath="#Cube" >
- <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 1 0 100 100 4 0 100 100 5 90 100 100 7 90 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 1 0 100 100 4 90 100 100 5 0 100 100 7 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 1 -90 100 100 4 -90 100 100 5 -90 100 100 7 0 100 100 10 0 100 100</AnimationTrack>
- <AnimationTrack property="scale.x" type="EaseInOut" >0 1 100 100 2 1.5 100 100 3 1.5 100 100 6 2 100 100 7 1 100 100 8 1 100 100 9 1 100 100</AnimationTrack>
- <AnimationTrack property="scale.y" type="EaseInOut" >0 1 100 100 2 1.5 100 100 3 1.5 100 100 6 2 100 100 7 2 100 100 8 1 100 100 9 1 100 100</AnimationTrack>
- <AnimationTrack property="scale.z" type="EaseInOut" >0 1 100 100 2 1 100 100 3 1.5 100 100 6 2 100 100 7 2 100 100 8 2 100 100 9 1 100 100</AnimationTrack>
- </Add>
- <Add ref="#Basic Green_animatable" name="Basic Green_animatable" blendmode="Normal" bumpamount="0.5" diffuse="0.180392 1 0 1" diffuselightwrap="0" displaceamount="20" emissivecolor="1 1 1 1" emissivepower="0" fresnelPower="0" importfile="" importid="" ior="1.5" opacity="100" shaderlighting="Pixel" sourcepath="" specularamount="0" specularmodel="Default" specularroughness="0" speculartint="1 1 1 1" translucentfalloff="1" type="Material" vertexcolors="False" />
- </State>
- <State id="Scene-Slide2" name="Slide2" playmode="Play Through To..." playthroughto="Previous" >
- <Set ref="#Layer" endtime="5000" />
- <Set ref="#Camera" endtime="5000" />
- <Set ref="#Light" endtime="5000" />
- <Add ref="#Cube2" name="Cube2" endtime="5000" position="-401.836 -18.4752 600" scale="3 3 3" sourcepath="#Cube" />
- <Add ref="#Basic Red_animatable" name="Basic Red_animatable" blendmode="Normal" bumpamount="0.5" diffuse="1 0 0.0156863 1" diffuselightwrap="0" displaceamount="20" emissivecolor="1 1 1 1" emissivepower="0" fresnelPower="0" importfile="" importid="" ior="1.5" opacity="100" shaderlighting="Pixel" sourcepath="" specularamount="0" specularmodel="Default" specularroughness="0" speculartint="1 1 1 1" translucentfalloff="1" type="Material" vertexcolors="False" />
- </State>
- </State>
- </Logic>
- </Project>
-</UIP>
diff --git a/tests/scenes/simple_cube_animation/simple_cube_animation.uia b/tests/scenes/simple_cube_animation/simple_cube_animation.uia
deleted file mode 100644
index ca2d770f..00000000
--- a/tests/scenes/simple_cube_animation/simple_cube_animation.uia
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<application xmlns="http://qt.io/qt3dstudio/uia">
- <assets initial="simple_cube_animation">
- <presentation id="simple_cube_animation" src="presentations/simple_cube_animation.uip"/>
- <dataInput metadata="" name="newDataInput" type="Float"/>
- </assets>
- <statemachine ref="#logic">
- <visual-states>
- <state ref="Initial">
- <enter>
- <goto-slide rel="next" element="main:Scene"/>
- </enter>
- </state>
- </visual-states>
- </statemachine>
-</application>
diff --git a/tests/tests.pro b/tests/tests.pro
index c458bbbe..96710850 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -1,4 +1 @@
TEMPLATE = subdirs
-
-!package: SUBDIRS += \
- auto