简体   繁体   中英

Blender Python Object "Grouping"

I'm writing a Blender (2.81) Python Addon which needs to display one mesh in the Viewport (low res) and one for Rendering (high res) (these are plants/trees). I currently create two objects and use the low-res object as the parent of the high-res object. While this is configurable, by default the high-res object is not visible in the viewport and is not selectable. This presents the low-res object to user in the viewport where they can move, rotate, and scale it and have those changes affect the high-res child at render time (and the user doesn't have to think about the high-res object at all).

The challenge I currently have is deleting the parent in the viewport leaves the child in the scene, where I would expect to be able to delete “the tree” by clicking on it in the viewport and pressing X.

Am I thinking about object composition the right way here, or is my brain still stuck in SketchUp land and I need to adjust to think in Blender terms?

Is the Parent/Child mechanism the right approach for this kind of composing?

Should I be using a custom collection to contain the two objects instead? (still can't delete with X in the 3D viewport).

For example, in the image below the viewport looks like the upper-left by default. It can be configured to show the high-res in the viewport as in the lower-left, but only the low-res is selectable (in wireframe if the high-res is visible). Either way, only the high-res is rendered as in the lower right:

在此处输入图片说明

With the ability to use an unlimited number of collections, yes, make one to group together your objects. In the outliner you can right click on the collection and choose delete heirarchy to get them all in one go, thats the best you can do.

Objects also have a selectable option, you can make the hires unselectable so that only the lores parent can be selected.

Know that anyone can change these options after your addon has created the object. It is just a choice of what you consider the best way to initially present the objects.

Another possibility to consider is merging them into one object. Two mask modifiers can be used to hide the lores mesh in render and the hires mesh in viewport. Only one vertex group is needed as you can invert the choice in the second mask. You will need to see if this gives the same performance benefit you get from having two objects.

蒙版修饰符

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM