Remove crappy ChunkMerge tool and merge collisions ourself.

This commit is contained in:
Empathic Qubit 2021-06-13 06:14:54 -04:00
parent 53f0d31b52
commit 29bad2801e
8 changed files with 54 additions and 127 deletions

13
.vscode/launch.json vendored
View file

@ -10,15 +10,14 @@
"request": "launch",
"python": "${command:python.interpreterPath}",
"program": "${file}",
"args": ["--", "${workspaceFolder}/plugin/Data/Meshes/_EQ_ItemRoulette/roulette_container_final.nif"],
"args": [
"--",
"${workspaceFolder}/plugin/Data/Meshes/_EQ_ItemRoulette/roulette_container_mesh.nif",
"${workspaceFolder}/plugin/Data/Meshes/_EQ_ItemRoulette/roulette_container_final.nif",
"${workspaceFolder}/Source/Meshes/_EQ_ItemRoulette/roulette_container_template.nif"
],
//"args": ["--", "${env:USERPROFILE}/Desktop/cabbage01.nif"],
"console": "integratedTerminal"
},
{
"type": "papyrus",
"name": "Skyrim",
"request": "attach",
"game": "skyrimSpecialEdition"
}
]
}

View file

@ -1,28 +0,0 @@
SetTitleMatchMode, RegEx
WinWait, ahk_exe i)ChunkMerge.exe
WinGet, ChunkMain, ID, ahk_exe i)ChunkMerge.exe
WinActivate, ahk_id %ChunkMain%
Clipboard := ChunkMerge_NifFile
ControlFocus Edit1, ahk_id %ChunkMain%
Send +{Insert}
Clipboard := ChunkMerge_CollisionFile
ControlFocus Edit2, ahk_id %ChunkMain%
Send +{Insert}
ControlFocus, ComboBox1, ahk_id %ChunkMain%
Send, %ChunkMerge_TemplateFile%
ControlClick, Mesh Data, ahk_id %ChunkMain%
ControlClick, Name of NiTriShape, ahk_id %ChunkMain%
ControlSend Convert, {Space}, ahk_id %ChunkMain%
Loop {
Sleep 100
ControlGetText, FinishedText, RichEdit20W1, ahk_id %ChunkMain%
IfInString, FinishedText, Nif converted successfully
{
Break
}
}

View file

@ -63,65 +63,8 @@ plugin/Data/Textures/_EQ_ItemRoulette/%.dds: Source/Textures/_EQ_ItemRoulette/%.
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/ChunkMerge.xml: build/ChunkMerge/ChunkMerge.exe
cat > "$@" <<'HERE'
<Config>
<PathSkyrim>$(SKYRIM_BASE)</PathSkyrim>
<PathNifXML>$(current_dir)/nif.xml</PathNifXML>
<PathTemplate>$(current_dir)\\Source\\Meshes\\_EQ_ItemRoulette</PathTemplate>
<LastTexture></LastTexture>
<LastTemplate></LastTemplate>
<DirSource></DirSource>
<DirDestination></DirDestination>
<DirCollision></DirCollision>
<MatHandling>0</MatHandling>
<VertexColorHandling>0</VertexColorHandling>
<UpdateTangentSpace>1</UpdateTangentSpace>
<ReorderProperties>1</ReorderProperties>
<CollTypeHandling>1</CollTypeHandling>
<CollMaterial>-553455049</CollMaterial>
<MaterialScan>
<MatScanTag>SkyrimHavokMaterial</MatScanTag>
<MatScanName>SKY_HAV_</MatScanName>
<MatScanPrefixList>
<MatScanPrefix>Material</MatScanPrefix>
</MatScanPrefixList>
<MatScanIgnoreList>
<MatScanIgnore>Unknown</MatScanIgnore>
</MatScanIgnoreList>
</MaterialScan>
<DirectXView>
<ShowTexture>1</ShowTexture>
<ShowWireframe>0</ShowWireframe>
<ShowColorWire>0</ShowColorWire>
<ForceDDS>0</ForceDDS>
<ColorWireframe>ffffffff</ColorWireframe>
<ColorWireCollision>ffffff00</ColorWireCollision>
<ColorBackground>ff200020</ColorBackground>
<ColorSelected>ffff00ff</ColorSelected>
<TexturePathList>
</TexturePathList>
</DirectXView>
</Config>
HERE
plugin/Data/Meshes/_EQ_ItemRoulette/%_final.nif: setalpha.py .venv/pyvenv.cfg plugin/Data/Meshes/_EQ_ItemRoulette/%_chunkmerge.nif
pyenv exec python -m pipenv run python "$<" -- "$(word 3,$^)" "$@"
.PRECIOUS: plugin/Data/Meshes/_EQ_ItemRoulette/%_chunkmerge.nif
plugin/Data/Meshes/_EQ_ItemRoulette/%_chunkmerge.nif: Source/Meshes/_EQ_ItemRoulette/%_template.nif plugin/Data/Meshes/_EQ_ItemRoulette/%_collision.nif plugin/Data/Meshes/_EQ_ItemRoulette/%_mesh.nif build/ChunkMerge/ChunkMerge.xml
cp "$(filter %_mesh.nif,$^)" "$@"
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'
plugin/Data/Meshes/_EQ_ItemRoulette/%_final.nif: setalpha.py .venv/pyvenv.cfg plugin/Data/Meshes/_EQ_ItemRoulette/%_mesh.nif Source/Meshes/_EQ_ItemRoulette/%_template.nif
pyenv exec python -m pipenv run python "$<" -- "$(word 3,$^)" "$@" "$(word 4,$^)"
.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
@ -145,8 +88,3 @@ build/blender.zip:
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 build/blender-windows64/blender.exe
BLENDER="$(word 2, $^)"
"$$BLENDER" --background --python "./export_blender_models.py" -- "$<" "$@"

View file

@ -6,13 +6,24 @@ Static Property _EQ_ItemRoulette_Roulette Auto
ObjectReference[] DisplayItems
ObjectReference Roulette
Int MAX_ITEMS = 5
Float UI_DISTANCE = 48.0
Float UI_DEGREES = 7.0
Float UI_ZEES = 4.0
Float UI_ITEM_SCALE = 0.2
Int MAX_ITEMS
Float UI_DISTANCE
Float UI_DEGREES
Float UI_ZEES
Float UI_ITEM_SCALE
Event OnInit()
; Placeholder for things to happen only on first load for this save
Main()
EndEvent
Function Main()
MAX_ITEMS = 5
UI_DISTANCE = 48.0
UI_DEGREES = 14.0
UI_ZEES = 12.0
UI_ITEM_SCALE = 0.25
DisplayItems = New ObjectReference[127]
int index = 0
While index < MAX_ITEMS
@ -20,10 +31,6 @@ Event OnInit()
index += 1
EndWhile
Main()
EndEvent
Function Main()
Debug.Trace("Item Roulette loaded")
Roulette = PlayerRef.PlaceAtMe(_EQ_ItemRoulette_Roulette)
RegisterForModEvent("_EQ_ItemRoulette_Activate", "OnMyAction")
@ -32,9 +39,6 @@ Function Main()
EndFunction
Event OnUpdate()
Float handX = VRIK.VrikGetHandX(true)
Float handY = VRIK.VrikGetHandY(true)
Float handZ = VRIK.VrikGetHandZ(true)
Float playerAngle = PlayerRef.GetAngleZ()
Roulette.TranslateTo(PlayerRef.X + UI_DISTANCE * Math.sin(playerAngle), PlayerRef.Y + UI_DISTANCE * Math.cos(playerAngle), VRIK.VrikGetHmdZ(), 0, 0, playerAngle, 1000)
@ -56,7 +60,7 @@ Event OnUpdate()
Else
top = UI_ZEES
EndIf
DisplayItems[index].MoveTo(PlayerRef, UI_DISTANCE * Math.sin(playerAngle - left), UI_DISTANCE * Math.cos(playerAngle - left), (VRIK.VrikGetHmdZ() - PlayerRef.Z) + top)
DisplayItems[index].MoveTo(PlayerRef, UI_DISTANCE * Math.sin(playerAngle - left), UI_DISTANCE * Math.cos(playerAngle - left), (VRIK.VrikGetHmdZ() - PlayerRef.Z) - top)
index += 1
EndWhile

View file

@ -4,6 +4,15 @@ import pickle
from pyffi.formats.nif import NifFormat
import sys
def validate_nif(mesh_data, nif_stream):
mesh_data.inspect_version_only(nif_stream)
if mesh_data.version >= 0:
mesh_data.read(nif_stream)
elif mesh_data.version == -1:
raise UnsupportedOperation("Unsupported NIF version")
else:
raise UnsupportedOperation("Not a NIF")
argv = sys.argv
try:
index = argv.index("--") + 1
@ -11,27 +20,32 @@ except ValueError:
index = len(argv)
argv = argv[index:]
print(argv[0] + ' --> ' + argv[1])
print(argv[0] + ' --> ' + argv[1] + ' TEMPLATE: ' + argv[2])
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")
mesh_data = NifFormat.Data()
with open(argv[0], 'rb') as mesh_file:
validate_nif(mesh_data, mesh_file)
alpha_index = len(data.header.block_types)
alpha_index = len(mesh_data.header.block_types)
for child in data.get_global_iterator():
for child in mesh_data.get_global_iterator():
# Replace the generic collision data with data from the template,
# but preserve the collision vertices
if isinstance(child, NifFormat.bhkCollisionObject):
template_data = NifFormat.Data()
with open(argv[2], 'rb') as template_file:
validate_nif(template_data, template_file)
new_collision = template_data.roots[0].collision_object
new_collision.body.shape = child.body.shape
child.target.collision_object = new_collision
# Fix the alpha value
if isinstance(child, NifFormat.NiTriShape):
alpha = NifFormat.NiAlphaProperty(parent=child)
alpha.flags = 4845
child.bs_properties[-1] = alpha
data.roots.append(alpha)
data.blocks.append(alpha)
mesh_data.blocks.append(alpha)
with open(argv[1], 'wb') as nif_out:
data.write(nif_out)
mesh_data.write(nif_out)