[Tutorial] - Creating your own vehicle

Discussion in 'Content Creation' started by Nadeox1, Aug 13, 2013.

  1. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    THIS TUTORIAL COVERS ONLY THE BASIC OF JBEAMING. IF YOU PLAN BUILDING SOMETHING COMPLEX LIKE A PROPER VEHICLE, HAVE A LOOK AT HOW DEFAULT VEHICLES ARE DONE, AND TAKE THE CUE FROM THAT.


    This is just an "How to start", I'm not showing all the features of Jbeam (like Hydros for steering and wheels). Always check the wiki and use it as main reference!
    Click on the picture to enlarge them.


    INDEX
    Part 1 - Getting Ready
    1. Creating JBeam
    2. Jbeam Sample
    3. Creating Folder

    Part 2 - Creating your first structure
    1. Nodes
    2. Beams
    3. Checking changes real-time Ingame

    Part 3 - Model exporting and In-Game
    1. Exporting
    2. Collada (.dae) name
    3. Flexbody section
    4. Reloading vehicle & Final result



    Things you need to know:
    -Jbeam (and how to work with Node and Beams) - JBeam
    -3D Modelling- You need to get your model ingame, no?
    -A LOT of patience (Building a car for BeamNG isn't a thing you learn in 1 day)

    You need:
    -Your 3D model (don't use other people model, it's against rules and you can get yourself banned from here)
    -A text editor (I suggest Notepad++, it's free - http://notepad-plus-plus.org/)

    Keep in mind:
    -The Jbeam file MUST end with
    Code:
    }
    }
    
    -After each section, use
    Code:
    ],


    Part 1 - Getting Ready
    1. First of all you need to create a Jbeam file. Simple create a text file, and rename the extension to .Jbeam.
    414rF.jpg

    2. Now open your Jbeam file with a text editor and copy this sample into it
    Code:
    {"YourCarName": {
        "information":{
            "authors":"YourName",
            "name":"Your Car Name",
        }
        "refNodes":[
            ["ref:", "back:", "left:", "up:"]
            ["0", "1", "2", "3"]
            ],
        
    --add stuff here--
    
    
    }
    }
    
    
    Keep in mind the refNodes, it's for the camera.
    Ref is the node the camera rotates around.
    Back/left/up give the car the correct orientation.

    3.
    Now make a folder inside "BeamNG/Vehicles" and name it like you want (I suggest a short easy name).
    414Br.png



    Part 2 - Creating your first structure

    =====1. NODES
    =====
    You now have to create your Jbeam structure. How much it will take depends on how complex you make it.
    Startup BeamNG, and open a map (I suggest PureGrid).
    I would build a cube to start the car.
    The first thing we do is creating the nodes (Nodes). You can copy my sample and replace it with the "--add stuff here--"
    Code:
        "nodes": [         ["id", "posX", "posY", "posZ"],
             {"nodeWeight":70},
             {"group":"MyCar"},
             {"frictionCoef":0.7},
             {"nodeMaterial":"|NM_METAL"},
             {"collision":true}
             {"selfCollision":false}
    
    
    ],
    
    -Node Weight defines how heavy is a node
    -Group is needed for flexbody (it will require for which group the mesh will deform)
    -Friction of the node
    -Material of the node (for particles?)
    -If it's collideable with the environment
    -I'm not sure what selfcollision is for.


    A cube is made out of 8 vertices, so we make 8 nodes.
    You can call nodes whatever you want (Potato, cheescake- 1kx,2kx- or simply 1,2)
    Code:
        "nodes": [         ["id", "posX", "posY", "posZ"],
             {"nodeWeight":70},
             {"group":"MyCar"},
             {"frictionCoef":0.7},
             {"nodeMaterial":"|NM_METAL"},
             {"collision":true}
             {"selfCollision":false}
             ["1a", 1, 1, 0],
             ["1b", 0, 1, 0],
             ["1c", 1, 0, 0],
             ["1d", 0, 0, 0],
             ["1e", 1, 1, 1],
             ["1f", 0, 1, 1],
             ["2a", 1, 0, 1],
             ["2b", 0, 0, 1],
        ],
    
    =====2. BEAMS=====Without beams, your nodes will not have nothing in common, they will just be individual points.
    A beam section looks like this:
    Code:
        "beams": [     ["id1:", "id2:"], 
         {"beamSpring":500000,"beamDamp":800},
         {"beamDeform":75000,"beamStrength":"50000"},
    
    The values for Spring,Damp,Deform,Strength are your choice. For example, higher the beamDeform, more force you need to deform a beam.
    We now need to create connections between our nodes.
    Code:
        "beams": [     ["id1:", "id2:"], 
         {"beamSpring":500000,"beamDamp":800},
         {"beamDeform":75000,"beamStrength":"FLT_MAX"},
         // bottom
         ["1a","1b"],
         ["1c","1d"],
         ["1a","1c"],
         ["1b","1d"],
         // top
         ["1e","2a"],
         ["1f","2b"],
         ["1e","2b"],
         ["1f","2a"],
         // support 
         ["1a","1e"],
         ["1b","1f"],
         ["1c","2a"],
         ["1d","2b"],
    
    
         
         // diagonals
         ["1a","1d"],
         ["1b","1c"],
         ["1e","1f"],
         ["2a","2b"],
         
         ["1f","1a"],
         ["1b","1e"],
         ["1e","1c"],
         ["2a","1a"],
         
         ["2b","1b"],
         ["1f","1d"],
         ["1d","2a"],
         ["1c","2b"],
        
        ],
    // Are comments. The only purpouse is to remind you something or make it easier for organizing the Section. It's not necessary. You can also disable a whole line by inserting // infront of it.


    =====3. Realtime Changes=====
    While you work on your Jbeam, you can check the changes ingame. Just load your vehicle (CTRL+E, select it from the list) and voila. You can use CTRL+R to reload the whole vehicle (usefull if you made changes, added nodes, etc.)

    DON'T FORGET TO CHANGE REF NODES! (I've talked about it in Part 1 at Point 2)

    Code:
        "refNodes":[        ["ref:", "back:", "left:", "up:"]
            ["1a", "1b", "1c", "1e"]
            ],
        
    415e0.jpg

    Then press L or K to go into debug mode till you see your structure
    417zc.jpg

    Now you need your model to start building around it. *Please turn tape*



    Part 3 - Model exporting and In-game
    1. Go into your 3D software and after you divided each part into single object (if you need separate parts), export it as COLLADA (.DAE).
    Cattura.PNG

    2. Place the .dae into your vehicle folder.
    The collada (.dae) MUST have the same name of your folder!

    3. You now need to make a flexbody section (I suggest before the node section). Sample down here.
    Code:
        ],
        "flexbodies": [
             ["mesh", "[group]:"],
         ],
    Then add your own model. Create a line and instead of "mesh" put your OBJECT NAME (not .DAE name!), and for group for the deformation (Node group, which I've talked about in Part 2 at point 1.)
    Code:
        "flexbodies": [
             ["mesh", "[group]:"],
             ["Cube_a", ["MyCar"]]
         ],
    
    4. Save the file and reload the vehicle (CTRL+R).
    4188S.jpg

    Voila! You got your very first model ingame! :D

    If you want your thing to collide with other vehicles, you have to add "TRIANGLES". You can look in the wiki for them.



    FAQ:
    Q: MY MODEL IS NOT CENTERED D:
    A:
    You need to place it right in the 3d software (remember about the origin too!)

    Q: MY WHEELS ARE NOT CENTERED ;_;
    A: Same as above, but this time you can use the Wheel node coordinates (if you made any wheel nodes..) to place them correctly

    Q: CAMERA FREEZES, NOTHING HAPPENS ?_?
    A. It's the game way to tell you made something wrong, check your JBeam twice and look for the error. Pressing @ (In EUR keyboard) will show up the console, sometimes useful as it says which line of the JBeam is the error.


    Apply the same method to build a whole car, remember to look at the wiki for reference and help!
    The guide may expand later :p

    Huge thanks to juju for his help and the file.
     
    #1 Nadeox1, Aug 13, 2013
    Last edited: Jul 15, 2015
    • Like Like x 3
  2. theWOODman

    theWOODman
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    91
    Thank you in advance for doing this. I've been searching this forum, RoR forum, wikis, google for the best way to do this. Most of the tools I've found are either buggy, outdated, or have little instruction on how to go about it. I was curious as to how you go about and I can't wait for the next chapter. It would be nice if later we had an in-game vehicle editor for creating the beam file as we do for making maps.
     
  3. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    And completed the basic.
     
  4. blinkingyellow

    blinkingyellow
    Expand Collapse

    Joined:
    Mar 9, 2013
    Messages:
    276
    You just can not imagine how amazingly you helped me. thank you for this thread.
     
  5. Deewad

    Deewad
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    240
    This is very nice, Im looking forward to the new vehicles that will be released because of this, Thanks Nadeox
     
  6. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    I missed the beam part. Will add tomorrow.
     
  7. gabester

    gabester
    Expand Collapse
    Vehicle Director
    BeamNG Team

    Joined:
    Jun 6, 2012
    Messages:
    2,653
    Don't, uh, use frictionCoef 1.8 for metal. Use like 0.7 or something.
     
  8. blinkingyellow

    blinkingyellow
    Expand Collapse

    Joined:
    Mar 9, 2013
    Messages:
    276
    Damn, i just can't make a BOX imported in game, i am very stupid for scripting 100%. i think am cancelling my car i am just out of nervers, also noone is helping me, i did not think it would be so hard.
     
  9. physicsfreak

    physicsfreak
    Expand Collapse

    Joined:
    Aug 11, 2013
    Messages:
    15
    Thanks for this was looking for this information, very useful! Will see if I can slam something together myself :cool:

    - - - Updated - - -

    I will see if I can make this tutorial work, maybe I can help a little. So far it just looks like simple JSON (or something like it) to me, must figure the structure out a little but doesn't seem to hard at first glance.
     
    #9 physicsfreak, Aug 13, 2013
    Last edited: Aug 13, 2013
  10. Mumia76

    Mumia76
    Expand Collapse

    Joined:
    Aug 9, 2012
    Messages:
    77
    Sorry, but this seems way to vague for me to even start thinking about doing anything.

    What are those and why? And what do you mean by change?

    Wait, slow down, what node group? You entered solidcube here, but the only group I see up there is mycar, this is really confusing.
    And why did you leave the sample mesh / group line there? is it needed? Or is that an error.


    On the broader scheme of things, this game really needs some better way to do the beam/node structures, than typing it out in a text editor, if you expect modding to catch on.
     
  11. physicsfreak

    physicsfreak
    Expand Collapse

    Joined:
    Aug 11, 2013
    Messages:
    15
    Agreed could use a little more detail and explanation, first glance it looked simple but how longer I look how more questions I have
     
  12. VeyronEB

    VeyronEB
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    1,537
    This should be extremely helpful, cant thank you enough :D
     
  13. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    Added beams and an index.
    Cleared out those points :)
    And yeah, my mistake on the flexbody group, fixed :p

    If you feel I need to clear out anything else, just say :)
     
    #13 Nadeox1, Aug 13, 2013
    Last edited: Aug 13, 2013
  14. physicsfreak

    physicsfreak
    Expand Collapse

    Joined:
    Aug 11, 2013
    Messages:
    15
    Nice work keep it coming!

    I am only stuck at the moment, got the following structure from your tutorial and a little snooping around in the other cars:
    Code:
    {
        "testcar":{
            "information":{
                "authors":"physicsfreak",
                "name":"testcar"
            },
            "nodes": [
                ["id", "posX", "posY", "posZ"],
                {"nodeWeight":70},
                {"frictionCoef":1.0},
                {"nodeMaterial":"|NM_METAL"},
                {"collision":true},
                {"selfCollision":false},
                {"group":"cube_group"},
                ["1a", 1, 1, 0],
                ["1b", 0, 1, 0],
                ["1c", 1, 0, 0],
                ["1d", 0, 0, 0],
                ["1e", 1, 1, 1],
                ["1f", 0, 1, 1],
                ["2a", 1, 0, 1],
                ["2b", 0, 0, 1]
            ],
            "refNodes":[
                ["ref:", "back:", "left:", "up:"],
                ["1a", "1b", "1c", "1e"]
            ],
            "flexbodies":[
                ["mesh", "[group]:", "nonFlexMaterials"],
                 {"isCollisionMesh":false},
                ["Cube", ["cube_group"]]
            ]
        }
    }
    
    But I am getting the following error:
    lua/vehicle/material.lua:31 bad argument #1 to 'pairs' (table expected, got nil)

    So i looked at the code in material.lua:
    Code:
    for flexKey, flexbody in pairs(v.data.flexbodies) do
    So my flexbodies are somehow not available in v.data, while I got them nicely defined in my .jbeam file, what am I missing?

    (btw, got a testcar.dea with an object named Cube in it, it also shows up in the game so this seems to be ok)
     
  15. SgtSpike

    SgtSpike
    Expand Collapse

    Joined:
    Aug 14, 2013
    Messages:
    47
    I am not much into modeling (in fact, not at all into modeling), but am curious - is it easy to modify some of the existing vehicles? Not modifying the modeling, but modifying the physical makeup of them? Make them heavier, or easier to deform, etc?
     
  16. TheBestOut

    TheBestOut
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    31
    Thank you, this is beyond helpful, but i have a problem. I need some help with part 3 , specifically when you said "OBJECT NAME". You did say "not .DAE name". So which object are you pertaining to?
     
  17. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    First, I suggest to move the RefNode section before the nodes and see if that helps.
    Also, you forgot to a comma after you closed the flexbody section
     
    #17 Nadeox1, Aug 14, 2013
    Last edited: Aug 14, 2013
  18. TheBestOut

    TheBestOut
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    31
    Thank you for the reply!:eek:
    I can't get it to appear. My attached picture shows my current situation. The model is in .DAE and the object is called "frame", but i can not get it to appear in game.
    Any idea's?
     

    Attached Files:

    • 1.jpg
  19. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    Can you post your torqued.log please? In the same folder of the BeamNG executable.

    Have you checked if it isn't underground?
     
  20. TheBestOut

    TheBestOut
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    31
    Here you go.
    I moved the cube up and did not see anything
    I also added my .jbeam file just in case the error was caused by my possible recently developed inability to follow tutorials correctly;)
    In the torque3d.log file my car is first mentioned on the 809th line. It is called "Buggy".
    Anything you need from me, just shoot. I appreciate the help.
     

    Attached Files:

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice