Quantcast
Channel: With a Glass of Wine
Viewing all articles
Browse latest Browse all 30

[Research] Load OBJ Models in ARToolKit

$
0
0

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



Viewing all articles
Browse latest Browse all 30

Trending Articles