com.threed.jpct
Class Loader
java.lang.Object
com.threed.jpct.Loader
- public final class Loader
- extends java.lang.Object
Loader offers some static methods for loading files. Various methods for
loading objects and animations as well as some very basic methods for loading
text-files can be found here.
Method Summary |
static void |
clearCache()
Empties the file-cache. |
static Object3D[] |
load3DS(java.io.InputStream stream,
float scale)
Loads a file in 3DS-format into an array of objects. 3DS is a 3D-Studio
format supported by many converter tools. |
static Object3D[] |
load3DS(java.lang.String filename,
float scale)
Loads a file in 3DS-format into an array of objects. 3DS is a 3D-Studio
format supported by many converter tools. |
static Object3D[] |
load3DS(java.net.URL docBase,
java.lang.String filename,
float scale)
Loads a file in 3DS-format into an array of objects. 3DS is a 3D-Studio
format supported by many converter tools. |
static Object3D |
loadASC(java.io.InputStream stream,
float scale,
boolean swap)
Loads a file in ASC-format into an object. |
static Object3D |
loadASC(java.lang.String filename,
float scale,
boolean swap)
Loads a file in ASC-format into an object. |
static Object3D |
loadASC(java.net.URL docBase,
java.lang.String filename,
float scale,
boolean swap)
Loads a file in ASC-format into an object. |
static Object3D |
loadJAW(java.io.InputStream stream,
float scale,
boolean texinfo)
Loads a file in JAW-format into an object. |
static Object3D |
loadJAW(java.lang.String filename,
float scale,
boolean texinfo)
Loads a file in JAW-format into an object. |
static Object3D |
loadJAW(java.net.URL docBase,
java.lang.String filename,
float scale,
boolean texinfo)
Loads a file in JAW-format into an object. |
static Object3D |
loadMD2(java.io.InputStream stream,
float newScale)
Loads an object out of a file in MD2-format (Quake2 model format). |
static Object3D |
loadMD2(java.lang.String filename,
float newScale)
Loads an object out of a file in MD2-format (Quake2 model format). |
static Object3D |
loadMD2(java.net.URL docBase,
java.lang.String filename,
float newScale)
Loads an object out of a file in MD2-format (Quake2 model format). |
static Object3D[] |
loadOBJ(java.io.InputStream objStream,
java.io.InputStream mtlStream,
float scale)
Loads a file in OBJ-format into an array of objects. |
static Object3D[] |
loadOBJ(java.lang.String objName,
java.lang.String mtlName,
float scale)
Loads a file in OBJ-format into an array of objects. |
static Object3D[] |
loadOBJ(java.net.URL docBase,
java.lang.String objName,
java.lang.String mtlName,
float scale)
Loads a file in OBJ-format into an array of objects. |
static void |
loadSceneFromXML(java.io.InputStream stream,
World world)
Loads a scene from XML. |
static void |
loadSceneFromXML(java.lang.String filename,
World world)
Loads a scene from XML. |
static void |
loadSceneFromXML(java.net.URL docBase,
java.lang.String filename,
World world)
Loads a scene from XML. |
static Object3D |
loadSerializedObject(java.io.InputStream is)
Loads an object in serialized format. |
static Object3D[] |
loadSerializedObjectArray(java.io.InputStream is)
Loads an object-array in serialized format. |
static java.lang.String |
loadTextFile(java.io.InputStream stream)
Loads a text-file into a String. |
static java.lang.String |
loadTextFile(java.lang.String filename)
Loads a text-file into a String. |
static java.lang.String |
loadTextFile(java.net.URL docBase,
java.lang.String filename)
Loads a text-file into a String. |
static java.lang.String[] |
readTextureNames3DS(java.io.InputStream stream)
Reads the texture names from a 3DS-file. |
static java.lang.String[] |
readTextureNames3DS(java.lang.String filename)
Reads the texture names from a 3DS-file. |
static java.lang.String[] |
readTextureNames3DS(java.net.URL docBase,
java.lang.String filename)
Reads the texture names from a 3DS-file. |
static void |
setVertexOptimization(boolean enabled)
Enables(default)/Disables vertex optimizations for the Loader. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
setVertexOptimization
public static void setVertexOptimization(boolean enabled)
- Enables(default)/Disables vertex optimizations for the Loader. Using
this, vertices can be combined to one if they cover exactly the same
point in space. This reduces vertex count. If you disable this, be sure
to have a reason...
This setting affects ASC, 3DS and OBJ files only. If used for loading 3DS
or OBJ files, the vertex sharing information from the files will be used
instead (Could be helpful to use these files as keyframes).
- Parameters:
enabled
- optimize vertex usage
loadTextFile
public static java.lang.String loadTextFile(java.lang.String filename)
- Loads a text-file into a String. Used internally by jPCT and maybe useful
for other applications.
- Parameters:
filename
- the name of the textfile
- Returns:
- the file content
loadTextFile
public static java.lang.String loadTextFile(java.net.URL docBase,
java.lang.String filename)
- Loads a text-file into a String. Used internally by jPCT and maybe useful
for other applications. This method is for usage in applets/for accessing
files via an URL.
- Parameters:
docBase
- the document basefilename
- the name of the textfile
- Returns:
- the file content
loadTextFile
public static java.lang.String loadTextFile(java.io.InputStream stream)
- Loads a text-file into a String. Used internally by jPCT and maybe useful
for other applications. This method is for accessing files from an
InputStream.
- Parameters:
stream
- the InputStream
- Returns:
- the file content
loadSerializedObject
public static Object3D loadSerializedObject(java.io.InputStream is)
- Loads an object in serialized format. This format can be created by using
the DeSerializer.
Actually, this method is a shortcut to the method in DeSerializer.
- Parameters:
is
- the inputstream
- Returns:
- the object
loadSerializedObjectArray
public static Object3D[] loadSerializedObjectArray(java.io.InputStream is)
- Loads an object-array in serialized format. This format can be created by
using the DeSerializer.
Actually, this method is a shortcut to the method in DeSerializer.
- Parameters:
is
- the inputstream
- Returns:
- the objects
loadMD2
public static Object3D loadMD2(java.lang.String filename,
float newScale)
- Loads an object out of a file in MD2-format (Quake2 model format). The
object is loaded including all keyframes so that the returned object
already contains the animation for this object. All meshes of the
animation will be stored in compressed format. The texture indicated in
the file is ignored (the texture coordinates are of course not).
- Parameters:
filename
- the name of the filenewScale
- a scaling parameter, 1 means no changes to the mesh
- Returns:
- the object including all animation data
- See Also:
Mesh.compress()
loadMD2
public static Object3D loadMD2(java.net.URL docBase,
java.lang.String filename,
float newScale)
- Loads an object out of a file in MD2-format (Quake2 model format). The
object is loaded including all keyframes so that the returned object
already contains the animation for this object. The texture indicated in
the file is ignored (the texture coordinates are of course not). All
meshes of the animation will be stored in compressed format. This method
is for usage in applets/for accessing files via an URL.
- Parameters:
docBase
- the document basefilename
- the name of the filenewScale
- a scaling parameter, 1 means no changes to the mesh
- Returns:
- the object including all animation data
- See Also:
Mesh.compress()
loadMD2
public static Object3D loadMD2(java.io.InputStream stream,
float newScale)
- Loads an object out of a file in MD2-format (Quake2 model format). The
object is loaded including all keyframes so that the returned object
already contains the animation for this object. The texture indicated in
the file is ignored (the texture coordinates are of course not). All
meshes of the animation will be stored in compressed format. This method
is for accessing files from an InputStream.
- Parameters:
stream
- the InputStreamnewScale
- a scaling parameter, 1 means no changes to the mesh
- Returns:
- the object including all animation data
- See Also:
Mesh.compress()
loadSceneFromXML
public static void loadSceneFromXML(java.lang.String filename,
World world)
- Loads a scene from XML. The used format is a proprietary jPCT-XML format
(see the documention about file-formats for more details), that supports
lights, textures (to a degree), objects and portals. It's not suitable to
describe a scene completely. Its main purpose is to offer a format that
supports portals (because none of the other formats does). The loaded
scene will be added to the world. It's advised to run this method with an
empty world. For each object loaded by this method, build() will be
called. Calling build() again on these objects will reset rotationPivot
and center. Keep this in mind.
This method uses the texture-names from the XML-file. If any of these
textures doesn't exist yet, a dummy texture with the name will be
created.
This method is for usage in applications/for accessing files on the local
machine.
- Parameters:
filename
- the filenameworld
- the world that contains the scene afterwards
loadSceneFromXML
public static void loadSceneFromXML(java.net.URL docBase,
java.lang.String filename,
World world)
- Loads a scene from XML. The used format is a proprietary jPCT-XML format
(see the documention about file-formats for more details), that supports
lights, textures (to a degree), objects and portals. It's not suitable to
describe a scene completely. Its main purpose is to offer a format that
supports portals (because none of the other formats does). The loaded
scene will be added to the world. It's advised to run this method with an
empty world. For each object loaded by this method, build() will be
called. Calling build() again on these objects will reset rotationPivot
and center. Keep this in mind.
This method uses the texture-names from the XML-file. If any of these
textures doesn't exist yet, a dummy texture with the name will be
created.
This method is for usage in applets/for accessing files via an URL.
- Parameters:
docBase
- the document basefilename
- the filenameworld
- the world that contains the scene afterwards
loadSceneFromXML
public static void loadSceneFromXML(java.io.InputStream stream,
World world)
- Loads a scene from XML. The used format is a proprietary jPCT-XML format
(see the documention about file-formats for more details), that supports
lights, textures (to a degree), objects and portals. It's not suitable to
describe a scene completely. Its main purpose is to offer a format that
supports portals (because none of the other formats does). The loaded
scene will be added to the world. It's advised to run this method with an
empty world. For each object loaded by this method, build() will be
called. Calling build() again on these objects will reset rotationPivot
and center. Keep this in mind.
This method uses the texture-names from the XML-file. If any of these
textures doesn't exist yet, a dummy texture with the name will be
created.
This method is for accessing files from an InputStream.
- Parameters:
stream
- the InputStreamworld
- the world that contains the scene afterwards
load3DS
public static Object3D[] load3DS(java.lang.String filename,
float scale)
- Loads a file in 3DS-format into an array of objects. 3DS is a 3D-Studio
format supported by many converter tools. A 3DS-file can contain many
different objects. Each object will be named like its 3DS-name (the name
this object has in 3D-Studio) plus a suffix "_jPCT" plus the object's
internal ID.Texture coordinates are supported, but texture tiling is
supported only by the OpenGL- and the SoftGL-renderer. The legacy
renderer doesn't support it and will clamp the coordinates instead.
The loader will read the textures' names out of the 3DS-file and will add
dummy textures with these names to the texture-manager (If the name is
already in use, no new dummy texture will be added). So one may load some
textures and add them to the manager with the appropiate names before
loading the 3DS-file or replace the ones generated by the loader after
loading is finished. If the materials used in the file are not using
textures, small, single colored textures will be generated that represent
the diffuse colors of the materials. This method is for usage in
applications/for accessing files on the local machine.
- Parameters:
filename
- the filenamescale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescaling
- Returns:
- the objects from the file (i.e. the complete 3DS-scene)
load3DS
public static Object3D[] load3DS(java.net.URL docBase,
java.lang.String filename,
float scale)
- Loads a file in 3DS-format into an array of objects. 3DS is a 3D-Studio
format supported by many converter tools. A 3DS-file can contain many
different objects. Each object will be named like its 3DS-name (the name
this object has in 3D-Studio) plus a suffix "_jPCT" plus the object's
internal ID. Texture coordinates are supported, but texture tiling is
supported only by the OpenGL- and the SoftGL-renderer. The legacy
renderer doesn't support it and will clamp the coordinates instead.
The loader will read the textures' names out of the 3DS-file and will add
dummy textures with these names to the texture-manager (If the name is
already in use, no new dummy texture will be added). So one may load some
textures and add them to the manager with the appropiate names before
loading the 3DS-file or replace the ones generated by the loader after
loading is finished. If the materials used in the file are not using
textures, small, single colored textures will be generated that represent
the diffuse colors of the materials. This method is for usage in
applets/for accessing files via an URL.
- Parameters:
docBase
- the document basefilename
- the filenamescale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescaling
- Returns:
- the objects from the file (i.e. the complete 3DS-scene)
load3DS
public static Object3D[] load3DS(java.io.InputStream stream,
float scale)
- Loads a file in 3DS-format into an array of objects. 3DS is a 3D-Studio
format supported by many converter tools. A 3DS-file can contain many
different objects. Each object will be named like its 3DS-name (the name
this object has in 3D-Studio) plus a suffix "_jPCT" plus the object's
internal ID. Texture coordinates are supported, but texture tiling is
supported only by the OpenGL- and the SoftGL-renderer. The legacy
renderer doesn't support it and will clamp the coordinates instead.
The loader will read the textures' names out of the 3DS-file and will add
dummy textures with these names to the texture-manager (If the name is
already in use, no new dummy texture will be added). So one may load some
textures and add them to the manager with the appropiate names before
loading the 3DS-file or replace the ones generated by the loader after
loading is finished. If the materials used in the file are not using
textures, small, single colored textures will be generated that represent
the diffuse colors of the materials. This method is for accessing files
from an InputStream.
- Parameters:
stream
- the InputStreamscale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescaling
- Returns:
- the objects from the file (i.e. the complete 3DS-scene)
readTextureNames3DS
public static java.lang.String[] readTextureNames3DS(java.lang.String filename)
- Reads the texture names from a 3DS-file.
- Parameters:
filename
- the file name
- Returns:
- String[] the texture names
readTextureNames3DS
public static java.lang.String[] readTextureNames3DS(java.net.URL docBase,
java.lang.String filename)
- Reads the texture names from a 3DS-file.
- Parameters:
docBase
- the document basefilename
- the file name
- Returns:
- String[] the texture names
readTextureNames3DS
public static java.lang.String[] readTextureNames3DS(java.io.InputStream stream)
- Reads the texture names from a 3DS-file.
- Parameters:
stream
- the input stream for the file
- Returns:
- String[] the texture names
loadASC
public static Object3D loadASC(java.lang.String filename,
float scale,
boolean swap)
- Loads a file in ASC-format into an object. ASC is an ASCII-based
3D-Studio format supported by many converter tools. This method is for
usage in applications/for accessing files on the local machine.
- Parameters:
filename
- the filenamescale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescalingswap
- if set to true, y and z coordinates of the object will be
swaped. This could be helpful for correct backface culling on
some Object3Ds.
- Returns:
- the object
loadASC
public static Object3D loadASC(java.net.URL docBase,
java.lang.String filename,
float scale,
boolean swap)
- Loads a file in ASC-format into an object. ASC is an ASCII-based
3D-Studio format supported by many converter tools. This method is for
usage in applets/for accessing files via an URL.
- Parameters:
docBase
- the document basefilename
- the filenamescale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescalingswap
- if set to true, y and z coordinates of the object will be
swaped. This could be helpful for correct backface culling on
some Object3Ds.
- Returns:
- the object
loadASC
public static Object3D loadASC(java.io.InputStream stream,
float scale,
boolean swap)
- Loads a file in ASC-format into an object. ASC is an ASCII-based
3D-Studio format supported by many converter tools. This method is for
accessing files from an InputStream.
- Parameters:
stream
- the InputStreamscale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescalingswap
- if set to true, y and z coordinates of the object will be
swaped. This could be helpful for correct backface culling on
some Object3Ds.
- Returns:
- the object
loadOBJ
public static Object3D[] loadOBJ(java.lang.String objName,
java.lang.String mtlName,
float scale)
- Loads a file in OBJ-format into an array of objects. OBJ is Wavefront's
Advanced Visualizer format supported by many converter tools. A OBJ-file
can contain many different objects/groups. Each object will be named like
its OBJ-name (the name this object has in the file) plus a suffix "_jPCT"
plus the object's internal ID. Texture coordinates are supported, but
texture tiling is supported only by the OpenGL- and the SoftGL-renderer.
The legacy renderer doesn't support it and will clamp the coordinates
instead. This loader loads polygonal information only (i.e. no splines
and similar things) and supports polygons with up to 4 vertices.
Everything higher will be loaded with a warning and most likely not
displayed correctly.
The loader will read the textures' names out of the OBJ-file and will add
dummy textures with these names to the texture-manager (If the name is
already in use, no new dummy texture will be added). So one may load some
textures and add them to the manager with the appropiate names before
loading the OBJ-file or replace the ones generated by the loader after
loading is finished. If the materials used in the file are not using
textures, small, single colored textures will be generated that represent
the diffuse colors of the materials.
This method is for usage in applications/for accessing files on the local
machine.
- Parameters:
objName
- the name of the actual OBJ-filemtlName
- the name of the material file. May be null.scale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescaling
- Returns:
- the objects/groups from the file (i.e. the complete polygonal
content)
loadOBJ
public static Object3D[] loadOBJ(java.net.URL docBase,
java.lang.String objName,
java.lang.String mtlName,
float scale)
- Loads a file in OBJ-format into an array of objects. OBJ is Wavefront's
Advanced Visualizer format supported by many converter tools. A OBJ-file
can contain many different objects/groups. Each object will be named like
its OBJ-name (the name this object has in the file) plus a suffix "_jPCT"
plus the object's internal ID. Texture coordinates are supported, but
texture tiling is supported only by the OpenGL- and the SoftGL-renderer.
The legacy renderer doesn't support it and will clamp the coordinates
instead. This loader loads polygonal information only (i.e. no splines
and similar things) and supports polygons with up to 4 vertices.
Everything higher will be loaded with a warning and most likely not
displayed correctly.
The loader will read the textures' names out of the OBJ-file and will add
dummy textures with these names to the texture-manager (If the name is
already in use, no new dummy texture will be added). So one may load some
textures and add them to the manager with the appropiate names before
loading the OBJ-file or replace the ones generated by the loader after
loading is finished. If the materials used in the file are not using
textures, small, single colored textures will be generated that represent
the diffuse colors of the materials.
This method is for usage in applets/for accessing files via an URL.
- Parameters:
objName
- the name of the actual OBJ-filemtlName
- the name of the material file. May be null.scale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescaling
- Returns:
- the objects/groups from the file (i.e. the complete polygonal
content)
loadOBJ
public static Object3D[] loadOBJ(java.io.InputStream objStream,
java.io.InputStream mtlStream,
float scale)
- Loads a file in OBJ-format into an array of objects. OBJ is Wavefront's
Advanced Visualizer format supported by many converter tools. A OBJ-file
can contain many different objects/groups. Each object will be named like
its OBJ-name (the name this object has in the file) plus a suffix "_jPCT"
plus the object's internal ID. Texture coordinates are supported, but
texture tiling is supported only by the OpenGL- and the SoftGL-renderer.
The legacy renderer doesn't support it and will clamp the coordinates
instead. This loader loads polygonal information only (i.e. no splines
and similar things) and supports polygons with up to 4 vertices.
Everything higher will be loaded with a warning and most likely not
displayed correctly.
The loader will read the textures' names out of the OBJ-file and will add
dummy textures with these names to the texture-manager (If the name is
already in use, no new dummy texture will be added). So one may load some
textures and add them to the manager with the appropiate names before
loading the OBJ-file or replace the ones generated by the loader after
loading is finished. If the materials used in the file are not using
textures, small, single colored textures will be generated that represent
the diffuse colors of the materials. This method is for accessing files
from an InputStream.
- Parameters:
objStream
- the InputStream of the actual OBJ-filemtlStream
- the InputStream of the material file. May be null.scale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescaling
- Returns:
- the objects/groups from the file (i.e. the complete polygonal
content)
loadJAW
public static Object3D loadJAW(java.lang.String filename,
float scale,
boolean texinfo)
- Loads a file in JAW-format into an object. JAW is a hardly used format
from the JAW-engine. The method is implemented because the JAW-format is
very simple and clean. jPCT supports an extension of the original
JAW-format that introduces texture information. This method is for usage
in applications/for accessing files on the local machine.
- Parameters:
filename
- the filenamescale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescalingtexinfo
- true, if the file contains texture information, otherwise
false
- Returns:
- the object
loadJAW
public static Object3D loadJAW(java.net.URL docBase,
java.lang.String filename,
float scale,
boolean texinfo)
- Loads a file in JAW-format into an object. JAW is a hardly used format
from the JAW-engine. The method is implemented because the JAW-format is
very simple and clean. jPCT supports an extension of the original
JAW-format that introduces texture information. This method is for usage
in applets/for accessing files via an URL.
- Parameters:
docBase
- the document basefilename
- the filenamescale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescalingtexinfo
- true, if the file contains texture information, otherwise
false
- Returns:
- the object
loadJAW
public static Object3D loadJAW(java.io.InputStream stream,
float scale,
boolean texinfo)
- Loads a file in JAW-format into an object. JAW is a hardly used format
from the JAW-engine. The method is implemented because the JAW-format is
very simple and clean. jPCT supports an extension of the original
JAW-format that introduces texture information. This method is for
accessing files from an InputStream.
- Parameters:
stream
- the InputStreamscale
- a scaling parameter to scale the object right after loading.
Should be set to 1 to avoid rescalingtexinfo
- true, if the file contains texture information, otherwise
false
- Returns:
- the object
clearCache
public static void clearCache()
- Empties the file-cache. Useful to free some memory after loading has
definitly finished.