obj2off can't use materials file

5 views
Skip to first unread message

Roger Kaufman

unread,
Mar 23, 2023, 2:42:25 PM3/23/23
to anti...@googlegroups.com
Hi Adrian,

I've tested the materials file which off2obj will generate on various
programs and get no errors.

But obj2off doesn't have the option to read the materials file for
element colors.

Writing a parser that would work for any obj/mtl file pair would be
formidable. These are formated all sorts of ways I've noticed. But on
github is a header file which may make it easy to implement.

Do you see a problem with the permissions that we wouldn't want to use this?

https://github.com/Bly7/OBJ-Loader

Roger

Adrian Rossiter

unread,
Mar 23, 2023, 4:16:15 PM3/23/23
to anti...@googlegroups.com
Hi Roger

On Thu, 23 Mar 2023, Roger Kaufman wrote:
> But obj2off doesn't have the option to read the materials file for element
> colors.
>
> Writing a parser that would work for any obj/mtl file pair would be
> formidable. These are formated all sorts of ways I've noticed. But on github
> is a header file which may make it easy to implement.
>
> Do you see a problem with the permissions that we wouldn't want to use this?
>
> https://github.com/Bly7/OBJ-Loader

The licence is MIT, and so fine. If you use it then it would be useful to
add the licence text at the beginning of the header. Also, it needs to
be included at the end of the COPYING file (which has a special format
https://dep-team.pages.debian.net/deps/dep5/ but look at the other
licenses in this file for an example).

Adrian
--
Adrian Rossiter
adr...@antiprism.com
http://antiprism.com/adrian

Roger Kaufman

unread,
Mar 23, 2023, 7:15:27 PM3/23/23
to anti...@googlegroups.com
OK that one was too hard to use with segfaults even in the demo. I was
putting quite a few fixes in it.

I'll have to look for something else or write something just for what we
need.

Roger

Roger Kaufman

unread,
Mar 24, 2023, 10:30:20 AM3/24/23
to anti...@googlegroups.com
Hi Adrian,

The header file in this project compiles without warnings and has read
all the object files I have tried so far.

https://github.com/tinyobjloader/tinyobjloader

Roger

Roger Kaufman

unread,
Mar 24, 2023, 8:10:27 PM3/24/23
to anti...@googlegroups.com
Hi Adrian,

This was a more productive day. I've learned something about obj files
and my previous code for generating them was incorrect.

obj file can support colored faces but in the form of x y z r g b. The
'p' (for point) items in the obj file I was generating for coloring were
non-functional. They were raising warnings in meshlab and blender. I
changed this to the correct way. Alpha values are not supported.

http://www.paulbourke.net/dataformats/obj/colour.html

There is no facility in the file format for edge colors. I commented out
the code to write edge colors, but there is virtually no chance edge
colors would ever be put into the format. Neither meshlab nor blender
will display edge lines nicely if at all when furnished in a format.

The obj2off program now can read in an obj file with face and vertex
colors being used from the mtl file. The mtl file is specified in the
obj file and is usually the same file name with mtl file type. off2obj
needs to specify this as a parameter since the filename might not be
known. If there is no mtl file specified, obj files can still work but
they will have all plain elements with no color. Even if the mtl is
missing the obj file will still load.

The tinyobjloader.h has a #def to allow it to work without needing to be
compiled to an object file. It only needed one change; it made the
default vertex color 1,1,1 which is now none. There is a comment at the
top of the file about this.

Meshlab will import OFF files directly. It was also import some vrml and
be able to output and OFF but it throws an error with our vrml files.

I think the off2obj and obj2off programs are now correct. I'll wait a
bit and then push these programs.

Roger

Roger Kaufman

unread,
Mar 25, 2023, 6:24:37 PM3/25/23
to anti...@googlegroups.com
Hi Adrian,

On 3/24/2023 8:10 PM, Roger Kaufman wrote:
> I think the off2obj and obj2off programs are now correct. I'll wait a
> bit and then push these programs.

I've pushed this and added tiny_obj_loader.h.

I had a bit of trouble in my branch because the NEWS file had already
been updated and I forgot to do a merge pre my commit. All seems to be
straightened out now.

I put the MIT license at the bottom of COPYING.

I ran obj2off against all the models folder in the tiny _obj_loader
project and found no segfaults. The previous incarnation of obj2off
segfault-ed on the majority of them.

There was an option to triangulate the OFF output but I didn't think
anyone would want that so I didn't make it available.

Roger

Roger Kaufman

unread,
Mar 25, 2023, 8:59:46 PM3/25/23
to anti...@googlegroups.com
I updated the helps to mention line colors are not preserved

On 3/24/2023 8:10 PM, Roger Kaufman wrote:

Adrian Rossiter

unread,
Mar 26, 2023, 10:57:36 AM3/26/23
to anti...@googlegroups.com
Hi Roger

On Sat, 25 Mar 2023, Roger Kaufman wrote:
> I've pushed this and added tiny_obj_loader.h.
>
> I had a bit of trouble in my branch because the NEWS file had already been
> updated and I forgot to do a merge pre my commit. All seems to be
> straightened out now.
>
> I put the MIT license at the bottom of COPYING.

I have pushed your changes. I reviewed the COPYING file, and thought it
might also be an idea to review the debian package build. It had some
warnings, which I fixed. I noticed that COPYING should be the same as
debian/copyright, which it wasn't. I have corrected and synchronised the
files for now. I think a symlink can be stored on github, even if it
doesn't always resolve on a particular system, and this might be a
solution, with COPYING as the real file. Another idea is that the files
in the debian directory are small and rarely change. I could just generate
them from the script I use to build the debian package, and they don't
even need to be included in Antiprism. I could check the script in
instead. I think I prefer this.

Adrian.

Adrian Rossiter

unread,
Mar 27, 2023, 7:26:25 AM3/27/23
to anti...@googlegroups.com
Hi Roger

On Sun, 26 Mar 2023, Adrian Rossiter wrote:
> solution, with COPYING as the real file. Another idea is that the files
> in the debian directory are small and rarely change. I could just generate
> them from the script I use to build the debian package, and they don't
> even need to be included in Antiprism. I could check the script in
> instead. I think I prefer this.

I have removed the debian packaging files from the repository. In the
end, I don't think there is any need to distribute and maintain the build
script, but I am attaching a copy here for reference.
build_debs.py

Roger Kaufman

unread,
Apr 20, 2024, 2:13:02 PMApr 20
to anti...@googlegroups.com
Hi Adrian,

I checked tiny_obj_loader on github and it has been updated. I tested it
against what we use of it.

I have pushed src/tiny_obj_loader.h. The Licence hasn't change.

Roger
Reply all
Reply to author
Forward
0 new messages