Sign in to follow this  
rofseek

Translating Obj face data into useful D3D10 rendering data

Recommended Posts

Assuming the following definition of a 10cm^3 cube:
v  -1.1556 0.0000 0.6891
v  -1.1556 0.0000 -3.2479
v  2.7814 0.0000 -3.2479
v  2.7814 0.0000 0.6891
v  -1.1556 3.9370 0.6891
v  2.7814 3.9370 0.6891
v  2.7814 3.9370 -3.2479
v  -1.1556 3.9370 -3.2479
# 8 vertices

vn 0.0000 -1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 -0.0000
# 6 vertex normals

vt 1.0000 0.0000 0.0000
vt 1.0000 1.0000 0.0000
vt 0.0000 1.0000 0.0000
vt 0.0000 0.0000 0.0000
# 4 texture coords

g Box01
usemtl wire_229154215
s 2
f 1/1/1 2/2/1 3/3/1 4/4/1 
s 4
f 5/4/2 6/1/2 7/2/2 8/3/2 
s 8
f 1/4/3 4/1/3 6/2/3 5/3/3 
s 16
f 4/4/4 3/1/4 7/2/4 6/3/4 
s 32
f 3/4/5 2/1/5 8/2/5 7/3/5 
s 64
f 2/4/6 1/1/6 5/2/6 8/3/6 
# 6 polygons
How can the face data be processed/translated into useful information for rendering?

Share this post


Link to post
Share on other sites
The easy way is just use a model loader lib; there will be many of them I'd imagine, they will import and compile all the information and should be well tested.

I'd personally use assimp to import from a wide variety of formats then produce my own format with only the information I require.

But you could also just get a specific .obj loader.

Share this post


Link to post
Share on other sites
obj format for the "f" face data is defined as:

f v1[/vt1][/vn1] v2[/vt2][/vn2] v3[/vt3][/vn3] ...

So a face is a triangle, composed of three vertex position, uv texture and vertex normal. Since some of the values could be duplicate, it's indexed. DirectX offer vertexbuffer and indexbuffer just for that, look it up.

http://msdn.microsoft.com/en-us/library/bb205130%28VS.85%29.aspx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this