Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
"# assets"
# neoAssets

This repository contains the runtime assets used by the [neo](https://github.com/NeotokyoRebuild/neo/) repo.


## Installation

When neo configures CMake, it copies the `neo/` tree from this repository into neo's `game/neo/` directory.
By default, CMake downloads and installs the `NeotokyoRebuild/neoAssets` `master` branch.


## Using a local checkout

To use a local neoAssets checkout, set neo's CMake variable `NEO_EXTRA_ASSETS_ALT_PATH` to the `neoAssets` checkout root configuring CMake.
(Do not set it to the `neo/` subfolder.)

Without a local checkout override, a later neo CMake configure can replace changes in the game copy with files from the downloaded `master` branch.
This can result in lost work if the only copies were in the local neo/game/neo installation.

Setting this override allows one to edit this repository to version changes locally, while enabling the use of CMake configure from `neo` to update the game copy.
Binary file added neo/models/weapons/v_jinrai_tachi.dx80.vtx
Binary file not shown.
Binary file added neo/models/weapons/v_jinrai_tachi.dx90.vtx
Binary file not shown.
Binary file added neo/models/weapons/v_jinrai_tachi.mdl
Binary file not shown.
Binary file added neo/models/weapons/v_jinrai_tachi.sw.vtx
Binary file not shown.
Binary file added neo/models/weapons/v_jinrai_tachi.vvd
Binary file not shown.
Binary file added neo/models/weapons/v_nsf_tachi.dx80.vtx
Binary file not shown.
Binary file added neo/models/weapons/v_nsf_tachi.dx90.vtx
Binary file not shown.
Binary file added neo/models/weapons/v_nsf_tachi.mdl
Binary file not shown.
Binary file added neo/models/weapons/v_nsf_tachi.sw.vtx
Binary file not shown.
Binary file added neo/models/weapons/v_nsf_tachi.vvd
Binary file not shown.
21 changes: 21 additions & 0 deletions neo/modelsrc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Models and Animations

## Tools

* Use Blender 5.2.2 or newer.
* Use Blender Source Tools 3.4.3 or later to export SMD files from Blender.
* Use Python 3 to run the optional compile helper scripts. Export helper scripts run inside Blender, which includes `bpy`.
* Source SDK Base 2013 Multiplayer's `studiomdl.exe` compiles Source models.

## Exporting animations

In Blender, open Scene Properties > Source Engine Export and use **Scene Export** with these options:

* Set **Export Path** to `//` to write beside the Blender project.
* Set **Export Format** to SMD.
* Set **Engine Path** to the local `studiomdl.exe` location in Source SDK Base 2013 Multiplayer. (e.g. `C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base 2013 Multiplayer\bin\`)
* Set the armature's **Action Selection** to **Slot Filter** to export every animation slot.
The default first option, **Current Action Slot**, exports only the selected slot.
* For animation-only changes, leave mesh export disabled.

Note: Model and animation round trips can cause small floating-point and compiler compression differences.
27 changes: 27 additions & 0 deletions neo/modelsrc/weapons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Weapon model sources

The Tachi viewmodels are the first weapons maintained under these conventions.
Expect the folder layout, scripts and steps here to change as more weapons are added.

Each model has a source folder here, such as `jinrai_tachi/`, containing one `.blend` file and one `.qc` file.
The scripts take the names of the source folders to work on.


## Exporting animations

To export from Blender to SMD, for example for both Tachi projects, run:

```sh
blender --background --python-exit-code 1 --python export_viewmodels.py -- jinrai_tachi nsf_tachi
```


## Compiling models

Set `--compiler` to Source SDK Base 2013 Multiplayer's `studiomdl.exe`, and `--game` to the neo game directory containing `gameinfo.txt`:

```sh
python compile_viewmodels.py jinrai_tachi nsf_tachi --compiler "C:/Program Files (x86)/Steam/steamapps/common/Source SDK Base 2013 Multiplayer/bin/studiomdl.exe" --game "C:/path/to/neo/game/neo"
```

To save the compiled models in neoAssets, copy the generated files (`v_*_tachi.*` for the Tachi) from the neo game directory's `models/weapons/` folder to `neo/models/weapons/`.
63 changes: 63 additions & 0 deletions neo/modelsrc/weapons/compile_viewmodels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Compile exported viewmodel SMDs using Valve's Source SDK 2013 studiomdl.

Run with Python 3: compile_viewmodels.py SOURCE [SOURCE ...] --compiler PATH --game PATH

Each SOURCE is a folder beside this script that contains one .qc file.
The game path must contain gameinfo.txt.
Compilation uses a temporary game configuration because SDK tools cannot resolve the client's appid search path.
The resulting model files are copied to the chosen destination, while gameinfo.txt is not changed
"""
import argparse
from pathlib import Path
import shutil
import subprocess
import tempfile


def main():
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('sources', nargs='+', metavar='SOURCE',
help='Source folder beside this script, such as jinrai_tachi')
parser.add_argument('--compiler', type=Path, required=True,
help='Path to studiomdl.exe in the Source SDK Base 2013 Multiplayer bin folder')
parser.add_argument('--game', type=Path, required=True,
help='Destination neo game directory (contains gameinfo.txt)')
args = parser.parse_args()
compiler = args.compiler.resolve()
game = args.game.resolve()
if not compiler.is_file():
parser.error('Compiler does not exist: ' + str(compiler))
if not (game / 'gameinfo.txt').is_file():
parser.error('Game directory must contain gameinfo.txt: ' + str(game))
root = Path(__file__).resolve().parent
qcs = []
for source in args.sources:
found = sorted((root / source).glob('*.qc'))
if len(found) != 1:
parser.error('Source folder must contain one .qc file: ' + source)
qcs.append(found[0])
with tempfile.TemporaryDirectory(prefix='neo-viewmodel-') as temporary:
staging = Path(temporary)
(staging / 'gameinfo.txt').write_text(
'"GameInfo" { "game" "Viewmodel compile" "FileSystem" { '
'"SteamAppId" "243750" "SearchPaths" { '
'"Game" "|gameinfo_path|." } } }\n', encoding='ascii')
outputs = []
for qc in qcs:
name = qc.stem
subprocess.run([str(compiler), '-nop4', '-game', str(staging), str(qc)], check=True)
for extension in ('.mdl', '.vvd', '.dx90.vtx'):
path = staging / 'models/weapons' / (name + extension)
if not path.is_file():
raise RuntimeError('Compiler did not create ' + str(path))
outputs.extend((staging / 'models/weapons').glob(name + '.*'))
destination = game / 'models/weapons'
destination.mkdir(parents=True, exist_ok=True)
for path in outputs:
shutil.copy2(path, destination / path.name)
print('Installed', destination / path.name)


if __name__ == '__main__':
main()
53 changes: 53 additions & 0 deletions neo/modelsrc/weapons/export_viewmodels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Export saved viewmodel Blender sources with Blender Source Tools.

Run: blender --background --python-exit-code 1 --python export_viewmodels.py -- SOURCE [SOURCE ...]
Each SOURCE is a folder beside this script that contains one .blend file.
Requires Blender 5.2.2 and Blender Source Tools 3.4.3 or newer.
This helper reads .blend sources, and writes SMD exports.
"""
from pathlib import Path
import sys

import bpy


def export_project(project):
bpy.ops.wm.open_mainfile(filepath=str(project))
bpy.ops.preferences.addon_enable(module='io_scene_valvesource')
missing = [image.filepath for image in bpy.data.images
if image.source == 'FILE' and not image.packed_file
and not Path(bpy.path.abspath(image.filepath)).is_file()]
if missing:
raise RuntimeError('Missing preview images: ' + ', '.join(missing))
folder = project.parent
reference = folder / 'reference.smd'
reference_bytes = reference.read_bytes()
armature = next(obj for obj in bpy.context.scene.objects if obj.type == 'ARMATURE')
expected = [folder / 'anims' / (slot.name_display + '.smd')
for slot in armature.animation_data.action.slots]
previous = {path: path.stat().st_mtime_ns if path.exists() else None
for path in expected}
result = bpy.ops.export_scene.smd(export_scene=True)
if result != {'FINISHED'}:
raise RuntimeError('Source Tools export failed: ' + str(result))
if any(not path.is_file() or path.stat().st_mtime_ns == previous[path]
for path in expected):
raise RuntimeError('Source Tools did not freshly export every expected SMD')
if reference.read_bytes() != reference_bytes:
raise RuntimeError('The preview mesh must not overwrite reference.smd')
print('EXPORTED', project.name, len(expected), 'animation SMD files; reference retained')


if __name__ == '__main__':
root = Path(__file__).resolve().parent
sources = sys.argv[sys.argv.index('--') + 1:] if '--' in sys.argv else []
if not sources:
raise RuntimeError('List the source folders to export after --')
projects = []
for source in sources:
found = sorted((root / source).glob('*.blend'))
if len(found) != 1:
raise RuntimeError('Source folder must contain one .blend file: ' + source)
projects.append(found[0])
for project in projects:
export_project(project)
Loading