Game Development Community

Torque3D's Import System

by raa brubb · in Torque 3D Professional · 05/05/2014 (2:39 pm) · 75 replies

Hey all,

I've been doing some research about OpenGL, Assimp, and other things. I would like to implement Assimp (even though that would be a while from now) into Torque3D. My only concern was how does Torque3D's import system work? Does it only support DTS and import DAEs by conversion.

I had previously brought up this idea in the forums, but I seriously think it should be implemented into Torque3D 4.0. I'm not pushing anything, but this would seriously fix the problem with importing. The only importing supported by Torque3D is DAE and FBX (using a community add-on). This could be fixed using Assimp. Not to mention Assimp has an open source viewer as well. What do you think? Could this be easily implemented or totally impossible?
#41
05/13/2014 (5:13 am)
First:
Holy crap Andrew you are awesome! I've dived into the TSShapeLoader a couple of times while working on my MeshEmitters, and man that thing scares the crap out of me! (Which is useful if I'm constipated)
Theres so many weird things going on in there, kudos on adapting so easily to that code!

Second:
@Raa if you want to learn more about the engine, then you should look at Nuny abusiness's engine analysis on youtube.

Thats the only tutorial I know on the subject except the documentation.

Remember, I try to keep this list up-to-date with just about every available T3D tutorial, if it exists then there is a great chance that it's on the list.
#42
05/13/2014 (1:17 pm)
@Andrew Mac
Very interesting, if I understand correctly that you are using a blender and your cubes are invisible when you export them to the engine, I have correctly understood this phrase?
Quote:
My 4cube.blend is still not displaying 4 cubes though. It has the right sized bounding box and node positions so I suspect its a material issue.
If yes that, maybe I can give a pinch of my humble observations, I also work a lot with Blender, and the effect that you see completely right and natural in the case if you did not create any of the material for your cubes, then he must be invisible and it's perfect!With the help of such a property I managed to make a lot of interesting effects, especially useful when the shape of a rigid body object in the engine, must be different from visible form. For this, I created in Blender are two forms in the same space, one is invisible (without materials)of this form, I would like a rigid body, and the second, is more complex and decorated with textures. I should also note that this trick you can do with any form of no matter there is animation or static object, the effect is the same work, (but rigid body after the creation of the engine will not animate their shape in the process of the engine, and the animation will be only visible body).
#43
05/13/2014 (4:14 pm)
@ Olexiy Kravchuk

4cube.blend is actually a testing file that comes with assimp. In every other viewer it shows up as 4 cubes no problem. It's a problem with my import code, not with the file itself.

@ Everyone

I've hit a bit of a snag. I'm back to trying to get the library to compile into torque and admittingly I don't entirely know what I'm doing. Here's the facts:

- Assimp project has been added to the torque solution via the project generator. I created the generation files for it from examples like libvorbis, tinyxml, etc. It generates the project fine and it's included in the solution. So, the project in question has not been manually configured by me, it's been spit out by project generator.

- When I compile the whole project assimp.lib is produced out in libs/compiled along with all the other ones (tinyxml.lib, libvorbis.lib, etc)

- I checked off the assimp project as a dependency of the torque dll.

Clearly there is a missing piece here because I still get unresolved external symbols for all the assimp functions referenced in the engine. I can get around this and get it working by adding "assimp.lib" to the linker and adding libs/compiled to the library search directories. The problem with that is no other lib in torque seems to do this.

So, what am I missing?
#44
05/13/2014 (4:52 pm)
Add to beginModule( 'assimp' ):
if( inProjectConfig() )
{
   addProjectDependency( 'assimp' );
   addSolutionProjectRef( 'assimp' );
}

Maybe better than the module and the library, not have the same names.
#45
05/13/2014 (5:19 pm)
Bit of a long shot, I have encountered this if code generation -> runtime library was not the same across projects...
#46
05/13/2014 (11:58 pm)
You nailed it Luis. I got it working. I've pushed the latest to my github:

github.com/andr3wmac/Torque3D/tree/assimp

It generates the solution including assimp and compiles and loads fine. I also added changes to the world editor so it will show all the different formats under the Meshes tab. I handled it with a bit of a band-aid solution for now:

$Tools::FormatExtensions = "*.dts" TAB "*.dae" TAB "*.kmz" TAB "*.dif"
      TAB "*.blend" TAB "*.3ds" TAB "*.ase" TAB "*.obj" TAB "*.fbx"
      TAB "*.ifc" TAB "*.xgl" TAB "*.zgl" TAB "*.ply"
      TAB "*.dxf" TAB "*.lwo" TAB "*.lws" TAB "*.lxo"
      TAB "*.stl" TAB "*.x" TAB "*.ac" TAB "*.ms3d" 
      TAB "*.cob" TAB "*.xml" TAB "*.irrmesh" TAB "*.irr" 
      TAB "*.mdl" TAB "*.md2" TAB "*.md3" TAB "*.pk3"
      TAB "*.mdc" TAB "*.md5" TAB "*.smd" TAB "*.vta"
      TAB "*.m3" TAB "*.3d" TAB "*.b3d" TAB "*.q3d"
      TAB "*.q3s" TAB "*.nff" TAB "*.off" TAB "*.raw"
      TAB "*.ter" TAB "*.mdl" TAB "*.hmp" TAB "*.ndo";

I'm thinking instead there should be a list of supported formats somewhere inside the engine so that the collada module can add .dae and the assimp module can add all the rest. Removing either module will make the editors no longer look for those file types. Removing both will leave it only supporting dts.

Anyway, test it out. Let me know what issues you run into.

A note on testing models: assimp has a viewer application that you can test models in. If it won't show up in there it's not going to import into torque. Here is a compiled version of the viewer built off the latest assimp from github (with FBX support):

bloodandmana.com/assimp_view.zip
#47
05/14/2014 (4:29 pm)
I had a question about the animations, does Assimp allow animation importing through DAE, FBX, etc? In other words, could you import a model that has an animation successfully?
#48
05/14/2014 (9:35 pm)
Nice work. We had planned to implement Assimp but unfortunately never had the time or any interest from the community -- glad to see that's changing.
#49
05/14/2014 (10:02 pm)
Fantastic work Luis and Andrew. I'm going to fold this in and play around with it when I can. I'm pretty sure Luis gave me that exact same piece of advice when I was trying to get Walkabout working with the project manager. Should have remembered.

raa: assimp does support animations but Andrew hasn't gotten that far yet.
#50
05/15/2014 (11:43 am)
Just updated the repo. It's ready for testing. What I've added:

- Created a supported formats system so if assimp is excluded from the engine its formats disappear from the loading dialog/library browsing.
- Fixed model orientation ( Z is up now )
- Support for vertex colors
- Automatic materials.cs generation and a material bug fix
- cached.dts automatic save/load.

So, that's about it for static shapes I think. There's a few more improvements I can make on material generation, like material colors, but nothing super critical. You can go into the world editor, open meshes tab, add any one of the supported formats (I've tried .x, .blend, and .fbx) and next time you load up the map it doesn't use assimp at all. It just loads the dts file like usual.

If we can get some testing done on this I could clean it up a bit and try to get the PRs up for 3.6 before Monday. The actual engine changes are very minimal. Mainly just adding support for finding more than .dae and .dts files. The bulk of the work is done in the new assimp files so it should be an easy merge. Also, unless you try to load a format other than dae or dts, assimp is not used at all, so it won't break any existing functionality.
#51
05/15/2014 (3:34 pm)
Great work.

When the work is ready and sufficiently tested, would have to think to deprecate the collada loader?
#52
05/15/2014 (7:36 pm)
Can this be used in the world editor yet, or just in datablocks?

EDIT: Maybe silly question :P. Ah well. Damn, tried to load some FBX I downloaded and it didn't work. I haven't tried it in the Assimp viewer but I assume it will fail.

EDIT: Yep, turns out Assimp doesn't support that version of the FBX format. I did get console errors but it'd be nice to have a dialog warning or something. Not sure where scripts would handle that is all.
#53
05/15/2014 (8:35 pm)
It's been quite different for me. I loaded in numerous FBX and OBJ files successfully and it worked great! :)

@Daniel, You can import it into Blender or 3DS Max and export it to an older version of FBX, It should make exporting errors.
#54
05/15/2014 (11:06 pm)
Another update:
- More automatic material settings
- uv2 support
- Now handles missing node names, which fixes .ply loading
- More detailed error message when model fails to load

I've been tweaking the assimp post processing settings to try and find the best results and I think I may end up creating an import dialog in the shape editor similar to the collada one and let people check off what they want done to the model. It has a handsome list of options. Some highlights:

aiProcess_JoinIdenticalVertices    | // join identical vertices/ optimize indexing
aiProcess_ImproveCacheLocality     | // improve the cache locality of the output vertices
aiProcess_RemoveRedundantMaterials | // remove redundant materials
aiProcess_GenUVCoords              | // convert spherical, cylindrical, box and planar mapping to proper UVs
aiProcess_OptimizeMeshes		     | // join small meshes, if possible;

But not all options are suited for every situation.

@ Daniel
It seems like FBX is limited to 2011, 2012, and 2013. I don't know what version the latest blender is supposed to be exporting but I can't get it to work either. Good news is 3DS Max 2012 exports working FBX files :D
#55
05/16/2014 (1:13 pm)
I think it's because the last version of Assimp was released in 2012, and they haven't updated the FBX importer.
#56
05/19/2014 (12:43 am)
Has the committee decided whether or not to include Assimp as of now in T3D 3.6? Or will it wait before animations are added? The implementation is close to done, so what will happen?
#57
05/19/2014 (5:53 am)
Check the 3.6 issues list - assimp is in there. I realised I needed to clarify the freeze announcement - it's an issue freeze, not a PR freeze. So when it's done, it will be PRed to fix the issue.
#58
05/21/2014 (7:15 pm)
@daniel:
try
http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=22694909

(This end fbx to fbx borked, dae to fbx showed rotation mangling.) keeping a list github.com/andr3wmac/Torque3D/issues/1 by request so it doesn't get buried in-thread if folks want to verify.
#59
05/21/2014 (7:57 pm)
It's fine, I just tried pulling down a random file from some guy's website. As long as we can provide sensible errors when conversions fail, I don't really mind.
#60
05/27/2014 (11:09 am)
This project isn't finished, but I guess it will do.