Skip to content

Commit

Permalink
rewrite BSP tree generator to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
marekzajac97 committed Dec 30, 2023
1 parent 2883b36 commit 26b4d51
Show file tree
Hide file tree
Showing 10 changed files with 490 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__/
*.code-workspace
*.code-workspace
*.pyd
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "bsp_builder/pybind11"]
path = bsp_builder/pybind11
url = ../../pybind/pybind11
branch = stable
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ After installation, setup your `BF2 mod directory` (`Edit -> Preferences -> Add-
- When exporting, you can select/deselect bones for export in the export menu (matters for 3P animations, depending on whether you're making soldier or weapon animations, different bone set needs to be selected).

#### Static modeling:
Export options will only be avaliable when you have an object active in the viewport. This is written 100% in Python which means the export is painfully slow, be patient! Collmesh export with ~4k tris can take up to 20 minutes, trying to export more complex stuff will be a suicide.
Export options will only be avaliable when you have an object active in the viewport.

##### StaticMesh exporting:
- The active object needs to be the root of the hierarchy, each child of the root object must be a GEOM object (suffixed with `_geom<index>`), each child of the GEOM object must be a LOD object (suffixed with `_lod<index>`) containing mesh data.
Expand All @@ -42,6 +42,7 @@ root
- Inside the `Shader Editor`, assign texture files to the desired texture map types. There should be be 7 `Image Texture` nodes, each corresponding to Base, Detail, Dirt, Crack, Detail Normal, Crack Normal. The last one (SpecularLUT) can be ignored. Detail, Dirt, Crack and their normal maps are optional (can be removed or left unset). There should also be 5 `UV Map` nodes (linked to their corresponding image texture nodes), assign UV layers to them as described below.
- 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: 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.
- Setting material's Blend Mode to `Alpha Blend` or `Alpha Clip` will export the material with BF2's `Alpha Blend` (not fully supported yet) or `Alpha Test` transparency modes respectively.
- Export is currently written 100% in Python which means the it is painfully slow, be patient!

##### CollisionMesh exporting:
- The active object needs to be the root of the hierarchy, each child of the root object must be a GEOM object (suffixed with `_geom<index>`), each child of the geom object must be a SUBGEOM object (suffixed with `_subgeom<index>`) , each child of the SUBGEOM object must be a LOD object (suffixed with `_lod<index>`) containing mesh data.
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author" : "Marek Zajac",
"description" : "",
"blender" : (3, 4, 0),
"version" : (0, 1, 2),
"version" : (0, 2, 0),
"location" : "",
"warning" : "",
"category" : "Import-Export"
Expand Down
8 changes: 8 additions & 0 deletions bsp_builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
dist/
_build/
_generate/
*.so
*.py[cod]
*.egg-info
*env*
7 changes: 7 additions & 0 deletions bsp_builder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.4...3.18)
project(bsp_builder)

set(PYBIND11_PYTHON_VERSION "3.10")

add_subdirectory(pybind11)
pybind11_add_module(bsp_builder src/main.cpp)
1 change: 1 addition & 0 deletions bsp_builder/pybind11
Submodule pybind11 added at 8b03ff
Loading

0 comments on commit 26b4d51

Please sign in to comment.