001: /*
002: * $RCSfile: Loader.java,v $
003: *
004: * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * - Redistribution of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * - Redistribution in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * Neither the name of Sun Microsystems, Inc. or the names of
019: * contributors may be used to endorse or promote products derived
020: * from this software without specific prior written permission.
021: *
022: * This software is provided "AS IS," without a warranty of any
023: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026: * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027: * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028: * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029: * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030: * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031: * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032: * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033: * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034: * POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that this software is not designed, licensed or
037: * intended for use in the design, construction, operation or
038: * maintenance of any nuclear facility.
039: *
040: * $Revision: 1.4 $
041: * $Date: 2007/02/09 17:20:06 $
042: * $State: Exp $
043: */
044:
045: package com.sun.j3d.loaders;
046:
047: import java.net.URL;
048: import java.io.Reader;
049: import java.io.FileNotFoundException;
050:
051: /**
052: * The Loader interface is used to specify the location
053: * and elements of a file format to load.
054: * The interface is used to give loaders of various
055: * file formats a common public interface. Ideally
056: * the Scene interface will be implemented to give
057: * the user a consistent interface to extract the
058: * data.
059: *
060: * @see com.sun.j3d.loaders.Scene
061: */
062: public interface Loader {
063:
064: // These are the values to be used in constructing the
065: // load flags for the loader. Users should OR the selected
066: // values together to construct an aggregate flag integer
067: // (see the setFlags() method). Users wishing to load all
068: // data in a file should use the LOAD_ALL specifier.
069:
070: /** This flag enables the loading of light objects into the scene.*/
071: public static final int LOAD_LIGHT_NODES = 1;
072:
073: /** This flag enables the loading of fog objects into the scene.*/
074: public static final int LOAD_FOG_NODES = 2;
075:
076: /** This flag enables the loading of background objects into the scene.*/
077: public static final int LOAD_BACKGROUND_NODES = 4;
078:
079: /** This flag enables the loading of behaviors into the scene.*/
080: public static final int LOAD_BEHAVIOR_NODES = 8;
081:
082: /** This flag enables the loading of view (camera) objects into
083: * the scene.*/
084: public static final int LOAD_VIEW_GROUPS = 16;
085:
086: /** This flag enables the loading of sound objects into the scene.*/
087: public static final int LOAD_SOUND_NODES = 32;
088:
089: /** This flag enables the loading of all objects into the scene.*/
090: public static final int LOAD_ALL = 0xffffffff;
091:
092: // Loading methods
093:
094: /**
095: * This method loads the named file and returns the Scene
096: * containing the scene. Any data files referenced by this
097: * file should be located in the same place as the named file;
098: * otherwise users should specify an alternate base path with
099: * the setBasePath(String) method.
100: */
101: public Scene load(String fileName) throws FileNotFoundException,
102: IncorrectFormatException, ParsingErrorException;
103:
104: /**
105: * This method loads the named file and returns the Scene
106: * containing the scene. Any data files referenced by the Reader
107: * should be located in the same place as the named file; otherwise,
108: * users should specify an alternate base path with the setBaseUrl(URL)
109: * method.
110: */
111: public Scene load(URL url) throws FileNotFoundException,
112: IncorrectFormatException, ParsingErrorException;
113:
114: /**
115: * This method loads the Reader and returns the Scene
116: * containing the scene. Any data files referenced by the Reader should
117: * be located in the user's current working directory.
118: */
119: public Scene load(Reader reader) throws FileNotFoundException,
120: IncorrectFormatException, ParsingErrorException;
121:
122: // Variable get/set methods
123:
124: /**
125: * This method sets the base URL name for data files associated with
126: * the file passed into the load(URL) method.
127: * The basePath should be null by default, which is an indicator
128: * to the loader that it should look for any associated files starting
129: * from the same directory as the file passed into the load(URL) method.
130: */
131: public void setBaseUrl(URL url);
132:
133: /**
134: * This method sets the base path name for data files associated with
135: * the file passed into the load(String) method.
136: * The basePath should be null by default, which is an indicator
137: * to the loader that it should look for any associated files starting
138: * from the same directory as the file passed into the load(String)
139: * method.
140: */
141: public void setBasePath(String pathName);
142:
143: /**
144: * Returns the current base URL setting. By default this is null,
145: * implying the loader should look for associated files starting
146: * from the same directory as the file passed into the load(URL) method.
147: */
148: public URL getBaseUrl();
149:
150: /**
151: * Returns the current base path setting. By default this is null,
152: * implying the loader should look for associated files starting
153: * from the same directory as the file passed into the load(String)
154: * method.
155: */
156: public String getBasePath();
157:
158: /**
159: * This method sets the load flags for the file. The flags should
160: * equal 0 by default (which tells the loader to only load geometry).
161: * To enable the loading of any particular scene elements, pass
162: * in a logical OR of the LOAD values specified above.
163: */
164: public void setFlags(int flags);
165:
166: /**
167: * Returns the current loading flags setting.
168: */
169: public int getFlags();
170: }
|