Skip to content

Commit

Permalink
fix bad texture paths
Browse files Browse the repository at this point in the history
  • Loading branch information
marekzajac97 committed Jan 10, 2024
1 parent af7a2a0 commit b87109c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ I'm probably like 15 years too late but anyway, here are some tools for importin
- CollisionMesh (`.collisionMesh`) import/export

## Limitations:
- Exporting skinned parts (e.g. tank tracks) for BundledMesh not yet supported
- Exporting deforming parts (e.g. tank tracks) for BundledMesh not yet supported
- Exporting animated UVs for BundledMesh not yet supported
- collision mesh exports to a slightly older file version (9) than 3DsMax exporter (10), which will make BF2 regenerate some missing data on load time, not a big deal.
- Generating `.samples` for static meshes is not yet supported, use [bfmeshview](http://www.bytehazard.com/bfstuff/bfmeshview/)!
Expand Down Expand Up @@ -42,15 +42,15 @@ After installation, set up your `BF2 mod directory` (`Edit -> Preferences -> Add
- Each child of the Geom object must be an object that corresponds to Lod (prefixed with `G<index>L<index>__`) containing mesh data. Each Lod should be a simplified version of the previous one. There must be at least one Lod.
- Each Lod may contain multiple child objects that will be exported as separate ObjectTemplates using different geometry parts, each Lod must contain the same hierarchy of them. StaticMeshes usually don't have any parts, so Lod will be just a single object, but for BundledMeshes you might want to have multiple geometry parts (e.g. "hull" as root and a "turret" and "motor" as its child objects). Those objects cannot be empty, each one must contain mesh data to export properly! However, if you just want them to export as invisible but separate logical objects (e.g. the `Engine` ObjectTemplate of the vehicle) you can delete all geometry (verts/faces) from the mesh object.
- Each object in the hierarchy should have its corresponding BF2 ObjectTemplate type set (e.g. `Bundle`, `PlayerControlObject` etc). You will find this property in the `Object Properties` tab, it defaults to `SimpleObject`. However, you may want some meshes to export as separate geometry parts but at the same time don't export as separate ObjectTemplates (e.g. an animatable magazine that is a part of `GenericFirearm`) in such case simply leave this property empty.
- Each object may contain collision mesh data. To add it, you need to define an empty object prefixed with `NONVIS__`. The object should have a maximum of 4 child objects (suffixed with `__COL<index>`) containing collision mesh data, each corresponding to a specific collision type: Projectile = COL0, Vehicle = COL1, Soldier = COL2, AI (navmesh) = COL3. Collision meshes should only be added to object's Geom1/Lod0 or Geom2/Lod0 hierarchies.
- Each object may contain collision mesh data. To add it, you need to define an empty object prefixed with `NONVIS__`. The object should have a maximum of 4 child objects (suffixed with `__COL<index>`) containing collision mesh data, each corresponding to a specific collision type: Projectile = COL0, Vehicle = COL1, Soldier = COL2, AI (navmesh) = COL3. Collision meshes should only be added to object's Lod0 hierchies.
- Each COL can have an arbitrary number of materials assigned, no special material settings are required, the material mapping will be dumped to the `.con` file.
- Each material that is assigned to any visible mesh must be set up for export. To setup BF2 material go to `Material Properties`, you should see `BF2 Material` panel there. Enable `Is BF2 Material` and choose appropriate settings: `Alpha Mode`, `Shader` and `Technique` (for BundledMesh only). Click on `Apply Material`, which will change some material settings and build a tree of Shader Nodes that try to mimic BF2 rendering.
- Inside the `Shader Editor`, assign texture files to the desired texture map types:
- For StaticMesh: There should be 6 `Image Texture` nodes, each corresponding to Base, Detail, Dirt, Crack, Detail Normal, and Crack Normal. Only Base texture is mandatory, if others are not meant to be used delete them, otherwise the mesh will appear all black! There should also be 5 `UV Map` nodes (linked to their corresponding image texture nodes), assign UV layers to them as described in the next bullet point.
- For BundledMesh: There should be 3 `Image Texture` nodes, each corresponding to Diffuse, Normal, and Shadow (optional). There should also be 1 `UV Map` node.
- Each LOD's mesh must have assigned a minimum of 1 and a maximum of 5 UV layers and each UV layer must be called `UV<index>`, where each one corresponds to the following texture maps:
- For StaticMesh UV0 = Base, UV1 = Detail, UV2 = Dirt, UV3 (or UV2 if Dirt layer is not present) = Crack and the last one (always UV4) is the Lightmap UV, when Lightmap UV is not present it will be generated.
- For BundledMesh there's only UV0, exporting BundledMeshes with more than one UV layer is not supported right now.
- For BundledMesh there's only UV0 for all texture maps.
- Export requires one UV map to be chosen for tangent space calculation, this must be the same UV that was used to bake the normal map, for static meshes (which reuse textures) it should likely be UV1 (Detail Normal).

### Example object hierarchies
Expand Down
3 changes: 1 addition & 2 deletions core/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ def _export_mesh_lod(mesh_type, bf2_lod, lod_obj, texture_path='', tangent_uv_ma
if texture_path: # make relative
txt_map_file = os.path.relpath(txt_map_file, start=texture_path)
# conv to linux path and lowercase
txt_map_file.replace('\\', '/').lower()
texture_maps[node.name] = txt_map_file
texture_maps[node.name] = txt_map_file.replace('\\', '/').lower()

if mesh_type == BF2StaticMesh:
staticmesh_maps = get_ordered_staticmesh_maps(texture_maps)
Expand Down

0 comments on commit b87109c

Please sign in to comment.