This URL has Read-Only access.

Statistics
| Branch: | Tag: | Revision:

root / examples / 03.AboutSceneGraphs.pd @ 61820aa5

History | View | Annotate | Download (3.7 kB)

1
#N canvas 1497 -429 1022 752 10;
2
#X obj 16 65 cnv 15 24 24 empty empty 1 4 12 1 24 -99865 -262144 0
3
;
4
#X obj 123 153 cnv 15 24 24 empty empty 3 4 12 1 24 -99865 -262144
5
0;
6
#X obj 75 343 s \$0-to-SPIN;
7
#X obj 173 242 cnv 15 24 24 empty empty 4 4 12 1 24 -99865 -262144
8
0;
9
#X obj 32 391 cnv 15 24 24 empty empty 5 4 12 1 24 -99865 -262144 0
10
;
11
#X obj 592 37 cnv 15 24 24 empty empty 6 4 12 1 24 -99865 -262144 0
12
;
13
#X obj 74 104 cnv 15 24 24 empty empty 2 4 12 1 24 -99865 -262144 0
14
;
15
#X obj 16 10 widget-spinConnect \$0;
16
#X msg 56 69 createNode grid GridNode;
17
#X text 222 68 create a grid so we can orient ourselves;
18
#X obj 647 146 r \$0-from-SPIN;
19
#X obj 647 164 route /shp;
20
#X obj 647 182 route global6DOF;
21
#X obj 592 241 cnv 15 24 24 empty empty 7 4 12 1 24 -99865 -262144
22
0;
23
#X obj 592 422 cnv 15 24 24 empty empty 8 4 12 1 24 -99865 -262144
24
0;
25
#X obj 647 200 print GLOBAL-COORDS;
26
#X msg 647 59 /shp setReportMode 1;
27
#X text 267 108 create a parent node;
28
#X obj 94 542 subwidget-PAT \$0;
29
#X msg 131 484 shp;
30
#X text 206 237 Create a second parent node and use the attachTo method
31
to attach (a clone) of the node to another parent.;
32
#X text 191 316 NOTE: The setParent message is really two commands
33
in one. ie \, "setParent p" is equivalent to "detachFrom *" and "attachTo
34
p";
35
#X msg 182 277 createNode p2 GroupNode \, /p2 setTranslation 2 0 0
36
\, /shp attachTo p2;
37
#X msg 113 448 p2;
38
#X msg 112 108 createNode p1 GroupNode;
39
#X text 155 144 Create a child node called 'shp' \, set it's parent
40
to 'p1' \, and offset it -1 units along the x-axis. Note this offset
41
is relative to the parent's coordinate system.;
42
#X msg 158 193 createNode shp ShapeNode \, /shp setParent p1 \, /shp
43
setTranslation -1 0 0;
44
#X text 142 449 <- same for p2;
45
#X msg 84 397 p1;
46
#X obj 647 80 s \$0-to-SPIN;
47
#X text 627 38 Tell "shp" to report it's global coordinates;
48
#X obj 652 384 s \$0-to-SPIN;
49
#X msg 645 295 deleteNode p1;
50
#X msg 735 295 deleteNode p2;
51
#X text 625 237 Deleting all parent nodes will orphan a child. ie \,
52
it will still exist in the spinserver \, but won't be in the scene
53
graph.;
54
#X msg 665 476 deleteGraph p1;
55
#X obj 665 501 s \$0-to-SPIN;
56
#X text 122 396 <- select "p1" and try changing the yaw. Notice that
57
the child is automatically updated and keeps the 1 unit offset with
58
respect to the parent;
59
#X text 168 483 <- now \, notice that there is only ONE "shp" node
60
attached to both parents \, and changing it's position will occur in
61
BOTH parent's subgraphs.;
62
#X text 626 418 Repeat steps 2-4 and then try the deleteGraph message
63
to delete the specified node \, plus all children and their children.
64
;
65
#X msg 672 593 /shp detachFrom p2;
66
#X obj 748 710 s \$0-to-SPIN;
67
#X obj 592 542 cnv 15 24 24 empty empty 9 4 12 1 24 -99865 -262144
68
0;
69
#X text 620 104 ... and look at the print outs in the Pd window while
70
you play with the controller in step 5;
71
#X text 624 537 Repeat steps 2-4 and then see how you can selectively
72
detach nodes using the detachFrom method;
73
#X msg 708 619 /shp detachFrom *;
74
#X msg 642 573 /shp detachFrom p1;
75
#X msg 855 610 /shp attachTo p2;
76
#X msg 845 590 /shp attachTo p1;
77
#X obj 138 685 s \$0-to-SPIN;
78
#X msg 138 662 debug scenegraph;
79
#X text 96 641 NOTE: you can get a text print-out of the scene graph
80
like this:;
81
#X msg 835 679 /shp attachTo world;
82
#X text 831 649 can also attach to world;
83
#X text 860 661 (no parent);
84
#X connect 8 0 2 0;
85
#X connect 10 0 11 0;
86
#X connect 11 0 12 0;
87
#X connect 12 0 15 0;
88
#X connect 16 0 29 0;
89
#X connect 19 0 18 0;
90
#X connect 22 0 2 0;
91
#X connect 23 0 18 0;
92
#X connect 24 0 2 0;
93
#X connect 26 0 2 0;
94
#X connect 28 0 18 0;
95
#X connect 32 0 31 0;
96
#X connect 33 0 31 0;
97
#X connect 35 0 36 0;
98
#X connect 40 0 41 0;
99
#X connect 45 0 41 0;
100
#X connect 46 0 41 0;
101
#X connect 47 0 41 0;
102
#X connect 48 0 41 0;
103
#X connect 50 0 49 0;
104
#X connect 52 0 41 0;