Skip to content

Want to load a stage in unreal with asset resolver context #22

@28Rohit

Description

@28Rohit

Hello!

This is not an issue, I want help to set a custom resolver before opening the stage in side unreal so that even some tries to load stage with the help of USD stage importer, the stage should open with that context.

Build for unreal asset resolver

REM build.bat

set AR_RESOLVER_NAME=pythonResolver
REM Define App
set AR_DCC_NAME=UNREAL
set UE_ENGINE_LOCATION=C:\Program Files\Epic Games\UE_5.3

REM Clear existing build data and invoke cmake
rmdir /S /Q build
rmdir /S /Q dist
REM Make sure to match the correct VS version the DCC was built with
cmake . -B build -G "Visual Studio 17 2022" -A x64 -T v143
cmake --build build  --clean-first --config Release
cmake --install build

CMakeList.txt

elseif("$ENV{AR_DCC_NAME}" STREQUAL "UNREAL")

    set(AR_UNREAL_ENGINE $ENV{UE_ENGINE_LOCATION}/Engine CACHE PATH "Unreal Engine install directory")
    set(UE_THIRD_PARTY_LOCATION ${AR_UNREAL_ENGINE}/Source/ThirdParty) 
    set(PYTHON_SOURCE_LOCATION ${UE_THIRD_PARTY_LOCATION}/Python3/Win64)

    # TBB 
    set( TBB_LOCATION ${UE_THIRD_PARTY_LOCATION}/Intel/TBB/IntelTBB-2019u8 )
    set( TBB_INCLUDE_LOCATION ${TBB_LOCATION}/include )
    include_directories(${TBB_INCLUDE_LOCATION}) 
    link_directories(${TBB_LOCATION}/lib/Win64/vc14) 

    # Python
    link_directories(${PYTHON_SOURCE_LOCATION}/libs)
    if (WIN32)
        set(AR_PYTHON_LIB python3.9)
        set(AR_PYTHON_LIB_NUMBER python39)       
        set(AR_PYTHON_EXECUTABLE ${AR_UNREAL_ENGINE}/Binaries/ThirdParty/Python3/Win64/python.exe )               
        set(AR_PYTHON_INCLUDE_DIR ${PYTHON_SOURCE_LOCATION}/include)
    else()
        message(FATAL_ERROR "LINUX Configuration pending!")
    endif()

    # Boost
    set(BOOST_LOCATION ${UE_THIRD_PARTY_LOCATION}/Boost/boost-1_80_0)
    set(AR_BOOST_NAMESPACE boost)
    if (WIN32)
        set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}-mt-x64) #Done ( lib directory needs to add )
        set(AR_BOOST_INCLUDE_DIR ${BOOST_LOCATION}/include) #Done

        # Unreal has seperate link directory
        link_directories(${BOOST_LOCATION}/lib/Win64)

    else()
        message(FATAL_ERROR "LINUX Configuration pending!")
    endif()

    # Usd
    set(UE_USD_IMPORTER ${AR_UNREAL_ENGINE}/Plugins/Importers/USDImporter)
    set(UE_USD_RESOURCE ${UE_USD_IMPORTER}/Source/ThirdParty/USD)
    set(AR_PXR_INCLUDE_DIR ${UE_USD_RESOURCE}/include) #DONE
    set(AR_PXR_LIB_DIR ${UE_USD_RESOURCE}/lib)    #DONE
    set(AR_PXR_LIB_PREFIX "usd_") #Done
    if (WIN32)
        set(AR_PXR_PYTHON_LIB_SITEPACKAGES ${UE_USD_IMPORTER}/Content/Python/Lib/Win64/site-packages ) #DONE
    else()
        message(FATAL_ERROR "LINUX Configuration pending!")
    endif()

endif()

setup.bat

@echo off
REM Clear current session log 
cls
set AR_RESOLVER_NAME=pythonResolver
REM Define App
set AR_DCC_NAME=UNREAL

set REPO_ROOT=C:/path/to//VFX-UsdAssetResolver-main

set UE_PYTHONPATH=%REPO_ROOT%/dist/%AR_RESOLVER_NAME%/lib/python;%PYTHONPATH%
set PXR_PLUGINPATH_NAME=%REPO_ROOT%/dist/%AR_RESOLVER_NAME%/resources;%PXR_PLUGINPATH_NAME%
set LD_LIBRARY_PATH=%REPO_ROOT%/dist/%AR_RESOLVER_NAME%/lib;%LD_LIBRARY_PATH%

set AR_SEARCH_PATHS=%REPO_ROOT%/files/generic/workspace/shots;%REPO_ROOT%/files/generic/workspace/assets
set AR_SEARCH_REGEX_EXPRESSION="(bo)"
set AR_SEARCH_REGEX_FORMAT="Bo"
set TF_DEBUG=AR_RESOLVER_INIT

"C:\Program Files\Epic Games\UE_5.3\Engine\Binaries\Win64\UnrealEditor.exe" -log

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions