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

Request: multi-object obj import #182

Open
hamoid opened this issue Nov 28, 2023 · 2 comments
Open

Request: multi-object obj import #182

hamoid opened this issue Nov 28, 2023 · 2 comments

Comments

@hamoid
Copy link

hamoid commented Nov 28, 2023

Is your feature request related to a problem? Please describe.
The issue is described at https://blenderartists.org/t/stop-motion-obj-obj-stl-ply-sequence-importer-v2-1-1/670105/144

Basically, I would like to be able to apply transformations separately to the objects imported in an obj file. Currently they are grouped together and applying something like extrusion affects all o elements in the file.

Describe the solution you'd like
I would like that imported objects are not grouped (as an option).

Describe alternatives you've considered
The suggested alternative is for me to export one sequence per object, then import all the sequences. My only concern is that it is going to be a lot of files on disk, but I guess it should work.

Additional context
Here the test files I have been using. obj-anim-frames.zip

It's an animation of two objects rotating, each with a different material (and different colors).

screen01
screen02

When I Edit -> Extrude, fill (press F) and bevel, both shapes are rendered with the same color. I do not know enough Blender to know where this issue comes from.

screen03

@neverhood311
Copy link
Owner

There are two parts to your post:

  1. Multi-object sequences

and

  1. Issues with multiple materials

Regarding 1, it's been requested before, but I've not had the bandwidth to work on it.
Regarding 2, I inspected some of your meshes in a text editor and noticed that you're defining the material before you define the object, like this:

usemtl Foo1
o obj1
# lists of vertices and lines

usemtl Foo2
o obj2
# more lists of vertices and lines

If you import a single .obj file using the built-in importer, it assigns both materials to obj1 and no material to obj2

If possible, switch the order of the usemtl and o commands, like this:

o obj1
usemtl Foo1
# lists of vertices and lines

o obj2
usemtl Foo2
# more lists of vertices and lines

As far as I can tell, Blender's obj importer expects to have an object defined before you can set its material. I tested this out and it works (the square and the circle have different materials) when you import a single .obj file.
This still doesn't help you with multi-object sequences, unfortunately, since the obj importer seems to be applying the material to all objects in the .obj file. This might also have to do with the fact that you're using 2D lines instead of 3D faces; I've tested multi-material .obj files in the past and they've worked fine.

@hamoid
Copy link
Author

hamoid commented Nov 29, 2023

Thank you very much for your help! :-)

I noticed I was also calling mtllib in the .mtl file instead of the .obj file.

I fixed that and thanks to your tips now loading multiple shapes from disk is working 🎉

Now to do some Python scripting in Blender :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants