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
|
/*
* Copyright 1997-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;
import javax.vecmath.Color3f;
/**
* The Fog leaf node defines Fog parameters.
* It also specifies an region of influence in which this fog node
* is active.
*/
abstract class FogRetained extends LeafRetained{
// Statics used when something in the fog changes
static final int COLOR_CHANGED = 0x0001;
static final int SCOPE_CHANGED = 0x0002;
static final int BOUNDS_CHANGED = 0x0004;
static final int BOUNDINGLEAF_CHANGED = 0x0008;
static final int INIT_MIRROR = 0x0010;
static final int CLEAR_MIRROR = 0x0020;
static final int LAST_DEFINED_BIT = 0x0020;
// Fog color.
Color3f color = new Color3f(0.0f, 0.0f, 0.0f);
/**
* The Boundary object defining the lights's region of influence.
*/
Bounds regionOfInfluence = null;
/**
* The bounding leaf reference
*/
BoundingLeafRetained boundingLeaf = null;
/**
* Vector of GroupRetained nodes that scopes this fog.
*/
Vector<GroupRetained> scopes = new Vector<GroupRetained>();
// An int that is set when this fog is changed
int isDirty = 0xffff;
// This is true when this fog is referenced in an immediate mode context
boolean inImmCtx = false;
/**
* The transformed value of the applicationRegion.
*/
Bounds region = null;
// A reference to the scene graph fog
FogRetained sgFog = null;
// The mirror copy of this fog
FogRetained mirrorFog = null;
// Target threads to be notified when light changes
static final int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |
J3dThread.UPDATE_RENDER;
// Boolean to indicate if this object is scoped (only used for mirror objects
boolean isScoped = false;
// The object that contains the dynamic HashKey - a string type object
// Used in scoping
HashKey tempKey = new HashKey(250);
/**
* The EnvironmentSets which reference this fog.
* Note that multiple RenderBin update thread may access
* this shared environmentSets simultaneously.
* So we use UnorderList when sync. all the operations.
*/
UnorderList environmentSets = new UnorderList(1, EnvironmentSet.class);
// Is true, if the mirror fog is viewScoped
boolean isViewScoped = false;
// Scale value extracted from localToVworld transform
private double localToVworldScale = 1.0;
FogRetained() {
localBounds = new BoundingBox((Bounds)null);
}
/**
* Initialize the fog color to the specified color.
*/
void initColor(Color3f color) {
this.color.set(color);
}
/**
* Sets the fog color to the specified color and send message
*/
void setColor(Color3f color) {
this.color.set(color);
sendMessage(COLOR_CHANGED, new Color3f(color));
}
/**
* Sets the fog color to the specified color.
*/
void initColor(float r, float g, float b) {
this.color.x = r;
this.color.y = g;
this.color.z = b;
}
/**
* Sets the fog color to the specified color and send message
*/
void setColor(float r, float g, float b) {
initColor(r, g, b);
sendMessage(COLOR_CHANGED, new Color3f(r, g, b));
}
/**
* Retrieves the fog color.
*/
void getColor(Color3f color) {
color.set(this.color);
}
/**
* Set the Fog's region of influence.
*/
void initInfluencingBounds(Bounds region) {
if (region != null) {
this.regionOfInfluence = (Bounds) region.clone();
} else {
this.regionOfInfluence = null;
}
if (staticTransform != null) {
this.regionOfInfluence.transform(staticTransform.transform);
}
}
/**
* Set the Fog's region of influence and send message
*/
void setInfluencingBounds(Bounds region) {
initInfluencingBounds(region);
sendMessage(BOUNDS_CHANGED,
(region != null ? region.clone() : null));
}
/**
* Get the Fog's region of Influence.
*/
Bounds getInfluencingBounds() {
Bounds b = null;
if (regionOfInfluence != null) {
b = (Bounds)regionOfInfluence.clone();
if (staticTransform != null) {
Transform3D invTransform = staticTransform.getInvTransform();
b.transform(invTransform);
}
}
return b;
}
/**
* Set the Fog's region of influence to the specified Leaf node.
*/
void initInfluencingBoundingLeaf(BoundingLeaf region) {
if (region != null) {
boundingLeaf = (BoundingLeafRetained)region.retained;
} else {
boundingLeaf = null;
}
}
/**
* Set the Fog's region of influence to the specified Leaf node.
*/
void setInfluencingBoundingLeaf(BoundingLeaf region) {
if (boundingLeaf != null)
boundingLeaf.mirrorBoundingLeaf.removeUser(mirrorFog);
if (region != null) {
boundingLeaf = (BoundingLeafRetained)region.retained;
boundingLeaf.mirrorBoundingLeaf.addUser(mirrorFog);
} else {
boundingLeaf = null;
}
sendMessage(BOUNDINGLEAF_CHANGED,
(boundingLeaf != null ?
boundingLeaf.mirrorBoundingLeaf : null));
}
/**
* Get the Fog's region of influence.
*/
BoundingLeaf getInfluencingBoundingLeaf() {
return (boundingLeaf != null ?
(BoundingLeaf)boundingLeaf.source : null);
}
/**
* Replaces the specified scope with the scope provided.
* @param scope the new scope
* @param index which scope to replace
*/
void initScope(Group scope, int index) {
scopes.setElementAt((GroupRetained)(scope.retained), index);
}
/**
* Replaces the specified scope with the scope provided.
* @param scope the new scope
* @param index which scope to replace
*/
void setScope(Group scope, int index) {
ArrayList addScopeList = new ArrayList();
ArrayList removeScopeList = new ArrayList();
Object[] scopeInfo = new Object[3];
GroupRetained group = scopes.get(index);
tempKey.reset();
group.removeAllNodesForScopedFog(mirrorFog, removeScopeList, tempKey);
group = (GroupRetained)scope.retained;
initScope(scope, index);
tempKey.reset();
// If its a group, then add the scope to the group, if
// its a shape, then keep a list to be added during
// updateMirrorObject
group.addAllNodesForScopedFog(mirrorFog,addScopeList, tempKey);
scopeInfo[0] = addScopeList;
scopeInfo[1] = removeScopeList;
scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE:Boolean.FALSE);
sendMessage(SCOPE_CHANGED, scopeInfo);
}
/**
* Inserts the specified scope at specified index.before the
* fog is live
* @param scope the new scope
* @param index position to insert new scope at
*/
void initInsertScope(Node scope, int index) {
GroupRetained group = (GroupRetained)scope.retained;
group.setFogScope();
scopes.insertElementAt((GroupRetained)(scope.retained), index);
}
/**
* Inserts the specified scope at specified index and sends
* a message
* @param scope the new scope
* @param index position to insert new scope at
*/
void insertScope(Node scope, int index) {
Object[] scopeInfo = new Object[3];
ArrayList addScopeList = new ArrayList();
initInsertScope(scope, index);
GroupRetained group = (GroupRetained)scope.retained;
tempKey.reset();
group.addAllNodesForScopedFog(mirrorFog,addScopeList, tempKey);
scopeInfo[0] = addScopeList;
scopeInfo[1] = null;
scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);
sendMessage(SCOPE_CHANGED, scopeInfo);
}
void initRemoveScope(int index) {
GroupRetained group = scopes.elementAt(index);
scopes.removeElementAt(index);
group.removeFogScope();
}
void removeScope(int index) {
Object[] scopeInfo = new Object[3];
ArrayList removeScopeList = new ArrayList();
GroupRetained group = scopes.elementAt(index);
tempKey.reset();
group.removeAllNodesForScopedFog(mirrorFog, removeScopeList, tempKey);
initRemoveScope(index);
scopeInfo[0] = null;
scopeInfo[1] = removeScopeList;
scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);
sendMessage(SCOPE_CHANGED, scopeInfo);
}
/**
* Returns the scope specified by the index.
* @param index which scope to return
* @return the scoperen at location index
*/
Group getScope(int index) {
return (Group)(scopes.elementAt(index).source);
}
/**
* Returns an enumeration object of the scoperen.
* @return an enumeration object of the scoperen
*/
Enumeration<Group> getAllScopes() {
Enumeration<GroupRetained> elm = scopes.elements();
Vector<Group> v = new Vector<Group>(scopes.size());
while (elm.hasMoreElements()) {
v.add((Group)elm.nextElement().source);
}
return v.elements();
}
/**
* Appends the specified scope to this node's list of scopes before
* the fog is alive
* @param scope the scope to add to this node's list of scopes
*/
void initAddScope(Group scope) {
GroupRetained group = (GroupRetained)scope.retained;
scopes.addElement(group);
group.setFogScope();
}
/**
* Appends the specified scope to this node's list of scopes.
* @param scope the scope to add to this node's list of scopes
*/
void addScope(Group scope) {
Object[] scopeInfo = new Object[3];
ArrayList addScopeList = new ArrayList();
GroupRetained group = (GroupRetained)scope.retained;
initAddScope(scope);
tempKey.reset();
group.addAllNodesForScopedFog(mirrorFog,addScopeList, tempKey);
scopeInfo[0] = addScopeList;
scopeInfo[1] = null;
scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);
sendMessage(SCOPE_CHANGED, scopeInfo);
}
/**
* Returns a count of this nodes' scopes.
* @return the number of scopes descendant from this node
*/
int numScopes() {
return scopes.size();
}
/**
* Returns the index of the specified scope within this nodes' list of scopes
* @param scope whose index is desired
* @return index of specified scope
*/
int indexOfScope(Group scope) {
if(scope != null)
return scopes.indexOf(scope.retained);
else
return scopes.indexOf(null);
}
/**
* Removes the specified scope from this nodes' list of scopes
* @param scope to be removed. If the scope is not found,
* the method returns silently
*/
void removeScope(Group scope) {
int i = indexOfScope(scope);
if(i >= 0)
removeScope(i);
}
void initRemoveScope(Group scope) {
int i = indexOfScope(scope);
if(i >= 0)
initRemoveScope(i);
}
/**
* Removes all the scopes from this node's list of scopes.
* The node should revert to universal
* scope after this method returns
*/
void removeAllScopes() {
Object[] scopeInfo = new Object[3];
ArrayList removeScopeList = new ArrayList();
int n = scopes.size();
tempKey.reset();
for (int index = n - 1; index >= 0; index--) {
GroupRetained group = scopes.elementAt(index);
group.removeAllNodesForScopedFog(mirrorFog, removeScopeList, tempKey);
initRemoveScope(index);
}
scopeInfo[0] = null;
scopeInfo[1] = removeScopeList;
scopeInfo[2] = Boolean.FALSE;
sendMessage(SCOPE_CHANGED, scopeInfo);
}
/**
* Removes all scopes from this node
*/
void initRemoveAllScopes() {
int n = scopes.size();
for(int index = n-1; index >= 0; index--)
initRemoveScope(index);
}
/**
* This sets the immedate mode context flag
*/
void setInImmCtx(boolean inCtx) {
inImmCtx = inCtx;
}
/**
* This gets the immedate mode context flag
*/
boolean getInImmCtx() {
return (inImmCtx);
}
boolean isScoped() {
return (scopes != null);
}
/**
* This abstract method is used to update the current native
* context fog values.
*/
abstract void update(Context ctx, double scale);
void updateImmediateMirrorObject(Object[] objs) {
int i;
int component = ((Integer)objs[1]).intValue();
if ((component & BOUNDS_CHANGED) != 0) {
mirrorFog.regionOfInfluence = (Bounds) objs[2];
if (mirrorFog.boundingLeaf == null) {
if (objs[2] != null) {
mirrorFog.region = mirrorFog.regionOfInfluence.copy(mirrorFog.region);
mirrorFog.region.transform(
mirrorFog.regionOfInfluence,
getCurrentLocalToVworld());
}
else {
mirrorFog.region = null;
}
}
}
else if ((component & BOUNDINGLEAF_CHANGED) != 0) {
mirrorFog.boundingLeaf = (BoundingLeafRetained)objs[2];
if (objs[2] != null) {
mirrorFog.region = mirrorFog.boundingLeaf.transformedRegion;
}
else {
if (mirrorFog.regionOfInfluence != null) {
mirrorFog.region = mirrorFog.regionOfInfluence.copy(mirrorFog.region);
mirrorFog.region.transform(
mirrorFog.regionOfInfluence,
getCurrentLocalToVworld());
}
else {
mirrorFog.region = null;
}
}
}
else if ((component & SCOPE_CHANGED) != 0) {
Object[] scopeList = (Object[])objs[2];
ArrayList addList = (ArrayList)scopeList[0];
ArrayList removeList = (ArrayList)scopeList[1];
boolean isScoped = ((Boolean)scopeList[2]).booleanValue();
if (addList != null) {
mirrorFog.isScoped = isScoped;
for (i = 0; i < addList.size(); i++) {
Shape3DRetained obj = ((GeometryAtom)addList.get(i)).source;
obj.addFog(mirrorFog);
}
}
if (removeList != null) {
mirrorFog.isScoped = isScoped;
for (i = 0; i < removeList.size(); i++) {
Shape3DRetained obj = ((GeometryAtom)removeList.get(i)).source;
obj.removeFog(mirrorFog);
}
}
}
}
/**
* The update Object function.
*/
@Override
void updateMirrorObject(Object[] objs) {
int component = ((Integer)objs[1]).intValue();
if ((component & COLOR_CHANGED) != 0) {
mirrorFog.color.set((Color3f)objs[2]);
}
if ((component & INIT_MIRROR) != 0) {
mirrorFog.color.set((Color3f)objs[3]);
}
}
/**
* Note: This routine will only be called on
* the mirror object - will update the object's
* cached region and transformed region
*/
@Override
void updateBoundingLeaf() {
if (boundingLeaf != null && boundingLeaf.switchState.currentSwitchOn) {
region = boundingLeaf.transformedRegion;
} else {
if (regionOfInfluence != null) {
region = regionOfInfluence.copy(region);
region.transform(regionOfInfluence,
getCurrentLocalToVworld());
} else {
region = null;
}
}
}
/**
* This setLive routine just calls the superclass's method (after
* checking for use by an immediate context). It is up to the
* subclasses of fog to add themselves to the list of fogs
*/
@Override
void setLive(SetLiveState s) {
if (inImmCtx) {
throw new IllegalSharingException(J3dI18N.getString("FogRetained0"));
}
super.doSetLive(s);
if (inSharedGroup) {
throw new
IllegalSharingException(J3dI18N.getString("FogRetained1"));
}
// Create the mirror object
// Initialization of the mirror object during the INSERT_NODE
// message (in updateMirrorObject)
if (mirrorFog == null) {
// mirrorFog = (FogRetained)this.clone(true);
mirrorFog = (FogRetained)this.clone();
// Assign the bounding leaf of this mirror object as null
// it will later be assigned to be the mirror of the lights
// bounding leaf object
mirrorFog.boundingLeaf = null;
mirrorFog.sgFog = this;
}
// initMirrorObject();
// If bounding leaf is not null, add the mirror object as a user
// so that any changes to the bounding leaf will be received
if (boundingLeaf != null) {
boundingLeaf.mirrorBoundingLeaf.addUser(mirrorFog);
}
if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {
s.viewScopedNodeList.add(mirrorFog);
s.scopedNodesViewList.add(s.viewLists.get(0));
} else {
s.nodeList.add(mirrorFog);
}
if (s.transformTargets != null && s.transformTargets[0] != null) {
s.transformTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);
s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
}
// process switch leaf
if (s.switchTargets != null &&
s.switchTargets[0] != null) {
s.switchTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);
}
mirrorFog.switchState = s.switchStates.get(0);
s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|
J3dThread.UPDATE_RENDER;
super.markAsLive();
}
// This is called on the parent object
void initMirrorObject(Object[] args) {
Shape3DRetained shape;
Object[] scopeInfo = (Object[]) args[2];
Boolean scoped = (Boolean)scopeInfo[0];
ArrayList shapeList = (ArrayList)scopeInfo[1];
BoundingLeafRetained bl=(BoundingLeafRetained)((Object[])args[4])[0];
Bounds bnds = (Bounds)((Object[])args[4])[1];
mirrorFog.inBackgroundGroup = ((Boolean)((Object[])args[4])[2]).booleanValue();
mirrorFog.geometryBackground = (BackgroundRetained)((Object[])args[4])[3];
for (int i = 0; i < shapeList.size(); i++) {
shape = ((GeometryAtom)shapeList.get(i)).source;
shape.addFog(mirrorFog);
}
mirrorFog.isScoped = scoped.booleanValue();
if (bl != null) {
mirrorFog.boundingLeaf = bl.mirrorBoundingLeaf;
mirrorFog.region = boundingLeaf.transformedRegion;
} else {
mirrorFog.boundingLeaf = null;
mirrorFog.region = null;
}
if (bnds != null) {
mirrorFog.regionOfInfluence = bnds;
if (mirrorFog.region == null) {
mirrorFog.region = (Bounds)regionOfInfluence.clone();
mirrorFog.region.transform(regionOfInfluence, getLastLocalToVworld());
}
}
else {
mirrorFog.regionOfInfluence = null;
}
}
// This is called on the parent object
void clearMirrorObject(Object[] args) {
Shape3DRetained shape;
ArrayList shapeList = (ArrayList)args[2];
for (int i = 0; i < shapeList.size(); i++) {
shape = ((GeometryAtom)shapeList.get(i)).source;
shape.removeFog(mirrorFog);
}
mirrorFog.isScoped = false;
}
/**
* This clearLive routine first calls the superclass's method, then
* it removes itself to the list of fogs
*/
@Override
void clearLive(SetLiveState s) {
int i;
GroupRetained group;
super.clearLive(s);
if (s.switchTargets != null &&
s.switchTargets[0] != null) {
s.switchTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);
}
s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|
J3dThread.UPDATE_RENDER;
// Remove this mirror light as users of the bounding leaf
if (mirrorFog.boundingLeaf != null)
mirrorFog.boundingLeaf.removeUser(mirrorFog);
if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {
s.viewScopedNodeList.add(mirrorFog);
s.scopedNodesViewList.add(s.viewLists.get(0));
} else {
s.nodeList.add(mirrorFog);
}
if (s.transformTargets != null && s.transformTargets[0] != null) {
s.transformTargets[0].addNode(mirrorFog, Targets.ENV_TARGETS);
s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
}
if (scopes.size() > 0) {
J3dMessage createMessage = new J3dMessage();
createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
createMessage.universe = universe;
createMessage.type = J3dMessage.FOG_CHANGED;
createMessage.args[0] = this;
createMessage.args[1]= new Integer(CLEAR_MIRROR);
ArrayList removeScopeList = new ArrayList();
for (i = 0; i < scopes.size(); i++) {
group = scopes.get(i);
tempKey.reset();
group.removeAllNodesForScopedFog(mirrorFog, removeScopeList, tempKey);
}
createMessage.args[2] = removeScopeList;
VirtualUniverse.mc.processMessage(createMessage);
}
}
// Clone the retained side only, internal use only
@Override
protected Object clone() {
FogRetained fr = (FogRetained)super.clone();
fr.color = new Color3f(color);
Bounds b = getInfluencingBounds();
if (b != null) {
fr.initInfluencingBounds(b);
}
fr.scopes = new Vector<GroupRetained>();
fr.isDirty = 0xffff;
fr.inImmCtx = false;
fr.region = null;
fr.sgFog = null;
fr.mirrorFog = null;
fr.environmentSets = new UnorderList(1, EnvironmentSet.class);
return fr;
}
@Override
void updateTransformChange() {
super.updateTransformChange();
setLocalToVworldScale(sgFog.getLastLocalToVworld().getDistanceScale());
}
// Called on mirror object
void updateImmediateTransformChange() {
// If bounding leaf is null, tranform the bounds object
if (boundingLeaf == null) {
if (regionOfInfluence != null) {
region = regionOfInfluence.copy(region);
region.transform(regionOfInfluence,
sgFog.getCurrentLocalToVworld());
}
}
}
final void sendMessage(int attrMask, Object attr) {
J3dMessage createMessage = new J3dMessage();
createMessage.threads = targetThreads;
createMessage.universe = universe;
createMessage.type = J3dMessage.FOG_CHANGED;
createMessage.args[0] = this;
createMessage.args[1]= new Integer(attrMask);
createMessage.args[2] = attr;
VirtualUniverse.mc.processMessage(createMessage);
}
@Override
void mergeTransform(TransformGroupRetained xform) {
super.mergeTransform(xform);
if (regionOfInfluence != null) {
regionOfInfluence.transform(xform.transform);
}
}
@Override
void getMirrorObjects(ArrayList leafList, HashKey key) {
leafList.add(mirrorFog);
}
/**
* Scale distances from local to eye coordinate
*/
protected void validateDistancesInEc(double vworldToCoexistenceScale) {
assert false : "subclasses should override this method";
}
double getLocalToVworldScale() {
return localToVworldScale;
}
void setLocalToVworldScale(double localToVworldScale) {
this.localToVworldScale = localToVworldScale;
}
}
|