1

I have a program which is able to parse and interprets OBJ file format in an OpenGL context.

I created a little project in Blender containing a simple sphere with 'Hair' particles on it.

After conversion (separating particules from the sphere) my particles form a new mesh. So I have two meshes in my project (named 'Sphere' and 'Hair'). When I want to export the mesh 'Sphere' in an OBJ file (File/export/Wavefront (.obj)), selecting 'include Normals', after exportation, the file contains all informations about normals (ex: vn 0.5889 0.14501 0.45455, ...).

When I try to do the same thing with particles, selecting 'include Normals' too, I don't have normals in the OBJ file. (Before the exporting I have selected the right mesh.)

So, I don't unsterstand why normals properties are not exported for mesh of type particles.

Here's above the general Blender render of my hair particules. As you can see all particules have a reaction with the light. So Blender use normals properties for thoses particules.

enter image description here

And now, the picture above shows (in Blender 'Edit mode' -> after conversion) that particules are formed of several lines. In my opengl program I use GL_LINES to render the same particules. I just want to have normals information to manage light properties on my particules.

enter image description here

Do you have an idea how to export normals properties for particules meshes?

Thanks in advance for your help.

user1364743
  • 5,283
  • 6
  • 51
  • 90
  • Are particles in this situation described by points? If so, why would they have normals? – Jacob Parker Mar 16 '13 at 15:49
  • Possibly relevant http://blenderartists.org/forum/archive/index.php/t-147629.html – Jacob Parker Mar 16 '13 at 15:51
  • Yes I have already see this page and my hair particules are already converted in OBJ file but without normals informations. My particules, are discribed by lines (a hair is formed by several small lines). So I think it's possible to have normals properties (I believe that a line (GL_LINES) is a tiny polygon and all polygons in OpenGL should have normals properties). What do you think about my point of view ? Thanks – user1364743 Mar 16 '13 at 16:01
  • Ah, missed the bit about hair. I'm guessing this is for a good reason in Blender, and I explained more in my answer below (it didn't want to fit in a comment :)) – Jacob Parker Mar 16 '13 at 16:27

1 Answers1

3

You are trying to give normals to lines. Let's think about what that means.

When we talk about normal vectors on a surface, we mean "pointing out of the surface"

surface normals

For triangles, when we define one side to be the "front" face, there is exactly one normal. For lines, any vector perpendicular to the line counts as a normal - there are infinite and any one will "do".

What are some reasons we care about normals in graphics?

  • Lighting: e.g. diffuse lighting is approximated by using the dot product of the normal with the incident light vector. This doesn't apply to hair though!
  • Getting a transformation matrix: for this you can pick any normal (do you want to transform into hair-space?)

In short: you either can pick any perpendicular vector for your normal (it's easy to calculate this) or just not use normals at all for your hair. It depends on what you are trying to do.

Jacob Parker
  • 2,546
  • 18
  • 31
  • Tanks for this answer. As you can see it above Blender uses Normals to display its particules because when I move my model all hairs have a reaction with light properties. So, maybe the Blender exportation script does not include the normals properties for particules exportation. Furthermore if I use in my openGL program the method glLineWith(10.0) you could see that lines look like planes (so a line is a polygon) So in this case I will calculate them, of course. But have you already use Blender for this kind of work ? – user1364743 Mar 16 '13 at 16:36
  • 1
    To light hair you want the normal that is on the same plane as the line segment you are lighting and the light ray. In virtually all cases there is such a normal. You can then light as normal. However, this changes based on your hairs position, the light position etc. so you can't store it in the .obj directly. – Jacob Parker Mar 16 '13 at 16:39
  • Ok so I'm going to compute my own normals. Thanks for your answers. – user1364743 Mar 16 '13 at 16:45
  • 1
    You will need to compute them *for each light* and *for each camera position*. A common OpenGL approach is to upload the vector for the line segment and calculate the normal in a vertex shader. (p.s. if my answer solved your problem, please "accept" it :) ) – Jacob Parker Mar 16 '13 at 16:47