New JOGL Chapter Online (OBJ models, picking, JOAL, fog)

Dear All,

I’ve just added a new chapter on JOGL to the Killer Game Programming in Java website at http://fivedots.coe.psu.ac.th/~ad/jg/. It’s in the JOGL section near the bottom of the page.

The chapter is called JOGL 3. Picking on the Models.

This chapter is about four things: loading and positioning Wavefront OBJ models, picking with the mouse, 3D sound using JOAL, and fog. The OBJ model loader supports shapes with multiple colors and textures.

Comments are appreciated.

  • Andrew

Looks like a nice step-by-step tutorial. The content seems technically correct to me.

Curious: why is JOAL in this topic? I know you dedicated an entire chapter to JOAL a while back (and I read it too), so I’m just wondering how JOAL fits into a topic on picking?

JOAL’s included because it’s fun to have 3D sound :), and it shows that I can reuse the code I wrote for adding 3D sound to my earlier Java 3D example.

Just a question.

Why not also explain picking in terms of moving through coordinate systems and bounding volumes?

The second JOGL chapter explains how the camera position can be checked to see if the user is near something (in the example, it’s a billboard on the floor), so it shoudn’t be too hard to generalise that to volumes.

The picking in this chapter is unique to OpenGL, and a good way of implementing user interaction with the mouse.

I´ve tried the source code.

there is a problem with the OBJ loader. the penguin example is loaded correctly, but when i take other models (not your examples) their textures are misaligned. these models only have one texture file.

but the models are definitely correct. when i use the java 3d OBJ loader every texture is aligned correctly.

zebhed,

If possible, can you send me one of your problem models, and perhaps a screenshot of how it should look. Then I’ll do some testing of the code.

Please contact me directly, at ad@fivedots.coe.psu.ac.th.

  • Andrew

sent :slight_smile:

Martin,

I tested your models using Java SE 6 and JSR-231 1.1.0 RC 2,and got the same problem. In fact, it also started happening to my penguin example as well.

The problem seems to lie in JOGL’s TextureIO class. It’s flipping the loaded image around the y-axis.

The simplest solution right now is to use a graphics program to flip the image around the y-axis, and supply that as the image used by the MTL file.

I tried this for your gorilla and house images, and the models are textured correctly.

I’ll open a new thread about this problem.

I could hack together some code for reversing the flipping,
but it seems better to fix TextureIO.

  • Andrew

I’ve recoded the loader to flip the model’s texture coordinates depending on the result of Texture.getImageTexCoords(). The examples sent to me by zebhed, and my own, now render correctly in JOGL 1.1.0 RC 2.