3
\$\begingroup\$

I have a question regarding model imports using ASSIMP. I've been working on an Entity and Component (e.g. unity gameobject component) based game engine for fun and to learn in my spare time. I've decided to tackle frustum culling, because it interests me and seems like a relatively simple optimisation to make. I had the algorithm implemented and noticed a problem, while the culling works as expected, the entire sponza scene i have loaded disappears when looking in certain orientations. This happens because it uses the entity the mesh is attached to's position, which in all cases is (0,0,0) or something similar.

This means, despite the fact each mesh of the sponza scene is drawn using it's own model matrix and each entity has the same position (Meaning each mesh should be overlapping surely?) the scene looks entirely normal. Now i know ASSIMP does provide you the transformation for each note (guessing this would be what im looking for) but I can't figure out why the scene just looks normal, does assimp pre-offset the vertices based on the node transform? if so how can i disable this feature?

Any and all literature / tidbits would be welcome, Apologies for not being a super well defined question.

TLDR; How do node transformations work in Assimp

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

I don't understood everything, but the anwser to this question :

does assimp pre-offset the vertices based on the node transform ?

is yes, or at least, I came across the same observation.

You extracted the vertices data from your_scene->mMeshes[]->mVertices[], right ?

EDIT

What you could do is getting the transformation matrices for all your meshes by reading the node hierarchy starting with your_scene->mMeshes->mRootNode and stacking the transforms. Once you have them, pre-transform the meshes by their inverse offset transform. That way you will have all your meshes overlapping at (0,0,0)

\$\endgroup\$
4
  • \$\begingroup\$ Thats a great clarification. Yes I did, is there a way to avoid this offset? \$\endgroup\$
    – tadge
    Commented Aug 25, 2019 at 22:04
  • \$\begingroup\$ What you could do is getting the transformation matrices for all your meshes by reading the node hierarchy starting with your_scene->mMeshes->mRootNode and stacking the transforms. Once you have them, pre-transform the meshes by their inverse offset transform. That way you will have all your meshes overlapping at (0,0,0). \$\endgroup\$
    – Kiord
    Commented Aug 25, 2019 at 22:13
  • \$\begingroup\$ I am adding this as an edit to your response because this is exactly what I was looking for. Thank you so much :) \$\endgroup\$
    – tadge
    Commented Aug 25, 2019 at 22:16
  • \$\begingroup\$ See those links : learnopengl.com/Model-Loading/Assimp / ogldev.atspace.co.uk/www/tutorial38/tutorial38.html to know more about how Assimp organizes its data. \$\endgroup\$
    – Kiord
    Commented Aug 25, 2019 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .