diff --git a/.vscode/launch.json b/.vscode/launch.json index 7425398..f38d043 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" } ] } \ No newline at end of file diff --git a/ChunkMerge.ahk b/ChunkMerge.ahk deleted file mode 100644 index 685a224..0000000 --- a/ChunkMerge.ahk +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/Makefile b/Makefile index d68da92..ccb5fcd 100644 --- a/Makefile +++ b/Makefile @@ -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' - - $(SKYRIM_BASE) - $(current_dir)/nif.xml - $(current_dir)\\Source\\Meshes\\_EQ_ItemRoulette - - - - - - 0 - 0 - 1 - 1 - 1 - -553455049 - - SkyrimHavokMaterial - SKY_HAV_ - - Material - - - Unknown - - - - 1 - 0 - 0 - 0 - ffffffff - ffffff00 - ff200020 - ffff00ff - - - - - 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 @@ -143,10 +86,5 @@ build/blender.zip: .PRECIOUS: plugin/Data/Meshes/_EQ_ItemRoulette/%_mesh.nif 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" -- "$<" "$@" \ No newline at end of file diff --git a/Source/Meshes/_EQ_ItemRoulette/roulette_container.blend b/Source/Meshes/_EQ_ItemRoulette/roulette_container.blend deleted file mode 100644 index 11ba423..0000000 Binary files a/Source/Meshes/_EQ_ItemRoulette/roulette_container.blend and /dev/null differ diff --git a/Source/Meshes/_EQ_ItemRoulette/roulette_container_collision.blend b/Source/Meshes/_EQ_ItemRoulette/roulette_container_collision.blend deleted file mode 100644 index 84c4fb5..0000000 Binary files a/Source/Meshes/_EQ_ItemRoulette/roulette_container_collision.blend and /dev/null differ diff --git a/Source/Meshes/_EQ_ItemRoulette/roulette_container_mesh.blend b/Source/Meshes/_EQ_ItemRoulette/roulette_container_mesh.blend index 4682687..2c62b3e 100644 Binary files a/Source/Meshes/_EQ_ItemRoulette/roulette_container_mesh.blend and b/Source/Meshes/_EQ_ItemRoulette/roulette_container_mesh.blend differ diff --git a/Source/Scripts/_EQ_ItemRoulette_Quest.psc b/Source/Scripts/_EQ_ItemRoulette_Quest.psc index 2375d32..7b719c8 100644 --- a/Source/Scripts/_EQ_ItemRoulette_Quest.psc +++ b/Source/Scripts/_EQ_ItemRoulette_Quest.psc @@ -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 diff --git a/setalpha.py b/setalpha.py index f5ab307..6fb5bb8 100644 --- a/setalpha.py +++ b/setalpha.py @@ -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) \ No newline at end of file + mesh_data.write(nif_out) \ No newline at end of file