WIP How to Mod a Vehicle (Basics) 2021

Discussion in 'Content Creation' started by CRGZ, May 16, 2021.

  1. CRGZ

    CRGZ
    Expand Collapse

    Joined:
    Sep 12, 2020
    Messages:
    115
    How to Create a BeamNG.Drive Mod
    (I ACCIDENTALLY POSTED THIS WITHOUT FINISHING)

    Description:
    This is a tutorial on how to begin creating a mod. This will NOT include modelling or texturing tutorials.
    This will only include a how-to for info.json files and Jbeam files.

    Applications Recommended:
    - Notepad++

    Created by:
    CRGZ



    Table of contents
    Part 1: Creating an info.json file
    Part 2: Creating the "Main" Jbeam file
    Part 3: Creating the Structure Jbeam file(s)
    Part 4: Creating other Jbeam file(s)
    Part 5: Jbeam Arguments




    Part 1: Creating an info.json file
    Description:
    An info.json file is the file that ultimately makes the mod show up in the vehicle selector. Though in order to actually spawn up the vehicle, you must have Jbeam which will be shown in later sections. The info.json file holds all the necessary information of the vehicle/prop for either one, or multiple configs.

    Example:
    upload_2021-5-16_0-6-16.png

    How to Create:
    1. Create a blank text document in your mods folder and name it "info". For example, I'll be putting my document in mods/unpacked/crgztutorial/vehicles/crgztutorial
    upload_2021-5-16_0-15-45.png

    2. Open it up with notepad or Notepad++

    3. Copy and paste this in:
    {
    "Name":"Your mod name here",
    "Brand":"Your brand name here",
    "Author":"You",
    "Country":"The country your mod originates from",
    "Transmission":"Manual/dual clutch/automatic/etc",
    "Drivetrain":"RWD/AWD/FWD/etc",
    "fuelType":"Gasoline/Electric/etc",
    "Description":"A description of your mod",
    "Type":"Car/bike/truck/prop/etc",
    "default_pc":"your default .pc file (configuration) you want being spawned",
    "default_color":"Pearl White",
    "default_color_2": "Pearl White",
    "default_color_3": "Pearl White",
    "Years":{
    "min":earliest year of production,
    "max":latest year of production,
    }
    "colors":{
    "Pearl White": "0.97 0.98 0.95 1.1",
    }
    }

    Explanation:
    Most of these arguments aren't needed, though it's better to keep all of the information that's relevant to your mod such as "Name", "Brand", "Author", "Country", etc.

    "default_pc": This argument is a MUST. Whatever .pc file you put in the "" is the configuration that's going to be defaulted. ".pc" files are obtained through the vehicle config tab located on the sidebar (gear icon), going to the "SAVE & LOAD" tab, typing a file name (lowercase, separate words using "_") and pressing save.

    "default_color": This is the "default" color of the first color palette your vehicle will spawn with (first color palette meaning the top left color palette in the "COLOR" section of the vehicle config icon, there are a total of 3 color palettes to customize your vehicle with, hence why my code gives you 'default_color', 'default_color_2', & 'default_color_3'"). This argument is linked to the "colors" argument at the bottom of the copy & paste section I've given you. For example, in the the available colors in the "colors" section is "Pearl White" with R/255 G/255 B/255 A×2 values. Therefore, the "default_color" would be "Pearl White"

    "colors": I've explained briefly about what this section is, though basically, arguments follow this sequence:

    "Any color name":"R/255 G/255 B/255 A×2",
    Add as many as you'd like.

    Step 4: Save the file as a "JSON File"
    upload_2021-5-16_1-1-42.png

    You're all finished this step. Now go into the game, look through the vehicle selector, and you should see a file like this, but with your vehicles name.
    upload_2021-5-16_1-2-48.png


    Part 2: Creating the "Main" Jbeam file

    Description:
    The "Main" Jbeam file refers to the slotType "main" which I'll get into later. This Jbeam file is recommended to obtain all non physical additions to the mod, such as glowMaps, props, paint_designs (Known as skins selections), etc.

    Example:
    upload_2021-5-16_1-9-41.png

    Yes, this looks intimidating, but it can be simplified as shown in later steps.

    How to Create:

    1. Create a blank text document in your mods folder and name it whatever you want, preferably your vehicle/props main name. For example, If was making a Toyota Corolla, I'd name the file "corolla".

    2. Open it up with notepad or Notepad++


    3. Copy and paste this in:
    {
    "part_name":{
    "information":{
    "name":"Part name",
    "authors":"Your name",
    },

    "slotType":"main",

    "slots": [
    ["type", "default", "description"] //Reference for the game
    ["'slotType' name here","name here", "Whatever name you want showing up in the parts selector",{"coreSlot":true}], //"coreSlot":true just means that you can't choose to remove this part of the vehicle.
    ["paint_design","", "Paint Design"], //Optional, for skins
    ],
    }

    Explanation:
    Starting at the top, "part_name" can be anything, though again to be organized, I'll name it "corolla" since the file name is that (there can NOT be any spaces, use "_" instead. Also no capitals).

    "name" can also be anything, but I'll choose to name it "Corolla" again (There can be capitals and spaces here).

    "authors" is self explanatory. Put in your name so people know you created it.

    "slotType": Now here comes the "main" I was talking about. This argument lets the game know that that file is the "primary" file all the other Jbeam files connect to. "slotType":"main" can only be used ONCE.

    "slots": This is the part of the Jbeam that makes vehicle/prop parts show up in the vehicle config/parts selector area.
    upload_2021-5-16_1-24-34.png
    Slots are defined with this reference section: ["type", "default", "description"].
    "type" being the name of the "slotType", "default" being the "part_name" at the top of my copy and paste section given to you, and "description" being well, the description of the Jbeam part. This slot section and it's arguments are primarily used to link other Jbeam files/parts to the "main" file. Though "slots" can be used in all Jbeam files to call upon another file to be linked. For example,
    upload_2021-5-16_1-38-13.png
    upload_2021-5-16_1-40-53.png
    The second image hopefully explains how slots work. The text circled in red links to the underlined argument in the "slots" section, same goes for the cyan.

    Step 4: Save the file as "all types" and add to the name ".jbeam".
    For example:
    upload_2021-5-16_1-43-52.png
    You're done your first main Jbeam file.


    Part 3: Creating the Structure Jbeam file(s)
    Description:
    The "structure" jbeam or the "chassis"/"body" jbeam features the primary nodes and beams that construct the main shape and physics to how it'll interact in the world.

    How to Create:

    1. Create a blank text document in your mods folder and name it whatever you want, preferably your vehicle/props main name + _chassis or _body. For example, If was making a Toyota Corolla, I'd name the file "corolla_chassis" or "corolla_body".

    2. Open it up with notepad or Notepad++

    3. Copy and paste this in:
    {
    "part_name":{
    "information":{
    "name":"Part name",
    "authors":"Your name",
    },

    "slotType":"slot_name", //Can not be "main" If you're doing a Corolla, you could put c_chassis or corolla_chassis

    "slots": [
    ["type", "default", "description"] //Reference for the game, DON'T CHANGE
    ["'slotType' name here","name here", "Whatever name you want showing up in the parts selector"],
    ]
    "flexbodies": [
    ["mesh", "[group]:", "nonFlexMaterials"], //Game reference, DON'T CHANGE
    ["mesh_name_from_blender_file", ["node_group_name"]], //"node_group_name" links to line 49
    ],

    "refNodes":[
    ["ref:", "back:", "left:", "up:","leftCorner:","rightCorner:"] //"leftCorner" and "rightCorner" are optional
    ["node1", "node2", "node3", "node4", "node5","node6"]
    //refNodes are important, the camera and spawning will work off these, make sure they are correct, enter false refNodes and your vehicle will not load.
    //The first number should be in the middle of the nodes, this is where the camera pivots from, if it's off to the side, the camera will be too
    ],

    //Cameras
    "cameraExternal":{ //--ORBIT--
    "distance":6.0, //How far away the default camera position should be
    "distanceMin":4, //How close can it get before it can't go any further
    "offset":{"x":0, "y":0.0, "z":0.57}, //Camera offset, X = Left/right, Y = Forward/backwards, Z = Height)
    "fov":65, //Field of view
    },

    "cameraChase":{ //--CHASE--
    "distance":5.5, //How far away the default camera position should be
    "distanceMin":4, //How close can it get before it can't go any further
    "offset":{"x":0, "y":0.0, "z":1.0}, //Camera offset, X = Left/right, Y = Forward/backwards, Z = Height
    "fov":65, //Field of view
    },

    "nodes": [
    ["id", "posX", "posY", "posZ"], //Reference for the game to know, DON'T CHANGE
    {"selfCollision":true}, //Can the node collide with it's own vehicle/prop nodes?
    {"collision":true}, //Can the node collide with the world?
    {"frictionCoef":0.8} //How much friction does the node have? Normal values are somewhere from 0.5 to 1.
    {"nodeMaterial":"|NM_METAL"}, //NM = "Node Material". Available sections: NM_METAL, NM_PLASTIC, NM_RUBBER, I don't know anymore
    {"nodeWeight":1.5}, //This can be any number but 0
    //Front Chassis
    {"group":"node_group_name"}, //The group name for the nodes below
    ["node_name_here",x,y,z], //Node_name_here = Keep it very short, if I was doing the front chassis, the node for example would be: fc0/fc1/fc2/fc3, etc. xyz = blender global coordinates.
    ]

    "beams": [
    ["id1:", "id2:"], //Reference for the game to know, DON'T CHANGE
    {"beamSpring":1000000,"beamDamp":50}, //"beamSpring" = how much force the beam connects to another beam. Example: Elastic bands or guitar strings. "beamDamp": How fast energy/vibrations are let out of the beam. Examples are limited, search it up
    {"beamDeform":"FLT_MAX","beamStrength":"FLT_MAX"}, //"beamDeform" = How much stress beams need to go through until permenantly deforming. "beamStrength" How much pressure is needed in order to break beams
    //"FLT_MAX" = the largest number. "beamStrength" with this value makes beams not able to break. "beamDeform" with this value makes beams unable to deform.
    {"beamType":"|NORMAL","beamPrecompression":1,"beamLongBound":1,"beamShortBound":1}
    ["node1,"node2"] //Connects a beam from node1, to node2
    ]
    }
    }

    Explanation:
    Everything here has been explained pretty thoroughly in the code itself.

    Flexbodies: Where the "looks" of the vehicle/prop comes from. You must have a 3D model (.DAE file) in your mod folder. "mesh_name_from_blender_file" refers to the side bar names here:
    upload_2021-5-16_13-32-49.png
    Flexbodies MUST be linked to a node group so that the mesh can be applied to the nodes and deform WITH the nodes. You must have at LEAST 3 nodes binded to the mesh in order for it to show up, otherwise you'll receive a "VY node error" in console.


    Any pre-existing arguements such as {"selfCollision":true}, {"frictionCoef":0.8}, {"nodeWeight":1.5} and {"group":"node_group_name"} in the "node" section affect every defined node below those arguments until a new pre-existing argument is placed after.
    For example:
    "nodes": [
    ["id", "posX", "posY", "posZ"],
    {"selfCollision":true},
    {"group":"first_group"},
    ["fcl0",0.096,0.296,0.794],
    ]
    {"selfCollision":true} and {"group":"first_group"} would affect node "fcl0", though if I put something like this:
    "nodes": [
    ["id", "posX", "posY", "posZ"],
    {"selfCollision":true},
    {"group":"first_group"},
    ["fcl0",0.096,0.296,0.794],
    {"group":"second_group"},
    ["fcc1",0.0,0.296,0.794],
    ]
    {"selfCollision":true} and {"group":"first_group"} would affect node "fcl0", though {"group":"second_group"} would affect node "fcc1". Since the "selfCollision" value didn't change, it stays true with node "fcc1".

    These rules apply the same way in the "beam" section as well

    NOTE:

    Nodes can be individually assigned pre-existing arguments within their node arguements
    Example:
    ["fcr38",-0.129,1.313,0.231{"group":"third_group"}, "selfCollision":false],
    This means the pre-existing arguments will ONLY affect this node. Nothing else.

    4. Write as many nodes as needed. Connect beams to nodes for structural integrity.
    REMEMBER: Nodes will always have a defined weight, therefore you should watch out for how many nodes your vehicle/prop body has. Too many or too little nodes will result in a unrealistic weight. Beams do NOT affect weight, only the nodes do.

    For help creating nodes and beams in Blender, refer to this: https://wiki.beamng.com/Blender_Exporter_plugin

    5. Save the file as "all types" and add to the name ".jbeam".

    6. Load up the game and test it out. If you don't have your mesh just yet, press CTRL+ B to bring up Jbeam viewer. If you can't see any green lines, load up console by pressing "~". It should tell you what's the issue.
    Refer to this page and see which issue(s) you have: https://wiki.beamng.com/Vehicle_Modding_Common_Problems


    You're done that part :)

    Part 4: Creating other Jbeam file(s)

    Description:
    The "other" Jbeam files, or addition addon Jbeam files are files that include other elements of the vehicle/prop. Sure you can put all the Jbeam into one file, but that's a mess to look through. For organizing purposes, we use multiple files to clearly know which file is which. Props will mainly stop at "Part 3: Creating the Structure Jbeam file(s)". For vehicle modding, these files may contain suspension (front, rear, etc), engine, doors, trunk, wheels, hood, headlights/taillights, etc.

    Example:

    My "Yamaha YZF-R6" mod includes all these (and more) Jbeam files:
    upload_2021-5-16_13-54-3.png

    How to Create:
    1. Follow "Part 3: Creating the Structure Jbeam file(s)".
    Nodes and beams are global throughout Jbeam, so any physical additions you'd like to add to the game needs nodes and beams. Everything has been explained in part 3. If you're stuck with the "slots" section and how to a part of the vehicle to another part, refer to this image:
    upload_2021-5-16_1-40-53.png
    I'll explain more about the types of Jbeam arguments in a later section.


    Part 5: Jbeam Arguments
    Description:
    The Jbeam arguments are difficult to describe in general terms, but basically they're "functions" that the game uses to do certain things.

    "triangles":


    Reference: ["id1:", "id2:", "id3:"],

    Full code:
    "triangles":[
    ["id1:", "id2:", "id3:"],
    ["yournode1", "yournode2", "yournode3"],
    ],

    Description: Connect 3 nodes to create a collision barrier so that vehicles or props don't go straight through your mod. Collision triangles, also known as "Coltris" are also affected by aerodynamics. The nodes MUST be assigned in counterclockwise.
    For example:
    upload_2021-5-16_14-1-57.png
    You'd put ["id1", "id2", "id3"],
    You may start at ANY node, but just follow a clockwise rotation when writing triangles.

    "quads":

    Reference: ["id1:", "id2:", "id3:", "id4:"],

    Full code:
    "quads":[
    ["id1:", "id2:", "id3:", "id4:"],
    ["yournode1", "yournode2", "yournode3","yournode4"],
    ],


    Description: Literally the same as triangles, but this just makes life easier. Instead of writing 3 nodes, you write 4. You still MUST write the nodes in COUNTERCLOCKWISE


    Other arguments for "triangles" and "quads":
    upload_2021-5-16_14-8-28.png
    - {"dragCoef":} Values range from 0-100


    "mainEngine"

    Reference: None

    Example:
    : upload_2021-5-16_14-11-21.png

    Description: Everything that has to do with the primary engine is here.

    There's a lot to explain, but most of the explanation is here: https://wiki.beamng.com/Engine_Thermal_Simulation

    "torque"

    Reference: ["rpm", "torque"]

    Full Code:
    ["rpm", "torque"]
    [0, 0],
    [rpm, torqueval],
    [rpm, torqueval],
    [rpm, torqueval],
    [rpm, torqueval],
    [rpm, torqueval],
    [rpm, torqueval],
    [rpm, torqueval],
    [rpm, torqueval],
    ],


    Description:
    These values define the torque of the engine. [rpm, torqueval], means what is the torque value at said RPM? You can add as many as you like, but the values always go upwards at a positive slope.
    For example, my Yamaha YZF-R6's torque value is:
    "torque":[
    ["rpm", "torque"]
    [0, 0],
    [500, 25],
    [1000, 40],
    [2000, 68],
    [3000, 90],
    [4000, 105],
    [5000, 120],
    [6000, 126],
    [7000, 126],
    [8000, 130],
    [9000, 134],
    [10000, 138],
    [11000, 143],
    [12000, 139],
    [13000, 131],
    [14000, 123],
    ],


    The MAX RPM value you can put should be the value you put for the argument: "maxRPM":yourRPM,

    "maxRPM"
    Reference: None

    Full Code: "maxRPM":yourRPM,

    Description: Defines the max RPM your engine can rev at

    "idleRPM"
    Reference: None

    Full Code: "idleRPM":yourRPM,

    Description: Defines the idle RPM your engine revs at without any acceleration. Basically when it's IDLE

    "inertia"

    Reference: None

    Full Code: "inertia":yourvalue,

    Description: Inertia describes the tendency of a body to resist changes in rotational speed for a given torque. (https://www.moog.com/news/ideas-in-motion-control/2003/11/inertia-and-motors.html#:~:text=Inertia describes the tendency of,speed for a given torque.&text=For a ratio of 1,the load and the motor.)

    "friction"
    Reference: None

    Full Code: "inertia":yourvalue,

    Description: I honestly don't know, someone help. Engine friction basically.

    "dynamicFriction"
    Reference: None

    Full Code: "dynamicFriction":yourvalue,

    Description: I honestly don't know either, someone help. Engine friction, but make it dynamic.

    "burnEfficiency"
    Reference: None

    Full Code: "burnEfficiency":yourvalue,

    Description: How well the engine consumes fuel.

    "torqueReactionNodes"
    Reference: None

    Full Code: "torqueReactionNodes":["node1","node2","node3"]

    Description: The nodes that shake when the engine revs. Identify any three nodes closest to the engine. It can be nodes from any Jbeam of the vehicle.

    "particulates"
    Reference: None

    Full Code: "particulates":"yourvalue"

    Description: How much particles come from the engine

    "energyStorage"
    Reference: None

    Full Code: "energyStorage":"mainTank"

    Description: Just keep it as it is, it lets the game know what type of energy storage the engine needs to get the "power" from. This is linked to the Jbeam with fuel tanks. I'll get on with that in later sections.

    "requiredEnergyType"
    Reference: None

    Full Code: "requiredEnergyType":"gasoline/diesel/kerosene/etc"

    Description: Tells the engine what type of fuel is needed to run properly, or run at all. If the fuel mixture in the fuel tank Jbeam is different than the "requiredEnergyType" value, the engine won't run.

    WILL UPDATE MORE SOON
     
    #1 CRGZ, May 16, 2021
    Last edited: May 16, 2021
    • Like Like x 20
    • Agree Agree x 1
  2. P_enta

    P_enta
    Expand Collapse

    Joined:
    Jan 11, 2020
    Messages:
    3,029
     
    • Agree Agree x 3
  3. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,061
    Some things wrong with the colors here:
    • You don't put the default colors in the main info json file, you should put them separately for each configuration, or else they will all have the same color
    • The format is not R G B A but R/255 G/255 B/255 A×2
    Other than that, great tutorial!
     
    • Agree Agree x 3
  4. Cincinnatus

    Cincinnatus
    Expand Collapse

    Joined:
    Aug 25, 2020
    Messages:
    643
    Nice tutorial!
     
    • Agree Agree x 1
  5. Aristurtle

    Aristurtle
    Expand Collapse

    Joined:
    Aug 31, 2020
    Messages:
    22
    the best tutorial working
     
  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