Source Code Cross Referenced for ShaderAppearance.java in  » 6.0-JDK-Modules » java-3d » javax » media » j3d » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » javax.media.j3d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: ShaderAppearance.java,v $
003:         *
004:         * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006:         *
007:         * This code is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License version 2 only, as
009:         * published by the Free Software Foundation.  Sun designates this
010:         * particular file as subject to the "Classpath" exception as provided
011:         * by Sun in the LICENSE file that accompanied this code.
012:         *
013:         * This code is distributed in the hope that it will be useful, but WITHOUT
014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:         * version 2 for more details (a copy is included in the LICENSE file that
017:         * accompanied this code).
018:         *
019:         * You should have received a copy of the GNU General Public License version
020:         * 2 along with this work; if not, write to the Free Software Foundation,
021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022:         *
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024:         * CA 95054 USA or visit www.sun.com if you need additional information or
025:         * have any questions.
026:         *
027:         * $Revision: 1.5 $
028:         * $Date: 2008/02/28 20:17:29 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.util.Hashtable;
035:
036:        /**
037:         * <p>The ShaderAppearance object defines programmable shading attributes
038:         * that can be set as a component object of a Shape3D node. The
039:         * ShaderAppearance rendering state adds the following attributes in
040:         * addition to those defined by Appearance:</p>
041:         *
042:         * <ul>
043:         * <li>Shader program - specifies the shader program...</li>
044:         *
045:         * <p></p>
046:         * <li>Shader attribute set - specifies the shader parameters, both as
047:         * explicit attributes and as implicit bindings to Java 3D
048:         * state...</li>
049:         * </ul>
050:         *
051:         * <p>The ShaderAppearance object modifies the definition of some of the
052:         * attributes in Appearance:</p>
053:         *
054:         * <ul>
055:         * <li>Coloring attributes - XXXXX</li>
056:         *
057:         * <p></p>
058:         * <li>Line attributes - XXXXX</li>
059:         *
060:         * <p></p>
061:         * <li>Point attributes - XXXXX</li>
062:         *
063:         * <p></p>
064:         * <li>Polygon attributes - XXXXX</li>
065:         *
066:         * <p></p>
067:         * <li>Rendering attributes - XXXXX</li>
068:         *
069:         * <p></p>
070:         * <li>Transparency attributes - XXXXX</li>
071:         *
072:         * <p></p>
073:         * <li>Material - XXXXX</li>
074:         *
075:         * <p></p>
076:         * <li>Texture - XXXXX</li>
077:         *
078:         * <p></p>
079:         * <li>Texture attributes - XXXXX</li>
080:         *
081:         * <p></p>
082:         * <li>Texture coordinate generation - XXXXX</li>
083:         *
084:         * <p></p>
085:         * <li>Texture unit state - XXXXX</li>
086:         * </ul>
087:         *
088:         * @see ShaderProgram
089:         * @see ShaderAttributeSet
090:         *
091:         * @since Java 3D 1.4
092:         */
093:        public class ShaderAppearance extends Appearance {
094:            /**
095:             * Specifies that this ShaderAppearance object allows reading its
096:             * ShaderProgram component information.
097:             */
098:            public static final int ALLOW_SHADER_PROGRAM_READ = CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_PROGRAM_READ;
099:
100:            /**
101:             * Specifies that this ShaderAppearance object allows writing its
102:             * ShaderProgram component information.
103:             */
104:            public static final int ALLOW_SHADER_PROGRAM_WRITE = CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_PROGRAM_WRITE;
105:
106:            /**
107:             * Specifies that this ShaderAppearance object allows reading its
108:             * ShaderAttributeSet component information.
109:             */
110:            public static final int ALLOW_SHADER_ATTRIBUTE_SET_READ = CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_ATTRIBUTE_SET_READ;
111:
112:            /**
113:             * Specifies that this ShaderAppearance object allows writing its
114:             * ShaderAttributeSet component information.
115:             */
116:            public static final int ALLOW_SHADER_ATTRIBUTE_SET_WRITE = CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_ATTRIBUTE_SET_WRITE;
117:
118:            // Array for setting default read capabilities
119:            private static final int[] readCapabilities = {
120:                    ALLOW_SHADER_PROGRAM_READ, ALLOW_SHADER_ATTRIBUTE_SET_READ };
121:
122:            /**
123:             * Constructs a ShaderAppearance component object using defaults for all
124:             * state variables. All component object references are initialized
125:             * to null.
126:             */
127:            public ShaderAppearance() {
128:                // Just use default values
129:                // set default read capabilities
130:                setDefaultReadCapabilities(readCapabilities);
131:            }
132:
133:            /**
134:             * Creates the retained mode ShaderAppearanceRetained object that this
135:             * ShaderAppearance component object will point to.
136:             */
137:            void createRetained() {
138:                this .retained = new ShaderAppearanceRetained();
139:                this .retained.setSource(this );
140:            }
141:
142:            /**
143:             * Sets the ShaderProgram object to the specified object.  Setting it to
144:             * null causes a default pass-through shader to be used ???
145:             *
146:             * @param shaderProgram object that specifies the desired shader program
147:             * @exception CapabilityNotSetException if appropriate capability is
148:             * not set and this object is part of live or compiled scene graph
149:             */
150:            public void setShaderProgram(ShaderProgram shaderProgram) {
151:
152:                if (isLiveOrCompiled()) {
153:                    if (!this .getCapability(ALLOW_SHADER_PROGRAM_WRITE))
154:                        throw new CapabilityNotSetException(J3dI18N
155:                                .getString("ShaderAppearance0"));
156:                }
157:
158:                ((ShaderAppearanceRetained) this .retained)
159:                        .setShaderProgram(shaderProgram);
160:
161:            }
162:
163:            /**
164:             * Retrieves the current ShaderProgram object.
165:             *
166:             * @return the ShaderProgram object
167:             * @exception CapabilityNotSetException if appropriate capability is
168:             * not set and this object is part of live or compiled scene graph
169:             */
170:            public ShaderProgram getShaderProgram() {
171:
172:                if (isLiveOrCompiled()) {
173:                    if (!this .getCapability(ALLOW_SHADER_PROGRAM_READ))
174:                        throw new CapabilityNotSetException(J3dI18N
175:                                .getString("ShaderAppearance1"));
176:                }
177:                return ((ShaderAppearanceRetained) this .retained)
178:                        .getShaderProgram();
179:            }
180:
181:            /**
182:             * Sets the ShaderAttributeSet object to the specified object.  Setting it to
183:             * null is equivalent to specifying an empty set of attributes.
184:             *
185:             * @param shaderAttributeSet object that specifies the desired shader attributes
186:             * @exception CapabilityNotSetException if appropriate capability is
187:             * not set and this object is part of live or compiled scene graph
188:             */
189:            public void setShaderAttributeSet(
190:                    ShaderAttributeSet shaderAttributeSet) {
191:                if (isLiveOrCompiled()) {
192:                    if (!this .getCapability(ALLOW_SHADER_ATTRIBUTE_SET_WRITE))
193:                        throw new CapabilityNotSetException(J3dI18N
194:                                .getString("ShaderAppearance2"));
195:                }
196:
197:                ((ShaderAppearanceRetained) this .retained)
198:                        .setShaderAttributeSet(shaderAttributeSet);
199:            }
200:
201:            /**
202:             * Retrieves the current ShaderAttributeSet object.
203:             *
204:             * @return the ShaderAttributeSet object
205:             * @exception CapabilityNotSetException if appropriate capability is
206:             * not set and this object is part of live or compiled scene graph
207:             */
208:            public ShaderAttributeSet getShaderAttributeSet() {
209:                if (isLiveOrCompiled()) {
210:                    if (!this .getCapability(ALLOW_SHADER_ATTRIBUTE_SET_READ))
211:                        throw new CapabilityNotSetException(J3dI18N
212:                                .getString("ShaderAppearance3"));
213:                }
214:                return ((ShaderAppearanceRetained) this .retained)
215:                        .getShaderAttributeSet();
216:            }
217:
218:            /**
219:             * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
220:             */
221:            public NodeComponent cloneNodeComponent() {
222:                ShaderAppearance a = new ShaderAppearance();
223:                a.duplicateNodeComponent(this );
224:                return a;
225:            }
226:
227:            /**
228:             * NOTE: Applications should <i>not</i> call this method directly.
229:             * It should only be called by the cloneNode method.
230:             *
231:             * @deprecated replaced with duplicateNodeComponent(
232:             *  NodeComponent originalNodeComponent, boolean forceDuplicate)
233:             */
234:            public void duplicateNodeComponent(
235:                    NodeComponent originalNodeComponent) {
236:                checkDuplicateNodeComponent(originalNodeComponent);
237:            }
238:
239:            /**
240:             * Copies all ShaderAppearance information from
241:             * <code>originalNodeComponent</code> into
242:             * the current node.  This method is called from the
243:             * <code>cloneNode</code> method which is, in turn, called by the
244:             * <code>cloneTree</code> method.<P>
245:             *
246:             * @param originalNodeComponent the original node to duplicate.
247:             * @param forceDuplicate when set to <code>true</code>, causes the
248:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
249:             *  <code>false</code>, the value of each node's
250:             *  <code>duplicateOnCloneTree</code> variable determines whether
251:             *  NodeComponent data is duplicated or copied.
252:             *
253:             * @exception RestrictedAccessException if this object is part of a live
254:             *  or compiled scenegraph.
255:             *
256:             * @see Node#cloneTree
257:             * @see NodeComponent#setDuplicateOnCloneTree
258:             */
259:            void duplicateAttributes(NodeComponent originalNodeComponent,
260:                    boolean forceDuplicate) {
261:                super 
262:                        .duplicateAttributes(originalNodeComponent,
263:                                forceDuplicate);
264:
265:                Hashtable hashtable = originalNodeComponent.nodeHashtable;
266:
267:                ShaderAppearanceRetained app = (ShaderAppearanceRetained) originalNodeComponent.retained;
268:
269:                ShaderAppearanceRetained rt = (ShaderAppearanceRetained) retained;
270:
271:                rt.setShaderProgram((ShaderProgram) getNodeComponent(app
272:                        .getShaderProgram(), forceDuplicate, hashtable));
273:            }
274:
275:            /**
276:             *  This function is called from getNodeComponent() to see if any of
277:             *  the sub-NodeComponents  duplicateOnCloneTree flag is true.
278:             *  If it is the case, current NodeComponent needs to
279:             *  duplicate also even though current duplicateOnCloneTree flag is false.
280:             *  This should be overwrite by NodeComponent which contains sub-NodeComponent.
281:             */
282:            boolean duplicateChild() {
283:                if (super .duplicateChild())
284:                    return true;
285:
286:                if (getDuplicateOnCloneTree())
287:                    return true;
288:
289:                ShaderAppearanceRetained rt = (ShaderAppearanceRetained) retained;
290:
291:                NodeComponent nc;
292:
293:                nc = rt.getShaderProgram();
294:                if ((nc != null) && nc.getDuplicateOnCloneTree())
295:                    return true;
296:
297:                return false;
298:            }
299:
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.