Jump to content
  • Advertisement
Sign in to follow this  
jnewlin

Assimp file loader

This topic is 2179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]Hi,[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]I am using Assimp to load obj files into my program. I want to take that data and construct my own data structure. My problem is that Assimp by default loads in repeated vertices, based on however many faces point to each vertex. So for a cube, I would want Assimp to load only 8 vertices.[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]For a more explicit example, here is part of the obj file maya outputs for a simple cube:[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v -1.000000 -1.000000 1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v 1.000000 -1.000000 1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v -1.000000 1.000000 1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v 1.000000 1.000000 1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v -1.000000 1.000000 -1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v 1.000000 1.000000 -1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v -1.000000 -1.000000 -1.000000[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]v 1.000000 -1.000000 -1.000000[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]...[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]f 1 2 4 3[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]f 3 4 6 5[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]f 5 6 8 7[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]f 7 8 2 1[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]f 2 8 6 4[/background][/font]
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]f 7 1 3 5[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]I would like assimp to give me that data. Instead, it gives me indices from 1->23, and repeats the vertices to match those indices.[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]I tried using aiProcess_JoinIdenticalVertices in my call to Importer::ReadFile, but that did not have the desired effect.[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]Has anyone had a similar problem and found a fix?[/background][/font]

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]Thanks![/background][/font]

Share this post


Link to post
Share on other sites
Advertisement
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif]

[background=rgb(250, 250, 250)]Has anyone had a similar problem and found a fix?[/background][/font]

I don't recall having this problem but if normal vector generation is set, then this is correct behavior. I don't see why this should happen by default, what are your loading init?
Do everyone a favor: use 0-based indexing.

As a side note: consider Collada instead, I've found it to be fairly more reliable and flexible than OBJ.

Share this post


Link to post
Share on other sites
I don't use assimp, but my Maya exporter also creates 3 vertices per each face. I have a collapsing step in my content pipeline that simply does a brute force n squared compare of each vertex to each other vertex, and merges them into one if they are the same. For a non-runtime process, this is plenty good enough as other parts of the pipeline take orders of magnitude longer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!