Code Monkey home page Code Monkey logo

reverse_tool's Introduction

reverse_tool

Todos

UI

  • 完成vsinput数据导出模型流程
  • 完成vsoutput数据导出模型流程
  • 使用Config类实例来传递对象,而不是分散的信号量
  • 打包exe
  • 保存配置
  • 属性id输入处改为ComboBox
  • 自动根据属性名匹配部分属性读取(例如SV_Position匹配到position属性, Textcoord匹配到uv属性...)
  • 完成rdc->csv部分流程,加入是否输出文件后缀(_input/_output)的功能
  • 完成csv->fbx部分流程,加入是否检查后缀的功能
  • 添加进度条
  • 添加提示/帮助/文档
  • 异步执行任务,不阻塞ui
  • 外观

Core

  • 解决从输入网格数据导出fbx法线值的mapping问题
  • 解决导出输入网格数据与直接从renderdoc ui版本导出不一致的问题
  • capture文件的长宽不一定是viewport的长宽,导致计算fov时与renderdoc中效果不对齐,需要查看源代码或想办法如何获取capture文件中输出的长宽比
  • 现在能够正常导出输入网格数据R10B10G10A2的格式,但是目前color属性与ui版本导出的解码方式不太一致,ui版本导出数据貌似会将范围映射为0-1,需要测试或查看源码检查是否是普遍情况
  • 保存纹理时能够保存所有slice
  • 添加shuffle通道功能
  • 完善fbx顶点色导出功能
  • 解决因index buffer产生的重复顶点问题
  • 将FbxComon.py集成到fbx_utils.py中
  • 优化网格数据导出速度
  • 完善其他特殊格式的解码

使用方式

从ui使用

工具整体UI界面

从代码使用

    import os
    from reverse_tool_core.renderdoc_utils_refactor import RenderdocImporter, CaptureManager
    from reverse_tool_core.fbx_utils import batch_csv_to_fbx

    renderdoc_dir = os.path.abspath(r"..\..\reverse_tool\renderdoc")
    rdc_file_path = r"your\rdc\file\path.rdc"
    export_dir = r"your\export\dir"
    begin_eid = 0
    end_eid = 1000
    position_id = 2
    normal_id = 0
    uv_ids = [6]
    proj_matrix = [[1.03466, 0.00, 0.00, 0.00],
                   [0.00, -2.41421, 0.00, 0.00],
                   [0.00, 0.00, 0.0003, -1.00],
                   [0.00, 0.00, 0.30009, 0.00]]
            
    with RenderDocImporter(renderdoc_dir) as rd:
        with CaptureManager(rdc_file_path) as cap:
            cap.save_textures(begin_eid, end_eid, export_dir, save_inputs=True, save_outputs=False)
            cap.save_mesh_data(begin_eid, end_eid, export_dir, save_inputs=False, save_outputs=True)
            
            batch_csv_to_fbx(export_dir, begin_eid, end_eid, 2, 0, [6], save_from_input=False, save_from_output=True, matrix_list=proj_matrix)

其中保存fbx也可以使用相机fov值

@dataclass
class CameraData:
    fov: float
    near_plane: float
    far_plane: float
    width: float
    height: float


with RenderDocImporter(renderdoc_dir) as rd:   
    with CaptureManager(rdc_file_path) as cap:
        controller = cap.get_controller()
        postvs = controller.GetPostVSData(0, 0, rd.MeshDataStage.VSOut)
        viewport = controller.GetPipelineState().GetViewport(0)
        camera_data = CameraData(fov=60,
                                near_plane=postvs.nearPlane,
                                far_plane=postvs.farPlane,
                                width=viewport.width,
                                height=viewport.height
                                )
        batch_csv_to_fbx(export_dir, begin_eid, end_eid, 2, 0, [6], save_from_input=False, save_from_output=True, camera_data=camera_data)

从源码运行

从github下载zip解压或使用git clone该仓库

git clone https://github.com/Ziur02/reverse_tool.git

安装相应版本的python解释器

该项目的renderdoc与fbx sdk均是为python3.10版本构建的,所以必须使用python3.10才能够运行

使用python -V查看当前python版本

PS python -V
Python 3.10.14

如果输出为Python 3.10.x,可以正常使用该工具

如果你现在拥有python 3.8即以上的版本,但是现在没有一个合适的管理python版本的工具,可以使用uv(这里尝试了一些管理python版本的工具,在各种工具中,uv是安装起来最方便的,其他或多或少都要使用到pip以外的下载方式或者修改全局变量)

使用pip安装uv

pip install uv==0.2.37

使用uv安装3.10版本的python解释器

uv python install 310

创建并使用venv

为了更好地管理不同项目的不同的依赖项,建议使用python虚拟环境,这里使用python官方支持的venv创建虚拟环境,也可以自行使用其他方式创建虚拟环境

对于全局python版本为3.10.x的用户:

python -m venv .venv

对于uv用户:

uv venv --python 310 --python-preference managed 

创建venv后,windows用户运行.venv\Script\activate即可激活该环境,或者在vscode中选择使用该虚拟环境的python解释器

.venv\Scripts\activate

安装依赖

依赖项在requirements.txt,使用pip进行安装

确保该环境中有pip

python -m ensurepip

安装依赖

python -m pip install -r .\requirements.txt 

运行reverse_tool_core中的代码

进入src文件夹

cd src

使用python -m <package>就可以执行该package__main__.py的代码

python -m reverse_tool_core

代码提示与补全功能

该项目使用vscode开发,关于vscode的配置已经放在.vscode\settings.json,在vscode python插件开启的情况下即可正常获取代码提示与补全功能,如果使用其他ide进行开发,需要在分析文件时将stub_files文件夹包含在内,这个文件夹内是renderdoc的python模块与fbx python sdk的python存根文件

reverse_tool's People

Stargazers

Dong Yuyang avatar

Watchers

Zhiyuan Li avatar

Forkers

ayuuumelon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.