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
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
|
/*
* 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;
/**
* The RenderingAttributes object defines common rendering attributes
* for all primitive types. The rendering attributes are:<p>
* <ul>
* <li>Depth test function - used to compare the incoming (source) depth of
* each pixel with depth of the pixel stored in frame buffer. If the test
* passes, the pixel is written, otherwise the pixel is not written. The depth test
* function is set with the <code>setDepthTestFunction</code>
* method. By default, LESS_OR_EQUAL is the function used. The depth test
* function is one of the following:</li><p>
* <ul>
* <li>ALWAYS - pixels are always drawn, irrespective of the depth
* value. This effectively disables depth testing.</li><p>
*
* <li>NEVER - pixels are never drawn, irrespective of the depth
* value.</li><p>
*
* <li>EQUAL - pixels are drawn if the incoming pixel depth is equal
* to the stored pixel depth in the frame buffer.</li><p>
*
* <li>NOT_EQUAL - pixels are drawn if the incoming pixel depth is
* not equal to the stored pixel depth in the frame buffer.</li><p>
*
* <li>LESS - pixels are drawn if the incoming pixel depth is less
* than the stored pixel depth in the frame buffer.</li><p>
*
* <li>LESS_OR_EQUAL - pixels are drawn if the incoming pixel depth
* is less than or equal to the stored pixel depth in the frame buffer.
* This is the default setting.</li><p>
*
* <li>GREATER - pixels are drawn if the incoming pixel depth is greater
* than the stored pixel depth in the frame buffer.</li><p>
*
* <li>GREATER_OR_EQUAL - pixels are drawn if the incoming pixel depth
* is greater than or equal to the stored pixel depth in the frame buffer.</li><p>
* </ul>
*
* <li>Alpha test function - used to compare the incoming (source) alpha value
* of each pixel with the alpha test value. If the test passes, the pixel is
* written, otherwise the pixel is not written. The alpha test
* function is set with the <code>setAlphaTestFunction</code>
* method. The alpha test
* function is one of the following:</li><p>
* <ul>
* <li>ALWAYS - pixels are always drawn, irrespective of the alpha
* value. This effectively disables alpha testing.
* This is the default setting.</li><p>
*
* <li>NEVER - pixels are never drawn, irrespective of the alpha
* value.</li><p>
*
* <li>EQUAL - pixels are drawn if the incoming pixel alpha value is equal
* to the alpha test value.</li><p>
*
* <li>NOT_EQUAL - pixels are drawn if the incoming pixel alpha value is
* not equal to the alpha test value.</li><p>
*
* <li>LESS - pixels are drawn if the incoming pixel alpha value is less
* than the alpha test value.</li><p>
*
* <li>LESS_OR_EQUAL - pixels are drawn if the incoming pixel alpha value
* is less than or equal to the alpha test value.</li><p>
*
* <li>GREATER - pixels are drawn if the incoming pixel alpha value is greater
* than the alpha test value.</li><p>
*
* <li>GREATER_OR_EQUAL - pixels are drawn if the incoming pixel alpha
* value is greater than or equal to the alpha test value.</li><p>
* </ul>
*
* <li>Alpha test value - the test value used by the alpha test function.
* This value is compared to the alpha value of each rendered pixel.
* The alpha test value is set with the <code>setAlphaTestValue</code>
* method. The default alpha test value is 0.0.</li><p>
*
* <li>Raster operation - the raster operation function for this
* RenderingAttributes component object. The raster operation is
* set with the <code>setRasterOp</code> method. The raster operation
* is enabled or disabled with the <code>setRasterOpEnable</code>
* method. The raster operation is one of the following:</li><p>
* <ul>
* <li>ROP_CLEAR - DST = 0.</li>
* <li>ROP_AND DST = SRC & DST.</li>
* <li>ROP_AND_REVERSE DST = SRC & ~DST.</li>
* <li>ROP_COPY - DST = SRC. This is the default operation.</li>
* <li>ROP_AND_INVERTED - DST = ~SRC & DST.</li>
* <li>ROP_NOOP - DST = DST.</li>
* <li>ROP_XOR - DST = SRC ^ DST.</li>
* <li>ROP_OR - DST = DST | SRC.</li>
* <li>ROP_NOR - DST = ~( DST | SRC .)</li>
* <li>ROP_EQUIV - DST = ~( DST ^ SRC .)</li>
* <li>ROP_INVERT - DST = ~DST.</li>
* <li>ROP_OR_REVERSE - DST = src | ~DST.</li>
* <li>ROP_COPY_INVERTED - DST = ~SRC.</li>
* <li>ROP_OR_INVERTED - DST = ~SRC | DST.</li>
* <li>ROP_NAND - DST = ~(SRC & DST.)</li>
* <li>ROP_SET - DST = 1.</li><p>
* </ul>
* <li>Vertex colors - vertex colors can be ignored for this
* RenderingAttributes object. This capability is set with the
* <code>setIgnoreVertexColors</code> method. If
* ignoreVertexColors is false, per-vertex colors are used, when
* present in the associated geometry objects, taking
* precedence over the ColoringAttributes color and the
* specified Material color(s). If ignoreVertexColors is true, per-vertex
* colors are ignored. In this case, if lighting is enabled, the
* Material diffuse color will be used as the object color.
* if lighting is disabled, the ColoringAttributes color is
* used. The default value is false.</li><p>
*
* <li>Visibility flag - when set, invisible objects are
* not rendered (subject to the visibility policy for
* the current view), but they can be picked or collided with.
* This flag is set with the <code>setVisible</code>
* method. By default, the visibility flag is true.</li><p>
*
* <li>Depth buffer - can be enabled or disabled for this
* RenderingAttributes component object. The
* <code>setDepthBufferEnable</code> method enables
* or disabled the depth buffer. The
* <code>setDepthBufferWriteEnable</code> method enables or disables
* writing the depth buffer for this object. During the transparent
* rendering pass, this attribute can be overridden by the
* depthBufferFreezeTransparent attribute in the View
* object. Transparent objects include BLENDED transparent and
* antialiased lines and points. Transparent objects do not
* include opaque objects or primitives rendered with
* SCREEN_DOOR transparency. By default, the depth buffer
* is enabled and the depth buffer write is enabled.</li><p>
*
* <li>Stencil buffer - can be enabled or disabled for this RenderingAttributes
* component object using the <code>setStencilEnable</code> method. If the
* stencil buffer is disabled, the stencil operation and function are ignored.
* If a scene graph is rendered on a Canvas3D that does not have a stencil
* buffer, the stencil buffer will be implicitly disabled for that
* canvas.</li><p>
*
* <li>Stencil write mask - mask that controls which bits of the stencil
* buffer are written when the stencil buffer is enabled. The default value is
* <code>~0</code> (all ones).</li><p>
*
* <li>Stencil operation - a set of three stencil operations performed
* when: 1) the stencil test fails; 2) the stencil test passes, but
* the depth test fails; or 3) both the stencil test and depth test pass.
* The stencil operations are set with the <code>setStencilOp</code>
* method. The stencil operation is one of the following:</li><p>
* <ul>
* <li>STENCIL_KEEP - keeps the current value (no operation performed).
* This is the default setting.</li>
* <li>STENCIL_ZERO - Sets the stencil buffer value to 0.</li>
* <li>STENCIL_REPLACE - Sets the stencil buffer value to
* <code>refValue</code>, as specified by <code>setStencilFunction</code>.</li>
* <li>STENCIL_INCR - Increments the current stencil buffer value.</li>
* <li>STENCIL_DECR - Decrements the current stencil buffer value.</li>
* <li>STENCIL_INVERT - Bitwise inverts the current stencil buffer value.</li><p>
* </ul>
*
* <li>Stencil test function - used to compare the stencil reference value with
* the per-pixel stencil value stored in the frame buffer. If the test passes,
* the pixel is written, otherwise the pixel is not written. The stencil
* test function, reference value, and comparison mask are set with the
* <code>setStencilFunction</code> method. The stencil comparison mask is
* bitwise-ANDed with both the stencil reference value and the stored stencil
* value prior to doing the comparison. The default value for the reference value
* is 0. The default value for the comparison mask is <code>~0</code> (all ones).
* The stencil test function is one of the following:</li><p>
* <ul>
* <li>ALWAYS - pixels are always drawn, irrespective of the stencil
* value. This effectively disables stencil testing.
* This is the default setting.</li><p>
*
* <li>NEVER - pixels are never drawn, irrespective of the stencil
* value.</li><p>
*
* <li>EQUAL - pixels are drawn if the stencil reference value is equal
* to the stored stencil value in the frame buffer.</li><p>
*
* <li>NOT_EQUAL - pixels are drawn if the stencil reference value is
* not equal to the stored stencil value in the frame buffer.</li><p>
*
* <li>LESS - pixels are drawn if the stencil reference value is less
* than the stored stencil value in the frame buffer.</li><p>
*
* <li>LESS_OR_EQUAL - pixels are drawn if the stencil reference value
* is less than or equal to the stored stencil value in the frame buffer.</li><p>
*
* <li>GREATER - pixels are drawn if the stencil reference value is greater
* than the stored stencil value in the frame buffer.</li><p>
*
* <li>GREATER_OR_EQUAL - pixels are drawn if the stencil reference value
* is greater than or equal to the stored stencil value in the frame buffer.</li><p>
* </ul>
*
* </ul>
*
* <p>Note: the alpha test, depth test, and stencil functions all use
* the same enums.</p>
*
* @see Appearance
*/
public class RenderingAttributes extends NodeComponent {
/**
* Specifies that this RenderingAttributes object
* allows reading its alpha test value component information.
*/
public static final int
ALLOW_ALPHA_TEST_VALUE_READ = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_ALPHA_TEST_VALUE_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its alpha test value component information.
*/
public static final int
ALLOW_ALPHA_TEST_VALUE_WRITE = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_ALPHA_TEST_VALUE_WRITE;
/**
* Specifies that this RenderingAttributes object
* allows reading its alpha test function component information.
*/
public static final int
ALLOW_ALPHA_TEST_FUNCTION_READ = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_ALPHA_TEST_FUNCTION_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its alpha test function component information.
*/
public static final int
ALLOW_ALPHA_TEST_FUNCTION_WRITE = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_ALPHA_TEST_FUNCTION_WRITE;
/**
* Specifies that this RenderingAttributes object
* allows reading its depth test function component information.
*
* @since Java 3D 1.4
*/
public static final int
ALLOW_DEPTH_TEST_FUNCTION_READ = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_DEPTH_TEST_FUNCTION_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its depth test function component information.
*
* @since Java 3D 1.4
*/
public static final int
ALLOW_DEPTH_TEST_FUNCTION_WRITE = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_DEPTH_TEST_FUNCTION_WRITE;
/**
* Specifies that this RenderingAttributes object
* allows reading its depth buffer enable and depth buffer write enable
* component information.
*/
public static final int
ALLOW_DEPTH_ENABLE_READ = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_DEPTH_ENABLE_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its depth buffer enable and depth buffer write enable
* component information.
*
* @since Java 3D 1.3
*/
public static final int ALLOW_DEPTH_ENABLE_WRITE =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_DEPTH_ENABLE_WRITE;
/**
* Specifies that this RenderingAttributes object
* allows reading its visibility information.
*
* @since Java 3D 1.2
*/
public static final int ALLOW_VISIBLE_READ =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_VISIBLE_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its visibility information.
*
* @since Java 3D 1.2
*/
public static final int ALLOW_VISIBLE_WRITE =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_VISIBLE_WRITE;
/**
* Specifies that this RenderingAttributes object
* allows reading its ignore vertex colors information.
*
* @since Java 3D 1.2
*/
public static final int ALLOW_IGNORE_VERTEX_COLORS_READ =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_IGNORE_VERTEX_COLORS_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its ignore vertex colors information.
*
* @since Java 3D 1.2
*/
public static final int ALLOW_IGNORE_VERTEX_COLORS_WRITE =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_IGNORE_VERTEX_COLORS_WRITE;
/**
* Specifies that this RenderingAttributes object
* allows reading its raster operation information.
*
* @since Java 3D 1.2
*/
public static final int ALLOW_RASTER_OP_READ =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_RASTER_OP_READ;
/**
* Specifies that this RenderingAttributes object
* allows writing its raster operation information.
*
* @since Java 3D 1.2
*/
public static final int ALLOW_RASTER_OP_WRITE =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_RASTER_OP_WRITE;
/**
* Specifies that this RenderingAttributes object allows reading
* its stencil enable, stencil op, stencil function, and
* stencil write mask information.
*
* @since Java 3D 1.4
*/
public static final int ALLOW_STENCIL_ATTRIBUTES_READ =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_STENCIL_ATTRIBUTES_READ;
/**
* Specifies that this RenderingAttributes object allows writing
* its stencil enable, stencil op, stencil function, and
* stencil write mask information.
*
* @since Java 3D 1.4
*/
public static final int ALLOW_STENCIL_ATTRIBUTES_WRITE =
CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_STENCIL_ATTRIBUTES_WRITE;
//
// Enums for alpha test, depth test, and stencil test
//
/**
* Specifies that pixels are always drawn irrespective of the
* values being tested.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
* This setting effectively disables alpha, depth, or stencil testing.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int ALWAYS = 0;
/**
* Specifies that pixels are never drawn irrespective of the
* values being tested.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int NEVER = 1;
/**
* Specifies that pixels are drawn if the two values being tested are equal.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int EQUAL = 2;
/**
* Specifies that pixels are drawn if the two values being tested are not equal.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int NOT_EQUAL = 3;
/**
* Specifies that pixels are drawn if the source/reference value is less
* than the destination/test value.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int LESS = 4;
/**
* Specifies that pixels are drawn if the source/reference value is less
* than or equal to the destination/test value.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int LESS_OR_EQUAL = 5;
/**
* Specifies that pixels are drawn if the source/reference value is greater
* than the destination/test value.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int GREATER = 6;
/**
* Specifies that pixels are drawn if the source/reference value is greater
* than or equal to the destination/test value.
* Can be used to specify the alpha test function, the depth test function,
* or the stencil function.
*
* @see #setAlphaTestFunction
* @see #setDepthTestFunction
* @see #setStencilFunction(int,int,int)
*/
public static final int GREATER_OR_EQUAL = 7;
//
// Raster op enums
//
/**
* Raster operation: <code>DST = 0</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_CLEAR = 0x0;
/**
* Raster operation: <code>DST = SRC & DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_AND = 0x1;
/**
* Raster operation: <code>DST = SRC & ~DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_AND_REVERSE = 0x2;
/**
* Raster operation: <code>DST = SRC</code>.
* @see #setRasterOp
*
* @since Java 3D 1.2
*/
public static final int ROP_COPY = 0x3;
/**
* Raster operation: <code>DST = ~SRC & DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_AND_INVERTED = 0x4;
/**
* Raster operation: <code>DST = DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_NOOP = 0x5;
/**
* Raster operation: <code>DST = SRC ^ DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.2
*/
public static final int ROP_XOR = 0x6;
/**
* Raster operation: <code>DST = DST | SRC</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_OR = 0x7;
/**
* Raster operation: <code>DST = ~( DST | SRC )</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_NOR = 0x8;
/**
* Raster operation: <code>DST = ~( DST ^ SRC )</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_EQUIV = 0x9;
/**
* Raster operation: <code>DST = ~DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_INVERT = 0xA;
/**
* Raster operation: <code>DST = src | ~DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_OR_REVERSE = 0xB;
/**
* Raster operation: <code>DST = ~SRC</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_COPY_INVERTED = 0xC;
/**
* Raster operation: <code>DST = ~SRC | DST</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_OR_INVERTED = 0xD;
/**
* Raster operation: <code>DST = ~(SRC & DST)</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_NAND = 0xE;
/**
* Raster operation: <code>DST = 1</code>.
* @see #setRasterOp
*
* @since Java 3D 1.4
*/
public static final int ROP_SET = 0xF;
//
// Stencil op enums
//
/**
* Stencil operation: <code>DST = DST</code>
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public static final int STENCIL_KEEP = 1;
/**
* Stencil operation: <code>DST = 0</code>
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public static final int STENCIL_ZERO = 2;
/**
* Stencil operation: <code>DST = REF</code>
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public static final int STENCIL_REPLACE = 3;
/**
* Stencil operation: <code>DST = DST + 1</code>
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public static final int STENCIL_INCR = 4;
/**
* Stencil operation: <code>DST = DST - 1</code>
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public static final int STENCIL_DECR = 5;
/**
* Stencil operation: <code>DST = ~DST</code>
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public static final int STENCIL_INVERT = 6;
// Array for setting default read capabilities
private static final int[] readCapabilities = {
ALLOW_ALPHA_TEST_FUNCTION_READ,
ALLOW_ALPHA_TEST_VALUE_READ,
ALLOW_DEPTH_ENABLE_READ,
ALLOW_DEPTH_TEST_FUNCTION_READ,
ALLOW_IGNORE_VERTEX_COLORS_READ,
ALLOW_RASTER_OP_READ,
ALLOW_STENCIL_ATTRIBUTES_READ,
ALLOW_VISIBLE_READ
};
/**
* Constructs a RenderingAttributes object with default parameters.
* The default values are as follows:
* <ul>
* depth buffer enable : true<br>
* depth buffer write enable : true<br>
* alpha test function : ALWAYS<br>
* alpha test value : 0.0f<br>
* visible : true<br>
* ignore vertex colors : false<br>
* raster operation enable : false<br>
* raster operation : ROP_COPY<br>
* depth test: LESS_OR_EQUAL<br>
* stencil enable : false<br>
* stencil write mask : ~0 (all ones)<br>
* stencil op - failOp : STENCIL_KEEP<br>
* stencil op - zFailOp : STENCIL_KEEP<br>
* stencil op - zPassOp : STENCIL_KEEP<br>
* stencil function : ALWAYS<br>
* stencil reference value : 0<br>
* stencil comparison mask : ~0 (all ones)
* </ul>
*/
public RenderingAttributes() {
// Just use default attributes
// set default read capabilities
setDefaultReadCapabilities(readCapabilities);
}
/**
* Constructs a RenderingAttributes object with specified values.
* @param depthBufferEnable a flag to turn depth buffer on/off
* @param depthBufferWriteEnable a flag to to make depth buffer
* read/write or read only
* @param alphaTestValue the alpha test reference value
* @param alphaTestFunction the function for comparing alpha values
*/
public RenderingAttributes(boolean depthBufferEnable,
boolean depthBufferWriteEnable,
float alphaTestValue,
int alphaTestFunction){
this(depthBufferEnable, depthBufferWriteEnable, alphaTestValue,
alphaTestFunction, true, false, false, ROP_COPY);
}
/**
* Constructs a RenderingAttributes object with specified values
* @param depthBufferEnable a flag to turn depth buffer on/off
* @param depthBufferWriteEnable a flag to make depth buffer
* read/write or read only
* @param alphaTestValue the alpha test reference value
* @param alphaTestFunction the function for comparing alpha values
* @param visible a flag that specifies whether the object is visible
* @param ignoreVertexColors a flag to enable or disable
* the ignoring of per-vertex colors
* @param rasterOpEnable a flag that specifies whether logical
* raster operations are enabled for this RenderingAttributes object.
* This disables all alpha blending operations.
* @param rasterOp the logical raster operation, one of:
* ROP_CLEAR, ROP_AND, ROP_AND_REVERSE, ROP_COPY, ROP_AND_INVERTED,
* ROP_NOOP, ROP_XOR, ROP_OR, ROP_NOR, ROP_EQUIV, ROP_INVERT,
* ROP_OR_REVERSE, ROP_COPY_INVERTED, ROP_OR_INVERTED, ROP_NAND or ROP_SET
*
* @since Java 3D 1.2
*/
public RenderingAttributes(boolean depthBufferEnable,
boolean depthBufferWriteEnable,
float alphaTestValue,
int alphaTestFunction,
boolean visible,
boolean ignoreVertexColors,
boolean rasterOpEnable,
int rasterOp) {
// set default read capabilities
setDefaultReadCapabilities(readCapabilities);
((RenderingAttributesRetained)this.retained).initDepthBufferEnable(depthBufferEnable);
((RenderingAttributesRetained)this.retained).initDepthBufferWriteEnable(depthBufferWriteEnable);
((RenderingAttributesRetained)this.retained).initAlphaTestValue(alphaTestValue);
((RenderingAttributesRetained)this.retained).initAlphaTestFunction(alphaTestFunction);
((RenderingAttributesRetained)this.retained).initVisible(visible);
((RenderingAttributesRetained)this.retained).initIgnoreVertexColors(ignoreVertexColors);
((RenderingAttributesRetained)this.retained).initRasterOpEnable(rasterOpEnable);
((RenderingAttributesRetained)this.retained).initRasterOp(rasterOp);
}
/**
* Enables or disables depth buffer mode for this RenderingAttributes
* component object.
*
* @param state true or false to enable or disable depth buffer mode
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see GraphicsConfigTemplate3D#setDepthSize
*/
public void setDepthBufferEnable(boolean state){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_DEPTH_ENABLE_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes0"));
if (isLive())
((RenderingAttributesRetained)this.retained).setDepthBufferEnable(state);
else
((RenderingAttributesRetained)this.retained).initDepthBufferEnable(state);
}
/**
* Retrieves the state of zBuffer Enable flag
* @return true if depth buffer mode is enabled, false
* if depth buffer mode is disabled
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*/
public boolean getDepthBufferEnable(){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_DEPTH_ENABLE_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes1"));
return ((RenderingAttributesRetained)this.retained).getDepthBufferEnable();
}
/**
* Enables or disables writing the depth buffer for this object.
* During the transparent rendering pass,
* this attribute can be overridden by
* the depthBufferFreezeTransparent attribute in the View object.
* @param state true or false to enable or disable depth buffer Write mode
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
* @see View#setDepthBufferFreezeTransparent
*/
public void setDepthBufferWriteEnable(boolean state) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_DEPTH_ENABLE_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes2"));
if (isLive())
((RenderingAttributesRetained)this.retained).setDepthBufferWriteEnable(state);
else
((RenderingAttributesRetained)this.retained).initDepthBufferWriteEnable(state);
}
/**
* Retrieves the state of Depth Buffer Write Enable flag.
* @return true if depth buffer is writable, false
* if depth buffer is read-only
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*/
public boolean getDepthBufferWriteEnable(){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_DEPTH_ENABLE_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes3"));
return ((RenderingAttributesRetained)this.retained).getDepthBufferWriteEnable();
}
/**
* Set alpha test value used by alpha test function. This value is
* compared to the alpha value of each rendered pixel.
* @param value the alpha test value
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*/
public void setAlphaTestValue(float value){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_ALPHA_TEST_VALUE_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes4"));
if (isLive())
((RenderingAttributesRetained)this.retained).setAlphaTestValue(value);
else
((RenderingAttributesRetained)this.retained).initAlphaTestValue(value);
}
/**
* Retrieves the alpha test value.
* @return the alpha test value.
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*/
public float getAlphaTestValue(){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_ALPHA_TEST_VALUE_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes5"));
return ((RenderingAttributesRetained)this.retained).getAlphaTestValue();
}
/**
* Set alpha test function. This function is used to compare
* each incoming (source) per-pixel alpha value with the alpha test value.
* If the test passes, the pixel is written otherwise the pixel is not
* written.
* @param function the new alpha test function. One of
* ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
* GREATER_OR_EQUAL
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*/
public void setAlphaTestFunction(int function){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_ALPHA_TEST_FUNCTION_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes6"));
if (isLive())
((RenderingAttributesRetained)this.retained).setAlphaTestFunction(function);
else
((RenderingAttributesRetained)this.retained).initAlphaTestFunction(function);
}
/**
* Retrieves current alpha test function.
* @return the current alpha test function
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*/
public int getAlphaTestFunction(){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_ALPHA_TEST_FUNCTION_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes7"));
return ((RenderingAttributesRetained)this.retained).getAlphaTestFunction();
}
/**
* Sets the visibility flag for this RenderingAttributes
* component object. Invisible objects are not rendered (subject to
* the visibility policy for the current view), but they can be picked
* or collided with. The default value is true.
* @param visible true or false to enable or disable visibility
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see View#setVisibilityPolicy
*
* @since Java 3D 1.2
*/
public void setVisible(boolean visible) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_VISIBLE_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes8"));
if (isLive())
((RenderingAttributesRetained)this.retained).setVisible(visible);
else
((RenderingAttributesRetained)this.retained).initVisible(visible);
}
/**
* Retrieves the visibility flag for this RenderingAttributes object.
* @return true if the object is visible; false
* if the object is invisible.
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.2
*/
public boolean getVisible() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_VISIBLE_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes9"));
return ((RenderingAttributesRetained)this.retained).getVisible();
}
/**
* Sets a flag that indicates whether vertex colors are ignored
* for this RenderingAttributes object. If
* <code>ignoreVertexColors</code> is false, per-vertex
* colors are used, when present in the associated Geometry
* objects, taking precedence over the ColoringAttributes color
* and the specified Material color(s). If <code>ignoreVertexColors</code>
* is true, per-vertex colors are ignored. In this case, if
* lighting is enabled, the Material diffuse color will be
* used as the object color. If lighting is disabled, the
* ColoringAttributes color will be used. The default value is false.
*
* @param ignoreVertexColors true or false to enable or disable
* the ignoring of per-vertex colors
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see ColoringAttributes
* @see Material
*
* @since Java 3D 1.2
*/
public void setIgnoreVertexColors(boolean ignoreVertexColors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_IGNORE_VERTEX_COLORS_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes12"));
if (isLive())
((RenderingAttributesRetained)this.retained).setIgnoreVertexColors(ignoreVertexColors);
else
((RenderingAttributesRetained)this.retained).initIgnoreVertexColors(ignoreVertexColors);
}
/**
* Retrieves the ignoreVertexColors flag for this
* RenderingAttributes object.
* @return true if per-vertex colors are ignored; false
* if per-vertex colors are used.
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.2
*/
public boolean getIgnoreVertexColors() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_IGNORE_VERTEX_COLORS_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes13"));
return ((RenderingAttributesRetained)this.retained).getIgnoreVertexColors();
}
/**
* Sets the rasterOp enable flag for this RenderingAttributes
* component object. When set to true, this enables logical
* raster operations as specified by the setRasterOp method.
* Enabling raster operations effectively disables alpha blending,
* which is used for transparency and antialiasing. Raster
* operations, especially XOR mode, are primarily useful when
* rendering to the front buffer in immediate mode. Most
* applications will not wish to enable this mode.
*
* @param rasterOpEnable true or false to enable or disable
* raster operations
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see #setRasterOp
*
* @since Java 3D 1.2
*/
public void setRasterOpEnable(boolean rasterOpEnable) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_RASTER_OP_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes10"));
if (isLive())
((RenderingAttributesRetained)this.retained).setRasterOpEnable(rasterOpEnable);
else
((RenderingAttributesRetained)this.retained).initRasterOpEnable(rasterOpEnable);
}
/**
* Retrieves the rasterOp enable flag for this RenderingAttributes
* object.
* @return true if raster operations are enabled; false
* if raster operations are disabled.
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.2
*/
public boolean getRasterOpEnable() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_RASTER_OP_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes11"));
return ((RenderingAttributesRetained)this.retained).getRasterOpEnable();
}
/**
* Sets the raster operation function for this RenderingAttributes
* component object.
*
* @param rasterOp the logical raster operation, one of:
* ROP_CLEAR, ROP_AND, ROP_AND_REVERSE, ROP_COPY, ROP_AND_INVERTED,
* ROP_NOOP, ROP_XOR, ROP_OR, ROP_NOR, ROP_EQUIV, ROP_INVERT,
* ROP_OR_REVERSE, ROP_COPY_INVERTED, ROP_OR_INVERTED, ROP_NAND or ROP_SET.
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.2
*/
public void setRasterOp(int rasterOp) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_RASTER_OP_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes10"));
if (isLive())
((RenderingAttributesRetained)this.retained).setRasterOp(rasterOp);
else
((RenderingAttributesRetained)this.retained).initRasterOp(rasterOp);
}
/**
* Retrieves the current raster operation for this RenderingAttributes
* object.
* @return one of:
* ROP_CLEAR, ROP_AND, ROP_AND_REVERSE, ROP_COPY, ROP_AND_INVERTED,
* ROP_NOOP, ROP_XOR, ROP_OR, ROP_NOR, ROP_EQUIV, ROP_INVERT,
* ROP_OR_REVERSE, ROP_COPY_INVERTED, ROP_OR_INVERTED, ROP_NAND or ROP_SET
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.2
*/
public int getRasterOp() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_RASTER_OP_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes11"));
return ((RenderingAttributesRetained)this.retained).getRasterOp();
}
/**
* Creates a retained mode RenderingAttributesRetained object that this
* RenderingAttributes component object will point to.
*/
@Override
void createRetained() {
this.retained = new RenderingAttributesRetained();
this.retained.setSource(this);
}
/**
* @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
*/
@Override
public NodeComponent cloneNodeComponent() {
RenderingAttributes ra = new RenderingAttributes();
ra.duplicateNodeComponent(this);
return ra;
}
/**
* Copies all node information from <code>originalNodeComponent</code> into
* the current node. This method is called from the
* <code>duplicateNode</code> method. This routine does
* the actual duplication of all "local data" (any data defined in
* this object).
*
* @param originalNodeComponent the original node to duplicate.
* @param forceDuplicate when set to <code>true</code>, causes the
* <code>duplicateOnCloneTree</code> flag to be ignored. When
* <code>false</code>, the value of each node's
* <code>duplicateOnCloneTree</code> variable determines whether
* NodeComponent data is duplicated or copied.
*
* @see Node#cloneTree
* @see NodeComponent#setDuplicateOnCloneTree
*/
@Override
void duplicateAttributes(NodeComponent originalNodeComponent,
boolean forceDuplicate) {
super.duplicateAttributes(originalNodeComponent, forceDuplicate);
RenderingAttributesRetained attr =
(RenderingAttributesRetained) originalNodeComponent.retained;
RenderingAttributesRetained rt =
(RenderingAttributesRetained) retained;
rt.initDepthBufferEnable(attr.getDepthBufferEnable());
rt.initDepthBufferWriteEnable(attr.getDepthBufferWriteEnable());
rt.initDepthTestFunction(attr.getDepthTestFunction());
rt.initAlphaTestValue(attr.getAlphaTestValue());
rt.initAlphaTestFunction(attr.getAlphaTestFunction());
rt.initVisible(attr.getVisible());
rt.initIgnoreVertexColors(attr.getIgnoreVertexColors());
rt.initRasterOpEnable(attr.getRasterOpEnable());
rt.initRasterOp(attr.getRasterOp());
rt.initStencilEnable(attr.getStencilEnable());
int[] ops = new int[3];
attr.getStencilOp(ops);
rt.initStencilOp(ops[0], ops[1], ops[2]);
attr.getStencilFunction(ops);
rt.initStencilFunction(ops[0], ops[1], ops[2]);
rt.initStencilWriteMask(attr.getStencilWriteMask());
}
/**
* Set depth test function. This function is used to compare each
* incoming (source) per-pixel depth test value with the stored per-pixel
* depth value in the frame buffer. If the test
* passes, the pixel is written, otherwise the pixel is not
* written.
* @param function the new depth test function. One of
* ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
* or GREATER_OR_EQUAL.
* The default value is LESS_OR_EQUAL.
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public void setDepthTestFunction(int function){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_DEPTH_TEST_FUNCTION_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes14"));
if (isLive())
((RenderingAttributesRetained)this.retained).setDepthTestFunction(function);
else
((RenderingAttributesRetained)this.retained).initDepthTestFunction(function);
}
/**
* Retrieves current depth test function.
* @return the current depth test function
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public int getDepthTestFunction(){
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_DEPTH_TEST_FUNCTION_READ))
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes15"));
return ((RenderingAttributesRetained)this.retained).getDepthTestFunction();
}
/**
* Enables or disables the stencil buffer for this RenderingAttributes
* component object. If the stencil buffer is disabled, the
* stencil operation and function are ignored. If a scene graph
* is rendered on a Canvas3D that does not have a stencil buffer,
* the stencil buffer will be implicitly disabled for that canvas.
*
* @param state true or false to enable or disable stencil buffer
* operations.
* If this is set to false, the stencilOp and stencilFunction parameters
* are not used.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see GraphicsConfigTemplate3D#setStencilSize
*
* @since Java 3D 1.4
*/
public void setStencilEnable(boolean state) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16"));
}
}
if (isLive())
((RenderingAttributesRetained)this.retained).setStencilEnable(state);
else
((RenderingAttributesRetained)this.retained).initStencilEnable(state);
}
/**
* Retrieves the stencil buffer enable flag for this RenderingAttributes
* object.
*
* @return true if stencil buffer operations are enabled; false
* if stencil buffer operations are disabled.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public boolean getStencilEnable() {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17"));
}
}
return ((RenderingAttributesRetained)this.retained).getStencilEnable();
}
/**
* Sets the stencil operations for this RenderingAttributes object to the
* specified parameters.
*
* @param failOp operation performed when the stencil test fails, one of:
* STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR,
* or STENCIL_INVERT.
*
* @param zFailOp operation performed when the stencil test passes and the
* depth test fails, one of:
* STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR,
* or STENCIL_INVERT.
*
* @param zPassOp operation performed when both the stencil test and the
* depth test pass, one of:
* STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR,
* or STENCIL_INVERT.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public void setStencilOp(int failOp, int zFailOp, int zPassOp) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16"));
}
}
if (isLive())
((RenderingAttributesRetained)this.retained).setStencilOp(failOp,
zFailOp,
zPassOp);
else
((RenderingAttributesRetained)this.retained).initStencilOp(failOp,
zFailOp,
zPassOp);
}
/**
* Sets the stencil operations for this RenderingAttributes object to the
* specified parameters.
*
* @param stencilOps an array of three integers that specifies the new
* set of stencil operations. Element 0 of the array specifies the
* <code>failOp</code> parameter, element 1 specifies the
* <code>zFailOp</code> parameter, and element 2 specifies the
* <code>zPassOp</code> parameter.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see #setStencilOp(int,int,int)
*
* @since Java 3D 1.4
*/
public void setStencilOp(int[] stencilOps) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16"));
}
}
if (isLive())
((RenderingAttributesRetained)this.retained).setStencilOp(stencilOps[0],
stencilOps[1],
stencilOps[2]);
else
((RenderingAttributesRetained)this.retained).initStencilOp(stencilOps[0],
stencilOps[1],
stencilOps[2]);
}
/**
* Retrieves the current set of stencil operations, and copies them
* into the specified array. The caller must ensure that this array
* has been allocated with enough space to hold the results.
*
* @param stencilOps array that will receive the current set of
* three stencil operations. The <code>failOp</code> parameter is copied
* into element 0 of the array, the <code>zFailOp</code> parameter is copied
* into element 1, and the <code>zPassOp</code> parameter is copied
* into element 2.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public void getStencilOp(int[] stencilOps) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17"));
}
}
((RenderingAttributesRetained)this.retained).getStencilOp(stencilOps);
}
/**
* Sets the stencil function, reference value, and comparison mask
* for this RenderingAttributes object to the specified parameters.
*
* @param function the stencil test function, used to compare the
* stencil reference value with the stored per-pixel
* stencil value in the frame buffer. If the test
* passes, the pixel is written, otherwise the pixel is not
* written. The stencil function is one of:
* ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER,
* or GREATER_OR_EQUAL.
*
* @param refValue the stencil reference value that is tested against
* the stored per-pixel stencil value
*
* @param compareMask a mask that limits which bits are compared; it is
* bitwise-ANDed with both the stencil reference value and the stored
* per-pixel stencil value before doing the comparison.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public void setStencilFunction(int function, int refValue, int compareMask) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16"));
}
}
if (isLive())
((RenderingAttributesRetained)this.retained).setStencilFunction(function,
refValue,
compareMask);
else
((RenderingAttributesRetained)this.retained).initStencilFunction(function,
refValue,
compareMask);
}
/**
* Sets the stencil function, reference value, and comparison mask
* for this RenderingAttributes object to the specified parameters.
*
* @param params an array of three integers that specifies the new
* stencil function, reference value, and comparison mask.
* Element 0 of the array specifies the
* stencil function, element 1 specifies the
* reference value, and element 2 specifies the
* comparison mask.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @see #setStencilFunction(int,int,int)
*
* @since Java 3D 1.4
*/
public void setStencilFunction(int[] params) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16"));
}
}
if (isLive())
((RenderingAttributesRetained)this.retained).setStencilFunction(params[0],
params[1],
params[2]);
else
((RenderingAttributesRetained)this.retained).initStencilFunction(params[0],
params[1],
params[2]);
}
/**
* Retrieves the stencil function, reference value, and comparison mask,
* and copies them into the specified array. The caller must ensure
* that this array has been allocated with enough space to hold the results.
*
* @param params array that will receive the current stencil function,
* reference value, and comparison mask. The stencil function is copied
* into element 0 of the array, the reference value is copied
* into element 1, and the comparison mask is copied
* into element 2.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public void getStencilFunction(int[] params) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17"));
}
}
((RenderingAttributesRetained)this.retained).getStencilFunction(params);
}
/**
* Sets the stencil write mask for this RenderingAttributes
* object. This mask controls which bits of the
* stencil buffer are written.
* The default value is <code>~0</code> (all ones).
*
* @param mask the new stencil write mask.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public void setStencilWriteMask(int mask) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16"));
}
}
if (isLive())
((RenderingAttributesRetained)this.retained).setStencilWriteMask(mask);
else
((RenderingAttributesRetained)this.retained).initStencilWriteMask(mask);
}
/**
* Retrieves the current stencil write mask for this RenderingAttributes
* object.
*
* @return the stencil write mask.
*
* @exception CapabilityNotSetException if appropriate capability is
* not set and this object is part of live or compiled scene graph
*
* @since Java 3D 1.4
*/
public int getStencilWriteMask() {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17"));
}
}
return ((RenderingAttributesRetained)this.retained).getStencilWriteMask();
}
}
|