summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2018-07-11 14:03:42 +0200
committerAndy Nichols <andy.nichols@qt.io>2018-07-16 08:16:13 +0000
commitf548947c3780285d103f9a4a947376596b8e41d1 (patch)
tree8ba20c10f8012786a832c4069e621f130b84f777 /tests
parent39b8fbca67348b2c078b4e52b432e8979cf383ef (diff)
Enablers for adding and removing layers to the scene at run time
Adding, removing and reordering layers is almost in place now. Some things are still missing when it comes to cameras since the mvp in the vertex shaders for layers introduced on-the-fly is incorrect. Extend also setparent() in the console to allow inserting new subtrees at arbitrary places. Q3DSGraphObject already has the necessary APIs (insertChildNodeAfter and friends). Therefore, doing object(newlayer, newlayer, Layer, null, Slide1) object(newlayer_cam, newlayer_cam, Camera, newlayer, Slide1) ... setparent(newlayer, Scene) Adds the new layer after all existing layers (and thus to the bottom of the stack since the 3D Studio object tree (and the editor's visualization of the tree) assumes front-to-back ordering for the layers which is weird but that's what it is). To instead add to the top (i.e. before the existing Layer children of Scene), we can now do: setparent(newlayer, Scene, null) This also matches what clicking the "Add new layer" button in the editor would do. To implement moving layers around (to change their ordering), one can now simply do setparent(newlayer, Scene, SomeOtherLayer) (or the equivalent using the Q3DSGraphObject APIs) in order to move newlayer after SomeOtherLayer. Change-Id: I9c832e4299cb7398d97a799dce5eaa3cd5518a77 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/newlayer.drgscr17
-rw-r--r--tests/scripts/newlayer_direct.drgscr13
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/scripts/newlayer.drgscr b/tests/scripts/newlayer.drgscr
new file mode 100644
index 0000000..ae7e556
--- /dev/null
+++ b/tests/scripts/newlayer.drgscr
@@ -0,0 +1,17 @@
+object(newlayer, newlayer, Layer, null, Slide1)
+
+object(newlayer_cam, newlayer_cam, Camera, newlayer, Slide1)
+// the default position does not work since the property is shared with nodes and those use 0 0 0 as the default,
+// unlike the expected 0 0 -600 for cameras. so must specify it explicitly.
+set(newlayer_cam, position, 0 0 -600)
+
+// must have a light to see something
+object(newlayer_light, newlayer_light, Light, newlayer, Slide1)
+
+// add some text
+object(newlayer_text, newlayer_text, Text, newlayer, Slide1)
+set(newlayer_text, textstring, New Layer!)
+set(newlayer_text, textcolor, 0 1 0)
+
+// use prependChildNode, i.e. add as the top-most (front) layer
+setparent(newlayer, Scene, null)
diff --git a/tests/scripts/newlayer_direct.drgscr b/tests/scripts/newlayer_direct.drgscr
new file mode 100644
index 0000000..4688a2b
--- /dev/null
+++ b/tests/scripts/newlayer_direct.drgscr
@@ -0,0 +1,13 @@
+// Here the layer and its children are connected one by one to the scene right away as they are created.
+// will end up as the bottom layer (last child of Scene)
+
+object(newlayer, newlayer, Layer, Scene, Slide1)
+
+object(newlayer_cam, newlayer_cam, Camera, newlayer, Slide1)
+set(newlayer_cam, position, 0 0 -600)
+
+object(newlayer_light, newlayer_light, Light, newlayer, Slide1)
+
+object(newlayer_text, newlayer_text, Text, newlayer, Slide1)
+set(newlayer_text, textstring, New Layer!)
+set(newlayer_text, textcolor, 0 1 0)