Jump to content
Sign in to follow this  
kiryha

Using animated FBX in Geometry context

Recommended Posts

What are the options for importing animated FBX files (from mixmao) into geometry context (to scatter, modify etc)?
Imported FBX file appears in the OBJ root context and currently I know 2 options to bring animated meshes to geometry context:
- With "Object Merge" node. The issue here is if I have a lot of parts it could be a long process to bring all meshes together. Could be scripted although.
- With "Agent" node. Not sure if I will have the same level of access to geometry data in this case, for example how to apply different materials to different parts of the mesh.

What is the usual way to do such things?

Share this post


Link to post
Share on other sites

Ok, quick script to merge FBX data into Geometry node

# 256 Pipeline tools
# Convert FBX subnetwork to Geometry node
# Import FBX into Houdini, select FBX subnetwork, run script in Python Source Editor

import hou
# Get selected FBX container and scene root
FBX = hou.selectedNodes()
OBJ = hou.node('/obj/')

def checkConditions():
    '''
    Check if environment conditions allows to run script without errors
    '''
    if not FBX:  # If user select anything
        print '>> Nothing selected! Select FBX subnetwork!'
        return 0

def convert_FBX():
    '''
    Create Geometry node and import all FBX part inside
    '''
    # Create Geometry node to store FBX parts
    geometry = OBJ.createNode('geo', run_init_scripts = False)
    geometry.setName('GEO_{}'.format(FBX.name()))
    geometry.moveToGoodPosition()
    # Get all paerts inside FBX container
    geometry_FBX = [node for node in FBX.children() if node.type().name() == 'geo']
    
    # Create merge node for parts
    merge = geometry.createNode('merge')
    
    # Replicate FBX structure in Geometry node
    for geo in geometry_FBX: 
        # Create Object Merge node
        objectMerge = geometry.createNode('object_merge')
        objectMerge.setName(geo.name())
        # Set path to FBX part object
        objectMerge.parm('objpath1').set(geo.path())
        objectMerge.parm('xformtype').set(1)
        # Link part to merge
        merge.setNextInput(objectMerge)
    
    # Set Merge Node flags to Render
    merge.setDisplayFlag(1)
    merge.setRenderFlag(1)
    # Layout geometry content in Nwtwork View 
    geometry.layoutChildren()

# Check if everything is fine and run script
if checkConditions() != 0:
    # Get FBX network
    FBX = FBX[0]
    # run conversion
    convert_FBX()
    print '>> CONVERSION DONE!'

 

  • Like 1

Share this post


Link to post
Share on other sites

Aha! There is a slightly more easy solution: "Import Directly Into obj/Network" checkbox in Import FBX dialog window...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×