views:

23

answers:

2

I'm using Java3D and JOGL, but I'm having a hard time figuring out how to do this by looking at the javadocs. I want to load a .obj file (other formats would be nice, too) and render it using JOGL.

Here's a loader class. It returns a Scene from a filename. How can I use this Scene in JOGL?

Thanks. I'm new to JOGL and Java3D.

A: 

The Scene object provides no access to triangles, which is what you would need to use in JOGL. In fact Java3D and JOGL are two very different libraries, and I wonder why you are using them both together (or how). Java3D is a scene graph API while JOGL is just a wrapper to low-level OpenGL. Are you aware of these things?

In any case, you'll need to write an OBJ loader for JOGL. It's not a hard task though! Just find some OBJ specs and write a loader which parses the file line-by-line into whatever format you choose to send to JOGL.

Or, stick with one of the two libraries. I see no sense in using both. Either you want to use low-level OpenGL, or you want the convenience of high-level Java3D, right?

Ricket
I'm not sure why I'm using both either; to be honest. It's for a class assignment. I think I'm supposed to use Java3D for matrix manipulation / vector calculation, and OpenGL for rendering.
Rosarch
OpenGL or JOGL? Java3D uses OpenGL, just at a higher level. If you weren't explicitly told to use JOGL, then your teacher probably meant to make sure Java3D was set to use OpenGL instead of DirectX, since it has the capability to render using either one.
Ricket
A: 

There is a OBJ loader using JOGL here: http://github.com/sgothel/jogl-demos/blob/master/src/demos/util/ObjReader.java

gouessej