summaryrefslogtreecommitdiffstats
path: root/src/javax/media/j3d/RenderMolecule.java
blob: 269c1a06520308c8532bcf302430c28b2b560bf3 (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
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
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
/*
 * Copyright 1999-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 javax.vecmath.Vector3d;

/**
 * The RenderMolecule manages a collection of RenderAtoms.
 */

class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponentUpdate {


    // different types of IndexedUnorderedSet that store RenderMolecule
    static final int REMOVE_RENDER_ATOM_IN_RM_LIST = 0;
    static final int RENDER_MOLECULE_LIST = 1;

    // total number of different IndexedUnorderedSet types
    static final int TOTAL_INDEXED_UNORDER_SET_TYPES = 2;

    /**
     * Values for the geometryType field
     */
    static final int POINT      = 0x01;
    static final int LINE       = 0x02;
    static final int SURFACE    = 0x04;
    static final int RASTER     = 0x08;
    static final int COMPRESSED = 0x10;

    static int RM_COMPONENTS = (AppearanceRetained.POLYGON |
				AppearanceRetained.LINE |
				AppearanceRetained.POINT |
				AppearanceRetained.MATERIAL |
				AppearanceRetained.TRANSPARENCY|
				AppearanceRetained.COLOR);

    // XXXX: use definingMaterial etc. instead of these
    // when sole user is completely implement
    PolygonAttributesRetained polygonAttributes = null;
    LineAttributesRetained lineAttributes = null;
    PointAttributesRetained pointAttributes = null;
    MaterialRetained material = null;
    ColoringAttributesRetained coloringAttributes = null;
    TransparencyAttributesRetained transparency = null;

    // Use Object instead of AppearanceRetained class for
    // state caching optimation memory performance

    boolean normalPresent = true;


    // Equivalent bits
    static final int POINTATTRS_DIRTY        = AppearanceRetained.POINT;
    static final int LINEATTRS_DIRTY         = AppearanceRetained.LINE;
    static final int POLYGONATTRS_DIRTY      = AppearanceRetained.POLYGON;
    static final int MATERIAL_DIRTY          = AppearanceRetained.MATERIAL;
    static final int TRANSPARENCY_DIRTY      = AppearanceRetained.TRANSPARENCY;
    static final int COLORINGATTRS_DIRTY     = AppearanceRetained.COLOR;

    static final int ALL_DIRTY_BITS    = POINTATTRS_DIRTY | LINEATTRS_DIRTY | POLYGONATTRS_DIRTY | MATERIAL_DIRTY | TRANSPARENCY_DIRTY | COLORINGATTRS_DIRTY;

    /**
     * bit mask of all attr fields that are equivalent across
     * renderMolecules
     */
    int dirtyAttrsAcrossRms = ALL_DIRTY_BITS;


    // Mask set to true is any of the component have changed
    int soleUserCompDirty = 0;

    /**
     * The PolygonAttributes for this RenderMolecule
     */
    PolygonAttributesRetained definingPolygonAttributes = null;

    /**
     * The LineAttributes for this RenderMolecule
     */
    LineAttributesRetained definingLineAttributes = null;

    /**
     * The PointAttributes for this RenderMolecule
     */
    PointAttributesRetained definingPointAttributes = null;

    /**
     * The TextureBin that this RenderMolecule resides
     */
    TextureBin textureBin = null;

    /**
     * The localToVworld for this RenderMolecule
     */
    Transform3D[] localToVworld = null;
    int[] localToVworldIndex = null;

    /**
     * The Material reference for this RenderMolecule
     */
    MaterialRetained definingMaterial = null;


    /**
     * The ColoringAttribute reference for this RenderMolecule
     */
    ColoringAttributesRetained definingColoringAttributes = null;


    /**
     * The Transparency reference for this RenderMolecule
     */
    TransparencyAttributesRetained definingTransparency = null;

    /**
     * Transform3D - point to the right one based on bg or not
     */
    Transform3D[] trans = null;


    /**
     * specify whether scale is nonuniform
     */
    boolean isNonUniformScale = false;

    /**
     * number of renderAtoms to be rendered in this RenderMolecule
     */
    int numRenderAtoms = 0;

    /**
     * number of render atoms, used during the renderBin update time
     */
    int numEditingRenderAtoms = 0;

    RenderAtom addRAs = null;
    RenderAtom removeRAs = null;

    /**
     * The cached ColoringAttributes color value.  It is
     * 1.0, 1.0, 1.0 if there is no ColoringAttributes.
     */
    float red = 1.0f;
    float green = 1.0f;
    float blue = 1.0f;


    /**
     * Cached diffuse color value
     */
    float dRed = 1.0f;
    float dGreen = 1.0f;
    float dBlue = 1.0f;



    /**
     * The cached TransparencyAttributes transparency value.  It is
     * 0.0 if there is no TransparencyAttributes.
     */
    float alpha = 0.0f;

    /**
     * The geometry type for this RenderMolecule
     */
    int geometryType = -1;

    /**
     * A boolean indicating whether or not lighting should be on.
     */
    boolean enableLighting = false;

    /**
     * A boolean indicating whether or not this molecule rendered Text3D
     */

    int primaryMoleculeType = 0;
    static int COMPRESSED_MOLECULE 	= 0x1;
    static int TEXT3D_MOLECULE     	= 0x2;
    static int DLIST_MOLECULE      	= 0x4;
    static int RASTER_MOLECULE     	= 0x8;
    static int ORIENTEDSHAPE3D_MOLECULE	= 0x10;
    static int SEPARATE_DLIST_PER_RINFO_MOLECULE = 0x20;


    /**
     * Cached values for polygonMode, line antialiasing, and point antialiasing
     */
    int polygonMode = PolygonAttributes.POLYGON_FILL;
    boolean lineAA = false;
    boolean pointAA = false;

    /**
     * The vertex format for this RenderMolecule.  Only looked
     * at for GeometryArray and CompressedGeometry objects.
     */
    int vertexFormat = -1;

    /**
     * The texCoordSetMap length for this RenderMolecule.
     */
    int texCoordSetMapLen = 0;

    /**
     * The primary renderMethod object for this RenderMolecule
     * this is either a Text3D, display list, or compressed geometry renderer.
     */
    RenderMethod primaryRenderMethod = null;

    /**
     * The secondary renderMethod object for this RenderMolecule
     * this is used for geometry that is shared
     */
    RenderMethod secondaryRenderMethod = null;

    /**
     * The RenderBino for this molecule
     */
    RenderBin renderBin = null;

    /**
     * The references to the next and previous RenderMolecule in the
     * list.
     */
    RenderMolecule next = null;
    RenderMolecule prev = null;


    /**
     * The list of RenderAtoms in this RenderMolecule that are not using
     * vertex arrays.
     */
    RenderAtomListInfo primaryRenderAtomList = null;


    /**
     * The list of RenderAtoms in this RenderMolecule that are using
     * separte dlist .
     */
    RenderAtomListInfo separateDlistRenderAtomList = null;


    /**
     * The list of RenderAtoms in this RenderMolecule that are using vertex
     * arrays.
     */
    RenderAtomListInfo vertexArrayRenderAtomList = null;

    /**
     * This BoundingBox is used for View Frustum culling on the primary
     * list
     */
    BoundingBox vwcBounds = null;


    /**
     * If this is end of the linked list for this xform, then
     * this field is non-null, if there is a map after this
     */
    RenderMolecule nextMap = null;
    RenderMolecule prevMap = null;

    /**
     * If the any of the node component of the appearance in RM will be changed
     * frequently, then confine it to a separate bin
     */
    boolean soleUser = false;
    Object appHandle = null;


    VertexArrayRenderMethod cachedVertexArrayRenderMethod =
	(VertexArrayRenderMethod)
	VirtualUniverse.mc.getVertexArrayRenderMethod();

    // In D3D separate Quad/Triangle Geometry with others in RenderMolecule
    // Since we need to dynamically switch whether to use DisplayList
    // or not in render() as a group.
    boolean isQuadGeometryArray = false;
    boolean isTriGeometryArray = false;

    // display list id, valid id starts from 1
    int displayListId = 0;
    Integer displayListIdObj = null;

    int onUpdateList = 0;
    static int NEW_RENDERATOMS_UPDATE = 0x1;
    static int BOUNDS_RECOMPUTE_UPDATE = 0x2;
    static int LOCALE_TRANSLATION = 0x4;
    static int UPDATE_BACKGROUND_TRANSFORM = 0x8;
    static int IN_DIRTY_RENDERMOLECULE_LIST = 0x10;
    static int LOCALE_CHANGED = 0x20;
    static int ON_UPDATE_CHECK_LIST = 0x40;


    // background geometry rendering
    boolean doInfinite;
    Transform3D[] infLocalToVworld;

    // Whether alpha is used in this renderMolecule
    boolean useAlpha = false;

    // Support for multiple locales
    Locale locale = null;

    // Transform when locale is different from the view's locale
    Transform3D[] localeLocalToVworld = null;

    // Vector used for locale translation
    Vector3d localeTranslation = null;

    boolean primaryChanged = false;

    boolean isOpaqueOrInOG = true;
    boolean inOrderedGroup = false;


    // closest switch parent
    SwitchRetained  closestSwitchParent = null;

    // the child index from the closest switch parent
    int closestSwitchIndex = -1;


    RenderMolecule(GeometryAtom ga,
		   PolygonAttributesRetained polygonAttributes,
		   LineAttributesRetained lineAttributes,
		   PointAttributesRetained pointAttributes,
		   MaterialRetained material,
		   ColoringAttributesRetained coloringAttributes,
		   TransparencyAttributesRetained transparency,
		   RenderingAttributesRetained renderAttrs,
		   TextureUnitStateRetained[] texUnits,
		   Transform3D[] transform, int[] transformIndex,
		   RenderBin rb) {
	renderBin = rb;
	IndexedUnorderSet.init(this, TOTAL_INDEXED_UNORDER_SET_TYPES);

	reset(ga, polygonAttributes, lineAttributes, pointAttributes,
	      material, coloringAttributes, transparency, renderAttrs,
	      texUnits, transform,
	      transformIndex);
    }

    void reset(GeometryAtom ga,
	       PolygonAttributesRetained polygonAttributes,
	       LineAttributesRetained lineAttributes,
	       PointAttributesRetained pointAttributes,
	       MaterialRetained material,
	       ColoringAttributesRetained coloringAttributes,
	       TransparencyAttributesRetained transparency,
	       RenderingAttributesRetained renderAttrs,
	       TextureUnitStateRetained[] texUnits,
	       Transform3D[] transform, int[] transformIndex) {
	primaryMoleculeType = 0;
	numRenderAtoms = 0;
        numEditingRenderAtoms = 0;
	onUpdateList = 0;
	dirtyAttrsAcrossRms = ALL_DIRTY_BITS;
	primaryRenderMethod = null;
	isNonUniformScale = false;
	primaryChanged = false;
        this.material = material;
        this.polygonAttributes = polygonAttributes;
        this.lineAttributes = lineAttributes;
        this.pointAttributes = pointAttributes;
        this.coloringAttributes = coloringAttributes;
        this.transparency = transparency;

        closestSwitchParent = ga.source.closestSwitchParent;
        closestSwitchIndex = ga.source.closestSwitchIndex;

	// Find the first non-null geometey
	GeometryRetained geo = null;
	int k = 0;
	isOpaqueOrInOG = true;
	inOrderedGroup = false;
	while (geo == null && (k < ga.geometryArray.length)) {
	    geo = ga.geometryArray[k];
	    k++;
	}

        // Issue 249 - check for sole user only if property is set
        soleUser = false;
        if (VirtualUniverse.mc.allowSoleUser) {
            if (ga.source.appearance != null) {
                soleUser = ((ga.source.appearance.changedFrequent & RM_COMPONENTS) != 0);
            }
	}

        // Set the appearance only for soleUser case
	if (soleUser)
	    appHandle = ga.source.appearance;
	else
		appHandle = this;

	// If its of type GeometryArrayRetained
	if (ga.geoType <= GeometryRetained.GEO_TYPE_GEOMETRYARRAY ||
	    ga.geoType == GeometryRetained.GEO_TYPE_TEXT3D) {

            if (ga.source instanceof OrientedShape3DRetained) {
                primaryRenderMethod =
                    VirtualUniverse.mc.getOrientedShape3DRenderMethod();
                primaryMoleculeType = ORIENTEDSHAPE3D_MOLECULE;
	    } else if (ga.geoType == GeometryRetained.GEO_TYPE_TEXT3D) {
	        primaryRenderMethod =
		    VirtualUniverse.mc.getText3DRenderMethod();
		primaryMoleculeType = TEXT3D_MOLECULE;
	    } else {
		// Make determination of dlist or not during addRenderAtom
		secondaryRenderMethod = cachedVertexArrayRenderMethod;
	    }
	}
	else {
	    if (ga.geoType == GeometryRetained.GEO_TYPE_COMPRESSED) {
		primaryRenderMethod =
		    VirtualUniverse.mc.getCompressedGeometryRenderMethod();
		primaryMoleculeType = COMPRESSED_MOLECULE;
	    }
	    else if (geo instanceof RasterRetained) {
		primaryRenderMethod =
		    VirtualUniverse.mc.getDefaultRenderMethod();
		primaryMoleculeType = RASTER_MOLECULE;
	    }
	}

	prev = null;
	next = null;
	prevMap = null;
	nextMap = null;

	primaryRenderAtomList = null;
	vertexArrayRenderAtomList = null;



	switch (ga.geoType) {
	case GeometryRetained.GEO_TYPE_POINT_SET:
	case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
	    this.geometryType = POINT;
	    break;
	case GeometryRetained.GEO_TYPE_LINE_SET:
	case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
	case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
	case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
	    this.geometryType = LINE;
	    break;
	case GeometryRetained.GEO_TYPE_RASTER:
	    this.geometryType = RASTER;
	    break;
	case GeometryRetained.GEO_TYPE_COMPRESSED:
	    this.geometryType = COMPRESSED;

	    switch (((CompressedGeometryRetained)geo).getBufferType()) {
	    case CompressedGeometryHeader.POINT_BUFFER:
		this.geometryType |= POINT ;
		break ;
	    case CompressedGeometryHeader.LINE_BUFFER:
		this.geometryType |= LINE ;
		break ;
	    default:
	    case CompressedGeometryHeader.TRIANGLE_BUFFER:
		this.geometryType |= SURFACE ;
		if (polygonAttributes != null) {
		    if (polygonAttributes.polygonMode ==
			PolygonAttributes.POLYGON_POINT) {
			this.geometryType |= POINT;
		    } else if (polygonAttributes.polygonMode ==
			       PolygonAttributes.POLYGON_LINE) {
			this.geometryType |= LINE;
		    }
		}
		break ;
	    }
	    break;
	default:
	    this.geometryType = SURFACE;
	    if (polygonAttributes != null) {
		if (polygonAttributes.polygonMode ==
		    PolygonAttributes.POLYGON_POINT) {
		    this.geometryType |= POINT;
		} else if (polygonAttributes.polygonMode ==
			   PolygonAttributes.POLYGON_LINE) {
		    this.geometryType |= LINE;
		}
	    }
	    break;
	}

	isQuadGeometryArray = (geo.getClassType() ==
			       GeometryRetained.QUAD_TYPE);
	isTriGeometryArray = (geo.getClassType() ==
			      GeometryRetained.TRIANGLE_TYPE);

	this.localToVworld = transform;
	this.localToVworldIndex = transformIndex;
        doInfinite = ga.source.inBackgroundGroup;
        if (doInfinite) {
	    if (infLocalToVworld == null) {
		infLocalToVworld = new Transform3D[2];
		infLocalToVworld[0] = infLocalToVworld[1] = new Transform3D();
	    }
            localToVworld[0].getRotation(infLocalToVworld[0]);
        }
	int mask = 0;
	if (polygonAttributes != null) {
	    if (polygonAttributes.changedFrequent != 0) {
		definingPolygonAttributes = polygonAttributes;

		mask |= POLYGONATTRS_DIRTY;
	    }
	    else {
		if (definingPolygonAttributes != null) {
		    definingPolygonAttributes.set(polygonAttributes);
		}
		else {
		    definingPolygonAttributes = (PolygonAttributesRetained)polygonAttributes.clone();
		}
	    }
	    polygonMode = definingPolygonAttributes.polygonMode;
	} else {
	    polygonMode = PolygonAttributes.POLYGON_FILL;
	    definingPolygonAttributes = null;
	}

	if (lineAttributes != null) {
	    if (lineAttributes.changedFrequent != 0) {
		definingLineAttributes = lineAttributes;
		mask |= LINEATTRS_DIRTY;
	    }
	    else {
		if (definingLineAttributes != null) {
		    definingLineAttributes.set(lineAttributes);
		}
		else {
		    definingLineAttributes = (LineAttributesRetained)lineAttributes.clone();
		}
	    }
	    lineAA = definingLineAttributes.lineAntialiasing;
	} else {
	    lineAA = false;
	    definingLineAttributes = null;
	}

	if (pointAttributes != null) {
	    if (pointAttributes.changedFrequent != 0) {
		definingPointAttributes = pointAttributes;
		mask |= POINTATTRS_DIRTY;

	    }
	    else {
		if (definingPointAttributes != null) {
		    definingPointAttributes.set(pointAttributes);
		}
		else {
		    definingPointAttributes = (PointAttributesRetained)pointAttributes.clone();
		}
	    }
	    pointAA = definingPointAttributes.pointAntialiasing;
	} else {
	    pointAA = false;
	    definingPointAttributes = null;
	}

	normalPresent = true;
	if (geo instanceof GeometryArrayRetained) {
	    GeometryArrayRetained gr = (GeometryArrayRetained)geo;
	    this.vertexFormat = gr.vertexFormat;

	    if (gr.texCoordSetMap != null) {
	        this.texCoordSetMapLen = gr.texCoordSetMap.length;
	    } else {
	        this.texCoordSetMapLen = 0;
	    }

	    // Throw an exception if lighting is enabled, but no normals defined
	    if ((vertexFormat & GeometryArray.NORMALS) == 0) {
		// Force lighting to false
		normalPresent = false;
	    }

	}
	else if (geo instanceof CompressedGeometryRetained) {
	    this.vertexFormat =
		((CompressedGeometryRetained)geo).getVertexFormat();
	    // Throw an exception if lighting is enabled, but no normals defined
	    if ((vertexFormat & GeometryArray.NORMALS) == 0) {
		// Force lighting to false
		normalPresent = false;
	    }

	    this.texCoordSetMapLen = 0;

	} else {
	    this.vertexFormat = -1;
	    this.texCoordSetMapLen = 0;
	}

	if (material != null) {
	    if (material.changedFrequent != 0) {
		definingMaterial = material;
		mask |= MATERIAL_DIRTY;
	    }
	    else {
		if (definingMaterial != null)
		    definingMaterial.set(material);
		else {
		    definingMaterial = (MaterialRetained)material.clone();
		}
	    }

	}
	else {
	    definingMaterial = null;
	}
	evalMaterialCachedState();
	if (coloringAttributes != null) {
	    if (coloringAttributes.changedFrequent != 0) {
		definingColoringAttributes = coloringAttributes;
		mask |= COLORINGATTRS_DIRTY;
	    }
	    else {
		if (definingColoringAttributes != null) {
		    definingColoringAttributes.set(coloringAttributes);
		}
		else {
		    definingColoringAttributes = (ColoringAttributesRetained)coloringAttributes.clone();
		}
	    }
	    red = coloringAttributes.color.x;
	    green = coloringAttributes.color.y;
	    blue = coloringAttributes.color.z;
	} else {
	    red = 1.0f;
	    green = 1.0f;
	    blue = 1.0f;
	    definingColoringAttributes = null;
	}

	if (transparency != null) {

	    if (transparency.changedFrequent != 0) {
		definingTransparency = transparency;
		mask |= TRANSPARENCY_DIRTY;
	    }
	    else {
		if (definingTransparency != null) {
		    definingTransparency.set(transparency);
		}
		else {
		    definingTransparency =
			(TransparencyAttributesRetained)transparency.clone();
		}
	    }
	    alpha = 1.0f - transparency.transparency;

	} else {
	    alpha = 1.0f;
	    definingTransparency = null;

	}

	locale = ga.source.locale;
	if (locale != renderBin.locale) {
	    if (localeLocalToVworld == null) {
		localeLocalToVworld = new Transform3D[2];
	    }
	    localeLocalToVworld[0] = new Transform3D();
	    localeLocalToVworld[1] = new Transform3D();
	    localeTranslation = new Vector3d();
	    ga.locale.hiRes.difference(renderBin.locale.hiRes, localeTranslation);
	    translate();
	}
	else {
	    localeLocalToVworld = localToVworld;
	}

	if (doInfinite) {
	    trans = infLocalToVworld;
	}
	else {
	    trans = localeLocalToVworld;
	}

	evalAlphaUsage(renderAttrs, texUnits);
	isOpaqueOrInOG = isOpaque() || (ga.source.orderedPath != null);
	inOrderedGroup = (ga.source.orderedPath != null);
	//	System.err.println("isOpaque = "+isOpaque() +" OrInOG = "+isOpaqueOrInOG);
	if (mask != 0) {
	    if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		renderBin.rmUpdateList.add(this);
	    }
	    soleUserCompDirty |= mask;
	}
    }


    /**
     * This tests if the given attributes matches this TextureBin
     */
    boolean equals(RenderAtom ra,
		   PolygonAttributesRetained polygonAttributes,
		   LineAttributesRetained lineAttributes,
		   PointAttributesRetained pointAttributes,
		   MaterialRetained material,
		   ColoringAttributesRetained coloringAttributes,
		   TransparencyAttributesRetained transparency,
		   Transform3D[] transform) {
	int geoType = 0;
	GeometryAtom ga = ra.geometryAtom;

	if (this.localToVworld != transform) {
	    return (false);
	}

	if (locale != ra.geometryAtom.source.locale) {
	    return (false);
	}

	if (ra.geometryAtom.source.closestSwitchParent != closestSwitchParent ||
	    ra.geometryAtom.source.closestSwitchIndex != closestSwitchIndex) {
	    return (false);
	}

	// Find the first non-null geometey
	GeometryRetained geo = null;
	int k = 0;
	while (geo == null && (k < ga.geometryArray.length)) {
	    geo = ga.geometryArray[k];
	    k++;
	}

	// XXXX: Add tags
	switch (ga.geoType) {
	case GeometryRetained.GEO_TYPE_POINT_SET:
	case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
	    geoType = POINT;
	    break;
	case GeometryRetained.GEO_TYPE_LINE_SET:
	case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
	case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
	case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
	    geoType = LINE;
	    break;
	case GeometryRetained.GEO_TYPE_RASTER:
	    geoType = RASTER;
	    break;
	case GeometryRetained.GEO_TYPE_COMPRESSED:
	    geoType = COMPRESSED;
	    switch (((CompressedGeometryRetained)geo).getBufferType()) {
	    case CompressedGeometryHeader.POINT_BUFFER:
		geoType |= POINT ;
		break ;
	    case CompressedGeometryHeader.LINE_BUFFER:
		geoType |= LINE ;
		break ;
	    default:
	    case CompressedGeometryHeader.TRIANGLE_BUFFER:
		geoType |= SURFACE ;
		break ;
	    }
	    break;
	default:
	    geoType = SURFACE;
	    if (polygonAttributes != null) {
		if (polygonAttributes.polygonMode ==
		    PolygonAttributes.POLYGON_POINT) {
		    geoType |= POINT;
		} else if (polygonAttributes.polygonMode ==
			   PolygonAttributes.POLYGON_LINE) {
		    geoType |= LINE;
		}
	    }
	    break;
	}

	if (this.geometryType != geoType) {
	    return (false);
	}
	/*
	// XXXX : Check this
	if (useDisplayList &&
	    (ga.geometry.isEditable ||
	     ga.geometry.refCount > 1 ||
	     ((GroupRetained)ga.source.parent).switchLevel >= 0 ||
	     ga.alphaEditable)) {
	    return (false);
	}
	*/
	if (ga.geoType == GeometryRetained.GEO_TYPE_TEXT3D &&
	    primaryMoleculeType != 0 &&
	    ((primaryMoleculeType & TEXT3D_MOLECULE) == 0)) {
	    return (false);
	}


	if(!(ra.geometryAtom.source instanceof OrientedShape3DRetained)
	   && ((primaryMoleculeType & ORIENTEDSHAPE3D_MOLECULE) != 0)) {
	    //System.err.println("RA's NOT a OrientedShape3DRetained and RM is a ORIENTEDSHAPE3D_MOLECULE ");

	    return (false);
	}

	// XXXX: Its is necessary to have same vformat for dl,
	// Howabout iteration, should we have 2 vformats in rm?
	if (geo instanceof GeometryArrayRetained) {
	    GeometryArrayRetained gr = (GeometryArrayRetained)geo;
	    if (this.vertexFormat != gr.vertexFormat) {
	        return (false);
	    }


	    // we are requiring that texCoordSetMap length to be the same
	    // so that we can either put all multi-tex ga to a display list,
	    // or punt all to vertex array. And we don't need to worry
	    // about some of the ga can be in display list for this canvas,
	    // and some other can be in display list for the other canvas.
	    if (((gr.texCoordSetMap != null) &&
		 (this.texCoordSetMapLen != gr.texCoordSetMap.length)) ||
		((gr.texCoordSetMap == null) && (this.texCoordSetMapLen != 0))) {
		return (false);
	    }

	} else if (geo instanceof CompressedGeometryRetained) {
	    if (this.vertexFormat !=
		((CompressedGeometryRetained)geo).getVertexFormat()) {
	        return (false);
	    }
	} else {
            //XXXX: compare isEditable
	    if (this.vertexFormat != -1) {
	        return (false);
	    }
	}

	// If the any reference to the appearance components  that is cached renderMolecule
	// can change frequently, make a separate bin
	if (soleUser || (ra.geometryAtom.source.appearance != null &&
			 ((ra.geometryAtom.source.appearance.changedFrequent & RM_COMPONENTS) != 0))) {
		if (appHandle == ra.geometryAtom.source.appearance) {

                // if this RenderMolecule is currently on a zombie state,
                // we'll need to put it on the update list to reevaluate
                // the state, because while it is on a zombie state,
                // state could have been changed. Example,
                // application could have detached an appearance,
                // made changes to the appearance state, and then
                // reattached the appearance. In this case, the
                // changes would not have reflected to the RenderMolecule

                if (numEditingRenderAtoms == 0) {

		    if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			renderBin.rmUpdateList.add(this);
		    }
		    soleUserCompDirty |= ALL_DIRTY_BITS;
		}
		return true;
	    }
	    else {
		return false;
	    }

	}
	// Assign the cloned value as the original value

	// Either a changedFrequent or a null case
	// and the incoming one is not equal or null
	// then return;
	// This check also handles null == null case
	if (definingPolygonAttributes != null) {
	    if ((this.definingPolygonAttributes.changedFrequent != 0) ||
		(polygonAttributes !=null && polygonAttributes.changedFrequent != 0))
		if (definingPolygonAttributes == polygonAttributes) {
		    if (definingPolygonAttributes.compChanged != 0) {
			if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			    renderBin.rmUpdateList.add(this);
			}
			soleUserCompDirty |= POLYGONATTRS_DIRTY;
		    }
		}
		else {
		    return false;
		}
	    else if (!definingPolygonAttributes.equivalent(polygonAttributes)) {
		return false;
	    }
	}
	else if (polygonAttributes != null) {
	    return false;
	}

	if (definingLineAttributes != null) {
	    if ((this.definingLineAttributes.changedFrequent != 0) ||
		(lineAttributes !=null && lineAttributes.changedFrequent != 0))
		if (definingLineAttributes == lineAttributes) {
		    if (definingLineAttributes.compChanged != 0) {
			if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			    renderBin.rmUpdateList.add(this);
			}
			soleUserCompDirty |= LINEATTRS_DIRTY;
		    }
		}
		else {
		    return false;
		}
	    else if (!definingLineAttributes.equivalent(lineAttributes)) {
		return false;
	    }
	}
	else if (lineAttributes != null) {
	    return false;
	}


	if (definingPointAttributes != null) {
	    if ((this.definingPointAttributes.changedFrequent != 0) ||
		(pointAttributes !=null && pointAttributes.changedFrequent != 0))
		if (definingPointAttributes == pointAttributes) {
		    if (definingPointAttributes.compChanged != 0) {
			if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			    renderBin.rmUpdateList.add(this);
			}
			soleUserCompDirty |= POINTATTRS_DIRTY;
		    }
		}
		else {
		    return false;
		}
	    else if (!definingPointAttributes.equivalent(pointAttributes)) {
		return false;
	    }
	}
	else if (pointAttributes != null) {
	    return false;
	}




	if (definingMaterial != null) {
	    if ((this.definingMaterial.changedFrequent != 0) ||
		(material !=null && material.changedFrequent != 0))
		if (definingMaterial == material) {
		    if (definingMaterial.compChanged != 0) {
			if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			    renderBin.rmUpdateList.add(this);
			}
			soleUserCompDirty |= MATERIAL_DIRTY;
		    }
		}
		else {
		    return false;
		}
	    else if (!definingMaterial.equivalent(material)) {
		return false;
	    }
	}
	else if (material != null) {
	    return false;
	}



	if (definingColoringAttributes != null) {
	    if ((this.definingColoringAttributes.changedFrequent != 0) ||
		(coloringAttributes !=null && coloringAttributes.changedFrequent != 0))
		if (definingColoringAttributes == coloringAttributes) {
		    if (definingColoringAttributes.compChanged != 0) {
			if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			    renderBin.rmUpdateList.add(this);
			}
			soleUserCompDirty |= COLORINGATTRS_DIRTY;
		    }
		}
		else {
		    return false;
		}
	    else if (!definingColoringAttributes.equivalent(coloringAttributes)) {
		return false;
	    }
	}
	else if (coloringAttributes != null) {
	    return false;
	}

	// if the definingTransparency is a non cloned values and the incoming
	// one is equivalent, then check if the component is dirty
	// this happens when all the RAs from this RM have been removed
	// but new ones are not added yet (rbin visibility) not run yet
	// and when there is a change in nc based on the new RA, we wil;
	// miss the change, doing this check will catch the change durin
	// new RAs insertRenderAtom
	if (definingTransparency != null) {
	    if ((this.definingTransparency.changedFrequent != 0) ||
		(transparency !=null && transparency.changedFrequent != 0))
		if (definingTransparency == transparency) {
		    if (definingTransparency.compChanged != 0) {
			if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
			    renderBin.rmUpdateList.add(this);
			}
			soleUserCompDirty |= TRANSPARENCY_DIRTY;
		    }
		}
		else {
		    return false;
		}
	    else if (!definingTransparency.equivalent(transparency)) {
		return false;
	    }
	}
	else if (transparency != null) {
	    return false;
	}

	return (true);
    }

    public void updateRemoveRenderAtoms() {
	RenderAtom r;
	RenderAtomListInfo rinfo;

	// Check if this renderMolecule was created and destroyed this frame.
	// so, no display list was created
	if (numRenderAtoms == 0 && removeRAs == null && addRAs == null) {
	    textureBin.removeRenderMolecule(this);
	    return;
	}

	while (removeRAs != null) {
		r = removeRAs;
	    r.removed = null;
	    numRenderAtoms--;

	    // Loop thru all geometries in the renderAtom, they could
	    // potentially be in different buckets in the rendermoleulce
	    for (int index = 0; index < r.rListInfo.length; index++) {
		rinfo = r.rListInfo[index];
		// Don't remove  null geo
		if (rinfo.geometry() == null)
		    continue;

		if ((rinfo.groupType & RenderAtom.PRIMARY) != 0) {
		    primaryChanged = true;
		    if (rinfo.prev == null) { // At the head of the list
			primaryRenderAtomList = rinfo.next;
			if (rinfo.next != null) {
			    rinfo.next.prev = null;
			}
		    } else { // In the middle or at the end.
			rinfo.prev.next = rinfo.next;
			if (rinfo.next != null) {
			    rinfo.next.prev = rinfo.prev;
			}
		    }

		    // If the molecule type is Raster, then add it to the lock list
		    if (primaryMoleculeType == RASTER) {
			RasterRetained geo = (RasterRetained)rinfo.geometry();
			renderBin.removeGeometryFromLockList(geo);
			if (geo.image != null)
				renderBin.removeNodeComponent(geo.image);

		    }
		    else if ((rinfo.groupType & RenderAtom.SEPARATE_DLIST_PER_RINFO) != 0) {
			if (!rinfo.renderAtom.inRenderBin()) {
			    renderBin.removeDlistPerRinfo.add(rinfo);
			}
		    }
		}
		else if ((rinfo.groupType & RenderAtom.SEPARATE_DLIST_PER_GEO) != 0) {
		    if (rinfo.prev == null) { // At the head of the list
			separateDlistRenderAtomList = rinfo.next;
			if (rinfo.next != null) {
			    rinfo.next.prev = null;
			}
		    } else { // In the middle or at the end.
			rinfo.prev.next = rinfo.next;
			if (rinfo.next != null) {
			    rinfo.next.prev = rinfo.prev;
			}
		    }
		    renderBin.removeGeometryDlist(rinfo);

		}
		else {
		    if (rinfo.prev == null) { // At the head of the list
			vertexArrayRenderAtomList = rinfo.next;
			if (rinfo.next != null) {
			    rinfo.next.prev = null;
			}
		    } else { // In the middle or at the end.
			rinfo.prev.next = rinfo.next;
			if (rinfo.next != null) {
			    rinfo.next.prev = rinfo.prev;
			}
		    }
		    // For indexed geometry there is no need to lock since
		    // the mirror is changed only when the renderer is not
		    // running
		    // For indexed geometry, if use_coord is set, then either we
		    // are using the index geometry as is or we will be unindexifying
		    // on the fly, so its better to lock
		    GeometryArrayRetained geo = (GeometryArrayRetained)rinfo.geometry();
		    if (!(geo instanceof IndexedGeometryArrayRetained) ||
			((geo.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0)) {
			renderBin.removeGeometryFromLockList(geo);
		    }
		}
		rinfo.prev = null;
		rinfo.next = null;
	    }
	    removeRAs = removeRAs.nextRemove;
	    r.nextRemove = null;
	    r.prevRemove = null;
	    if (r.isOriented()) {
		renderBin.orientedRAs.remove(r);
	    }

	    if ((textureBin.environmentSet.lightBin.geometryBackground == null) &&
		!isOpaqueOrInOG && renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY) {
		renderBin.removeTransparentObject(r);
	    }
	}
	// If this renderMolecule will not be touched for adding new RenderAtoms
	// then ..
	if (addRAs == null) {
	    // If there are no more renderAtoms and there will be no more
	    // renderatoms added to this renderMolecule , then remove
	    if (numRenderAtoms == 0) {
		// If both lists are empty remove this renderMolecule
		if ((primaryMoleculeType &DLIST_MOLECULE) != 0) {
		    renderBin.addDisplayListResourceFreeList(this);
		    vwcBounds.set(null);
		    displayListId = 0;
		    displayListIdObj = null;
		}
		if (locale != renderBin.locale) {
		    localeLocalToVworld = null;
		}
		textureBin.removeRenderMolecule(this);
	    } else {
		if ((primaryMoleculeType &DLIST_MOLECULE) != 0 && primaryChanged) {

		    // If a renderAtom is added to the display list
		    // structure then add this to the dirty list of rm
		    // for which the display list needs to be recreated
		    renderBin.addDirtyRenderMolecule(this);
		    vwcBounds.set(null);
		    rinfo = primaryRenderAtomList;
		    while (rinfo != null) {
			vwcBounds.combine(rinfo.renderAtom.localeVwcBounds);
			rinfo = rinfo.next;
		    }
		    primaryChanged = false;
		}
	    }
	}
	numEditingRenderAtoms = numRenderAtoms;
    }

    @Override
    public void updateObject() {
	int i;
	RenderAtom renderAtom;
	RenderAtomListInfo r;
	if (textureBin == null) {
	    return;
	}

	if (addRAs != null) {
	    while (addRAs != null) {

		numRenderAtoms++;
			renderAtom = addRAs;
		renderAtom.renderMolecule = this;
		renderAtom.added = null;
		for (int j = 0; j < renderAtom.rListInfo.length; j++) {
				r = renderAtom.rListInfo[j];
		    // Don't add null geo
		    if (r.geometry() == null)
			continue;
		    r.groupType = evalRinfoGroupType(r);
		    if ((r.groupType & RenderAtom.PRIMARY) != 0) {
			if ((r.groupType & RenderAtom.DLIST) != 0 && primaryRenderMethod == null) {
			    primaryMoleculeType = DLIST_MOLECULE;
			    renderBin.renderMoleculeList.add(this);

			    if (vwcBounds == null)
				vwcBounds = new BoundingBox((BoundingBox)null);
			    primaryRenderMethod =
				VirtualUniverse.mc.getDisplayListRenderMethod();
			    // Assign a displayListId for this renderMolecule
			    if (displayListId == 0) {
				displayListIdObj = VirtualUniverse.mc.getDisplayListId();
				displayListId =  displayListIdObj.intValue();
			    }
			}
			else if ((r.groupType & RenderAtom.SEPARATE_DLIST_PER_RINFO) != 0 &&
				 primaryRenderMethod == null) {
			    primaryMoleculeType = SEPARATE_DLIST_PER_RINFO_MOLECULE;
			    renderBin.renderMoleculeList.add(this);
			    primaryRenderMethod =
				VirtualUniverse.mc.getDisplayListRenderMethod();

			}
			primaryChanged = true;
			if (primaryRenderAtomList == null) {
			    primaryRenderAtomList = r;
			}
			else {
			    r.next = primaryRenderAtomList;
			    primaryRenderAtomList.prev = r;
			    primaryRenderAtomList = r;
			}
			if (primaryMoleculeType == SEPARATE_DLIST_PER_RINFO_MOLECULE) {
			    if (r.renderAtom.dlistIds == null) {
				r.renderAtom.dlistIds = new int[r.renderAtom.rListInfo.length];

				for (int k = 0; k < r.renderAtom.dlistIds.length; k++) {
				    r.renderAtom.dlistIds[k] = -1;
				}
			    }
			    if (r.renderAtom.dlistIds[r.index] == -1) {
				r.renderAtom.dlistIds[r.index] = VirtualUniverse.mc.getDisplayListId().intValue();
				renderBin.addDlistPerRinfo.add(r);
			    }
			}

			// If the molecule type is Raster, then add it to the lock list
			if (primaryMoleculeType == RASTER) {
			    RasterRetained geo = (RasterRetained)r.geometry();
			    renderBin.addGeometryToLockList(geo);
			    if (geo.image != null)
				renderBin.addNodeComponent(geo.image);
			}
		    }
		    else if ((r.groupType & RenderAtom.SEPARATE_DLIST_PER_GEO) != 0) {
			if (separateDlistRenderAtomList == null) {
			    separateDlistRenderAtomList = r;
			}
			else {
			    r.next = separateDlistRenderAtomList;
			    separateDlistRenderAtomList.prev = r;
			    separateDlistRenderAtomList = r;
			}
			((GeometryArrayRetained)r.geometry()).assignDlistId();
			renderBin.addGeometryDlist(r);
		    }
		    else {
			if (secondaryRenderMethod == null)
			    secondaryRenderMethod = cachedVertexArrayRenderMethod;
			if (vertexArrayRenderAtomList == null) {
			    vertexArrayRenderAtomList = r;
			}
			else {
			    r.next = vertexArrayRenderAtomList;
			    vertexArrayRenderAtomList.prev = r;
			    vertexArrayRenderAtomList = r;
			}
			// For indexed geometry there is no need to lock since
			// the mirror is changed only when the renderer is not
			// running
			// For indexed geometry, if use_coord is set, then either we
			// are using the index geometry as is or we will be unindexifying
			// on the fly, so its better to loc
			GeometryArrayRetained geo = (GeometryArrayRetained)r.geometry();
			if (!(geo instanceof IndexedGeometryArrayRetained) ||
			    ((geo.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0)) {
			    renderBin.addGeometryToLockList(geo);
			    // Add the geometry to the dirty list only if the geometry is by
			    // refernce and there is color and we need to use alpha
                            // Issue 113 - ignore multiScreen
			    if ((( geo.vertexFormat & GeometryArray.BY_REFERENCE)!=0) &&
				(geo.c4fAllocated == 0) &&
				((geo.vertexFormat & GeometryArray.COLOR) != 0) &&
				useAlpha) {
				renderBin.addDirtyReferenceGeometry(geo);
			    }
			}
		    }
		}
		addRAs = addRAs.nextAdd;
		renderAtom.nextAdd = null;
		renderAtom.prevAdd = null;
		if (renderAtom.isOriented()) {
		    renderBin.orientedRAs.add(renderAtom);

		}
		// If transparent and not in bg geometry and is depth sorted transparency
		if (!isOpaqueOrInOG && (textureBin.environmentSet.lightBin.geometryBackground == null)&&
		    (renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY)) {
		    GeometryRetained geo = null;
		    int k = 0;
		    while (geo == null && k < renderAtom.rListInfo.length) {
			geo = renderAtom.rListInfo[k].geometry();
			k++;
		    }
		    if (geo != null) {
			if (renderAtom.parentTInfo != null && renderAtom.parentTInfo[k-1] != null) {
			    renderBin.updateTransparentInfo(renderAtom);
			}
			// Newly added renderAtom
			else {
			    renderBin.addTransparentObject(renderAtom);
			}
		    }
		    // Moving within the renderBin

		}
	    }

	    if ((primaryMoleculeType &DLIST_MOLECULE) != 0 && primaryChanged) {

		// If a renderAtom is added to the display list
		// structure then add this to the dirty list of rm
		// for which the display list needs to be recreated
		renderBin.addDirtyRenderMolecule(this);
		vwcBounds.set(null);
		r = primaryRenderAtomList;
		while (r != null) {
		    vwcBounds.combine(r.renderAtom.localeVwcBounds);
		    r = r.next;
		}
		primaryChanged = false;
	    }


	    if ((onUpdateList & LOCALE_CHANGED) != 0) {
		handleLocaleChange();
	    }

	    if (locale != renderBin.locale) {
		translate();
	    }
	}
	else {
	    // The flag LOCALE_CHANGED only gets sets when there is a new additon
	    // There are cases when RM updateObject() get called (due to addition
	    // in renderBin - see processTransformChanged()), we need to
	    // evaluate locale change for this  case as well
	    if (renderBin.localeChanged) {
		handleLocaleChange();
	    }

	    if (locale != renderBin.locale) {
		translate();
	    }

            if ((onUpdateList & UPDATE_BACKGROUND_TRANSFORM) != 0) {
                i = localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD];
                localeLocalToVworld[i].getRotation(infLocalToVworld[i]);
            }

	    // No new renderAtoms were added, but need to
	    // recompute vwcBounds in response to xform change
	    if ((onUpdateList & BOUNDS_RECOMPUTE_UPDATE) != 0) {
		vwcBounds.set(null);
		r = primaryRenderAtomList;
		while (r != null) {
		    vwcBounds.combine(r.renderAtom.localeVwcBounds);
		    r = r.next;
		}
	    }
	}

	// Clear all bits except the IN_DIRTY_LIST
	onUpdateList &= IN_DIRTY_RENDERMOLECULE_LIST;

	numEditingRenderAtoms = numRenderAtoms;
    }

    boolean canBeInDisplayList(GeometryRetained geo, GeometryAtom ga) {
        if (ga.source.sourceNode instanceof MorphRetained) {
            return false;
        }

	return geo.canBeInDisplayList(ga.alphaEditable);
    }

    // If dlist will be altered due to alpha or ignoreVertexColors, then don't
    // put in a separate dlist that can be shared ...
    final boolean geoNotAltered(GeometryArrayRetained geo) {
	return !(((geo.vertexFormat & GeometryArray.COLOR) != 0) &&
		 (textureBin.attributeBin.ignoreVertexColors || useAlpha));
    }

    int evalRinfoGroupType(RenderAtomListInfo r) {
	int groupType = 0;

	GeometryRetained geo = r.geometry();
	if (geo == null)
	    return groupType;

	if ((primaryMoleculeType & (COMPRESSED_MOLECULE |
				    RASTER_MOLECULE     |
				    TEXT3D_MOLECULE	|
				    ORIENTEDSHAPE3D_MOLECULE)) != 0) {
	    groupType = RenderAtom.OTHER;
	}
	else if (canBeInDisplayList(geo, r.renderAtom.geometryAtom)) {
	    // if geometry is under share group we immediate set the
	    // dlistID to something other than -1
	    if ( !((GeometryArrayRetained)geo).isShared ||
		// if we do a compiled and push the transform down to
		// Geometry, we can't share the displayList
		(r.renderAtom.geometryAtom.source.staticTransform != null)) {
		// If the molecule is already defined to be SEPARATE_DLIST_PER_RINFO_MOLECULE
		// continue adding in that mode even if it was switched back to
		// no depth sorted mode
		//		System.err.println("isOpaqueOrInOG ="+isOpaqueOrInOG+" primaryMoleculeType ="+primaryMoleculeType+" renderBin.transpSortMode ="+renderBin.transpSortMode);
		if (primaryMoleculeType == SEPARATE_DLIST_PER_RINFO_MOLECULE) {
		    groupType = RenderAtom.SEPARATE_DLIST_PER_RINFO;
		}
		else {
		    if (isOpaqueOrInOG ||
			renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE) {
			groupType = RenderAtom.DLIST;
		    }
		    else {
			groupType = RenderAtom.SEPARATE_DLIST_PER_RINFO;
		    }
		}

	    } else if (geoNotAltered((GeometryArrayRetained)r.geometry()) ) {
		groupType = RenderAtom.SEPARATE_DLIST_PER_GEO;
	    }
	    else {
		groupType = RenderAtom.VARRAY;
	    }
	}
	else {
	    groupType = RenderAtom.VARRAY;
	}
	return groupType;
    }

    /**
     * Adds the given RenderAtom to this RenderMolecule.
     */
    void addRenderAtom(RenderAtom renderAtom, RenderBin rb) {
	int i;

	renderAtom.envSet = textureBin.environmentSet;
	renderAtom.renderMolecule = this;
	renderAtom.dirtyMask &= ~RenderAtom.NEED_SEPARATE_LOCALE_VWC_BOUNDS;

        AppearanceRetained raApp = renderAtom.geometryAtom.source.appearance;

	MaterialRetained mat = (raApp == null)? null : raApp.material;
        if (!soleUser && material != mat) {
	    // no longer sole user
            material = definingMaterial;
        }

        if ((geometryType & SURFACE) != 0) {
	    PolygonAttributesRetained pgAttrs =
		(raApp == null)? null : raApp.polygonAttributes;
            if (!soleUser && polygonAttributes != pgAttrs) {
	        // no longer sole user
                polygonAttributes = definingPolygonAttributes;
            }

        }
	if ((geometryType & LINE) != 0) {
	    LineAttributesRetained lnAttrs =
		(raApp == null)? null : raApp.lineAttributes;
            if (!soleUser && lineAttributes != lnAttrs) {
	        // no longer sole user
                lineAttributes = definingLineAttributes;
            }

        }
	if ((geometryType & POINT) != 0) {
	    PointAttributesRetained pnAttrs =
		(raApp == null)? null : raApp.pointAttributes;
	    if (!soleUser && pointAttributes != pnAttrs) {
	        // no longer sole user
                pointAttributes = definingPointAttributes;
            }
        }

	ColoringAttributesRetained coAttrs =
	    (raApp == null)? null : raApp.coloringAttributes;
        if (!soleUser && coloringAttributes != coAttrs) {
	    // no longer sole user
            coloringAttributes = definingColoringAttributes;
        }

	TransparencyAttributesRetained trAttrs =
	    (raApp == null)? null : raApp.transparencyAttributes;
        if (!soleUser && transparency != trAttrs) {
	    // no longer sole user
            transparency = definingTransparency;
        }



	// If the renderAtom is being inserted first time, then evaluate
	// the groupType to determine if need separate localeVwcBounds
	if (!renderAtom.inRenderBin()) {
	    for (i = 0; i < renderAtom.rListInfo.length; i++) {
		if (renderAtom.rListInfo[i].geometry() == null)
		    continue;
		int groupType = evalRinfoGroupType(renderAtom.rListInfo[i]);
		if (groupType != RenderAtom.DLIST) {
		    renderAtom.dirtyMask |= RenderAtom.NEED_SEPARATE_LOCALE_VWC_BOUNDS;
		}
	    }
	}
	if (renderAtom.removed == this) {
	    // Remove the renderAtom from the list of removeRAs
	    // If this is at the head of the list
	    if (renderAtom == removeRAs) {
		removeRAs = renderAtom.nextRemove;
		if (removeRAs != null)
		    removeRAs.prevRemove = null;
		renderAtom.nextRemove = null;
		renderAtom.prevRemove = null;
	    }
	    // Somewhere in the middle
	    else {
		renderAtom.prevRemove.nextRemove = renderAtom.nextRemove;
		if (renderAtom.nextRemove != null)
		    renderAtom.nextRemove.prevRemove = renderAtom.prevRemove;
		renderAtom.nextRemove = null;
		renderAtom.prevRemove = null;
	    }

	    renderAtom.removed = null;
	    // Redo any dlist etc, because it has been added
	    for ( i = 0; i < renderAtom.rListInfo.length; i++) {
		if (renderAtom.rListInfo[i].geometry() == null)
		    continue;
		if ((renderAtom.rListInfo[i].groupType & RenderAtom.DLIST) != 0)
		    renderBin.addDirtyRenderMolecule(this);
		else if ((renderAtom.rListInfo[i].groupType & RenderAtom.SEPARATE_DLIST_PER_RINFO) != 0) {
		    renderBin.addDlistPerRinfo.add(renderAtom.rListInfo[i]);
		}
		else if ((renderAtom.rListInfo[i].groupType & RenderAtom.SEPARATE_DLIST_PER_GEO) != 0)
		    renderBin.addGeometryDlist(renderAtom.rListInfo[i]);

	    }
	    if (removeRAs == null)
		rb.removeRenderAtomInRMList.remove(this);
	}
	else {
	    // Add this renderAtom to the addList
	    if (addRAs == null) {
		addRAs = renderAtom;
		renderAtom.nextAdd = null;
		renderAtom.prevAdd = null;
	    }
	    else {
		renderAtom.nextAdd = addRAs;
		renderAtom.prevAdd = null;
		addRAs.prevAdd = renderAtom;
		addRAs = renderAtom;
	    }
	    renderAtom.added = this;
	    if (onUpdateList == 0)
		rb.objUpdateList.add(this);
	    onUpdateList |= NEW_RENDERATOMS_UPDATE;

	}
	if (renderBin.localeChanged && !doInfinite) {
	    if (onUpdateList == 0)
		rb.objUpdateList.add(this);
	    onUpdateList |= LOCALE_CHANGED;
	}

	// inform the texture bin that this render molecule is no longer
	// in zombie state

	if (numEditingRenderAtoms == 0) {
	    textureBin.incrActiveRenderMolecule();
	}
	numEditingRenderAtoms++;
    }

    /**
     * Removes the given RenderAtom from this RenderMolecule.
     */
    void removeRenderAtom(RenderAtom r) {

	r.renderMolecule = null;
	if (r.added == this) {
	    //Remove this renderAtom from the addRAs list

	    // If this is at the head of the list
	    if (r == addRAs) {
		addRAs = r.nextAdd;
		if (addRAs != null)
		    addRAs.prevAdd = null;
		r.nextAdd = null;
		r.prevAdd = null;
	    }
	    // Somewhere in the middle
	    else {
		r.prevAdd.nextAdd = r.nextAdd;
		if (r.nextAdd != null)
		    r.nextAdd.prevAdd = r.prevAdd;
		r.nextAdd = null;
		r.prevAdd = null;
	    }

	    r.added = null;
	    r.envSet = null;
	    // If the number of renderAtoms is zero, and it is on the
	    // update list for adding new renderatroms only (not for
	    // bounds update), then remove this rm from the update list

	    // Might be expensive to remove this entry from the renderBin
	    // objUpdateList, just let it call the renderMolecule
	    /*
	      if (addRAs == null) {
	      if (onUpdateList == NEW_RENDERATOMS_UPDATE){
	      renderBin.objUpdateList.remove(renderBin.objUpdateList.indexOf(this));
	      }
	      onUpdateList &= ~NEW_RENDERATOMS_UPDATE;
	      }
	    */

	}
	else {
	    // Add this renderAtom to the remove list
	    if (removeRAs == null) {
		removeRAs = r;
		r.nextRemove = null;
		r.prevRemove = null;
	    }
	    else {
		r.nextRemove = removeRAs;
		r.prevRemove = null;
		removeRAs.prevRemove = r;
		removeRAs = r;
	    }
	    r.removed = this;
	}

	// Add it to the removeRenderAtom List , in case the renderMolecule
	// needs to be removed
	if (!renderBin.removeRenderAtomInRMList.contains(this)) {
	    renderBin.removeRenderAtomInRMList.add(this);
	}

	// decrement the number of editing render atoms in this render molecule
	numEditingRenderAtoms--;

	// if there is no more editing render atoms, inform the texture bin
	// that this render molecule is going to zombie state

	if (numEditingRenderAtoms == 0) {
	    textureBin.decrActiveRenderMolecule();
	}
    }

    /**
     * Recalculates the vwcBounds for a RenderMolecule
     */
    void recalcBounds() {
	RenderAtomListInfo ra;

	if (primaryRenderMethod ==
	    VirtualUniverse.mc.getDisplayListRenderMethod()) {
	    vwcBounds.set(null);
	    ra = primaryRenderAtomList;
	    while (ra != null) {
		vwcBounds.combine(ra.renderAtom.localeVwcBounds);
		ra = ra.next;
	    }
	}
    }

    void evalAlphaUsage(RenderingAttributesRetained renderAttrs,
			TextureUnitStateRetained[] texUnits) {
        boolean alphaBlend, alphaTest, textureBlend = false;

	alphaBlend = TransparencyAttributesRetained.useAlpha(definingTransparency);

	if (texUnits != null) {
	    for (int i = 0;
		 textureBlend == false && i < texUnits.length;
		 i++) {
		if (texUnits[i] != null &&
		    texUnits[i].texAttrs != null) {
		    textureBlend = textureBlend ||
            		(texUnits[i].texAttrs.textureMode ==
			 TextureAttributes.BLEND);
		}
	    }
	}

        alphaTest =
            renderAttrs != null && renderAttrs.alphaTestFunction != RenderingAttributes.ALWAYS;

	boolean oldUseAlpha = useAlpha;
        useAlpha = alphaBlend || alphaTest || textureBlend;

	if( !oldUseAlpha && useAlpha) {
	    GeometryArrayRetained geo = null;

	    if(vertexArrayRenderAtomList != null)
		geo = (GeometryArrayRetained)vertexArrayRenderAtomList.geometry();

	    if(geo != null) {
		if (!(geo instanceof IndexedGeometryArrayRetained) ||
		    ((geo.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0)) {
		    renderBin.addGeometryToLockList(geo);
		    // Add the geometry to the dirty list only if the geometry is by
		    // reference and there is color and we need to use alpha
		    // Issue 113 - ignore multiScreen
		    if ((( geo.vertexFormat & GeometryArray.BY_REFERENCE)!=0) &&
			(geo.c4fAllocated == 0) &&
			((geo.vertexFormat & GeometryArray.COLOR) != 0) &&
			useAlpha) {
			renderBin.addDirtyReferenceGeometry(geo);
		    }
		}
	    }
	}
    }

    final boolean isSwitchOn() {
 	// The switchOn status of the entire RM can be determined
	// by the switchOn status of any renderAtoms below.
        // This is possible because renderAtoms generated from a common
        // switch branch are placed in the same renderMolecule
	if (primaryRenderAtomList != null) {
	    return primaryRenderAtomList.renderAtom.geometryAtom.
		source.switchState.lastSwitchOn;

	}

	if (vertexArrayRenderAtomList != null) {
	    return vertexArrayRenderAtomList.renderAtom.geometryAtom.
		source.switchState.lastSwitchOn;

	}

	if (separateDlistRenderAtomList != null) {
	    return separateDlistRenderAtomList.renderAtom.geometryAtom.
		source.switchState.lastSwitchOn;
	}
	return false;
    }

    /**
     * Renders this RenderMolecule
     */
    boolean render(Canvas3D cv, int pass, int dirtyBits) {
        assert pass < 0;

	boolean isVisible = isSwitchOn();

	if (!isVisible) {
	    return false;
	}

	isVisible = false;

        // include this LightBin to the to-be-updated list in Canvas
        cv.setStateToUpdate(Canvas3D.RENDERMOLECULE_BIT, this);

	boolean modeSupportDL = true;
	isNonUniformScale = !trans[localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD]].isCongruent();
	// We have to dynamically switch between using displaymode
	// mode or not instead of decide in canBeInDisplayList(),
	// since polygonAttribute can be change by editable Appearance
	// or editable polygonAttribute which mode we can't take
	// advantage of display list mode in many cases just because
	// there are three special cases to handle.

	// Another case for punting to vertex array is if pass specifies
	// something other than -1. That means, we are in the
	// multi-texturing multi-pass case. Then we'll use vertex array
	// instead. Or the length of the texCoordSetMap is greater than
	// the number of texture units supported by the Canvas, then
	// we'll have to punt to vertex array as well.

	if ((pass != TextureBin.USE_DISPLAYLIST) ||
	    (texCoordSetMapLen > cv.maxTexCoordSets)) {
	    modeSupportDL = false;
	}

	/*
	System.err.println("texCoord " + texCoordSetMapLen + " " +
			   cv.maxTexCoordSets + " " + modeSupportDL);

	System.err.println("primaryMoleculeType = "+primaryMoleculeType+" primaryRenderAtomList ="+primaryRenderAtomList+" separateDlistRenderAtomList ="+separateDlistRenderAtomList+" vertexArrayRenderAtomList ="+vertexArrayRenderAtomList);
	*/
	// Send down the model view only once, if its not of type text
	if ((primaryMoleculeType & (TEXT3D_MOLECULE| ORIENTEDSHAPE3D_MOLECULE)) == 0) {

	    if (primaryRenderAtomList != null) {
		if ((primaryRenderMethod != VirtualUniverse.mc.getDisplayListRenderMethod()) ||
		    modeSupportDL) {
		    if (primaryMoleculeType != SEPARATE_DLIST_PER_RINFO_MOLECULE) {

			if (primaryRenderMethod.render(this, cv, primaryRenderAtomList,dirtyBits))
			    isVisible = true;
		    }
		    else {
			if (renderBin.dlistRenderMethod.renderSeparateDlistPerRinfo(this, cv, primaryRenderAtomList,dirtyBits))
			    isVisible = true;

		    }
		} else {
		    if(cachedVertexArrayRenderMethod.render(this, cv,
							    primaryRenderAtomList,
							    dirtyBits)) {
			isVisible = true;
		    }
		}
	    }
	}
	else {	// TEXT3D or ORIENTEDSHAPE3D

	    if (primaryRenderAtomList != null) {
		if(primaryRenderMethod.render(this, cv, primaryRenderAtomList,
					      dirtyBits)) {
		    isVisible = true;
		}
	    }
	}

	if (separateDlistRenderAtomList != null) {
            if (modeSupportDL) {
                if(renderBin.dlistRenderMethod.renderSeparateDlists(this, cv,
                        separateDlistRenderAtomList,
                        dirtyBits)) {
                    isVisible = true;
                }

	    } else {
		if(cachedVertexArrayRenderMethod.render(this, cv,
							separateDlistRenderAtomList,
							dirtyBits)) {
		    isVisible = true;
		}
	    }

	}

	// XXXX: In the case of independent primitives such as quads,
	// it would still be better to call multi draw arrays
	if (vertexArrayRenderAtomList != null) {
	    if(cachedVertexArrayRenderMethod.render(this, cv,
						    vertexArrayRenderAtomList,
						    dirtyBits)) {
		isVisible = true;
	    }
	}
	return isVisible;
    }

    void updateAttributes(Canvas3D cv, int dirtyBits) {


	boolean setTransparency = false;

	// If this is a beginning of a frame OR diff. geometryType
	// then reload everything for the first rendermolecule
	//	System.err.println("updateAttributes");
	int bitMask = geometryType | Canvas3D.MATERIAL_DIRTY|
	    Canvas3D.COLORINGATTRS_DIRTY|
	    Canvas3D.TRANSPARENCYATTRS_DIRTY;

	// If beginning of a frame then reload all the attributes
	if ((cv.canvasDirty & bitMask) != 0) {
	    if ((geometryType & SURFACE) != 0) {
		if (definingPolygonAttributes == null) {
		    cv.resetPolygonAttributes(cv.ctx);
		} else {
		    definingPolygonAttributes.updateNative(cv.ctx);
		}
		cv.polygonAttributes = polygonAttributes;
	    }
	    if ((geometryType & LINE) != 0) {
		if (definingLineAttributes == null) {
		    cv.resetLineAttributes(cv.ctx);
		} else {
		    definingLineAttributes.updateNative(cv.ctx);
		}
		cv.lineAttributes = lineAttributes;
	    }
	    if ((geometryType & POINT) != 0) {
		if (definingPointAttributes == null) {
		    cv.resetPointAttributes(cv.ctx);
		} else {
		    definingPointAttributes.updateNative(cv.ctx);
		}
		cv.pointAttributes = pointAttributes;
	    }

	    if (definingTransparency == null) {
		cv.resetTransparency(cv.ctx, geometryType,
				     polygonMode, lineAA, pointAA);
	    } else {
		definingTransparency.updateNative(cv.ctx,
						  alpha, geometryType,
						  polygonMode, lineAA,
						  pointAA);
	    }
	    cv.transparency = transparency;

	    if (definingMaterial == null) {
		cv.updateMaterial(cv.ctx, red, green, blue, alpha);
	    } else {
		definingMaterial.updateNative(cv.ctx,
					      red, green, blue, alpha,
					      enableLighting);
	    }
	    cv.material = material;
	    cv.enableLighting = enableLighting;

	    if (definingColoringAttributes == null) {
		cv.resetColoringAttributes(cv.ctx, red, green, blue,
					   alpha, enableLighting);
	    } else {
		definingColoringAttributes.updateNative(cv.ctx,
							dRed,
							dBlue,
							dGreen,alpha,
							enableLighting);
	    }
	    cv.coloringAttributes = coloringAttributes;

            // Use Object instead of AppearanceRetained class for
            // state caching optimation for memory performance
            cv.appHandle = appHandle;
	}

        // assuming neighbor dirty bits ORing is implemented
        // note that we need to set it to ALL_DIRTY at the
        // begining of textureBin first and only do the ORing
        // whenever encounter a non-visible rm

	else if (cv.renderMolecule != this && (dirtyBits != 0)) {

	    // no need to download states if appHandle is the same
	    if (cv.appHandle != appHandle) {

		// Check if the attribute bundle in the canvas is the same
		// as the attribute bundle in this renderMolecule

		if (cv.transparency != transparency &&
		    (dirtyBits & TRANSPARENCY_DIRTY) != 0) {
		    setTransparency = true;
		    if (definingTransparency == null) {

			cv.resetTransparency(cv.ctx, geometryType,
					     polygonMode, lineAA, pointAA);
		    } else {
			definingTransparency.updateNative(cv.ctx, alpha,
							  geometryType, polygonMode,
							  lineAA, pointAA);
		    }
		    cv.transparency = transparency;
		}

		if (setTransparency || ((cv.enableLighting != enableLighting) ||
					(cv.material != material) &&
					(dirtyBits & MATERIAL_DIRTY) != 0)){
		    if (definingMaterial == null) {
			cv.updateMaterial(cv.ctx, red, green, blue, alpha);
		    } else {
			definingMaterial.updateNative(cv.ctx, red, green,
						      blue, alpha,
						      enableLighting);
		    }
		    cv.material = material;
		    cv.enableLighting = enableLighting;
		}

		if (((geometryType & SURFACE) != 0) &&
		    cv.polygonAttributes != polygonAttributes &&
		    (dirtyBits & POLYGONATTRS_DIRTY) != 0) {

		    if (definingPolygonAttributes == null) {
			cv.resetPolygonAttributes(cv.ctx);
		    } else {
			definingPolygonAttributes.updateNative(cv.ctx);
		    }
		    cv.polygonAttributes = polygonAttributes;
		}

		if (((geometryType & LINE) != 0) &&
		    cv.lineAttributes != lineAttributes &&
		    (dirtyBits & LINEATTRS_DIRTY) != 0) {

		    if (definingLineAttributes == null) {
			cv.resetLineAttributes(cv.ctx);
		    } else {
			definingLineAttributes.updateNative(cv.ctx);
		    }
		    cv.lineAttributes = lineAttributes;
		}

		if (((geometryType & POINT) != 0) &&
		    cv.pointAttributes != pointAttributes &&
		    (dirtyBits & POINTATTRS_DIRTY) != 0) {

		    if (definingPointAttributes == null) {
			cv.resetPointAttributes(cv.ctx);
		    } else {
			definingPointAttributes.updateNative(cv.ctx);
		    }
		    cv.pointAttributes = pointAttributes;
		}

		// Use Object instead of AppearanceRetained class for
		// state caching optimation for memory performance
		cv.appHandle = appHandle;
	    }
	    // no state caching for color attrs, which can also be
	    // changed by primitive with colors
	    if(setTransparency || ((dirtyBits & COLORINGATTRS_DIRTY) != 0)) {

		if (definingColoringAttributes == null) {
		    cv.resetColoringAttributes(cv.ctx,
					       red, green, blue, alpha,
					       enableLighting);
		} else {
		    definingColoringAttributes.updateNative(cv.ctx,
							    dRed,
							    dBlue,
							    dGreen,alpha,
							    enableLighting);

		}
                cv.coloringAttributes = coloringAttributes;
	    }

	}

	if ((primaryMoleculeType & (TEXT3D_MOLECULE| ORIENTEDSHAPE3D_MOLECULE)) == 0) {
	    /* System.err.println("updateAttributes  setModelViewMatrix (1)"); */

	    Transform3D modelMatrix =
	        trans[localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD]];

	    if (cv.modelMatrix != modelMatrix) {
		/* System.err.println("updateAttributes  setModelViewMatrix (2)"); */

		cv.setModelViewMatrix(cv.ctx, cv.vworldToEc.mat,
				      modelMatrix);
	    }
	}

	cv.canvasDirty &= ~bitMask;
	cv.renderMolecule = this;
    }

    void transparentSortRender(Canvas3D cv, int pass, TransparentRenderingInfo tinfo) {
        assert pass < 0;

	Transform3D modelMatrix =
	    trans[localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD]];

        // include this LightBin to the to-be-updated list in Canvas
        cv.setStateToUpdate(Canvas3D.RENDERMOLECULE_BIT, this);


	boolean modeSupportDL = true;

	// We have to dynamically switch between using displaymode
	// mode or not instead of decide in canBeInDisplayList(),
	// since polygonAttribute can be change by editable Appearance
	// or editable polygonAttribute which mode we can't take
	// advantage of display list mode in many cases just because
	// there are three special cases to handle.

        // Another case for punting to vertex array is if pass specifies
        // something other than -1. That means, we are in the
        // multi-texturing multi-pass case. Then we'll use vertex array
        // instead.

	if ((pass != TextureBin.USE_DISPLAYLIST) ||
	    (texCoordSetMapLen > cv.maxTexCoordSets)) {
	    modeSupportDL = false;
	}

	//	System.err.println("r.isOpaque = "+isOpaque+" rinfo = "+tinfo.rInfo+" groupType = "+tinfo.rInfo.groupType);
	// Only support individual dlist or varray
	// If this rInfo is a part of a bigger dlist, render as VA
	// XXXX: What to do with Text3D, Raster, CG?
	if ((tinfo.rInfo.groupType & RenderAtom.SEPARATE_DLIST_PER_RINFO) != 0) {
	    RenderAtomListInfo save= tinfo.rInfo.next;
	    // Render only one geometry
	    tinfo.rInfo.next = null;
	    //	    System.err.println("cachedVertexArrayRenderMethod = "+cachedVertexArrayRenderMethod);
	    //	    System.err.println("tinfo.rInfo = "+tinfo.rInfo);
	    if (modeSupportDL) {
		renderBin.dlistRenderMethod.renderSeparateDlistPerRinfo(this, cv,
									tinfo.rInfo,
									ALL_DIRTY_BITS);
	    }
	    else {
		cachedVertexArrayRenderMethod.render(this, cv, tinfo.rInfo,ALL_DIRTY_BITS);
	    }
	    tinfo.rInfo.next = save;
	}
	else if ((tinfo.rInfo.groupType & (RenderAtom.VARRAY| RenderAtom.DLIST)) != 0) {
	    RenderAtomListInfo save= tinfo.rInfo.next;
	    // Render only one geometry
	    tinfo.rInfo.next = null;
	    //	    System.err.println("cachedVertexArrayRenderMethod = "+cachedVertexArrayRenderMethod);
	    //	    System.err.println("tinfo.rInfo = "+tinfo.rInfo);
	    cachedVertexArrayRenderMethod.render(this, cv, tinfo.rInfo,
						 ALL_DIRTY_BITS);
	    tinfo.rInfo.next = save;
	}

	// Only support individual dlist or varray
	else if ((tinfo.rInfo.groupType & RenderAtom.SEPARATE_DLIST_PER_GEO) != 0) {
	    RenderAtomListInfo save= tinfo.rInfo.next;
	    tinfo.rInfo.next = null;
	    if (modeSupportDL) {
		renderBin.dlistRenderMethod.renderSeparateDlists(this, cv,
								 tinfo.rInfo,
								 ALL_DIRTY_BITS);
	    }
	    else {
		cachedVertexArrayRenderMethod.render(this, cv, tinfo.rInfo,
						     ALL_DIRTY_BITS);
	    }
	    tinfo.rInfo.next = save;
	}
	else {
	    RenderAtomListInfo save= tinfo.rInfo.next;
	    primaryRenderMethod.render(this, cv, primaryRenderAtomList,
				       ALL_DIRTY_BITS);
	    tinfo.rInfo.next = save;
	}

    }


    /**
     * This render method is used to render the transparency attributes.
     * It is used in the multi-texture multi-pass case to reset the
     * transparency attributes to what it was
     */
    void updateTransparencyAttributes(Canvas3D cv) {
	if (definingTransparency == null) {
	    cv.resetTransparency(cv.ctx, geometryType, polygonMode,
				 lineAA, pointAA);
	} else {
	    definingTransparency.updateNative(cv.ctx, alpha, geometryType,
					      polygonMode, lineAA, pointAA);
	}
    }

    void updateDisplayList(Canvas3D cv) {
	// This function only gets called when primaryRenderAtomsList are
	if (primaryRenderAtomList != null) {
	    ((DisplayListRenderMethod)primaryRenderMethod).buildDisplayList(this, cv);
	}
    }

    void releaseAllPrimaryDisplayListID() {

	if (primaryRenderAtomList != null) {
	    if (primaryMoleculeType == SEPARATE_DLIST_PER_RINFO_MOLECULE) {
		RenderAtomListInfo ra = primaryRenderAtomList;
		int id;

		while (ra != null) {
		    id = ra.renderAtom.dlistIds[ra.index];

		    if (id > 0) {
			VirtualUniverse.mc.freeDisplayListId(new Integer(id));
			ra.renderAtom.dlistIds[ra.index] = -1;
		    }
		    ra = ra.next;
		}
	    }
	    else if (primaryMoleculeType == DLIST_MOLECULE) {
		if (displayListIdObj != null) {
		    VirtualUniverse.mc.freeDisplayListId(displayListIdObj);
		    displayListIdObj = null;
		    displayListId = -1;
		}
	    }
	}

    }

    void releaseAllPrimaryDisplayListResources(Canvas3D cv, Context ctx) {
	if (primaryRenderAtomList != null) {
	    if (primaryMoleculeType == SEPARATE_DLIST_PER_RINFO_MOLECULE) {
		RenderAtomListInfo ra = primaryRenderAtomList;
		int id;
		while (ra != null) {
		    id = ra.renderAtom.dlistIds[ra.index];
		    if (id > 0) {
			Canvas3D.freeDisplayList(ctx, id);
		    }
		    ra = ra.next;
		}
	    }
	    else if (primaryMoleculeType == DLIST_MOLECULE) {
		if (displayListId > 0) {
			Canvas3D.freeDisplayList(ctx, displayListId);
		}
	    }
	}
    }

    void updateAllPrimaryDisplayLists(Canvas3D cv) {
	// This function only gets called when primaryRenderAtomsList are
	if (primaryRenderAtomList != null) {
	    if (primaryMoleculeType == SEPARATE_DLIST_PER_RINFO_MOLECULE) {
		RenderAtomListInfo ra = primaryRenderAtomList;
		while (ra != null) {
		    renderBin.dlistRenderMethod.buildDlistPerRinfo(ra, this, cv);
		    ra = ra.next;
		}
	    }
	    else if(primaryMoleculeType == DLIST_MOLECULE) {
		((DisplayListRenderMethod)primaryRenderMethod).buildDisplayList(this, cv);
	    }
	}
    }

    void checkEquivalenceWithBothNeighbors(int dirtyBits) {
	dirtyAttrsAcrossRms = ALL_DIRTY_BITS;

	if (prev != null) {
	    checkEquivalenceWithLeftNeighbor(prev, dirtyBits);
	}
	if (next != null) {
	    next.checkEquivalenceWithLeftNeighbor(this, dirtyBits);
	}
    }

    boolean reloadColor(RenderMolecule rm) {
	if (((rm.vertexFormat & GeometryArray.COLOR) == 0) ||
	    (((rm.vertexFormat & GeometryArray.COLOR) != 0) &&
	     (vertexFormat & GeometryArray.COLOR) != 0)) {
	    return false;
	}
	return true;
    }

    void checkEquivalenceWithLeftNeighbor(RenderMolecule rm, int dirtyBits) {
	boolean reload_color = reloadColor(rm);
	// XXXX : For now ignore the dirtyBits being sent in
	dirtyAttrsAcrossRms = ALL_DIRTY_BITS ;



	// There is some interdepenency between the different components
	// in the way it is sent down to the native code
	// Material is affected by transparency and coloring attrs
	// Transparency is affected by poly/line/pointAA
	// ColoringAttrs is affected by material and transaparency
	int materialColoringDirty = (MATERIAL_DIRTY |
				     TRANSPARENCY_DIRTY |
				     COLORINGATTRS_DIRTY);

	int transparencyDirty = (TRANSPARENCY_DIRTY|
				 POLYGONATTRS_DIRTY |
				 LINEATTRS_DIRTY |
				 POINTATTRS_DIRTY);

	if ((dirtyAttrsAcrossRms & POLYGONATTRS_DIRTY) != 0) {
	    if (rm.geometryType == geometryType &&
		(rm.polygonAttributes == polygonAttributes ||
		 ((rm.definingPolygonAttributes != null) &&
		  (rm.definingPolygonAttributes.equivalent(definingPolygonAttributes)))))
		dirtyAttrsAcrossRms &= ~POLYGONATTRS_DIRTY;

	}

	if ((dirtyAttrsAcrossRms & POINTATTRS_DIRTY) != 0) {
	    if (rm.geometryType == geometryType &&
		((rm.pointAttributes == pointAttributes) ||
		 ((rm.definingPointAttributes != null) &&
		  (rm.definingPointAttributes.equivalent(definingPointAttributes)))))
		dirtyAttrsAcrossRms &= ~POINTATTRS_DIRTY;

	}

	if ((dirtyAttrsAcrossRms & LINEATTRS_DIRTY) != 0) {
	    if (rm.geometryType == geometryType &&
		((rm.lineAttributes == lineAttributes) ||
		 ((rm.definingLineAttributes != null) &&
		  (rm.definingLineAttributes.equivalent(definingLineAttributes)))))
		dirtyAttrsAcrossRms &= ~LINEATTRS_DIRTY;
	}

	if ((dirtyAttrsAcrossRms & materialColoringDirty) != 0) {
	    if (materialEquivalent(rm, reload_color)) {
		dirtyAttrsAcrossRms &= ~MATERIAL_DIRTY;
	    }
	    else {
		dirtyAttrsAcrossRms |= MATERIAL_DIRTY;
	    }
	}




	if ((dirtyAttrsAcrossRms & materialColoringDirty) != 0) {
	    if (coloringEquivalent(rm, reload_color)) {
		dirtyAttrsAcrossRms &= ~COLORINGATTRS_DIRTY;
	    }
	    else {
		dirtyAttrsAcrossRms |= COLORINGATTRS_DIRTY;
	    }
	}

	if ((dirtyAttrsAcrossRms & transparencyDirty) != 0) {
	    if (transparencyEquivalent(rm)) {
		dirtyAttrsAcrossRms &= ~TRANSPARENCY_DIRTY;
	    }
	    else {
		dirtyAttrsAcrossRms |= TRANSPARENCY_DIRTY;
	    }
	}
    }
    void translate() {
	//	System.err.println("onUpdateList = "+onUpdateList+" renderBin.localeChanged = "+renderBin.localeChanged+" rm = "+this);
	int i = localToVworldIndex[NodeRetained.LAST_LOCAL_TO_VWORLD];

	localeLocalToVworld[i].mat[0] = localToVworld[i].mat[0];
	localeLocalToVworld[i].mat[1] = localToVworld[i].mat[1];
	localeLocalToVworld[i].mat[2] = localToVworld[i].mat[2];
	localeLocalToVworld[i].mat[3] = localToVworld[i].mat[3] + localeTranslation.x ;
	localeLocalToVworld[i].mat[4] = localToVworld[i].mat[4];
	localeLocalToVworld[i].mat[5] = localToVworld[i].mat[5];
	localeLocalToVworld[i].mat[6] = localToVworld[i].mat[6];
	localeLocalToVworld[i].mat[7] = localToVworld[i].mat[7]+ localeTranslation.y;
	localeLocalToVworld[i].mat[8] = localToVworld[i].mat[8];
	localeLocalToVworld[i].mat[9] = localToVworld[i].mat[9];
	localeLocalToVworld[i].mat[10] = localToVworld[i].mat[10];
	localeLocalToVworld[i].mat[11] = localToVworld[i].mat[11]+ localeTranslation.z;
	localeLocalToVworld[i].mat[12] = localToVworld[i].mat[12];
	localeLocalToVworld[i].mat[13] = localToVworld[i].mat[13];
	localeLocalToVworld[i].mat[14] = localToVworld[i].mat[14];
	localeLocalToVworld[i].mat[15] = localToVworld[i].mat[15];
	//	System.err.println("rm = "+this+" localTovworld = "+localeLocalToVworld[i]+" localeTranslation = "+localeTranslation);
    }


    boolean isOpaque() {
    if ((geometryType & SURFACE) != 0) {
	if (definingPolygonAttributes != null) {
	    if ((definingPolygonAttributes.polygonMode ==
		 PolygonAttributes.POLYGON_POINT) &&
		(definingPointAttributes != null) &&
		definingPointAttributes.pointAntialiasing) {
		return false;
	    } else if ((definingPolygonAttributes.polygonMode ==
			PolygonAttributes.POLYGON_LINE) &&
		       (definingLineAttributes != null) &&
		       definingLineAttributes.lineAntialiasing) {
		return false;
	    }
	}
        } else if ((geometryType & POINT) != 0) {
	if ((definingPointAttributes != null) &&
	    definingPointAttributes.pointAntialiasing) {
	    return false;
	}
    } else if ((geometryType & LINE) != 0) {
	if ((definingLineAttributes != null) &&
	    definingLineAttributes.lineAntialiasing) {
	    return false;
	}
    }
    return !TransparencyAttributesRetained.useAlpha(definingTransparency);
    }


    boolean updateNodeComponent() {
	//	System.err.println("soleUser = "+soleUser+" rm = "+this);
	if ((soleUserCompDirty & MATERIAL_DIRTY) != 0) {
	    // Note: this RM is a soleUser(only then this function is called)
	    // and if definingMaterial == material, then the material is freq
	    // changed and therefore is not cloned, only other time it can be
	    // same is when an equivalent material is added in and this can
	    // never be true when a bin is a soleUser of a appearance

	    // Evaluate before replacing the old Value
	    if (soleUser) {
		boolean cloned = definingMaterial != null && definingMaterial != material;
		//		System.err.println("===>Rm = "+this);

		//		System.err.println("===> updating node component, cloned = "+cloned+" material.changedFrequent = "+material.changedFrequent);
		//		System.err.println("===> definingMaterial ="+definingMaterial+" material = "+material);

		material = ((AppearanceRetained)appHandle).material;
		if (material == null)
		    definingMaterial = null;
		else {
		    if (material.changedFrequent != 0) {
			definingMaterial = material;
		    }
		    else {
			// If the one replaced is a cloned copy, then ..
			if (cloned) {
			    definingMaterial.set(material);
			}
			else {
			    definingMaterial = (MaterialRetained)material.clone();
			}
		    }
		}
	    }
	    evalMaterialCachedState();
	}
	if ((soleUserCompDirty & LINEATTRS_DIRTY) != 0) {
	    if (soleUser) {
		// Evaluate before replacing the old Value
		boolean cloned = definingLineAttributes != null && definingLineAttributes != lineAttributes;

		lineAttributes = ((AppearanceRetained)appHandle).lineAttributes;
		if (lineAttributes == null) {
		    lineAA = false;
		    definingLineAttributes = null;
		} else {
		    if (lineAttributes.changedFrequent != 0) {
			definingLineAttributes = lineAttributes;
		    }
		    else {
			// If the one replaced is a cloned copy, then ..
			if (cloned) {
			    definingLineAttributes.set(lineAttributes);
			}
			else {
			    definingLineAttributes = (LineAttributesRetained)lineAttributes.clone();
			}
		    }
		    lineAA = definingLineAttributes.lineAntialiasing;
		}
	    }
	    else {
		lineAA = definingLineAttributes.lineAntialiasing;
	    }
	}
	if ((soleUserCompDirty & POINTATTRS_DIRTY) != 0) {
	    if (soleUser) {
		// Evaluate before replacing the old Value
		boolean cloned = definingPointAttributes != null && definingPointAttributes != pointAttributes;

		pointAttributes = ((AppearanceRetained)appHandle).pointAttributes;
		if (pointAttributes == null) {
		    pointAA = false;
		    definingPointAttributes = null;
		} else {
		    if (pointAttributes.changedFrequent != 0) {
			definingPointAttributes = pointAttributes;
		    }
		    else {
			// If the one replaced is a cloned copy, then ..
			if (cloned) {
			    definingPointAttributes.set(pointAttributes);
			}
			else {
			    definingPointAttributes = (PointAttributesRetained)pointAttributes.clone();
			}
		    }
		    pointAA = definingPointAttributes.pointAntialiasing;
		}
	    }
	    else {
		pointAA = definingPointAttributes.pointAntialiasing;
	    }

	}
	if ((soleUserCompDirty & POLYGONATTRS_DIRTY) != 0) {
	    if (soleUser) {
		// Evaluate before replacing the old Value
		boolean cloned = definingPolygonAttributes != null && definingPolygonAttributes != polygonAttributes;


		polygonAttributes = ((AppearanceRetained)appHandle).polygonAttributes;

		if (polygonAttributes == null) {
		    polygonMode =  PolygonAttributes.POLYGON_FILL;
		    definingPolygonAttributes = null;
		} else {
		    if (polygonAttributes.changedFrequent != 0) {
			definingPolygonAttributes = polygonAttributes;
		    }
		    else {
			// If the one replaced is a cloned copy, then ..
			if (cloned) {
			    definingPolygonAttributes.set(polygonAttributes);
			}
			else {
			    definingPolygonAttributes = (PolygonAttributesRetained)polygonAttributes.clone();
			}
		    }

		    polygonMode = definingPolygonAttributes.polygonMode;
		}
	    }
	    else {
		polygonMode = definingPolygonAttributes.polygonMode;
	    }

	    if (polygonMode == PolygonAttributes.POLYGON_LINE) {
		geometryType |= LINE;
            } else if (polygonMode == PolygonAttributes.POLYGON_POINT) {
		geometryType |= POINT;
	    }
	}

	if ((soleUserCompDirty & TRANSPARENCY_DIRTY) != 0) {
	    if (soleUser) {
		// Evaluate before replacing the old Value
		boolean cloned = definingTransparency != null && definingTransparency != transparency;
		transparency = ((AppearanceRetained)appHandle).transparencyAttributes;

		if (transparency == null) {
		    alpha = 1.0f ;
		    definingTransparency = null;
		} else {
		    if (transparency.changedFrequent != 0) {
			definingTransparency = transparency;
		    }
		    else {
			// If the one replaced is a cloned copy, then ..
			if (cloned) {
			    definingTransparency.set(transparency);
			}
			else {
			    definingTransparency = (TransparencyAttributesRetained)transparency.clone();
			}
		    }

		    alpha = 1.0f - definingTransparency.transparency;
		}
	    }
	    else {
		alpha = 1.0f - definingTransparency.transparency;
	    }
	}

	if ((soleUserCompDirty & COLORINGATTRS_DIRTY) != 0) {
	    if (soleUser) {
		// Evaluate before replacing the old Value
		boolean cloned = definingColoringAttributes != null && definingColoringAttributes != coloringAttributes;

		coloringAttributes = ((AppearanceRetained)appHandle).coloringAttributes;
		//		System.err.println("coloringAttributes and soleUser");
		//		System.err.println("coloringAttributes ="+coloringAttributes);
		if (coloringAttributes == null) {
		    definingColoringAttributes = null;
		    red = 1.0f;
		    green = 1.0f;
		    blue = 1.0f;
		} else {
		    //		    System.err.println("coloringAttributes.changedFrequent  = "+coloringAttributes.changedFrequent );
		    if (coloringAttributes.changedFrequent != 0) {
			definingColoringAttributes = coloringAttributes;
		    }
		    else {
			// If the one replaced is a cloned copy, then ..
			if (cloned) {
			    definingColoringAttributes.set(coloringAttributes);
			}
			else {
			    definingColoringAttributes = (ColoringAttributesRetained)coloringAttributes.clone();
			}
		    }
		    red = definingColoringAttributes.color.x;
		    green = definingColoringAttributes.color.y;
		    blue = definingColoringAttributes.color.z;
		}
	    }
	    else {
		red = definingColoringAttributes.color.x;
		green = definingColoringAttributes.color.y;
		blue = definingColoringAttributes.color.z;
	    }
	}
	//	System.err.println("rm = "+this+"red = "+red+" green = "+green+" blue = "+blue);
	boolean newVal = isOpaque() || inOrderedGroup;
	return (isOpaqueOrInOG != newVal);

    }

    // Issue 129: method to add or remove all rendering atoms in this
    // RenderMolecule to or from the transparent info list when we are
    // in depth sorted transparency mode and the RenderMolecule
    // changes from opaque to transparent or vice versa.
    void addRemoveTransparentObject(RenderBin renderBin, boolean add) {
	addRemoveTransparentObject(renderBin, add, primaryRenderAtomList);
	addRemoveTransparentObject(renderBin, add, separateDlistRenderAtomList);
	addRemoveTransparentObject(renderBin, add, vertexArrayRenderAtomList);
    }

    private void addRemoveTransparentObject(RenderBin renderBin,
					    boolean add,
					    RenderAtomListInfo rinfo) {
	while (rinfo != null) {
	    if (add) {
		renderBin.addTransparentObject(rinfo.renderAtom);
	    }
	    else {
		renderBin.removeTransparentObject(rinfo.renderAtom);
	    }
	    rinfo = rinfo.next;
	}
    }

    void evalMaterialCachedState() {
	if (definingMaterial == null) {
	    enableLighting = false;;
	    definingMaterial = null;
	    dRed = 1.0f;
	    dGreen = 1.0f;
	    dBlue = 1.0f;
	}
	else {
	    if ((geometryType & RASTER) != 0) {
		enableLighting = false;
		dRed = 1.0f;
		dGreen = 1.0f;
		dBlue = 1.0f;
	    } else {
		if (normalPresent)
		    enableLighting = definingMaterial.lightingEnable;
		else
		    enableLighting = false;
		dRed = definingMaterial.diffuseColor.x;
		dGreen = definingMaterial.diffuseColor.y;
		dBlue = definingMaterial.diffuseColor.z;
	    }
	}
    }


    void markBitsAsDirty(int leftBits, int rightBits) {
	if (prev != null) {
	    checkEquivalenceWithLeftNeighbor(prev, leftBits);
	    prev.soleUserCompDirty &= ~ALL_DIRTY_BITS;
	}
	else if (prevMap != null) {
	    checkEquivalenceWithLeftNeighbor(prevMap, leftBits);
	    prevMap.soleUserCompDirty &= ~ALL_DIRTY_BITS;
	}
	if (next != null) {
	    if ((next.soleUserCompDirty & ALL_DIRTY_BITS) == 0) {
		next.checkEquivalenceWithLeftNeighbor(this, rightBits);
	    } else {
		next.soleUserCompDirty = rightBits;
	    }
	}
	else if (nextMap != null) {
	    if ((nextMap.soleUserCompDirty & ALL_DIRTY_BITS) == 0) {
		nextMap.checkEquivalenceWithLeftNeighbor(this, rightBits);
	    } else {
		nextMap.soleUserCompDirty = rightBits;
	    }
	}

    }

    void handleMaterialEquivalence() {
	// Check if it has equivalent material to any of the "non-dirty"
	// renderMolecules before this one
	RenderMolecule curPrevRm = null;
	RenderMolecule curNextRm = null;
	boolean found = false;
	int leftBits = ALL_DIRTY_BITS;
	int rightBits = ALL_DIRTY_BITS;
	if (prev != null) {
	    curPrevRm = prev.prev;
	    if (materialEquivalent(prev, reloadColor(prev))) {
		found = true;
		leftBits = (((soleUserCompDirty | prev.soleUserCompDirty) &ALL_DIRTY_BITS) & ~MATERIAL_DIRTY);
		rightBits = (soleUserCompDirty & ALL_DIRTY_BITS);
		markBitsAsDirty(leftBits, rightBits);
	    }
	}
	else if (!found && next != null) {
	    curNextRm = next.next;

	    if (materialEquivalent(next, reloadColor(next))) {
		found = true;
		int bits = 0;
		if (prev != null)
		    bits = prev.soleUserCompDirty;
		else if (prevMap != null)
		    bits = prevMap.soleUserCompDirty;

		leftBits = ((soleUserCompDirty |bits) &ALL_DIRTY_BITS);
		rightBits = ((soleUserCompDirty & ALL_DIRTY_BITS)  & ~MATERIAL_DIRTY);
		markBitsAsDirty(leftBits, rightBits);

	    }
	}
	// try place it next to a equivalent material on the left
	while (!found && curPrevRm != null) {
	    if (materialEquivalent(curPrevRm, reloadColor(curPrevRm))) {
		found = true;
		// Remove the renderMolecule from it place
		prev.next = next;
		prev.nextMap = nextMap;
		if (next != null) {
		    next.prev = prev;
		    if ((next.soleUserCompDirty & ALL_DIRTY_BITS) == 0) {
			next.checkEquivalenceWithLeftNeighbor(prev, ALL_DIRTY_BITS);
		    }
		    else {
			next.soleUserCompDirty = ALL_DIRTY_BITS;
		    }
		}
		else if (nextMap != null) {
		    nextMap.prevMap = prev;
		    if ((nextMap.soleUserCompDirty & ALL_DIRTY_BITS) == 0) {
			nextMap.checkEquivalenceWithLeftNeighbor(prev,ALL_DIRTY_BITS);
		    }
		    else {
			nextMap.soleUserCompDirty |= ALL_DIRTY_BITS;
		    }
		}

		// Insert it after the equivalent RM
		next = curPrevRm.next;
		nextMap = curPrevRm.nextMap;
		curPrevRm.nextMap = null;
		if (next != null) {
		    next.prev = this;
		}
		else if (nextMap != null) {
		    nextMap.prevMap = this;
		}
		prev = curPrevRm;
		curPrevRm.next = this;
		leftBits = (ALL_DIRTY_BITS & ~MATERIAL_DIRTY);
		markBitsAsDirty(leftBits, ALL_DIRTY_BITS);
	    }
	    curPrevRm = curPrevRm.prev;
	}

	// Check if it has equivalent material to any of the renderMolecules after
	// this one
	while (!found && curNextRm != null) {
	    if (materialEquivalent(curNextRm, reloadColor(curNextRm))) {
		found = true;
		// switch the pointers
		next.prev = prev;
		next.prevMap = prevMap;
		if (prev != null) {
		    prev.next = next;
		    if ((next.soleUserCompDirty & ALL_DIRTY_BITS) == 0) {
			next.checkEquivalenceWithLeftNeighbor(prev, ALL_DIRTY_BITS);
		    }
		    else {
			next.soleUserCompDirty = ALL_DIRTY_BITS;
		    }
		}
		else if (prevMap != null) {
		    prevMap.nextMap = next;
		    if ((next.soleUserCompDirty & ALL_DIRTY_BITS) == 0) {
			next.checkEquivalenceWithLeftNeighbor(prevMap, ALL_DIRTY_BITS);
		    }
		    else {
			next.soleUserCompDirty = ALL_DIRTY_BITS;
		    }
		}

		// Insert it before the equivalent RM
		prev = curNextRm.prev;
		prevMap = curNextRm.prevMap;
		curNextRm.prevMap = null;
		if (curNextRm.prev != null) {
		    curNextRm.prev.next = this;
		}
		else if (prevMap != null) {
		    prevMap.nextMap = this;
		}
		next = curNextRm;
		curNextRm.prev = this;
		rightBits =  (ALL_DIRTY_BITS & ~MATERIAL_DIRTY);
		markBitsAsDirty(ALL_DIRTY_BITS, rightBits);
	    }
	    curNextRm = curNextRm.next;
	}
	// If there are no equivalent ones, evaluate the dirty bits in the current place
	if (!found) {
	    if (prev != null) {
		leftBits = ((soleUserCompDirty|prev.soleUserCompDirty) & ALL_DIRTY_BITS);
	    }
	    else if (prevMap != null) {
		leftBits = ((soleUserCompDirty|prevMap.soleUserCompDirty) & ALL_DIRTY_BITS);
	    }
	    if (next != null) {
		rightBits = ((soleUserCompDirty|next.soleUserCompDirty) & ALL_DIRTY_BITS);
	    }
	    else if (nextMap != null) {
		rightBits = ((soleUserCompDirty|nextMap.soleUserCompDirty) & ALL_DIRTY_BITS);
	    }
	    markBitsAsDirty(leftBits, rightBits);
	}

    }

    void reEvaluateEquivalence () {
	// If Material changed, reInsert next to a equivalent material under
	// the same transform group
	// to prevent unnecessary material download
	// This RM may have been evaluated due to an other RM is the same list
	// If not, ...
	if ((soleUserCompDirty & ALL_DIRTY_BITS) != 0) {
	    if ((soleUserCompDirty & MATERIAL_DIRTY) != 0) {
		handleMaterialEquivalence();
	    }
	    else {
		int dirtyBits = (soleUserCompDirty & ALL_DIRTY_BITS);
		if (prev != null) {
		    checkEquivalenceWithLeftNeighbor(prev, ((dirtyBits|prev.soleUserCompDirty) & ALL_DIRTY_BITS));
		    prev.soleUserCompDirty = 0;
		} else if (prevMap != null) {
		    checkEquivalenceWithLeftNeighbor(prevMap, ((dirtyBits|prevMap.soleUserCompDirty) & ALL_DIRTY_BITS));
		    prevMap.soleUserCompDirty = 0;
		}
		if (next != null) {
		    next.checkEquivalenceWithLeftNeighbor(this,((next.soleUserCompDirty|soleUserCompDirty) & ALL_DIRTY_BITS));
		} else if (nextMap != null) {
		    nextMap.checkEquivalenceWithLeftNeighbor(this,((nextMap.soleUserCompDirty | soleUserCompDirty) & ALL_DIRTY_BITS));
		}
	    }
	}
	soleUserCompDirty &= ~ALL_DIRTY_BITS;
    }


    boolean materialEquivalent(RenderMolecule rm, boolean reloadColor) {
	if (!reloadColor) {
	    if (((this.material == rm.material) ||
		 ((rm.definingMaterial != null) &&
		  (rm.definingMaterial.equivalent(definingMaterial)))) &&
		rm.alpha == alpha &&
		enableLighting == rm.enableLighting &&
		(enableLighting ||
		 (!enableLighting  &&
		  rm.red ==red &&
		  rm.green == green &&
		  rm.blue == blue))) {
		return true;
	    }
	}
	return false;
    }

    boolean coloringEquivalent(RenderMolecule rm, boolean reload_color) {
	if (!reload_color) {
	    if (((rm.coloringAttributes == coloringAttributes) ||
		 ((rm.definingColoringAttributes != null) &&
		  (rm.definingColoringAttributes.equivalent(definingColoringAttributes)))) &&
		(!enableLighting || (enableLighting && (dRed == rm.dRed && dBlue == rm.dBlue && dGreen == rm.dGreen)))) {
		return true;
	    }
	}
	return false;
    }

    boolean transparencyEquivalent(RenderMolecule rm) {
	if (((rm.transparency == transparency) ||
	     ((rm.definingTransparency != null) &&
	      (rm.definingTransparency.equivalent(definingTransparency))) &&
	     (rm.definingTransparency.transparencyMode < TransparencyAttributes.SCREEN_DOOR &&
	      blendOn() == rm.blendOn()))) {
	    return true;
	}
	return false;
    }

    boolean blendOn() {
	if (lineAA && ((((geometryType & LINE) != 0) ||
			polygonMode == PolygonAttributes.POLYGON_LINE))) {
	    return true;
	}
	if (pointAA && ((((geometryType & POINT) != 0) ||
			 polygonMode == PolygonAttributes.POLYGON_POINT))) {
	    return true;
	}
	return false;
    }

    @Override
    VirtualUniverse getVirtualUniverse() {
	return null;
    }


    void handleLocaleChange() {
	if (locale == renderBin.locale) {
	    if (localToVworld != localeLocalToVworld) {
		localeLocalToVworld = localToVworld;
		localeTranslation = null;
	    }
	}
	else {
	    // Using the localToVworl then, go back to making a new copy
	    if (localeTranslation == null) {
		localeLocalToVworld = new Transform3D[2];
		localeLocalToVworld[0] = new Transform3D();
		localeLocalToVworld[1] = new Transform3D();

		localeTranslation = new Vector3d();
		locale.hiRes.difference(renderBin.locale.hiRes, localeTranslation);
		translate();
		int i = localToVworldIndex[NodeRetained.CURRENT_LOCAL_TO_VWORLD];

		localeLocalToVworld[i].mat[0] = localToVworld[i].mat[0];
		localeLocalToVworld[i].mat[1] = localToVworld[i].mat[1];
		localeLocalToVworld[i].mat[2] = localToVworld[i].mat[2];
		localeLocalToVworld[i].mat[3] = localToVworld[i].mat[3] + localeTranslation.x ;
		localeLocalToVworld[i].mat[4] = localToVworld[i].mat[4];
		localeLocalToVworld[i].mat[5] = localToVworld[i].mat[5];
		localeLocalToVworld[i].mat[6] = localToVworld[i].mat[6];
		localeLocalToVworld[i].mat[7] = localToVworld[i].mat[7]+ localeTranslation.y;
		localeLocalToVworld[i].mat[8] = localToVworld[i].mat[8];
		localeLocalToVworld[i].mat[9] = localToVworld[i].mat[9];
		localeLocalToVworld[i].mat[10] = localToVworld[i].mat[10];
		localeLocalToVworld[i].mat[11] = localToVworld[i].mat[11]+ localeTranslation.z;
		localeLocalToVworld[i].mat[12] = localToVworld[i].mat[12];
		localeLocalToVworld[i].mat[13] = localToVworld[i].mat[13];
		localeLocalToVworld[i].mat[14] = localToVworld[i].mat[14];
		localeLocalToVworld[i].mat[15] = localToVworld[i].mat[15];
	    }
	}

	trans = localeLocalToVworld;
    }


    /**
     * updateNodeComponentCheck is called for each soleUser RenderMolecule
     * into which new renderAtom has been added. This method is called before
     * updateNodeComponent() to allow RenderMolecule to catch any node
     * component changes that have been missed because the changes
     * come when there is no active renderAtom associated with the
     * TextureBin. See bug# 4503926 for details.
     */
    @Override
    public void updateNodeComponentCheck() {

	// If the renderMolecule has been removed, do nothing ..
	if ((onUpdateList &ON_UPDATE_CHECK_LIST ) == 0)
	    return;

	onUpdateList &= ~ON_UPDATE_CHECK_LIST;
	NodeComponentRetained nc = (NodeComponentRetained)appHandle;
	if ((nc.compChanged  & RM_COMPONENTS) != 0) {
	    if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		renderBin.rmUpdateList.add(this);
	    }
	    soleUserCompDirty |= (nc.compChanged  & RM_COMPONENTS);
	}
	if (definingPolygonAttributes != null &&
	    definingPolygonAttributes == polygonAttributes) {
	    if (definingPolygonAttributes.compChanged != 0) {
		if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		    renderBin.rmUpdateList.add(this);
		}
		soleUserCompDirty |= POLYGONATTRS_DIRTY;
	    }
	}
	if (definingLineAttributes != null &&
	    definingLineAttributes == lineAttributes) {
	    if (definingLineAttributes.compChanged != 0) {
		if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		    renderBin.rmUpdateList.add(this);
		}
		soleUserCompDirty |= LINEATTRS_DIRTY;
	    }
	}
	if (definingPointAttributes != null &&
	    definingPointAttributes.compChanged != 0) {
	    if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		renderBin.rmUpdateList.add(this);
	    }
	    soleUserCompDirty |= POINTATTRS_DIRTY;
	}

	if (definingMaterial != null &&
	    definingMaterial == material) {
	    if (definingMaterial.compChanged != 0) {
		if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		    renderBin.rmUpdateList.add(this);
		}
		soleUserCompDirty |= MATERIAL_DIRTY;
	    }
	}

	if (definingColoringAttributes != null &&
	    definingColoringAttributes == coloringAttributes) {
	    if (definingColoringAttributes.compChanged != 0) {
		if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		    renderBin.rmUpdateList.add(this);
		}
		soleUserCompDirty |= COLORINGATTRS_DIRTY;
	    }
	}

	if (definingTransparency != null &&
	    definingTransparency == transparency) {
	    if (definingTransparency.compChanged != 0) {
		if ((soleUserCompDirty& ALL_DIRTY_BITS) == 0 ) {
		    renderBin.rmUpdateList.add(this);
		}
		soleUserCompDirty |= TRANSPARENCY_DIRTY;
	    }
	}
    }
}