Jump to content
  • Advertisement
Sign in to follow this  
Paul C Skertich

Fix That Funny Imported FBX using ASSIMP

This topic is 1213 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

If you ever have imported FBX file with assimp - you'll notice that the model itself isn't imported correctly. If it turns out to be a spagetti mesh then the data wasn't loaded correctly. If the model's rotation was facing towards -Y axis where in 3DS Max or whatever 3D modeling tool you used is facing towards the +Z Up Axis or +Z Axis depending on modeling program again.

 

I created a very simple white wall with wood floor trim - i deleted the remaining unnecessary polygons. Upon importing the model to ASSIMP Scene you'll notice aiProcess_ declarations. The aiProcess declarations I used is as:

unsigned int processFlags =
		aiProcess_CalcTangentSpace | // calculate tangents and bitangents if possible
		aiProcess_JoinIdenticalVertices | // join identical vertices/ optimize indexing
		//aiProcess_ValidateDataStructure  | // perform a full validation of the loader's output
		aiProcess_Triangulate | // Ensure all verticies are triangulated (each 3 vertices are triangle)
		aiProcess_ConvertToLeftHanded | // convert everything to D3D left handed space (by default right-handed, for OpenGL)
		aiProcess_SortByPType | // ?
		aiProcess_ImproveCacheLocality | // improve the cache locality of the output vertices
		aiProcess_RemoveRedundantMaterials | // remove redundant materials
		aiProcess_FindDegenerates | // remove degenerated polygons from the import
		aiProcess_FindInvalidData | // detect invalid model data, such as invalid normal vectors
		aiProcess_GenUVCoords | // convert spherical, cylindrical, box and planar mapping to proper UVs
		aiProcess_TransformUVCoords | // preprocess UV transformations (scaling, translation ...)
		aiProcess_FindInstances | // search for instanced meshes and remove them by references to one master
		aiProcess_LimitBoneWeights | // limit bone weights to 4 per vertex
		aiProcess_OptimizeMeshes | // join small meshes, if possible;
		aiProcess_PreTransformVertices | //-- fixes the transformation issue.
		aiProcess_SplitByBoneCount | // split meshes with too many bones. Necessary for our (limited) hardware skinning shader
		0;

You'll notice the aiProcess_PreTransformVerticies that right there did the fix for me. Inside your modeller program if you're using Units of Feet - just know that the model will be imported large because it's using the 3D Modelling's units set up. I set my to export at 1 unit = 1 inch and unit's conversion to be inch 1.0 scale.

 

Here's a pretty snap shot taking from the app.

[attachment=28608:ScreenCaptured_nossao12079246.jpg]

 

Pretty nice wall eh? I can't model a female character worth a damn though but maybe I'll get there sooner or later. My female characters turn out to be creatures and somehow very not attractive - their faces look sinister and evil - don't know why that is. Any who - continuing on...

 

If you do get spaghetti meshes - it's mostly because of the indices. Conversion from openGL to DirectX isn't my best - so most of ASSIMP tutorials are in openGL including the skeletal animation which I still yet have to convert to DX understanding. 

 

I didn't really know where to post this half tutorial - so I posted it in coding horrors because sometimes coding can give nightmares. Oh forget the whole file format of the snap shot Screen-nossao - the file is generated with the resulting salt and a random seed of the time date kind of thing. SSAO is disabled for now until I get it working.

 

At first I cringed at using ASSIMP but it's beneficial in many ways - regardless how bulky the dll file is. If you're ASSImp (which is a funny name - I keep on thinking of the Doom's Imps.) - and run into either spaghetti meshes or the model is transforming on the not right axis - then would be a good read.

 

 

Share this post


Link to post
Share on other sites
Advertisement

Now you'll be able to see the FBX model wall. I updated the materials and how the different parts of the material are enabled. Hence this wall just has diffuse map only, pointless to render the model with heighmap, normal, specular lighting enabled too - whereas it's not.

 

[attachment=28610:ScreenCaptured_nossao16443736.jpg]

 

You can see how the brick material has height map with specular lighting and normal map - where as the wall just only has diffusemap enabled.

Share this post


Link to post
Share on other sites

also by using the

aiProcess_PreTransformVertices

declaration will strip the model from animations and skin data. The model will be  rotated in the X axis facing towards the ground - if you have that problem if it's not you then i got the problem.

Share this post


Link to post
Share on other sites

Sadly the team that developed ASSImp haven't updated within a year. So a crude adjustment when importing FBX file would just be to rotate it manually by 90 degrees on X AXIS.

 

the XMMatrixRotationAxis function takes in a XMVECTOR then the radians of angle. To get the 90 degrees just perform:

 

(angle wanted) * 3.14 / 180 = (radians).

 

My case:

 

90.0 * 3.14 / 180.0 = 1.57

 

So:

float degreeAngle = 90.0f * 3.14 / 180.0f;
XMVECTOR axisX = XMVectorSet(1,0,0,0);
XMMATRIX r = XMMatrixRotationAxis(axisX, degreeAngle);

.....

world = scale * rotation * translation;

it's a fix but until the team at Assimp fixes it then that's the fix is as for now. I would imagine the rotation of the bones has to be fixed - which I haven't got there yet.

Edited by SIC Games

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!