We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I have some obj-files containing several objects/groups and I have to access the single objects. At the moment i have just one PShape object and am not able to directly access the subshapes of this one, unless I create an extra obj-file for each single shape and load each of them into processing.
I wondered if it is possible to directly load these objects as PShapes into one PShape group object. So i could do something like:
PShape model = loadShape("myObj.obj");
model.getChild("someChild").doSomething();
I couldn't find any way to do this yet. Thanks for any kind of help in advance!
Answers
Hi, each face in the obj file is stored as a separate child subshapes, since the obj format doesn't contemplate a higher-order grouping level, at least as far as I know.
Any other form of grouping that is not face-based would need to be implemented in your code.
If you need to get a PShape that contains all the faces aggregated into a single object, you could call getTessellation() on the root group shape. This method will return a PShape containing all the geometry broken up as triangles.
Thanks for you answer. It is possible to group faces and define objects in obj format by giving them a name via the tags "g [Group name] and "o [Object name]". I can actually see and modify the single shapes i defined in my obj-file when opening it with Blender.
So i guess i have to go with single obj-files for each shape then. Is there any way this could be implemented in the future?
Hello, now that you mention the g and o tags, I realize I was wrong by saying that .obj files only support grouping by face. Right now this functionality is missing in P3D. Could you open an issue about this in the github page, and label it as "enhancement"?
Yes sure, will do that :) But i can't label it as enhancement as i am not a contributor..