4
$\begingroup$

I am trying to reconstruct a cube with normals that look like in the very first animation in the "Introducing normals" part of this article.

If I start out with the default cube, smooth the faces and export it with the following settings:

enter image description here

I get the following wavefront file:

# Blender v2.79 (sub 0) OBJ File: ''
# www.blender.org
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vn 0.5773 -0.5773 0.5773
vn -0.5773 -0.5773 -0.5773
vn 0.5773 -0.5773 -0.5773
vn -0.5773 0.5773 -0.5773
vn 0.5773 0.5773 0.5773
vn 0.5773 0.5773 -0.5773
vn -0.5773 -0.5773 0.5773
vn -0.5773 0.5773 0.5773
s 1
f 2//1 4//2 1//3
f 8//4 6//5 5//6
f 5//6 2//1 1//3
f 6//5 3//7 2//1
f 3//7 8//4 4//2
f 1//3 8//4 5//6
f 2//1 3//7 4//2
f 8//4 7//8 6//5
f 5//6 6//5 2//1
f 6//5 7//8 3//7
f 3//7 7//8 8//4
f 1//3 4//2 8//4

As far as I see it Blender is exporting the 8 vertex normals, which are the pink ones in the image below:

enter image description here

So I wonder about a couple of things:

  1. How to produce normals like the ones in the link above?
  2. Why does blender generate normals with odd values like 0.5773. I would have expected them to be in the range from -1 to 1.
  3. Is there a way to export the faces in a zero based manner?

If I try to render the wavefront output it looks something like this.

enter image description here

With gl.LINES:

enter image description here

$\endgroup$
  • $\begingroup$ Do you need to triangulate the faces? I tested exporting the cube without and the file gives all 1.0, 0 or -1,0 for vn. It also looks like the face normals are inverted? and the triangulation has formed internal faces? Can't tell because I don't have Wavefront. $\endgroup$ – d8sconz Jan 7 '18 at 3:45
  • $\begingroup$ @d8sconz Yes I need to triangulate them for WebGL. $\endgroup$ – チーズパン Jan 7 '18 at 12:04
  • $\begingroup$ Seems like face normals are ignored. You could try manually setting the normals you want as "custom" normals - blender has a relatively crude system for that. If the OBJ exporter does not support that either, you still have the workaround of splitting your cube into 6 separate faces. And if you don't want to do that either, your last option is editing the script, which is fairly easy as it is in python. $\endgroup$ – HENDRIX Jan 9 '18 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.