[Research] Load OBJ Models in ARToolKit

Last week I helped my FYP student to set up a simple project of loading 3D models of .obj format in ARToolKit. The source code is available at my git repo, here just take a note for future reference. (The cute models are drawn by Ms Ng Jie Li, credit for good goes to her while the errors and omissions are my own).

I) Working Environment and Open Sources

Two open sources are used: ARToolKit  & objViewer by dhpoware. The models are rendered in Maya, and exported as obj files, noted that we need both .obj and .mtl files to fully display the colors and materials of the models. ARToolKit libraries need to be linked.

II) The Problems and Solutions

For the simplicity, I choose to use fixed OpenGL pipeline for rendering. The objViewer provides handy Class and  Functions to load the model. The only problem is that before we scale the models using glScalef(), we need to make sure we enable GL_NORMALIZE, it is explained here. The main reason is that when we enlarge or shrink the model using glScalef() under modelview, we also change the length of the normals, which fails to sum up to 1.0. While the lighting equations assume that the normal has a length of 1.0. Therefore we need to make sure the normals are “normalized” after the scaling. The simple way to solve the problem as suggested is to call glEnable(GL_NORMALIZE).

III) Results

That’s interesting and we had quite a fun time.

arobj1

arobj2

One comment

  1. You have no idea how much I want to thank you for this. I’ve been circling around 3D importers to then use in ARToolkit but your clear and easy solution was the key! How can I credit you?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: