Git Product home page Git Product logo

Comments (12)

zhan-xu avatar zhan-xu commented on August 14, 2024 1

Hi, to get the information you will need some parser for your input format. This part is not so elegant and requires some manual check on the parser results (partially due to the inconsistency of different formats of rigged models). That is why I didn't release code for this.

There are some off-the-shelf parsers that I know:
pycollada https://pycollada.readthedocs.io/en/latest/
open3D 0.11.0 supports fbx gltf http://www.open3d.org/2020/10/15/open3d-0-11-0/
assimp: https://www.assimp.org/
and also shipped parser from Blender and Maya.

In my project, I initially use .dae models (collada). I found no parser can be used for all downloaded models. In the end I use pycollada and Maya to get the information, and check the results manually.

I released a Maya script to parse FBX format, as a reference that you can start from:
#8 (comment)
Note the limitation of this code (only for single geometry component, but you can definitely change that).

from rignet.

sunshineatnoon avatar sunshineatnoon commented on August 14, 2024 1

sorry but i don't have a ready-to-use parser for any fbx format. Maybe you can search if there is any latest python library that support it. My maya [script](new link) can only preprocess single component. I am not sure how hard it is to modify it for multiple components. Check Line 160 where I take [0] only and you might start from there. Or you can try if some software or library can convert multiple-component mesh to single-component one.

Thanks for the reply, I ended up using Maya to combine all components into a single component.

from rignet.

artursahak avatar artursahak commented on August 14, 2024

Thank you very much. I tried with .blv or other mocap formats in ascii but got confused. I'll tell you if I make up any other method for this task.
(By the way, I tried something similar to this but on 2d images and then sending coordinates to blender to edit the rigged skeleton automatically), but what you did here is quite impressive.

from rignet.

FishWoWater avatar FishWoWater commented on August 14, 2024

@zhan-xu Hi! I have tried your fbx parser with fbx models downloaded elsewhere. It seems that the texture or vertex color information is lost during the parsing process. Is there any way to restore this information or parse from fbx using mayapy? Also, how can I save obj, riginfo along with texture back into fbx? Can you offer some tutorials / blogs / links about this? Thanks !!!!!

from rignet.

zhan-xu avatar zhan-xu commented on August 14, 2024

Hi. My fbx parser if a very preliminary one and has many limitations. For your question, I think you need cmds.polyEditUV to get vertex UV, and cmds.polyColorPerVertex to get vertex color. In function record_obj, write the UV and color according to OBJ format.

Another possibility is instead of using record_obj, try something like:

cmds.select(geo_list[0]) # select a mesh.
cmds.file(output_filename, force=True, op="groups=0;ptgroups=0;materials=0;smoothing=0;normals=1", typ="OBJexport", pr=True, es=True) # save the selected mesh to OBJ file

There are several options you can choose for parameter "op". You need to figure out which flag to use to save vertex color and uv.

To reassemble rig_info and obj back to fbx, you can use RigNet/maya_save_fbx.py with mayapy. Still, i didn't consider color and texture here, but if your obj file already has that information, I assume they will be loaded when you open the OBJ.

from rignet.

FishWoWater avatar FishWoWater commented on August 14, 2024

Thanks for your quick and detailed reply!!!
I will try that!
Wish you all the best

from rignet.

FishWoWater avatar FishWoWater commented on August 14, 2024

Hi. My fbx parser if a very preliminary one and has many limitations. For your question, I think you need cmds.polyEditUV to get vertex UV, and cmds.polyColorPerVertex to get vertex color. In function record_obj, write the UV and color according to OBJ format.

Another possibility is instead of using record_obj, try something like:

cmds.select(geo_list[0]) # select a mesh.
cmds.file(output_filename, force=True, op="groups=0;ptgroups=0;materials=0;smoothing=0;normals=1", typ="OBJexport", pr=True, es=True) # save the selected mesh to OBJ file

There are several options you can choose for parameter "op". You need to figure out which flag to use to save vertex color and uv.

To reassemble rig_info and obj back to fbx, you can use RigNet/maya_save_fbx.py with mayapy. Still, i didn't consider color and texture here, but if your obj file already has that information, I assume they will be loaded when you open the OBJ.

I was able to use

cmds.file(output_filename, force=True, op="groups=0;ptgroups=0;materials=1;smoothing=0;normals=1", typ="OBJexport", pr=True, es=True) # save the selected mesh to OBJ file

to save the material into .mtl file and load the obj.
But when I tried to get vertex color by

for geo in geoList:
        vtxIndexList = cmds.getAttr(geo + ".vrts", multiIndices=True)
        for i in vtxIndexList:
            print(cmds.polyColorPerVertex(geo + ".vtx[" + str(i) + "]", query=True, rgb=True))
            # print(i)
            # print(cmds.polyEditUV)
            pos = cmds.xform( geo + ".vtx[" + str(i) + "]", query=True, translation=True, worldSpace=True )

in record_obj function, it saied RuntimeError: No components were found to query.
can you give some idea about this bug? I tried to use cmds.select to select the object or vertex but failed. Also , it worked well in edit mode but failed in query mode

from rignet.

zhan-xu avatar zhan-xu commented on August 14, 2024

Hi, I just tried by myself and had the same problem.
I think the first thing is to make sure whether the color comes from vertex color or texture. If they come from texture, you will need to query UV.

Take a look at the this https://gamedev.stackexchange.com/a/66270
Seems Maya is not able to export OBJ with vertex color. Not quite sure about this though.

from rignet.

FishWoWater avatar FishWoWater commented on August 14, 2024

@zhan-xu Got it! Thanks!!!

from rignet.

sunshineatnoon avatar sunshineatnoon commented on August 14, 2024

Hi, to get the information you will need some parser for your input format. This part is not so elegant and requires some manual check on the parser results (partially due to the inconsistency of different formats of rigged models). That is why I didn't release code for this.

There are some off-the-shelf parsers that I know: pycollada https://pycollada.readthedocs.io/en/latest/ open3D 0.11.0 supports fbx gltf http://www.open3d.org/2020/10/15/open3d-0-11-0/ assimp: https://www.assimp.org/ and also shipped parser from Blender and Maya.

In my project, I initially use .dae models (collada). I found no parser can be used for all downloaded models. In the end I use pycollada and Maya to get the information, and check the results manually.

I released a Maya script to parse FBX format, as a reference that you can start from: #8 (comment) Note the limitation of this code (only for single geometry component, but you can definitely change that).

Hi, Could you please elaborate more on how to process meshes with multiple components? Thanks!

from rignet.

zhan-xu avatar zhan-xu commented on August 14, 2024

sorry but i don't have a ready-to-use parser for any fbx format. Maybe you can search if there is any latest python library that support it. My maya [script](new link) can only preprocess single component. I am not sure how hard it is to modify it for multiple components. Check Line 160 where I take [0] only and you might start from there. Or you can try if some software or library can convert multiple-component mesh to single-component one.

from rignet.

siddharthKatageri avatar siddharthKatageri commented on August 14, 2024

Hi @sunshineatnoon, Can you please share your script for converting parsing .fbx files (that handles all the present components)?
Thanks!

from rignet.

Related Issues (20)

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.