Join also our Discord channel! Click here.

Horizon Zero Dawn

Post questions about game models here, or help out others!
AtomicJunkie
ultra-n00b
Posts: 3
Joined: Wed Apr 08, 2020 1:26 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Horizon Zero Dawn

Post by AtomicJunkie » Wed Sep 16, 2020 2:04 pm

This blender script snaps all the floating parts to their corresponding helper bones.
Additionally it adds a arrmature constraint to these parts so that they move with the armature.

Code: Select all

import bpy

# get the first armature in scene (blender valve importer names armatures after first imported filename)
for obj in bpy.context.scene.objects:
    if obj.type == 'ARMATURE':
        arma = obj
        break

# iterate through all bones from that armature
for b in arma.pose.bones:
    
    # get helper bones
    if b.name.endswith("_helper"):
    
        # remove unneccessary filename parts
        b.name = b.name.replace("_Lx","")
        
        # new variable to better compare bones with meshes
        bonename = b.name.replace("_helper","")
        
        # iterate through all the scenes objects
        for obj in bpy.context.scene.objects:
            
            # continue if object is a mesh
            if obj.type == 'MESH':
        
                # compare if mesh name matches bone name (bone: head_helper; mesh: head)
                if obj.name.casefold().startswith(bonename.casefold()):
                
                    # apply the ccordinates of the bone tail to the mesh
                    obj.location = b.head
                    
                    # clear existing constraints
                    obj.constraints.clear()
                    
                    # add a new armature constraint with bone target (used for animation)
                    con = obj.constraints.new('ARMATURE')
                    btg = con.targets.new()
                    btg.target = arma
                    btg.subtarget = b.name

# reset location of armature to 0 (needed for some characters)                
arma.location = (0,0,0)
Some example: https://youtu.be/d38kQcLxEBo

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2183
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 52 times
Been thanked: 1764 times

Re: Horizon Zero Dawn

Post by daemon1 » Wed Sep 16, 2020 4:04 pm

AtomicJunkie wrote:
Wed Sep 16, 2020 2:04 pm
This blender script snaps all the floating parts to their corresponding helper bones.
Additionally it adds a arrmature constraint to these parts so that they move with the armature.
I dont know why this script is needed, my tool already puts all parts to their corresponding helper bones and connects helper bones to main armature.

Only if you dont use the tool as intended and only extract individual parts.

AtomicJunkie
ultra-n00b
Posts: 3
Joined: Wed Apr 08, 2020 1:26 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Horizon Zero Dawn

Post by AtomicJunkie » Wed Sep 16, 2020 5:19 pm

daemon1 wrote:
Wed Sep 16, 2020 4:04 pm
I dont know why this script is needed, my tool already puts all parts to their corresponding helper bones and connects helper bones to main armature.

Only if you dont use the tool as intended and only extract individual parts.
I use your tool without the bat file generation you mentioned in one of your first posts.
Because that didn't work for me. Is this still implemented? Maybe I'm using it wrong.

Anyway after copying the skeleton in the smd file via script, I can import them into blender and even use the animations.

daemon1
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2183
Joined: Tue Mar 24, 2015 8:12 pm
Has thanked: 52 times
Been thanked: 1764 times

Re: Horizon Zero Dawn

Post by daemon1 » Wed Sep 16, 2020 5:34 pm

AtomicJunkie wrote:
Wed Sep 16, 2020 5:19 pm
I use your tool without the bat file generation you mentioned in one of your first posts.
Because that didn't work for me. Is this still implemented? Maybe I'm using it wrong.
Yes, that bat file is supposed to do that. And yes, it must still work, because game formats were never changed since the beginning.

Post Reply