• Bookmark hashtag #RDLMS on Twitter, Facebook and Instagram
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DOF Importer for 3dsmax

Discussion in 'Racer Physics and Technical' started by Juliusz, Jun 20, 2013.

  1. Hi everyone!

    I have been asked some time ago by one of the polish Racer fan to write a DOF importer for 3dsmax. I have just finished it recently. I thought that others may find it useful as well, so I just decided to share it with the Racer community:
    Below is the link:

    It's a scripted Utility - simple to use - can import either single files or entire folders - cars or tracks. It also loads textures - it can read them either from the DOF file or from the SHD file. (Note - the shaders are not completely recreated - just main textures to give overall idea of the object appearance).

    All the detailed info is in the ReadMe file in the archive, so I'm not going to elaborate too much now.

    The purpose of this tool is mainly educational, but it allows to create variations and improvements of existing models. However I would strongly suggest that you get permission from the author of the original track/car if you want to use some parts of it.

    Hope you find it useful, at least as much as I found it interesting to work on. That was also my first chance to hear about Racer game (and try it, of course :thumbsup: ).
    Any questions or issues - you can post here or contact me directly - details in the Readme file.


    P.S. below is a screengrab of how the Carlswood track looks like in 3dsmax:
    • Like Like x 3
  2. Very nice work Juliusz, I like the way you have made it in Maxscript too.

    I want to make a maxscript that works backwards to this which puts a whole track to DOF, special.ini, shader files, geometry.ini etc etc... your maxscript might give me a few ideas!

    There are a few old tracks I really like that this might be very useful for... not so much editing but just updating the shaders and things to get them looking great with the latest features :D


  3. Thanks Dave,
    Yes, Maxscript is perfect for these sort of things. And not too slow. I have seen some Exporter written as a plugin (in C++ presumably), but it seems to be very slow for some reason, especially with some higher poly meshes. Also I didn't see it exporting vertex colours, even though it said it did - but maybe something just didn't work for me. Anyway - having a solid and faster exporter would be definitely useful.

    Not sure if you had a look, but most of my script is really dealing with shaders. Loading geometry is relatively simple, but getting all materials correct was a bit complex thing. Especially dealing with multimaterials and making sure that identical shaders are instanced etc... And then reading SHD files was a big thing on its own.
    Exporting stuff however will be easier in many ways, but may open another can of worms. I don't know what's your experience, but if you have some questions regarding scripting or the DOF file itself I'll be happy to answer any questions.

  4. Hi Juliusz,

    Thanks for the feedback on what you did.

    Yeah you must have done a lot of work to read in the shader details. Very good work on checking for instances too! That should mean a very tidy and nice to work with project in Max.

    Yes the Some1 tool isn't perfect but it works ok and since we have so few tools like this it's invaluable to me.

    If you have seen the CTR (content tool Racer) then that is very very fast exporter, but it does a lot of splitting and renaming of objects when sometimes you don't want that behaviour.

    Again it's not perfect but it works ok in some cases.

    Ideally the maxscript I make will be a raw exporter that is then sent jobs to do, then that is where the user will have lots of options (kinda scripts that prep items before export)

    So if you want to export with a scale factor * 0.01, you can, or * 1000, you can.
    Export all the selection as one dof with a given file name, sure.
    Export all the selected objects to dof of the same object names, sure.
    Export all the selected objects with split materials, sure.
    Export all the selected objects with split materials and then atlas textures and re-merged shared shaders, sure.

    But first job is to just make the exporter which will export a single triangle with UV coords haha... it looks quite simple and I've done something similar before to ascii format, but dof is binary format so I need to do a lot of testing to understand that side of things.

    That is exactly where you maxscript might be very handy as reference!

    Another thing I'd love to do is write a maxscript material interface that will run some kind of overlay to allow you to build some basic shader logic in Max and have it export to the shader files...
    Tied in with a good viewport shader it might even be possible to get semi-accurate viewport rendering that looks a bit like it does in Racer.

    Again that is all new to me so would mean a lot of reading but I'm sure it can't be so bad once you get going.

  5. The exporter is slow, because the algorithm sucks :) But on the ther hand, it is not that trivial to just export a model to DOF, since one has to deal with multi-sub materials, smoothing groups etc. The only good thing about my exporter is that it also can do mesh optimization (and that code is straight from Racer exe).
  6. What exactly is the mesh optimisation Some1?

    I agree it's not easy to deal with multi-materials etc, I'm gonna have some headaches but it makes sense to get an exporter into a format that anyone can pick up/update/use/improve upon, and Maxscript makes a lot of sense.

    That way anyone with Max can have a go at improving it, or updating it etc, rather than it being a compiled plugin.
    Also having one source to maintain/update/host vs tens of versions, and that list growing every day, makes life easier for the person who writes it :D

    My only two problems with your tool have turned out to be the smooth groups one and an option for scaling outputs because I like to work in cm for cars.

    But personally I don't think you should feel the need to add these features because it's not your job and you don't get paid and it's hard work to maintain all the plugins.

    This is why I want to do a maxscript and we can try get people collaborating and taking more community responsibility because expecting one guy to do it all is too much and you've done a great job already :D

  7. Same thing in the Racer's Modeler or what's it called. Removes unecessary verts and stuff...

    Yeah, I'm all for a MAXScript exporter that would do everything my exporter does and also the things you pointed out! :)
    • Agree Agree x 1
  8. Mr Whippy - before I write any importer/exporter for a binary file, I try to understand files structure by writing a template in 010 Editor. 010 Editor is a hex editor, which let's you, among others, write so called templates - these are sort of scripts, which map values from the files directly to the variables, allowing you to read all the values in a structured way. Great way to understand binary files and to cross check the values in the file when the reading or writing from the file does not work as expected.
    I have made a template for a DOF file - let me know if you're interested. 010 Editor is available for an evaluation period, so you might play with it.

    And one more thing - most of DOF files I have dealt with have more material definitions than are used by the geometry in the file. A good example is Early Fall in Norway track - combined, all the DOF files have around 38 000 material definitions - mostly repetitions. But in order to make sure, that materials with the same names are instanced - not duplicated, I had to loop through them number of times, significantly slowing down the loading process.
    So, if you write an Exporter, my suggestion would be to limit material definitions to a minimum. No need to include all the materals from the Max scene in every DOF file.

    And yeah - the submaterials do complicate life. As DOF consists of a number of objects which are usually split by material anyway, there's no need to have them.