Java Doc for ObjectFile.java in  » 6.0-JDK-Modules » java-3d » com » sun » j3d » loaders » objectfile » 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 » com.sun.j3d.loaders.objectfile 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.j3d.loaders.objectfile.ObjectFile

All known Subclasses:   org.jdesktop.j3d.examples.geometry_compression.ObjectFileCompressor,
ObjectFile
public class ObjectFile implements Loader(Code)
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

A single vertex's geometric position in space. The first vertex listed in the file has index 1, and subsequent vertices are numbered sequentially.

vn float float float

A normal. The first normal in the file is index 1, and subsequent normals are numbered sequentially.

vt float float

A texture coordinate. The first texture coordinate in the file is index 1, and subsequent normals are numbered sequentially.

f int int int . . .

or

f int/int int/int int/int . . .

or

f int/int/int int/int/int int/int/int . . .

A polygonal face. The numbers are indexes into the arrays of vertex positions, texture coordinates, and normals respectively. There is no maximum number of vertices that a single polygon may contain. The .obj file specification says that each face must be flat and convex, but if the TRIANGULATE flag is sent to the ObjectFile constructor, each face will be triangulated by the Java 3D Triangulator, and therefore may be concave. A number may be omitted if, for example, texture coordinates are not being defined in the model. Numbers are normally positive indexes, but may also be negative. An index of -1 means the last member added to the respective array, -2 is the one before that, and so on.

g name

Faces defined after this token will be added to the named group. These geometry groups are returned as separated Shape3D objects attached to the parent SceneGroup. Each named Shape3D will also be in the Hashtable returned by Scene.getNamedObjects(). It is legal to add faces to a group, switch to another group, and then add more faces to the original group by reissuing the same name with the g token. If faces are added to the model before the g token is seen, the faces are put into the default group called "default."

s int

or

s off

If the vn token is not used in the file to specify vertex normals for the model, this token may be used to put faces into groups for normal calculation ("smoothing groups") in the same manner as the 'g' token is used to group faces geometrically. Faces in the same smoothing group will have their normals calculated as if they are part of the same smooth surface. To do this, we use the Java 3D NormalGenerator utility with the creaseAngle parameter set to PI (180 degrees - smooth shading, no creases) or to whatever the user has set the creaseAngle. Faces in group 0 or 'off' use a creaseAngle of zero, meaning there is no smoothing (the normal of the face is used at all vertices giving the surface a faceted look; there will be a crease, or "Hard Edge," between each face in group zero). There is also an implied hard edge between each smoothing group, where they meet each other.

If neither the vn nor the s token is used in the file, then normals are calculated using the creaseAngle set in the contructor. Normals are calculated on each geometry group separately, meaning there will be a hard edge between each geometry group.

usemtl name

The current (and subsequent) geometry groups (specified with the 'g' token) have applied to them the named material property. The following set of material properties are available by default:

 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

Load material properties from the named file. Materials with the same name as the predefined materials above will override the default value. Any directory path information in (filename) is ignored. The .mtl files are assumed to be in the same directory as the .obj file. If they are in a different directory, use Loader.setBasePath() (or Loader.setBaseUrl() ). The format of the material properties files are as follows:

newmtl name

Start the definition of a new named material property.

Ka float float float

Ambient color.

Kd float float float

Diffuse color.

Ks float float float

Specular color.

illum (0, 1, or 2)

0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting.

Ns float

Shininess (clamped to 1.0 - 128.0).

map_Kd filename

Texture map. Supports .rgb, .rgba, .int, .inta, .sgi, and .bw files in addition to those supported by TextureLoader.



Field Summary
final public static  intRESIZE
     Flag sent to constructor.
final public static  intREVERSE
     Flag sent to constructor.
final public static  intSTRIPIFY
     Flag sent to contructor.
final public static  intTRIANGULATE
     Flag sent to constructor.

Constructor Summary
public  ObjectFile(int flags, float radians)
     Constructor.
Parameters:
  flags - The constants from above or fromcom.sun.j3d.loaders.Loader, possibly "or'ed" (|) together.
Parameters:
  radians - Ignored if the vn token is present in the model (usernormals supplied).
public  ObjectFile(int flags)
     Constructor.
public  ObjectFile()
     Default constructor.

Method Summary
public  StringgetBasePath()
     Return the path where files associated with this .obj file (like material files) are located.
public  URLgetBaseUrl()
     Return the URL where files associated with this .obj file (like material properties files) will be found.
public  intgetFlags()
     Get the parameters currently defined for loading the model. Flags defined in Loader.java are ignored by the ObjectFile Loader because the .obj file format doesn't include lights, fog, background, behaviors, views, or sounds.
public  Sceneload(String filename)
     The Object File is loaded from the .obj file specified by the filename. To attach the model to your scene, call getSceneGroup() on the Scene object passed back, and attach the returned BranchGroup to your scene graph.
public  Sceneload(URL url)
     The object file is loaded off of the web. To attach the model to your scene, call getSceneGroup() on the Scene object passed back, and attach the returned BranchGroup to your scene graph.
public  Sceneload(Reader reader)
     The Object File is loaded from the already opened file. To attach the model to your scene, call getSceneGroup() on the Scene object passed back, and attach the returned BranchGroup to your scene graph.
 voidloadMaterialFile(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.
 voidreadFace(ObjectFileParser st)
     readFace Adds the indices of the current face to the arrays. ViewPoint files can have up to three arrays: Vertex Positions, Texture Coordinates, and Vertex Normals.
 voidreadFile(ObjectFileParser st)
     readFile Read the model data from the file.
 voidreadMaterialName(ObjectFileParser st)
    
 voidreadNormal(ObjectFileParser st)
    
 voidreadPartName(ObjectFileParser st)
    
 voidreadSmoothingGroup(ObjectFileParser st)
    
 voidreadTexture(ObjectFileParser st)
    
 voidreadVertex(ObjectFileParser st)
    
public  voidsetBasePath(String pathName)
     Set the path where files associated with this .obj file are located.
public  voidsetBaseUrl(URL url)
     For an .obj file loaded from a URL, set the URL where associated files (like material properties files) will be found.
public  voidsetFlags(int flags)
     Set parameters for loading the model. Flags defined in Loader.java are ignored by the ObjectFile Loader because the .obj file format doesn't include lights, fog, background, behaviors, views, or sounds.

Field Detail
RESIZE
final public static int RESIZE(Code)
Flag sent to constructor. The object's vertices will be changed so that the object is centered at (0,0,0) and the coordinate positions are all in the range of (-1,-1,-1) to (1,1,1).



REVERSE
final public static int REVERSE(Code)
Flag sent to constructor. Use if the vertices in your .obj file were specified with clockwise winding (Java 3D wants counter-clockwise) so you see the back of the polygons and not the front. Calls GeometryInfo.reverse().



STRIPIFY
final public static int STRIPIFY(Code)
Flag sent to contructor. After normals are generated the data will be analyzed to find triangle strips. Use this if your hardware supports accelerated rendering of strips.



TRIANGULATE
final public static int TRIANGULATE(Code)
Flag sent to constructor. The Shape3D object will be created by using the GeometryInfo POLYGON_ARRAY primitive, causing them to be Triangulated by GeometryInfo. Use this if you suspect concave or other non-behaving polygons in your model.




Constructor Detail
ObjectFile
public ObjectFile(int flags, float radians)(Code)
Constructor.
Parameters:
  flags - The constants from above or fromcom.sun.j3d.loaders.Loader, possibly "or'ed" (|) together.
Parameters:
  radians - Ignored if the vn token is present in the model (usernormals supplied). Otherwise, crease angle to use within smoothinggroups, or within geometry groups if the s token isn't present either.



ObjectFile
public ObjectFile(int flags)(Code)
Constructor. Crease Angle set to default of 44 degrees (see NormalGenerator utility for details).
Parameters:
  flags - The constants from above or fromcom.sun.j3d.loaders.Loader, possibly "or'ed" (|) together.



ObjectFile
public ObjectFile()(Code)
Default constructor. Crease Angle set to default of 44 degrees (see NormalGenerator utility for details). Flags set to zero (0).




Method Detail
getBasePath
public String getBasePath()(Code)
Return the path where files associated with this .obj file (like material files) are located.



getBaseUrl
public URL getBaseUrl()(Code)
Return the URL where files associated with this .obj file (like material properties files) will be found.



getFlags
public int getFlags()(Code)
Get the parameters currently defined for loading the model. Flags defined in Loader.java are ignored by the ObjectFile Loader because the .obj file format doesn't include lights, fog, background, behaviors, views, or sounds. However, several flags are defined specifically for use with the ObjectFile Loader (see above).



load
public Scene load(String filename) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException(Code)
The Object File is loaded from the .obj file specified by the filename. To attach the model to your scene, call getSceneGroup() on the Scene object passed back, and attach the returned BranchGroup to your scene graph. For an example, see j3d-examples/ObjLoad/ObjLoad.java.



load
public Scene load(URL url) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException(Code)
The object file is loaded off of the web. To attach the model to your scene, call getSceneGroup() on the Scene object passed back, and attach the returned BranchGroup to your scene graph. For an example, see j3d-examples/ObjLoad/ObjLoad.java.



load
public Scene load(Reader reader) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException(Code)
The Object File is loaded from the already opened file. To attach the model to your scene, call getSceneGroup() on the Scene object passed back, and attach the returned BranchGroup to your scene graph. For an example, see j3d-examples/ObjLoad/ObjLoad.java.



loadMaterialFile
void loadMaterialFile(ObjectFileParser st) throws ParsingErrorException(Code)
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. This should be the filename without any directory info.



readFace
void readFace(ObjectFileParser st) throws ParsingErrorException(Code)
readFace Adds the indices of the current face to the arrays. ViewPoint files can have up to three arrays: Vertex Positions, Texture Coordinates, and Vertex Normals. Each vertex can contain indices into all three arrays.



readFile
void readFile(ObjectFileParser st) throws ParsingErrorException(Code)
readFile Read the model data from the file.



readMaterialName
void readMaterialName(ObjectFileParser st) throws ParsingErrorException(Code)
readMaterialName



readNormal
void readNormal(ObjectFileParser st) throws ParsingErrorException(Code)
readNormal



readPartName
void readPartName(ObjectFileParser st)(Code)
readPartName



readSmoothingGroup
void readSmoothingGroup(ObjectFileParser st) throws ParsingErrorException(Code)
readSmoothingGroup



readTexture
void readTexture(ObjectFileParser st) throws ParsingErrorException(Code)
readTexture



readVertex
void readVertex(ObjectFileParser st) throws ParsingErrorException(Code)



setBasePath
public void setBasePath(String pathName)(Code)
Set the path where files associated with this .obj file are located. Only needs to be called to set it to a different directory from that containing the .obj file.



setBaseUrl
public void setBaseUrl(URL url)(Code)
For an .obj file loaded from a URL, set the URL where associated files (like material properties files) will be found. Only needs to be called to set it to a different URL from that containing the .obj file.



setFlags
public void setFlags(int flags)(Code)
Set parameters for loading the model. Flags defined in Loader.java are ignored by the ObjectFile Loader because the .obj file format doesn't include lights, fog, background, behaviors, views, or sounds. However, several flags are defined specifically for use with the ObjectFile Loader (see above).



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.