aboutsummaryrefslogtreecommitdiffstats
path: root/src/javax/media/j3d/Locale.java
blob: 4da6c4a1b9f8bae57287e6b2eaa1ee2ce883043f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
/*
 * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 *
 */

package javax.media.j3d;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Vector;

/**
 * A Locale object defines a high-resolution position within a
 * VirtualUniverse, and serves as a container for a collection of
 * BranchGroup-rooted subgraphs (branch graphs), at that position.
 * Objects within a Locale are defined using standard double-precision
 * coordinates, relative to the origin of the Locale.  This origin
 * defines the Virtual World coordinate system for that Locale.
 * <p>
 * A Locale object defines methods to set and get its high-resolution
 * coordinates, and methods to add, remove, and enumerate the branch
 * graphs.
 *
 * <p>
 * For more information, see the
 * <a href="doc-files/intro.html">Introduction to the Java 3D API</a> and
 * <a href="doc-files/VirtualUniverse.html">Scene Graph Superstructure</a>
 * documents.
 *
 * @see VirtualUniverse
 * @see HiResCoord
 * @see BranchGroup
 */

public class Locale extends Object {

    /**
     * The virtual universe that this Locale object is contained within.
     */
    VirtualUniverse universe;

    /**
     * The high resolution coordinate associated with this Locale object.
     */
    HiResCoord 	hiRes;

/**
 * List of BranchGroup objects included in this Locale
 */
Vector<BranchGroup> branchGroups = new Vector<BranchGroup>();

    // locale's identifier
    String nodeId = null;

    /**
     * Constructs and initializes a new high resolution Locale object
     * located at (0, 0, 0).
     * @param universe the virtual universe that will contain this
     * Locale object
     */
    public Locale(VirtualUniverse universe) {
	this.universe = universe;
	this.universe.addLocale(this);
	this.hiRes = new HiResCoord();
        nodeId = universe.getNodeId();
    }

    /**
     * Constructs and initializes a new high resolution Locale object
     * from the parameters provided.
     * @param universe the virtual universe that will contain this
     * Locale object
     * @param x an eight element array specifying the x position
     * @param y an eight element array specifying the y position
     * @param z an eight element array specifying the z position
     */
    public Locale(VirtualUniverse universe, int[] x, int[] y, int[] z) {
	this.universe = universe;
	this.universe.addLocale(this);
	this.hiRes = new HiResCoord(x, y, z);
        nodeId = universe.getNodeId();
    }

    /**
     * Constructs and initializes a new high resolution Locale object
     * at the location specified by the HiResCoord argument.
     * @param universe the virtual universe that will contain this
     * Locale object
     * @param hiRes the HiRes coordinate to use in creating this Locale
     */
    public Locale(VirtualUniverse universe, HiResCoord hiRes) {
	this.universe = universe;
	this.universe.addLocale(this);
	this.hiRes = new HiResCoord(hiRes);
        nodeId = universe.getNodeId();
    }

    /**
     * Retrieves the virtual universe within which this Locale object
     * is contained.  A null reference indicates that this
     * Locale has been removed from its VirtualUniverse.
     * @return the virtual universe within which this Locale object
     * is contained.
     */
    public VirtualUniverse getVirtualUniverse() {
	return universe;
    }

    /**
     * Sets the HiRes coordinate of this Locale to the location
     * specified by the parameters provided.
     * @param x an eight element array specifying the x position
     * @param y an eight element array specifying the y position
     * @param z an eight element array specifying the z position
     */
    public void setHiRes(int[] x, int[] y, int[] z) {
	this.hiRes.setHiResCoord(x, y, z);
    }

    /**
     * Sets the HiRes coordinate of this Locale
     * to the location specified by the HiRes argument.
     * @param hiRes the HiRes coordinate specifying this node's new location
     */
    public void setHiRes(HiResCoord hiRes) {
	this.hiRes.setHiResCoord(hiRes);
    }

    /**
     * Returns this node's HiResCoord.
     * @param hiRes a HiResCoord object that will receive the
     * HiRes coordinate of this Locale node
     */
    public void getHiRes(HiResCoord hiRes) {
	this.hiRes.getHiResCoord(hiRes);
    }

    /**
     * Add a new branch graph rooted at BranchGroup to
     * the list of branch graphs.
     * @param branchGroup root of the branch graph to be added
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     * @exception MultipleParentException if the specified BranchGroup node
     * is already live.
     */
    public void addBranchGraph(BranchGroup branchGroup){
	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

	// if the BranchGroup already has a parent, or has already been
	// added to a locale, throw MultipleParentException
        if ((((BranchGroupRetained)branchGroup.retained).parent != null) ||
	    (branchGroup.isLive())) {
	    throw new MultipleParentException(J3dI18N.getString("Locale0"));
        }

        universe.notifyStructureChangeListeners(true, this, branchGroup);
	universe.resetWaitMCFlag();
	synchronized (universe.sceneGraphLock) {
	    doAddBranchGraph(branchGroup);
	    universe.setLiveState.reset(this);
	}
	universe.waitForMC();
    }

    // The method that does the work once the lock is acquired.
    void doAddBranchGraph(BranchGroup branchGroup) {
	BranchGroupRetained bgr = (BranchGroupRetained)branchGroup.retained;
	J3dMessage createMessage;
	SetLiveState s = universe.setLiveState;

	// bgr.setLocale(this);

	// addElement needs to precede setLive or else any liveness checks
        // in the initialize() call of a user behavior (ie, calling collision
        // or picking constructor with a SceneGraphPath) will fail
        // when SceneGraphPath.validate() attempts to verify that
        // the proper Locale is associated with that SceneGraphPath
	bgr.attachedToLocale = true;
	branchGroups.addElement(branchGroup);
	s.reset(this);
	s.currentTransforms[0] = new Transform3D[2];
	s.currentTransforms[0][0] = new Transform3D();
	s.currentTransforms[0][1] = new Transform3D();
	s.currentTransformsIndex[0] = new int[2];
	s.currentTransformsIndex[0][0] = 0;
	s.currentTransformsIndex[0][1] = 0;

	s.localToVworld = s.currentTransforms;
	s.localToVworldIndex = s.currentTransformsIndex;

	s.branchGroupPaths = new ArrayList<BranchGroupRetained[]>();
	s.branchGroupPaths.add(new BranchGroupRetained[0]);

	s.orderedPaths = new ArrayList<OrderedPath>(1);
	s.orderedPaths.add(new OrderedPath());

	s.switchStates = new ArrayList<SwitchState>(1);
	s.switchStates.add(new SwitchState(false));

	bgr.setLive(s);

	createMessage = new J3dMessage();
	createMessage.threads = J3dThread.UPDATE_RENDER| J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	createMessage.type = J3dMessage.ORDERED_GROUP_INSERTED;
	createMessage.universe = universe;
	createMessage.args[0] = s.ogList.toArray();
	createMessage.args[1] = s.ogChildIdList.toArray();
	createMessage.args[2] = s.ogOrderedIdList.toArray();
	createMessage.args[3] = s.ogCIOList.toArray();
	createMessage.args[4] = s.ogCIOTableList.toArray();

	VirtualUniverse.mc.processMessage(createMessage);

	createMessage = new J3dMessage();
	createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	createMessage.type = J3dMessage.VIEWSPECIFICGROUP_INIT;
	createMessage.universe = universe;
	createMessage.args[0] = s.changedViewGroup;
	createMessage.args[1] = s.changedViewList;
	createMessage.args[2] = s.keyList;
	VirtualUniverse.mc.processMessage(createMessage);


	createMessage = new J3dMessage();
	createMessage.threads = s.notifyThreads;
        createMessage.type = J3dMessage.INSERT_NODES;
        createMessage.universe = universe;
        createMessage.args[0] = s.nodeList.toArray();
	createMessage.args[1] = null;
	createMessage.args[2] = null;
	if (s.viewScopedNodeList != null) {
	    createMessage.args[3] = s.viewScopedNodeList;
	    createMessage.args[4] = s.scopedNodesViewList;
	}
	VirtualUniverse.mc.processMessage(createMessage);

	int sz = s.behaviorNodes.size();
	for (int i=0; i< sz; i++) {
	    BehaviorRetained b = s.behaviorNodes.get(i);
	    b.executeInitialize();
	}

	createMessage = new J3dMessage();
        createMessage.threads = J3dThread.UPDATE_BEHAVIOR;
        createMessage.type = J3dMessage.BEHAVIOR_ACTIVATE;
        createMessage.universe = universe;
        VirtualUniverse.mc.processMessage(createMessage);

	// Free up memory.
	s.reset(null);
    }

    /**
     * Removes a branch graph rooted at BranchGroup from
     * the list of branch graphs.
     * @param branchGroup root of the branch graph to be removed
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     * @exception CapabilityNotSetException if the ALLOW_DETACH capability is
     * not set in the specified BranchGroup node.
     */
    public void removeBranchGraph(BranchGroup branchGroup){
	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

	if (! branchGroup.getCapability(BranchGroup.ALLOW_DETACH)) {
	    throw new CapabilityNotSetException(J3dI18N.getString("Locale1"));
	}
	universe.resetWaitMCFlag();
	synchronized (universe.sceneGraphLock) {
	    doRemoveBranchGraph(branchGroup, null, 0);
	    universe.setLiveState.reset(this);
	}
	universe.waitForMC();
    }


    // Method to remove all branch graphs from this Locale and remove
    // this Locale from the VirtualUniverse
    void removeFromUniverse() {
	if (branchGroups.size() > 0) {
	    universe.resetWaitMCFlag();
	    synchronized (universe.sceneGraphLock) {
		// Make a copy of the branchGroups list so that we can safely
		// iterate over it.
		Object[] bg = branchGroups.toArray();
		for (int i = 0; i < bg.length; i++) {
		    doRemoveBranchGraph((BranchGroup)bg[i], null, 0);
		}
	    }
	    // Put after sceneGraphLock to prevent deadlock
	    universe.waitForMC();
	}

	// free nodeId
	if (nodeId != null) {
	    universe.nodeIdFreeList.addElement(nodeId);
	    nodeId = null;
	}

	// Set universe pointer to null, indicating that this Locale
	// has been removed from its universe
	universe = null;
    }


    // The method that does the work once the lock is acquired.
    void doRemoveBranchGraph(BranchGroup branchGroup,
                                J3dMessage messages[], int startIndex) {

	BranchGroupRetained bgr = (BranchGroupRetained)branchGroup.retained;
	J3dMessage destroyMessage;

	if (!branchGroup.isLive())
	    return;
	bgr.attachedToLocale = false;
	branchGroups.removeElement(branchGroup);
	universe.setLiveState.reset(this);
	bgr.clearLive(universe.setLiveState);
	bgr.setParent(null);
	bgr.setLocale(null);

	if (messages == null) {
	    destroyMessage = new J3dMessage();
	} else {
	    destroyMessage = messages[startIndex++];
	}
	destroyMessage.threads = J3dThread.UPDATE_RENDER| J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	destroyMessage.type = J3dMessage.ORDERED_GROUP_REMOVED;
	destroyMessage.universe = universe;
	destroyMessage.args[0] = universe.setLiveState.ogList.toArray();
	destroyMessage.args[1] = universe.setLiveState.ogChildIdList.toArray();
	destroyMessage.args[3] = universe.setLiveState.ogCIOList.toArray();
	destroyMessage.args[4] = universe.setLiveState.ogCIOTableList.toArray();

        // Issue 312: We need to send the REMOVE_NODES message to the
        // RenderingEnvironmentStructure before we send VIEWSPECIFICGROUP_CLEAR,
        // since the latter clears the list of views that is referred to by
        // scopedNodesViewList and used by removeNodes.
	if (messages == null) {
            VirtualUniverse.mc.processMessage(destroyMessage);
            destroyMessage = new J3dMessage();
        } else {
            destroyMessage = messages[startIndex++];
        }
        destroyMessage.threads = universe.setLiveState.notifyThreads;
        destroyMessage.type = J3dMessage.REMOVE_NODES;
        destroyMessage.universe = universe;
        destroyMessage.args[0] = universe.setLiveState.nodeList.toArray();
	if (universe.setLiveState.viewScopedNodeList != null) {
	    destroyMessage.args[3] = universe.setLiveState.viewScopedNodeList;
	    destroyMessage.args[4] = universe.setLiveState.scopedNodesViewList;
	}

	if (messages == null) {
            VirtualUniverse.mc.processMessage(destroyMessage);
            destroyMessage = new J3dMessage();
        } else {
            destroyMessage = messages[startIndex++];
        }
	destroyMessage.threads =  J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	destroyMessage.type = J3dMessage.VIEWSPECIFICGROUP_CLEAR;
	destroyMessage.universe = universe;
	destroyMessage.args[0] = universe.setLiveState.changedViewGroup;
	destroyMessage.args[1] = universe.setLiveState.keyList;

	if (messages == null) {
            VirtualUniverse.mc.processMessage(destroyMessage);
        } else {
            destroyMessage = messages[startIndex++];
	}

	if (universe.isEmpty()) {
	    VirtualUniverse.mc.postRequest(MasterControl.EMPTY_UNIVERSE,
					   universe);
	}
	universe.setLiveState.reset(null); // cleanup memory
        universe.notifyStructureChangeListeners(false, this, branchGroup);
    }

    /**
     * Replaces the branch graph rooted at oldGroup in the list of
     * branch graphs with the branch graph rooted at
     * newGroup.
     * @param oldGroup root of the branch graph to be replaced.
     * @param newGroup root of the branch graph that will replace the old
     * branch graph.
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     * @exception CapabilityNotSetException if the ALLOW_DETACH capability is
     * not set in the old BranchGroup node.
     * @exception MultipleParentException if the new BranchGroup node
     * is already live.
     */
    public void replaceBranchGraph(BranchGroup oldGroup,
			    BranchGroup newGroup){

	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

	if (! oldGroup.getCapability(BranchGroup.ALLOW_DETACH)) {
	    throw new CapabilityNotSetException(J3dI18N.getString("Locale1"));
	}

        if (((BranchGroupRetained)newGroup.retained).parent != null) {
	    throw new MultipleParentException(J3dI18N.getString("Locale3"));
        }
	universe.resetWaitMCFlag();
        universe.notifyStructureChangeListeners(true, this, newGroup);
	synchronized (universe.sceneGraphLock) {
	    doReplaceBranchGraph(oldGroup, newGroup);
	    universe.setLiveState.reset(this);
	}
        universe.notifyStructureChangeListeners(false, this, oldGroup);
	universe.waitForMC();
    }

    // The method that does the work once the lock is acquired.
    void doReplaceBranchGraph(BranchGroup oldGroup,
			    BranchGroup newGroup){
	BranchGroupRetained obgr = (BranchGroupRetained)oldGroup.retained;
	BranchGroupRetained nbgr = (BranchGroupRetained)newGroup.retained;
	J3dMessage createMessage;
	J3dMessage destroyMessage;


	branchGroups.removeElement(oldGroup);
	obgr.attachedToLocale = false;
	universe.setLiveState.reset(this);
	obgr.clearLive(universe.setLiveState);

	destroyMessage = new J3dMessage();

	destroyMessage.threads = J3dThread.UPDATE_RENDER| J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	destroyMessage.type = J3dMessage.ORDERED_GROUP_REMOVED;
	destroyMessage.universe = universe;
	destroyMessage.args[0] = universe.setLiveState.ogList.toArray();
	destroyMessage.args[1] = universe.setLiveState.ogChildIdList.toArray();
	destroyMessage.args[3] = universe.setLiveState.ogCIOList.toArray();
	destroyMessage.args[4] = universe.setLiveState.ogCIOTableList.toArray();
	VirtualUniverse.mc.processMessage(destroyMessage);

	destroyMessage = new J3dMessage();
	destroyMessage.threads =  J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	destroyMessage.type = J3dMessage.VIEWSPECIFICGROUP_CLEAR;
	destroyMessage.universe = universe;
	destroyMessage.args[0] = universe.setLiveState.changedViewGroup;
	destroyMessage.args[1] = universe.setLiveState.keyList;
	VirtualUniverse.mc.processMessage(destroyMessage);


	destroyMessage = new J3dMessage();
        destroyMessage.threads = universe.setLiveState.notifyThreads;
        destroyMessage.type = J3dMessage.REMOVE_NODES;
        destroyMessage.universe = universe;
        destroyMessage.args[0] = universe.setLiveState.nodeList.toArray();
        VirtualUniverse.mc.processMessage(destroyMessage);

	branchGroups.addElement(newGroup);
	nbgr.attachedToLocale = true;
	universe.setLiveState.reset(this);
	universe.setLiveState.currentTransforms[0] = new Transform3D[2];
	universe.setLiveState.currentTransforms[0][0] = new Transform3D();
	universe.setLiveState.currentTransforms[0][1] = new Transform3D();
	universe.setLiveState.currentTransformsIndex[0] = new int[2];
	universe.setLiveState.currentTransformsIndex[0][0] = 0;
	universe.setLiveState.currentTransformsIndex[0][1] = 0;

	universe.setLiveState.localToVworld =
	    universe.setLiveState.currentTransforms;
	universe.setLiveState.localToVworldIndex =
	    universe.setLiveState.currentTransformsIndex;

	universe.setLiveState.branchGroupPaths = new ArrayList<BranchGroupRetained[]>();
	universe.setLiveState.branchGroupPaths.add(new BranchGroupRetained[0]);

	universe.setLiveState.orderedPaths = new ArrayList<OrderedPath>(1);
	universe.setLiveState.orderedPaths.add(new OrderedPath());

	universe.setLiveState.switchStates = new ArrayList<SwitchState>(1);
	universe.setLiveState.switchStates.add(new SwitchState(false));

	nbgr.setLive(universe.setLiveState);


	createMessage = new J3dMessage();
	createMessage.threads = J3dThread.UPDATE_RENDER| J3dThread.UPDATE_RENDERING_ENVIRONMENT;
	createMessage.type = J3dMessage.ORDERED_GROUP_INSERTED;
	createMessage.universe = universe;
	createMessage.args[0] = universe.setLiveState.ogList.toArray();
	createMessage.args[1] = universe.setLiveState.ogChildIdList.toArray();
	createMessage.args[2] = universe.setLiveState.ogOrderedIdList.toArray();
	createMessage.args[3] = universe.setLiveState.ogCIOList.toArray();
	createMessage.args[4] = universe.setLiveState.ogCIOTableList.toArray();
	VirtualUniverse.mc.processMessage(createMessage);

	// XXXX: make these two into one message
	createMessage = new J3dMessage();
        createMessage.threads = universe.setLiveState.notifyThreads;
        createMessage.type = J3dMessage.INSERT_NODES;
        createMessage.universe = universe;
        createMessage.args[0] = universe.setLiveState.nodeList.toArray();
	createMessage.args[1] = null;
	createMessage.args[2] = null;
	if (universe.setLiveState.viewScopedNodeList != null) {
	    createMessage.args[3] = universe.setLiveState.viewScopedNodeList;
	    createMessage.args[4] = universe.setLiveState.scopedNodesViewList;
	}
        VirtualUniverse.mc.processMessage(createMessage);

	BehaviorRetained[] behavNodes = new BehaviorRetained[universe.setLiveState.behaviorNodes.size()];
	behavNodes = universe.setLiveState.behaviorNodes.toArray(behavNodes);

	if (universe.isEmpty()) {
	    VirtualUniverse.mc.postRequest(MasterControl.EMPTY_UNIVERSE,
					   universe);
	}

        for (int i=0; i< behavNodes.length; i++) {
            behavNodes[i].executeInitialize();
        }

	createMessage = new J3dMessage();
        createMessage.threads = J3dThread.UPDATE_BEHAVIOR;
        createMessage.type = J3dMessage.BEHAVIOR_ACTIVATE;
        createMessage.universe = universe;
        VirtualUniverse.mc.processMessage(createMessage);

	// Free up memory.
	universe.setLiveState.reset(null);
    }

    /**
     * Get number of branch graphs in this Locale.
     * @return number of branch graphs in this Locale.
     */
    public int numBranchGraphs(){
	return  branchGroups.size();
    }

    /**
     * Gets an Enumeration object of all branch graphs in this Locale.
     * @return an Enumeration object of all branch graphs.
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     */
    public Enumeration getAllBranchGraphs(){
	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

	return branchGroups.elements();
    }


    void validateModeFlagAndPickShape(int mode, int flags, PickShape pickShape) {

        if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

        if((mode != PickInfo.PICK_BOUNDS) && (mode != PickInfo.PICK_GEOMETRY)) {

          throw new IllegalArgumentException(J3dI18N.getString("Locale5"));
        }

        if((pickShape instanceof PickPoint) && (mode == PickInfo.PICK_GEOMETRY)) {
          throw new IllegalArgumentException(J3dI18N.getString("Locale6"));
        }

        if(((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) &&
                ((flags & PickInfo.ALL_GEOM_INFO) != 0)) {
            throw new IllegalArgumentException(J3dI18N.getString("Locale7"));
        }

        if((mode == PickInfo.PICK_BOUNDS) &&
                (((flags & (PickInfo.CLOSEST_GEOM_INFO |
                            PickInfo.ALL_GEOM_INFO |
                            PickInfo.CLOSEST_DISTANCE |
                            PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) {

          throw new IllegalArgumentException(J3dI18N.getString("Locale8"));
        }

        if((pickShape instanceof PickBounds) &&
                (((flags & (PickInfo.CLOSEST_GEOM_INFO |
                            PickInfo.ALL_GEOM_INFO |
                            PickInfo.CLOSEST_DISTANCE |
                            PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) {

          throw new IllegalArgumentException(J3dI18N.getString("Locale9"));
        }
    }

    /**
     * Returns an array referencing all the items that are pickable below this
     * <code>Locale</code> that intersect with PickShape.
     * The resultant array is unordered.
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @see BranchGroup#pickAll
     */
    public SceneGraphPath[] pickAll( PickShape pickShape ) {
	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

        PickInfo[] pickInfoArr = pickAll( PickInfo.PICK_BOUNDS,
                PickInfo.SCENEGRAPHPATH, pickShape);

       if(pickInfoArr == null) {
            return null;
       }
        SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length];
        for( int i=0; i<sgpArr.length; i++) {
            sgpArr[i] = pickInfoArr[i].getSceneGraphPath();
        }

        return sgpArr;

    }


    /**
     * Returns an array unsorted references to all the PickInfo objects that are pickable
     * below this <code>Locale</code> that intersect with PickShape.
     * The accuracy of the pick is set by the pick mode. The mode include :
     * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
     * is specified via a masked variable, flags, indicating which components are
     * present in each returned PickInfo object.
     *
     * @param mode  picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>.
     *
     * @param flags a mask indicating which components are present in each PickInfo object.
     * This is specified as one or more individual bits that are bitwise "OR"ed together to
     * describe the PickInfo data. The flags include :
     * <ul>
     * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br>
     * <code>PickInfo.NODE</code> - request for computed intersected Node.<br>
     * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br>
     * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br>
     * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br>
     * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br>
     * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br>
     * </ul>
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
     * ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
     * is set to PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
     * nor PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is PickBounds
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @exception CapabilityNotSetException if the mode is
     * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
     * is not set in any Geometry objects referred to by any shape
     * node whose bounds intersects the PickShape.
     *
     * @exception CapabilityNotSetException if flags contains any of
     * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
     * or ALL_GEOM_INFO, and the capability bits that control reading of
     * coordinate data are not set in any GeometryArray object referred
     * to by any shape node that intersects the PickShape.
     * The capability bits that must be set to avoid this exception are as follows :
     * <ul>
     * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li>
     * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li>
     * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
     * (in addition to one of the above)</li>
     * </ul>
     *
     * @see BranchGroup#pickAll(int,int,javax.media.j3d.PickShape)
     * @see PickInfo
     *
     * @since Java 3D 1.4
     *
     */
    public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) {

        validateModeFlagAndPickShape(mode, flags, pickShape);

	GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape);

        return PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL);

    }

    /**
     * Returns a sorted array of references to all the pickable items
     * that intersect with the pickShape. Element [0] references the
     * item closest to <i>origin</i> of PickShape successive array
     * elements are further from the <i>origin</i>
     * <br>
     * NOTE: If pickShape is of type PickBounds, the resulting array
     * is unordered.
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @see BranchGroup#pickAllSorted
     */
    public SceneGraphPath[] pickAllSorted( PickShape pickShape ) {
	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

        PickInfo[] pickInfoArr = pickAllSorted( PickInfo.PICK_BOUNDS,
                PickInfo.SCENEGRAPHPATH, pickShape);

       if(pickInfoArr == null) {
            return null;
       }
        SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length];
        for( int i=0; i<sgpArr.length; i++) {
            sgpArr[i] = pickInfoArr[i].getSceneGraphPath();
        }

        return sgpArr;

    }

    /**
     * Returns a sorted array of PickInfo references to all the pickable
     * items that intersect with the pickShape. Element [0] references
     * the item closest to <i>origin</i> of PickShape successive array
     * elements are further from the <i>origin</i>
     * The accuracy of the pick is set by the pick mode. The mode include :
     * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
     * is specified via a masked variable, flags, indicating which components are
     * present in each returned PickInfo object.
     *
     * @param mode  picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>.
     *
     * @param flags a mask indicating which components are present in each PickInfo object.
     * This is specified as one or more individual bits that are bitwise "OR"ed together to
     * describe the PickInfo data. The flags include :
     * <ul>
     * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br>
     * <code>PickInfo.NODE</code> - request for computed intersected Node.<br>
     * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br>
     * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br>
     * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br>
     * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br>
     * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br>
     * </ul>
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
     * ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
     * is set to PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
     * nor PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is PickBounds
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @exception CapabilityNotSetException if the mode is
     * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
     * is not set in any Geometry objects referred to by any shape
     * node whose bounds intersects the PickShape.
     *
     * @exception CapabilityNotSetException if flags contains any of
     * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
     * or ALL_GEOM_INFO, and the capability bits that control reading of
     * coordinate data are not set in any GeometryArray object referred
     * to by any shape node that intersects the PickShape.
     * The capability bits that must be set to avoid this exception are as follows :
     * <ul>
     * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li>
     * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li>
     * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
     * (in addition to one of the above)</li>
     * </ul>
     *
     * @see BranchGroup#pickAllSorted(int,int,javax.media.j3d.PickShape)
     * @see PickInfo
     *
     * @since Java 3D 1.4
     *
     */
    public PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) {

        validateModeFlagAndPickShape(mode, flags, pickShape);
        GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape);

        if ((geomAtoms == null) || (geomAtoms.length == 0)) {
            return null;
        }

        PickInfo[] pickInfoArr  = null;

	if (mode == PickInfo.PICK_GEOMETRY) {
            // Need to have closestDistance set
            flags |= PickInfo.CLOSEST_DISTANCE;
            pickInfoArr= PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL);
	    if (pickInfoArr != null) {
		PickInfo.sortPickInfoArray(pickInfoArr);
	    }
        }
        else {
            PickInfo.sortGeomAtoms(geomAtoms, pickShape);
            pickInfoArr= PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL);
        }

        return pickInfoArr;
    }

    /**
     * Returns a SceneGraphPath which references the pickable item
     * which is closest to the origin of <code>pickShape</code>.
     * <br>
     * NOTE: If pickShape is of type PickBounds, the return is any
     * pickable node below this Locale.
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @see BranchGroup#pickClosest
     */
    public SceneGraphPath pickClosest( PickShape pickShape ) {
        if (universe == null) {
            throw new IllegalStateException(J3dI18N.getString("Locale4"));
        }

        PickInfo pickInfo = pickClosest( PickInfo.PICK_BOUNDS,
                PickInfo.SCENEGRAPHPATH, pickShape);

        if(pickInfo == null) {
            return null;
        }
        return pickInfo.getSceneGraphPath();
    }

    /**
     * Returns a PickInfo which references the pickable item
     * which is closest to the origin of <code>pickShape</code>.
     * The accuracy of the pick is set by the pick mode. The mode include :
     * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
     * is specified via a masked variable, flags, indicating which components are
     * present in each returned PickInfo object.
     *
     * @param mode  picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>.
     *
     * @param flags a mask indicating which components are present in each PickInfo object.
     * This is specified as one or more individual bits that are bitwise "OR"ed together to
     * describe the PickInfo data. The flags include :
     * <ul>
     * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br>
     * <code>PickInfo.NODE</code> - request for computed intersected Node.<br>
     * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br>
     * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br>
     * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br>
     * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br>
     * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br>
     * </ul>
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
     * ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
     * is set to PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
     * nor PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is PickBounds
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @exception CapabilityNotSetException if the mode is
     * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
     * is not set in any Geometry objects referred to by any shape
     * node whose bounds intersects the PickShape.
     *
     * @exception CapabilityNotSetException if flags contains any of
     * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
     * or ALL_GEOM_INFO, and the capability bits that control reading of
     * coordinate data are not set in any GeometryArray object referred
     * to by any shape node that intersects the PickShape.
     * The capability bits that must be set to avoid this exception are as follows :
     * <ul>
     * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li>
     * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li>
     * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
     * (in addition to one of the above)</li>
     * </ul>
     *
     * @see BranchGroup#pickClosest(int,int,javax.media.j3d.PickShape)
     * @see PickInfo
     *
     * @since Java 3D 1.4
     *
     */
    public PickInfo pickClosest( int mode, int flags, PickShape pickShape ) {

        PickInfo[] pickInfoArr = null;

        pickInfoArr = pickAllSorted( mode, flags, pickShape );

        if(pickInfoArr == null) {
            return null;
        }

        return pickInfoArr[0];

    }

    /**
     * Returns a reference to any item that is Pickable below this
     * Locale which intersects with <code>pickShape</code>.
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @see BranchGroup#pickAny
     */
    public SceneGraphPath pickAny( PickShape pickShape ) {
	if (universe == null) {
	    throw new IllegalStateException(J3dI18N.getString("Locale4"));
	}

        PickInfo pickInfo = pickAny( PickInfo.PICK_BOUNDS,
                PickInfo.SCENEGRAPHPATH, pickShape);

        if(pickInfo == null) {
            return null;
        }
        return pickInfo.getSceneGraphPath();

    }

    /**
     * Returns a PickInfo which references the pickable item  below this
     * Locale which intersects with <code>pickShape</code>.
     * The accuracy of the pick is set by the pick mode. The mode include :
     * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
     * is specified via a masked variable, flags, indicating which components are
     * present in each returned PickInfo object.
     *
     * @param mode  picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>.
     *
     * @param flags a mask indicating which components are present in each PickInfo object.
     * This is specified as one or more individual bits that are bitwise "OR"ed together to
     * describe the PickInfo data. The flags include :
     * <ul>
     * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br>
     * <code>PickInfo.NODE</code> - request for computed intersected Node.<br>
     * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br>
     * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br>
     * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br>
     * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br>
     * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br>
     * </ul>
     *
     * @param pickShape the description of this picking volume or area.
     *
     * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
     * ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
     * is set to PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
     * nor PICK_GEOMETRY.
     *
     * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalArgumentException if pickShape is PickBounds
     * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
     * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
     *
     * @exception IllegalStateException if this Locale has been
     * removed from its VirtualUniverse.
     *
     * @exception CapabilityNotSetException if the mode is
     * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
     * is not set in any Geometry objects referred to by any shape
     * node whose bounds intersects the PickShape.
     *
     * @exception CapabilityNotSetException if flags contains any of
     * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
     * or ALL_GEOM_INFO, and the capability bits that control reading of
     * coordinate data are not set in any GeometryArray object referred
     * to by any shape node that intersects the PickShape.
     * The capability bits that must be set to avoid this exception are as follows :
     * <ul>
     * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li>
     * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li>
     * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
     * (in addition to one of the above)</li>
     * </ul>
     *
     * @see BranchGroup#pickAny(int,int,javax.media.j3d.PickShape)
     * @see PickInfo
     *
     * @since Java 3D 1.4
     *
     */
    public PickInfo pickAny( int mode, int flags, PickShape pickShape ) {

        validateModeFlagAndPickShape(mode, flags, pickShape);
	GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape);

        PickInfo[] pickInfoArr = PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ANY);

        if(pickInfoArr == null) {
            return null;
        }

        return pickInfoArr[0];

    }

}