|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.j3d.loaders.objectfile.ObjectFile
public class ObjectFile
The ObjectFile class implements the Loader interface for the Wavefront .obj file format, a standard 3D object file format created for use with Wavefront's Advanced Visualizer (tm) and available for purchase from Viewpoint DataLabs, as well as other 3D model companies. Object Files are text based files supporting both polygonal and free-form geometry (curves and surfaces). The Java 3D .obj file loader supports a subset of the file format, but it is enough to load almost all commonly available Object Files. Free-form geometry is not supported.
The Object File tokens currently supported by this loader are:v float float float
vn float float float
vt float float
f int int int . . .
f int/int int/int int/int . . .
f int/int/int int/int/int int/int/int . . .
g name
s int
s off
usemtl name
amber amber_trans aqua aqua_filter archwhite archwhite2 bflesh black blondhair blue_pure bluegrey bluetint blugrn blutan bluteal bone bone1 bone2 brass brnhair bronze brown brownlips brownskn brzskin chappie charcoal deepgreen default dkblue dkblue_pure dkbrown dkdkgrey dkgreen dkgrey dkorange dkpurple dkred dkteal emerald fgreen flaqua flblack flblonde flblue_pure flbrown fldkblue_pure fldkdkgrey fldkgreen fldkgreen2 fldkgrey fldkolivegreen fldkpurple fldkred flesh fleshtransparent flgrey fllime flltbrown flltgrey flltolivegreen flmintgreen flmustard florange flpinegreen flpurple flred fltan flwhite flwhite1 flyellow glass glassblutint glasstransparent gold green greenskn grey hair iris jetflame lavendar lcdgreen lighttan lighttan2 lighttan3 lighttannew lightyellow lime lips ltbrown ltgrey meh metal mintgrn muscle navy_blue offwhite.cool offwhite.warm olivegreen orange pale_green pale_pink pale_yellow peach periwinkle pink pinktan plasma purple red redbrick redbrown redorange redwood rubber ruby sand_stone sapphire shadow ship2 silver skin sky_blue smoked_glass tan taupe teeth violet white yellow yellow_green yellowbrt yelloworng
mtllib filename
newmtl name
Ka float float float
Kd float float float
Ks float float float
illum (0, 1, or 2)
Ns float
map_Kd filename
Field Summary | |
---|---|
private static char |
BACKSLASH
|
private java.lang.String |
basePath
|
private java.net.URL |
baseUrl
|
private Point3f[] |
coordArray
|
private java.util.ArrayList |
coordIdxList
|
private java.util.ArrayList |
coordList
|
private java.lang.String |
curGroup
|
private java.lang.String |
curSgroup
|
private java.util.ArrayList |
curTriGroup
|
private java.util.ArrayList |
curTriSgroup
|
private static int |
DEBUG
|
private int |
flags
|
private boolean |
fromUrl
|
private java.util.HashMap |
groupMaterials
|
private java.util.HashMap |
groups
|
private ObjectFileMaterials |
materials
|
private Vector3f[] |
normArray
|
private java.util.ArrayList |
normIdxList
|
private java.util.ArrayList |
normList
|
private float |
radians
|
static int |
RESIZE
Flag sent to constructor. |
static int |
REVERSE
Flag sent to constructor. |
private java.util.HashMap |
sGroups
|
private java.util.ArrayList |
stripCounts
|
static int |
STRIPIFY
Flag sent to contructor. |
private TexCoord2f[] |
texArray
|
private java.util.ArrayList |
texIdxList
|
private java.util.ArrayList |
texList
|
private long |
time
|
static int |
TRIANGULATE
Flag sent to constructor. |
private java.util.HashMap |
triGroups
|
private java.util.HashMap |
triSgroups
|
Fields inherited from interface com.sun.j3d.loaders.Loader |
---|
LOAD_ALL, LOAD_BACKGROUND_NODES, LOAD_BEHAVIOR_NODES, LOAD_FOG_NODES, LOAD_LIGHT_NODES, LOAD_SOUND_NODES, LOAD_VIEW_GROUPS |
Constructor Summary | |
---|---|
ObjectFile()
Default constructor. |
|
ObjectFile(int flags)
Constructor. |
|
ObjectFile(int flags,
float radians)
Constructor. |
Method Summary | |
---|---|
private void |
convertToTriangles()
Each face is converted to triangles. |
java.lang.String |
getBasePath()
Return the path where files associated with this .obj file (like material files) are located. |
java.net.URL |
getBaseUrl()
Return the URL where files associated with this .obj file (like material properties files) will be found. |
int |
getFlags()
Get the parameters currently defined for loading the model. |
private Point3f[] |
getLimits()
getLimits Returns an array of Point3f which form a bounding box around the object. |
private int[] |
groupIndices(java.util.ArrayList sourceList,
java.util.ArrayList group)
Each group is a list of indices into the model's index lists, indicating the starting index of each triangle in the group. |
Scene |
load(java.io.Reader reader)
The Object File is loaded from the already opened file. |
Scene |
load(java.lang.String filename)
The Object File is loaded from the .obj file specified by the filename. |
Scene |
load(java.net.URL url)
The object file is loaded off of the web. |
(package private) void |
loadMaterialFile(ObjectFileParser st)
loadMaterialFile Both types of slashes are returned as tokens from our parser, so we go through the line token by token and keep just the last token on the line. |
private SceneBase |
makeScene()
|
private int[] |
objectToIntArray(java.util.ArrayList inList)
|
private Point3f[] |
objectToPoint3Array(java.util.ArrayList inList)
|
private TexCoord2f[] |
objectToTexCoord2Array(java.util.ArrayList inList)
|
private Vector3f[] |
objectToVectorArray(java.util.ArrayList inList)
|
(package private) void |
readFace(ObjectFileParser st)
readFace Adds the indices of the current face to the arrays. |
(package private) void |
readFile(ObjectFileParser st)
readFile Read the model data from the file. |
(package private) void |
readMaterialName(ObjectFileParser st)
readMaterialName |
(package private) void |
readNormal(ObjectFileParser st)
readNormal |
(package private) void |
readPartName(ObjectFileParser st)
readPartName |
(package private) void |
readSmoothingGroup(ObjectFileParser st)
readSmoothingGroup |
(package private) void |
readTexture(ObjectFileParser st)
readTexture |
(package private) void |
readVertex(ObjectFileParser st)
|
private void |
resize()
Center the object and make it (-1,-1,-1) to (1,1,1). |
void |
setBasePath(java.lang.String pathName)
Set the path where files associated with this .obj file are located. |
private void |
setBasePathFromFilename(java.lang.String fileName)
Takes a file name and sets the base path to the directory containing that file. |
void |
setBaseUrl(java.net.URL url)
For an .obj file loaded from a URL, set the URL where associated files (like material properties files) will be found. |
private void |
setBaseUrlFromUrl(java.net.URL url)
|
void |
setFlags(int flags)
Set parameters for loading the model. |
private void |
smoothingGroupNormals()
smoothingGroupNormals Smoothing groups are groups of faces who should be grouped together for normal calculation purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int DEBUG
public static final int RESIZE
public static final int TRIANGULATE
public static final int REVERSE
public static final int STRIPIFY
private static final char BACKSLASH
private int flags
private java.lang.String basePath
private java.net.URL baseUrl
private boolean fromUrl
private float radians
private java.util.ArrayList coordList
private java.util.ArrayList texList
private java.util.ArrayList normList
private java.util.ArrayList coordIdxList
private java.util.ArrayList texIdxList
private java.util.ArrayList normIdxList
private java.util.ArrayList stripCounts
private java.util.HashMap groups
private java.lang.String curGroup
private java.util.HashMap sGroups
private java.lang.String curSgroup
private java.util.HashMap groupMaterials
private java.util.HashMap triGroups
private java.util.ArrayList curTriGroup
private java.util.HashMap triSgroups
private java.util.ArrayList curTriSgroup
private Point3f[] coordArray
private Vector3f[] normArray
private TexCoord2f[] texArray
private long time
private ObjectFileMaterials materials
Constructor Detail |
---|
public ObjectFile(int flags, float radians)
flags
- The constants from above or from
com.sun.j3d.loaders.Loader, possibly "or'ed" (|) together.radians
- Ignored if the vn token is present in the model (user
normals supplied). Otherwise, crease angle to use within smoothing
groups, or within geometry groups if the s token isn't present either.public ObjectFile(int flags)
flags
- The constants from above or from
com.sun.j3d.loaders.Loader, possibly "or'ed" (|) together.public ObjectFile()
Method Detail |
---|
void readVertex(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void readNormal(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void readTexture(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void readFace(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void readPartName(ObjectFileParser st)
void readMaterialName(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void loadMaterialFile(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void readSmoothingGroup(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
void readFile(ObjectFileParser st) throws ParsingErrorException
ParsingErrorException
private void setBasePathFromFilename(java.lang.String fileName)
public Scene load(java.lang.String filename) throws java.io.FileNotFoundException, IncorrectFormatException, ParsingErrorException
load
in interface Loader
java.io.FileNotFoundException
IncorrectFormatException
ParsingErrorException
private void setBaseUrlFromUrl(java.net.URL url) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public Scene load(java.net.URL url) throws java.io.FileNotFoundException, IncorrectFormatException, ParsingErrorException
load
in interface Loader
java.io.FileNotFoundException
IncorrectFormatException
ParsingErrorException
private Point3f[] getLimits()
private void resize()
private int[] objectToIntArray(java.util.ArrayList inList)
private Point3f[] objectToPoint3Array(java.util.ArrayList inList)
private TexCoord2f[] objectToTexCoord2Array(java.util.ArrayList inList)
private Vector3f[] objectToVectorArray(java.util.ArrayList inList)
private int[] groupIndices(java.util.ArrayList sourceList, java.util.ArrayList group)
private void smoothingGroupNormals()
private void convertToTriangles()
private SceneBase makeScene()
public Scene load(java.io.Reader reader) throws java.io.FileNotFoundException, IncorrectFormatException, ParsingErrorException
load
in interface Loader
java.io.FileNotFoundException
IncorrectFormatException
ParsingErrorException
public void setBaseUrl(java.net.URL url)
setBaseUrl
in interface Loader
public java.net.URL getBaseUrl()
getBaseUrl
in interface Loader
public void setBasePath(java.lang.String pathName)
setBasePath
in interface Loader
public java.lang.String getBasePath()
getBasePath
in interface Loader
public void setFlags(int flags)
setFlags
in interface Loader
public int getFlags()
getFlags
in interface Loader
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |