Solved Map Mesh Missing Materials

Discussion in 'Mod Support' started by RoRbot, Nov 18, 2023.

  1. RoRbot

    RoRbot
    Expand Collapse

    Joined:
    Nov 18, 2023
    Messages:
    24
    I'm porting a map from another game and I have it as a huge mesh with 1462 individual materials. I'm currently using the smallgrid map to test the model out. In \BeamNG.drive\0.30\levels\smallgrid I have shar.dae and then the 1462 material files which are stored as PNG images.

    What's the best way to map the materials to the mesh?

    I was looking at how n-labs did it and there's a .cs file that seems to map the material:

    Code:
    singleton Material( Floor )
    {
       mapTo = "Floor";
       diffuseMap[0] = "levels/NLabs/art/defaultnouvs.dds";
       translucentBlendOp = "None";
       materialTag0 = "TestMaterial";
    };
    From what I understand this maps each material to part of the model, I don't want to have to manually do this for over 1000 materials if I can avoid it.

    One way I was thinking of doing it would be baking the materials in blender so its a single file, though this may be a very complex material?

    I searched for possible solutions and found https://www.beamng.com/threads/map-with-3d-mesh.43987/ which links to https://www.beamng.com/threads/adding-static-mesh-racetrack-video-from-3dsmax.8185/ this post has a video that now appears to be private.

    This is what the map looks like in-game:
    BeamNGdrivex64_kPyZQPQ8pf.png

    Wondering what the best approach here is?

    Thank you.
     
  2. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    535
    The cs format for materials is old. You should use the actual materials.json format. The only way I can think of is do some scripting to generate the materials JSON file. Reading all the material names out of the dae and in a loop build the entries for the materials. The dae can be parsed because it’s just an xml format.
     
  3. RoRbot

    RoRbot
    Expand Collapse

    Joined:
    Nov 18, 2023
    Messages:
    24
    Thanks for your reply.

    Is there really no way to generate the materials.json automatically currently? I've been told the game will generate one automatically for vehicles. Would it be possible to create a vehicle using the map mesh and have the game create a materials.json for it?

    I could look at writing a program to parse the xml and then generate a materials.json file but it feels like its going to be a lot of work and I don't want to do it if there's some other way.
     
  4. AlexKidd71

    AlexKidd71
    Expand Collapse

    Joined:
    Mar 16, 2022
    Messages:
    535
    In Maps the json is generated automatically for the base color only if the material names and the basecolor texture file is defined in the dae file.
     
  5. RoRbot

    RoRbot
    Expand Collapse

    Joined:
    Nov 18, 2023
    Messages:
    24
    Watching through it appears when placing a model using the world editor, the game creates a main.materials.json file. This does not happen for me.

    I've started to take a look at the Nordschleife map to study how the materials are mapped to the model in the main.materials.json
     
  6. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    505
    If you import a .dae into a folder which already has a materials.json, it won't automatically create one for you, but if it doesn't, it will. It will still need populating with the relevant information, but it will create the blank materials for your object.
     
  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