It's hard to believe setting the freaking alpha property is this

complicated.
This commit is contained in:
Empathic Qubit 2021-06-08 01:03:44 -04:00
parent 9ab6010ad8
commit 597fcd2f64
12 changed files with 142 additions and 10 deletions

2
.gitignore vendored
View file

@ -7,3 +7,5 @@
/build/
node_modules/
*.blend[0-9]*
.venv/*
!.venv/DONT_DELETE

1
.python-version Normal file
View file

@ -0,0 +1 @@
3.7.9

0
.venv/DONT_DELETE Normal file
View file

9
.vscode/launch.json vendored
View file

@ -4,6 +4,15 @@
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Aktuelle Datei",
"type": "python",
"request": "launch",
"python": "${command:python.interpreterPath}",
"program": "${file}",
"args": ["--", "${workspaceFolder}/plugin/Data/Meshes/_EQ_ItemRoulette/roulette_container_final.nif"],
"console": "integratedTerminal"
},
{
"type": "papyrus",
"name": "Skyrim",

4
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,4 @@
{
"python.pythonPath": "${workspaceFolder}/.venv/Scripts/python.exe",
"jupyter.jupyterServerType": "local"
}

View file

@ -1,4 +1,4 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/c/ProgramData/chocolatey/bin:$(SystemRoot)/System32/WindowsPowerShell/v1.0
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/c/ProgramData/chocolatey/bin:$(SystemRoot)/System32:$(SystemRoot)/System32/WindowsPowerShell/v1.0:$(word 1,$(HOME) $(USERPROFILE))/.pyenv/pyenv-win/bin
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
@ -40,17 +40,36 @@ plugin/Data/Scripts/%.pex: Source/Scripts/%.psc
textures: $(textureFiles)
pipenv: .venv/pyvenv.cfg
plugin/Data/Textures/_EQ_ItemRoulette/%.dds: Source/Textures/_EQ_ItemRoulette/%.xcf export_gimp_textures.py
GIMP=$$(powershell -Command '(Get-Item "$(ProgramW6432)/GIMP*/bin/gimp-console*.exe").FullName')
"$$GIMP" -n -i --batch-interpreter python-fu-eval -b 'import export_gimp_textures ; export_gimp_textures.main("$<", "$@")'
.venv/lib/site-packages/pyffi/formats/kfm/kfmxml/kfm.xml:
mkdir -p "$(dir $@)"
powershell -Command 'Invoke-WebRequest -Uri "https://raw.githubusercontent.com/niftools/kfmxml/develop/kfm.xml" -OutFile "$@"'
.venv/lib/site-packages/pyffi/formats/nif/nifxml/nif.xml:
mkdir -p "$(dir $@)"
powershell -Command 'Invoke-WebRequest -Uri "https://raw.githubusercontent.com/niftools/nifxml/959cb9c3dd59a319e60e819fc8a1402f821f3684/nif.xml" -OutFile "$@"'
.PRECIOUS: .venv/pyvenv.cfg
.venv/pyvenv.cfg: Pipfile .venv/lib/site-packages/pyffi/formats/nif/nifxml/nif.xml .venv/lib/site-packages/pyffi/formats/kfm/kfmxml/kfm.xml
pyenv install $$(cat ".python-version")
pyenv exec pip install --user pipenv
pyenv exec python -m pipenv install
models: $(modelFiles) textures
.PRECIOUS: build/ChunkMerge/ChunkMerge.exe
build/ChunkMerge/ChunkMerge.exe: build/chunkmerge.7z
7z x -y "-obuild" "$<"
touch -c "$@"
.PRECIOUS: build/chunkmerge.7z
build/chunkmerge.7z:
powershell -Command 'Invoke-WebRequest -Uri "https://github.com/downloads/skyfox69/NifUtils/ChunkMerge0155.7z" -OutFile build/chunkmerge.7z'
powershell -Command 'Invoke-WebRequest -Uri "https://github.com/downloads/skyfox69/NifUtils/ChunkMerge0155.7z" -OutFile "$@"'
build/ChunkMerge/ChunkMerge.xml: build/ChunkMerge/ChunkMerge.exe
cat > "$@" <<'HERE'
@ -100,12 +119,30 @@ plugin/Data/Meshes/_EQ_ItemRoulette/%_final.nif: Source/Meshes/_EQ_ItemRoulette/
build/ChunkMerge/ChunkMerge.exe &
powershell -Command '$$env:ChunkMerge_NifFile=Split-Path (Join-Path "$@" "."); $$env:ChunkMerge_CollisionFile=Split-Path (Join-Path "$(filter %_collision.nif,$^)" ".") ; $$env:ChunkMerge_TemplateFile="$(notdir $(filter %_template.nif,$^))" ; Start-Process -Wait -FilePath AutoHotKey -ArgumentList @("ChunkMerge.ahk") ; Stop-Process -Name ChunkMerge'
.PRECIOUS: build/blender-windows64/blender.exe
build/blender-windows64/blender.exe: build/blender.zip build/blender-windows64/2.93/scripts/addons/io_scene_niftools/__init__.py
7z x -y "-obuild" "$<"
touch -c "$@"
.PRECIOUS: build/blender-windows64/2.93/scripts/addons/io_scene_niftools/__init__.py
build/blender-windows64/2.93/scripts/addons/io_scene_niftools/__init__.py: build/blender-niftools.zip
7z x -y "-o$$(dirname "$$(dirname "$@")")" "$<"
touch -c "$@"
.PRECIOUS: build/blender-niftools.zip
build/blender-niftools.zip:
powershell -Command 'Invoke-WebRequest -Uri "https://github.com/niftools/blender_niftools_addon/releases/download/v0.0.6/blender_niftools_addon-v0.0.6-2021-04-24-fa4123d.zip" -OutFile "$@"'
.PRECIOUS: build/blender.zip
build/blender.zip:
powershell -Command 'Invoke-WebRequest -Uri "https://mirror.clarkson.edu/blender/release/Blender2.93/blender-2.93.0-windows-x64.zip" -OutFile "$@"'
.PRECIOUS: plugin/Data/Meshes/_EQ_ItemRoulette/%_mesh.nif
plugin/Data/Meshes/_EQ_ItemRoulette/%_mesh.nif: Source/Meshes/_EQ_ItemRoulette/%_mesh.blend
BLENDER=$$(powershell -Command '(Get-Item "$(ProgramW6432)/Blender*/Blender*/blender.exe").FullName')
"$$BLENDER" --background --python "./export_blender_models.py" -- "$^" "$@"
plugin/Data/Meshes/_EQ_ItemRoulette/%_mesh.nif: Source/Meshes/_EQ_ItemRoulette/%_mesh.blend build/blender-windows64/blender.exe
BLENDER="$(word 2, $^)"
"$$BLENDER" --background --python "./export_blender_models.py" -- "$<" "$@"
.PRECIOUS: plugin/Data/Meshes/_EQ_ItemRoulette/%_collision.nif
plugin/Data/Meshes/_EQ_ItemRoulette/%_collision.nif: Source/Meshes/_EQ_ItemRoulette/%_collision.blend
BLENDER=$$(powershell -Command '(Get-Item "$(ProgramW6432)/Blender*/Blender*/blender.exe").FullName')
"$$BLENDER" --background --python "./export_blender_models.py" -- "$^" "$@"
plugin/Data/Meshes/_EQ_ItemRoulette/%_collision.nif: Source/Meshes/_EQ_ItemRoulette/%_collision.blend build/blender-windows64/blender.exe
BLENDER="$(word 2, $^)"
"$$BLENDER" --background --python "./export_blender_models.py" -- "$<" "$@"

9
Pipfile Normal file
View file

@ -0,0 +1,9 @@
[[source]]
url = "https://pypi.python.org/simple"
[packages]
pyqt4 = {file = "https://download.lfd.uci.edu/pythonlibs/q4trcu4l/PyQt4-4.11.4-cp37-cp37m-win_amd64.whl"}
pyffi = {file = "https://github.com/amorilia/pyffi/archive/refs/tags/pyffi-2.2.2.zip"}
[requires]
python_version = "3.7.9"

33
Pipfile.lock generated Normal file
View file

@ -0,0 +1,33 @@
{
"_meta": {
"hash": {
"sha256": "bb61dfe357ea16e199e93ef79d83cabdc7fef8a99c5376ba3a5a6aa2428f4eeb"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.7.9"
},
"sources": [
{
"url": "https://pypi.python.org/simple"
}
]
},
"default": {
"pyffi": {
"file": "https://github.com/amorilia/pyffi/archive/refs/tags/pyffi-2.2.2.zip",
"hashes": [
"sha256:2ebdeb86e29e9b532b40fe61b6005e0d29973f2f7e966dbb9fc9c1f4680fa3ca"
],
"version": "==2.2.2"
},
"pyqt4": {
"file": "https://download.lfd.uci.edu/pythonlibs/q4trcu4l/PyQt4-4.11.4-cp37-cp37m-win_amd64.whl",
"hashes": [
"sha256:3bd04c8576ffdc6db3b991642d1657fcee4df803c869a97d11a6eaab1445d59a"
],
"version": "==4.11.4"
}
},
"develop": {}
}

View file

@ -63,7 +63,7 @@ if($InstallDependencies) {
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install blender gimp 7zip autohotkey make nodejs
choco install gimp 7zip autohotkey make nodejs pyenv-win
return 0
}

View file

@ -9,9 +9,10 @@ try:
index = argv.index("--") + 1
except ValueError:
index = len(argv)
argv = argv[index:]
bpy.ops.preferences.addon_enable(module='io_scene_niftools')
curdir = Path(__file__).parent
blend_path = Path(argv[0])
nif_path = Path(argv[1])

View file

@ -111,9 +111,11 @@
A standard 32-bit floating point number.
</basic>
<!--
<basic name="hfloat" count="0">
A 16-bit floating point number.
</basic>
-->
<basic name="HeaderString" count="0">
A variable length string that ends with a newline character (0x0A). The string starts as follows depending on the version:

34
setalpha.py Normal file
View file

@ -0,0 +1,34 @@
from io import UnsupportedOperation
import pyffi
import pickle
from pyffi.formats.nif import NifFormat
import sys
argv = sys.argv
try:
index = argv.index("--") + 1
except ValueError:
index = len(argv)
argv = argv[index:]
data = NifFormat.Data()
with open(argv[0], 'rb') as nif_stream:
data.inspect_version_only(nif_stream)
if data.version >= 0:
data.read(nif_stream)
elif data.version == -1:
raise UnsupportedOperation("Unsupported NIF version")
else:
raise UnsupportedOperation("Not a NIF")
for child in data.get_global_iterator():
if isinstance(child, NifFormat.NiTriShape):
alpha = NifFormat.NiAlphaProperty()
alpha.flags = 4845
child.bs_properties.append(alpha)
child.bs_properties.update_size()
with open('Z:/farts.nif', 'wb') as nif_out:
data.write(nif_out)
print('frick')