Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: FRONT3D Merge objects made of multiple parts #466

Open
eliabntt opened this issue Feb 5, 2022 · 7 comments
Open

[FEATURE]: FRONT3D Merge objects made of multiple parts #466

eliabntt opened this issue Feb 5, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@eliabntt
Copy link

eliabntt commented Feb 5, 2022

Some objects in the dataset are made of multiple parts/have erratic(strange) loadings. It would be neat to merge them and get a single object for every mesh loaded. In that way instance segmentation can work correctly, and the loaded world will have a greatly reduced number of parts.

Working points for this are either _move_and_duplicate_furniture or _load_furniture_objs.

A starting point could be #446.

@eliabntt eliabntt added the enhancement New feature or request label Feb 5, 2022
@eliabntt
Copy link
Author

eliabntt commented Feb 7, 2022

Apparently the merge can also be done here. I must have done something wrong on my first test. I do not have extensive time today to check it.

if len(objs) > 1:
    bpy.ops.object.select_all(action='DESELECT')
    for ob in objs:
        ob.blender_obj.select_set(True)
        bpy.context.view_layer.objects.active = ob.blender_obj
        lo = [ob]
    bpy.ops.object.join()
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
    all_objs.extend(lo)
else:
    all_objs.extend(objs)

seems to work. (probably on the first test I did not change the extend argument)

@themasterlink
Copy link
Contributor

As far as I understand this, this would join all objects, of the same .obj file. Is that correct?

@eliabntt
Copy link
Author

eliabntt commented Feb 7, 2022

Yep, the idea is that you load the obj, if that obj is made of multiple parts then those are joined together and form a single object that is then used in the scene and in the code.

The change of origin should be removed there though. That is only if one wants to add point lights in the right location.

@themasterlink
Copy link
Contributor

I agree, it makes sense to merge all objects from one file. This will make the instance separation easier.

At the same time, we can also check and remove the "shadow" object. A lot of files contain a plane below them to catch the shadow, in BlenderProc we do not need it and could remove it.

@eliabntt
Copy link
Author

Is that easily recognizable? My pc is currently occupied, cannot easily check. I'll be happy to address the changes and reopen the pr.

@kuaitoukid
Copy link

Thank

Apparently the merge can also be done here. I must have done something wrong on my first test. I do not have extensive time today to check it.

if len(objs) > 1:
    bpy.ops.object.select_all(action='DESELECT')
    for ob in objs:
        ob.blender_obj.select_set(True)
        bpy.context.view_layer.objects.active = ob.blender_obj
        lo = [ob]
    bpy.ops.object.join()
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
    all_objs.extend(lo)
else:
    all_objs.extend(objs)

seems to work. (probably on the first test I did not change the extend argument)

This really helps a lot! Thank you!

@eliabntt
Copy link
Author

eliabntt commented Apr 17, 2023

Note that this won't merge small objects like the kitchen furniture, just objects that have sub-parts that can be merged. To make a single "kitchen cabinet" more reasoned processing is needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
3 participants