PDA

View Full Version : OBJ export bugs



jonbee
03-25-2014, 07:55 PM
Not entirely sure if this is where I should be posting bugs, but here goes:

A good deal of my work with Lightwave is geared towards content for game engines, and specifically exporting to .obj files as an intermediary format. So, I've noticed a few quirks with the current exporter;

Groups
The group default (g default) is called ahead of vertex declarations and is then overridden by other group declarations making it useless.

Normals
Despite surface settings, normals are always exported as smoothed. A workaround is to unweld all polygons, but that is not the best solution in the world.
The smoothing group option is also turned on (s 1) by default

Materials
Surfaces that no longer contain any geometry are still exported in the .mtl file, taking up space.
Paths are usually not valid. Ex (C:ContentFolder/item.type) should be (C:/ContentFolder/etc...)

jonbee
03-26-2014, 09:18 PM
In response to a request for some sample content, I present the following case study:

Case One: All Points Merged, no Smoothing
121017

####
#
# OBJ File Generated by LightWave3D
# LightWave3D OBJ Export v2.3
#
####
o boxTest.obj
mtllib boxTest.mtl
g default
v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v 0.5 -0.5 0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v 0.5 0.5 0.5
vt 0 -7.45058e-010
vt 0 -2.23517e-010
vt 0 0
vt 0 1
vt 5.55112e-017 1
vt 1 -7.45058e-010
vt 1 0
vt 1 1
vn -0.57735 0.57735 0.57735
vn -0.57735 0.57735 -0.57735
vn -0.57735 -0.57735 -0.57735
vn -0.57735 -0.57735 0.57735
vn -0.57735 -0.57735 -0.57735
vn 0.57735 -0.57735 -0.57735
vn 0.57735 -0.57735 0.57735
vn -0.57735 -0.57735 0.57735
vn -0.57735 0.57735 -0.57735
vn 0.57735 0.57735 -0.57735
vn 0.57735 -0.57735 -0.57735
vn -0.57735 -0.57735 -0.57735
vn 0.57735 0.57735 0.57735
vn 0.57735 0.57735 -0.57735
vn -0.57735 0.57735 -0.57735
vn -0.57735 0.57735 0.57735
vn 0.57735 -0.57735 0.57735
vn 0.57735 0.57735 0.57735
vn -0.57735 0.57735 0.57735
vn -0.57735 -0.57735 0.57735
vn 0.57735 -0.57735 -0.57735
vn 0.57735 0.57735 -0.57735
vn 0.57735 0.57735 0.57735
vn 0.57735 -0.57735 0.57735
g box
usemtl box
s off
f 4/8/1 3/4/2 2/2/3 1/7/4
f 2/8/5 6/4/6 5/3/7 1/7/8
f 3/8/9 7/4/10 6/3/11 2/7/12
f 8/8/13 7/5/14 3/1/15 4/6/16
f 5/7/17 8/8/18 4/4/19 1/3/20
f 6/7/21 7/8/22 8/4/23 5/3/24
The resulting file leaves the smoothing flag turned off (correct), but automatically smooths/averages the resulting normals for each point.

Case Two: All Points Merged - Smoothing On
121016

####
#
# OBJ File Generated by LightWave3D
# LightWave3D OBJ Export v2.3
#
####
o boxTest_smooth.obj
mtllib boxTest_smooth.mtl
g default
v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v 0.5 -0.5 0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v 0.5 0.5 0.5
vt 0 -7.45058e-010
vt 0 -2.23517e-010
vt 0 0
vt 0 1
vt 5.55112e-017 1
vt 1 -7.45058e-010
vt 1 0
vt 1 1
vn -0.57735 0.57735 0.57735
vn -0.57735 0.57735 -0.57735
vn -0.57735 -0.57735 -0.57735
vn -0.57735 -0.57735 0.57735
vn -0.57735 -0.57735 -0.57735
vn 0.57735 -0.57735 -0.57735
vn 0.57735 -0.57735 0.57735
vn -0.57735 -0.57735 0.57735
vn -0.57735 0.57735 -0.57735
vn 0.57735 0.57735 -0.57735
vn 0.57735 -0.57735 -0.57735
vn -0.57735 -0.57735 -0.57735
vn 0.57735 0.57735 0.57735
vn 0.57735 0.57735 -0.57735
vn -0.57735 0.57735 -0.57735
vn -0.57735 0.57735 0.57735
vn 0.57735 -0.57735 0.57735
vn 0.57735 0.57735 0.57735
vn -0.57735 0.57735 0.57735
vn -0.57735 -0.57735 0.57735
vn 0.57735 -0.57735 -0.57735
vn 0.57735 0.57735 -0.57735
vn 0.57735 0.57735 0.57735
vn 0.57735 -0.57735 0.57735
g box
usemtl box
s off
f 4/8/1 3/4/2 2/2/3 1/7/4
f 2/8/5 6/4/6 5/3/7 1/7/8
f 3/8/9 7/4/10 6/3/11 2/7/12
f 8/8/13 7/5/14 3/1/15 4/6/16
f 5/7/17 8/8/18 4/4/19 1/3/20
f 6/7/21 7/8/22 8/4/23 5/3/24
This also leaves the smoothing flag off (wrong), and (correctly now) averages the normals for the points.

Case Three: All geometry unwelded - No Smoothing
121015

####
#
# OBJ File Generated by LightWave3D
# LightWave3D OBJ Export v2.3
#
####
o boxTest_unweld.obj
mtllib boxTest_unweld.mtl
g default
v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v -0.5 -0.5 0.5
v 0.5 -0.5 0.5
v 0.5 -0.5 -0.5
v -0.5 -0.5 -0.5
v -0.5 -0.5 -0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v -0.5 0.5 -0.5
v 0.5 0.5 -0.5
v 0.5 0.5 0.5
v -0.5 -0.5 0.5
v -0.5 0.5 0.5
v 0.5 0.5 0.5
v 0.5 -0.5 0.5
v 0.5 -0.5 0.5
v 0.5 0.5 0.5
v 0.5 0.5 -0.5
v 0.5 -0.5 -0.5
vt 0 -7.45058e-010
vt 0 -2.23517e-010
vt 0 0
vt 0 1
vt 5.55112e-017 1
vt 1 -7.45058e-010
vt 1 0
vt 1 1
vn -1 0 -0
vn -1 0 -0
vn -1 0 -0
vn -1 0 -0
vn 0 -1 -0
vn 0 -1 -0
vn 0 -1 -0
vn 0 -1 -0
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 1 -0
vn 0 1 -0
vn 0 1 -0
vn 0 1 -0
vn 0 0 1
vn 0 0 1
vn 0 0 1
vn 0 0 1
vn 1 0 -0
vn 1 0 -0
vn 1 0 -0
vn 1 0 -0
g box
usemtl box
s off
f 4/8/1 3/4/2 2/2/3 1/7/4
f 8/8/5 7/4/6 6/3/7 5/7/8
f 12/8/9 11/4/10 10/3/11 9/7/12
f 16/8/13 15/5/14 14/1/15 13/6/16
f 20/7/17 19/8/18 18/4/19 17/3/20
f 24/7/21 23/8/22 22/4/23 21/3/24
Technically, there is nothing wrong with this file; However, having to unweld all geometry that you want to remain non-smooth is a bit tedious, especially if you have to modify it at a later time.

madno
03-27-2014, 01:03 AM
Oh boy,
this obj thing goes for years now.
Last time as I remember here:
http://forums.newtek.com/showthread.php?139287
In each new version a little bit is fixed and sometimes new bugs introduced.
I have lost all hope.

Good luck with Alembic.

Ztreem
03-27-2014, 01:52 AM
Make a report in the fogbugz system. Start a new case in the link below and post you findings.
https://fogbugz.newtek.com/default.asp?pg=pgEditBug&command=new

jonbee
03-27-2014, 03:56 AM
I've got a report in the fogbugz system as well ^^

Silkrooster
03-29-2014, 11:30 PM
I thought most of that was fixed when they added support for zbrush. Guess that's what I get for thinking.

madno
03-30-2014, 12:07 AM
Instead of just whining as I did in my first reply I thought I try it in 11.6.1 Build 2727 (Win64).
It seems to me that the smoothing / normals part works.

Jonbee, did you use another version?

121086

madno
03-30-2014, 09:34 AM
I take back what I said above.
There is something wrong with obj export. But it seems to be related to
- when you export
- if you haved saved the object previously
- if LW is freshly started
- or whatever
I don't have the time to test all the combinations but it seems, sometimes the export is correct sometimes it is not.

One example:
- make a box - no smoothing (don't save as lwo) -> export as A.obj
- same box - activate smoothing (don't save as lwo) -> export as B.obj
- same box - deactivate smoothing (don't save as LWO) -> export as C.obj

121091

can somebody crosscheck?

I am not sure but to be on the save side, best seems to be:
- save LWO after a relevant change
- close Modeler
- open Modeler
- load LWO
- then export to obj
that seems to work at least for smoothing

jwiede
04-02-2014, 02:52 AM
One step forward, one step back. OBJ _was_ working quite well right after they put effort into getting it friendly with ZBrush, but there have been regressions since, and lately it's pretty flaky IME. In the big picture OBJ is a fairly basic format, so it's a bit depressing how inconsistent its quality has been in 10 & 11.

bobakabob
04-02-2014, 11:50 AM
I recently could ONLY get a LW -> obj export intended for Maya to open in Zbrush.
This was then exported as an obj and opened fine in Maya.
I was using the second to last release of LW so hopefully obj in LW has been fine tuned.

madno
04-02-2014, 11:13 PM
Another example of exporting a box with 11.6.1 Build 2727:

121144

I assume it is the same with 11.6.2 but have not tested.
It is fogged.