How to get a good Flexbody

From Rigs of Rods Wiki

Jump to:navigation, search

Flexbodies - A tutorial to get good working flexbodies

This tutorial shows, how to get a good working and deforming flexbody for a truck in RoR. It's brought to you by LIFTER, its still an ALPHA-Version Tutorial, will work out the BUGS in it later and add more detailed info to the different steps later on

You need at least 3dsmax9 with oFusion plugin and tommylommykins' 3ds-exporter, working RoR 0.35 with installed flexbody patch and a text editor of your choice, blender and ac3d are not necessary but sometimes quite useful too.


TWO things before:

  • To make a good working flexbody...forget all what you have done to build meshed vehicles in RoR so far.
  • I recommend that you center the body mesh for the prop/flexbody to 0,0,0 and DON'T move it anymore later on, the only way to get the reduced deformation structure appear in exact the same spot then the flexbody

Here we go:

  1. Build a technical working chassis first. Just position your wheels and other technical stuff correctly, add suspension and other addons and get it working proper for you in RoR.
    • You DO NOT worry about shape, just make the supporting frame box smaller then the outer shape of the vehicle you build. If you lack rigidity due to size, use Set_beam_defaults Set_beam_defaults to balance it correctly.
    • You DO NOT worry about submeshing/texturing here, just a node and beam construct
    • When you are done with testing make ALL Nodes Nodes flag C
    • Add a default set_beam_defaults line after the beam section manually
    • this file is called tec-truck in this tutorial from now on
  2. Create your desired body shape as a mesh in blender, 3ds or ac3d, i do use ac3d, very easy to learn and simple to use, but quite powerful.
    • this can be done very good using 3 view blueprints or appropriate pics. The mesh should be detailed with everything you need, it represent the visual part of your truck later on.
    • its basically the same technique then building a prop
    • watch your poly count ( more then 5k starts dropping fps severe ) and the normals facing correctly outside ( same thing like submeshing, always go counterclockwise on vertex selection )
    • make your mesh ONE object ( Merge ), weld duplicate vertices and optimize vertices and surfaces
    • when you are done with the mesh, add and position your textures correctly
    • then use the oFusion export tools and export this mesh as prop, don't forget to set material file correctly.
  3. Add your mesh as a prop to your truck
    • position it correctly, size and finalize it if necessary
    • remember to add the texture file and the material file correctly to your project
  4. Make it a working flexmesh now
    • export your mesh from ac3d into a 3ds format
    • import that file into 3ds, select it and highlight all vertices ( strg-a or ctrl-A )
    • use the BREAK function once
    • use the WELD / SELECTED function with a setting of 0.01 to 0.05 once
    • add SMOOTH from the modifierlist, click autosmooth and experiment with the value ( i like 15-25, but its depending on the model you use )
    • export with ofusuion, set the objectname and mesh name correctly and only export mesh and material, no scene file needed
    • we will still use it as a prop here, so don't change the tec-truck file right now
  5. Due to the point i am using ac3d to create my meshes, the files exported from 3ds this way will always have standard material names, what may cause problems by doing more then one at a time
    • convert the *.mesh with ogre command line tools to an xml-file
    • using a simple texteditor now you replace all materialfilenames found with the ones you want to use, should include a uniqueID part, you get the standard material name to search for in the material-file exported by ofusion/3ds
    • reconvert to *.mesh with the orge commandlinetools and copy the .mesh file to your project again
  6. Place all files in your zip file
    • the prop should still work fine when you done everything correctly, so lets test it
    • problems may occur through: typo errors, doubles or not following the tutorial correctly. Solve them... :)
  7. Creating a good deformation structure
    • duplicate your ac3d mesh file now via SAVE AS
    • reduce your vertex count to aprox 30% of the original value, for a good deforming truck 30-40 should be fine, you need at least 1 vertices on each "outer edge" of the body you created, you need to place some vertices in large flat areas to make them deform better, place all and add surfaces correctly, these will be needed for crash-contact areas later on, remove obsolete ones
    • export this file in 3ds format again
    • Import this file in 3ds
    • use edged-mode and select all ( strg-a or ctrl-a )
    • create shape from edges
    • rename that new object to "beam_1" ( this is vital to be typed correct without the "" )
    • for just a beam/node export use tommylommykins 3ds-exporter with maxscript/runscript, Name beam_1, linear and uncheck the box
  8. if you want submeshed contacter areas, follow these additional steps:
    • select your old pbject ( not the beam_1 )
    • change its name to "submesh_1" ( correct typo is vital again )
    • select all and unwrap UVW Modifiers, then right click this modifier and choose "Collapse ALL"
    • for a beam/node/submesh export use tommylommykins 3ds-exporter with maxscript/runscript, Name beam_1, linear and uncheck the box

You should now have created a truckfile, showing the exact copy of the reduced mesh and working in RoR ( maybe you got to remove a BEAMS tag a line before the end of the file to get it working.. still a minor bug in the 3ds-script right now )

Calling this file DEF-Truck file from now on

Check out the file in RoR, don't enter the vehicle though... it will collapse if you do so. Everything fine and in place except the ugly textured meshes ? ok--lets continue.

  1. Now we make the meshes in the deformation structure invisible and working as contacters
    • add a new material and a pic with a transparent layer to your project
    • if done correctly in the project pack and the DEF-truck file, the deforming structure should have invisible meshes now, check that now
    • add a C-flag to all cab triangles manually in the DEF-truck file
    • add a list of contacter nodes representing all nodes of the deformation mesh
    • Add default Setbeamdefaults before and after the beam-section of the deformationstructure
  2. Merging the files
    • do it manually or use a renumber tool to renumber ALL node/beam/contacterand submesh numbers in the deformation structure, you add the amount of nodes of the TEC-truck built in PART 1 so you can merge TEC and DEF exactly later on
    • copy the node part ( only the node lines ), the beam part ( including the setbeamdefault lines ) and the complete submesh part from DEF-truck to the TEC-truck file
    • watch exactly not to have duplicate node numbers, beam tags and setbeamdefault lines, remove obsolete ones, its vital that both files merge exactly together
    • set the globals in the TEC-truck to the transparent material you made for the submeshes in the DEF-truck
    • check the position of the deformationbody precisely, if not correct move the deformation structure in the DEF-truck file and then replace the deformationstructure node section then in the TEC-truck file
    • manually add supporting beams to the merged truck from your rigid chassisbox to the deformation body, place this beams within an extra default setbeamdefaults before and after this in the beams section.
    • do this until the deformation body does NOT collapse,wobble or twist around anymore, like a real body work connected to a supportframe
    • for testing issues uncomment the body prop with a ";", you should see a simple deformation structure with invisible submeshes now aligining to the truck
  3. Tuning your deformation structure
    • Use the setbemadefaults settings to get the structure deforming the way you want. Low values in spring, high values in damping and break, and extreme low values in perm-deformation help a lot to get a nice working structure
    • This is the fun part..crash your vehicle over and over again in different angles and with other trucks to get it working
    • sometimes you got to add selective setbeamdefauls values to some parts of the structure like hood/doors to get certain effects
    • When you are fine with the deformation, check out the nodes set to c in the truck file ( we did that in the tec-truck, so they should be still there in the merged file ),
    • Do you want any of them get harmed by crashes too ? Delete the C-flag and add the node number to the contacter list if needed, but watch it..contacters have a very high cpu-utilisation


Are you fine with your node and beam structure crashing abilities ? Anything set ? So now we make it flex :)


  1. Props to flexbody
    • just MOVE the bodymesh line from PROPS in your truckfile into the FLEXBODIES section, remove the ";" if its still there and Add ALL renumbered node numbers of the DEF-Truck to the forset line.

That's it, you (hopefully) made your first cool working flexbody ..have fun in crashing it  :D