Problem with lighting of a loaded obj-model


i’ve finally managed to export a .obj from blender and import it into jME, but because of any reason it doesn’t show any reaction to the light. (i’m using the default setup of SimpleGame … and just added the model to the scene with and without an applied material and texture … but the model has the same color on every vertex, no matter if there is light or none … (imo it should be darker on the side where no light was added… at least it works with a Box)

Is there any option i have to set so it reacts on lights ? or something ?

btw. there is a small typo in the ObjToJme converter:

        } else if ("Ks".equals(parts[0])){
            curGroup.m.setSpecular(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));
        } else if ("Ks".equals(parts[0])){

imo the second one should be "Ns" .. ( line 181)

Herbert Poul

Seems like you find a bug…

as long as normals are set, objects will react to lights. Are you certain the normals are set up? How are you seeing the object? Is it full brightness or dimly lit from the ambient lighting?

You can press ‘L’ to turn lighting on and off in SimpleGame, although it’s on by default.

Does the obj file define normals?

Strange typo you found there. I’ll look at it.

yes, normals are defined in the .obj file.

i made a screenshot of it: … the blue "ship" is loaded from the .obj file.

you can also take a look at the .obj file: (replace .obj with .mtl for the material definition)

if i deactivate lighting the only change is that it gets totally white…

another strange thing is, that with lighting on the blue changes to white sometimes depending on the camera rotation/position … this looks like: (i have not changed anything on the lighting … just moved/rotated the camera)

things I can think (in general in a 3d file producing this in any software)

  • shininess value 0 or close to 0. (an dof course, specular set to full white)

  • emissive value very high: white or close.

  • some ambient lighting in the engine code set to maximum.

    Normals can be there (of course, could be it not computing normals, but I suspect mre the above…) but with those extreme values can’t be apreciated.

    Those settings, if I remeber well, are stored in the mtl file, unless the engine puts random or initializated ones when it does not find the mtl and texture in same folder.

    as you mtl is also like obj an ascii file. You can write perfectly and edit the mtl file. though this is usually handled in your 3d app; sure you have a way to set the material not with those problems. If it’s averagely good, it must allow it…

    but u can see the values now in the mtl, and try writting emissive to full balck, shininess to 124 or 115, as u prefer, specular to black even though that’s a bit mor edrastic.

shininess is 96.0784313725

emissive value is the default value … 0,0,0,1

it seams that the emissive value is not supported by the .obj format ? it is not mentioned in the .obj file which i exported from blender… and there is nothing in which could set the emissive value…

i have no idea if the normals are correctly exported into the .obj file… don’t know how i should test them … but at least there are normals in the .obj file


a mtl generated by Ultimate Unwrap (a comercial converter)

Wavefront MTL file generated by Ultimate Unwrap3D

num_materials: 1

newmtl mat
Ka 0.000000 0.000000 0.000000
Kd 0.941177 0.647059 0.349020
Ks 0.000000 0.000000 0.000000
d 1.000000
illum 2
Ns 0.968750

# num_materials: 1

That's all.

Later on I'll see to put you the specs of each value (what is what)

Use ideaman plugin for OBJ, better :)

You can write manually your mtl

Honestly, I don’t really know why your obj isn’t loading, but I did compare it with the maggie.obj file and one difference I see is slight formatting differences:

maggie.obj -

usemtl MAGGIE_yellow_0

f 463//1429 332//1430 464//1431

your obj file -

usemtl Material

usemat SCshipmytest.PNG

f 1185/1/1 1812/2/2 1813/3/3

your f values contain a single ‘/’ and three values, maggie.obj contains ‘//’ and two values? Or ‘/’ and three values with the center value empty… not sure, but it might be enough of a difference that our exporter doesn’t handle the case properly.

Try taking the maggie.obj and importing it into AC3D, saving, then exporting it back out to obj, see if it still loads properly.

Sorry, can’t help any more than that, but I don’t know much about the obj exporter.

there it explains very well.

OK, next paragraph is from the thread of OBj export plugin…I use dthat one instead the one with Blender 2.35.

" Importer now imports inline ‘usemap’ keywords to assign UV textures, MTL export has changed a bit.

Bugfix where only the last object had materials applied to it was fixed.

Exporter now exports MTL files, as well as UV image textures.

Its now possible to export a large scene with materials and UV mapping/images

And import it- keeping all the properties supported by obj. "

An uv mapped sphere, with material and texture…

newmtl Material

Ns 96.078431

Kd 0.756191 0.756191 0.756191

Ka 1.000000 1.000000 1.000000

Ks 1.000000 1.000000 1.000000

d 1.000000

illum 2

newmtl Material.001

Ns 96.078431

Kd 0.800000 0.800000 0.800000

Ka 1.000000 1.000000 1.000000

Ks 1.000000 1.000000 1.000000

d 1.000000

illum 2

hmmm…I start to understand…

ambient is too high…

1.0, while the specs advice 0.2,0.2,0.2…

Some engines and 3d softwares read ambient (Ka) = 1 as a self illuminated thing…

NS is shininess…hmm…I’d try a 124 value, instead of 96…even I’d say, 128…

Ks is the specular color…ok, is pure white but that should not affect…

If u wanna try to see if specular are wasting you a bad joke, put illum 1 , which means no speculars at all, just pure good volume shading :slight_smile:

oops…blender skipped to export the texture file name…hmm…can add manually, though ,but… I think it’s this…

" map_Ka filename "

As i don’t know if Blender undesrtand well the obj shininess value, u could try with 0 value, too…but imho that’s indeed what would output a non shaded over illuminated mesh…I use to use 124 , 125, 128.

Also, make sure your OBJ is refering the mtl file somewhere, in that same url explains at the beguining how it must be read…

I guess is one of this problems, unless there’s some problem in the ambient lighting of objs or something in jME, whcih I doubt. Try these settings.

btw, Blender2.35 obj export I obtain here with IDEASMAN OBJ script, is this kind :

mtllib esfera.mtl

o Sphere_Sphere

v 0.740907 -7.761749 -1.407404

v 0.875552 -7.734967 -1.387040

v 1.007590 -7.708703 -1.353318




vt 0.0 0.0 0.0

vt 0.0 0.0 0.0

vt 0.0 0.0 0.0

vt 0.0 0.0 0.0




vn 0.172441 -0.973843 -0.079131

vn 0.173830 -0.973163 -0.080640

vn 0.181260 -0.972567 -0.070669




usemtl Material.001

f 63/1/1 1/2/2 994/3/3

f 994/4/4 1/5/5 2/6/6 993/7/7




f 351/1604/1604 396/1605/1605 397/1606/1606 350/1607/1607

f 350/1608/1608 397/1609/1609 398/1610/1610 349/1611/1611

f 349/1612/1612 398/1613/1613 399/1614/1614 348/1615/1615




Ultimate Unwrap one :

Wavefront OBJ file generated by Ultimate Unwrap3D

num_vertices: 130

num_vertex_normals: 130

num_uvs: 544

num_faces: 144

num_groups: 1

mtllib cap.mtl

v 0.000000 -8.000000 0.000000
v -0.585786 -7.695518 1.414213
v -1.082392 -7.695518 1.082392
vn -0.000000 -1.000000 0.000000
vn -0.146260 -0.924082 0.353102
vt 0.062500 0.250000
vt 0.062500 0.750000
g Capsule

usemtl mat
f 130/1/130 114/2/114 113/3/113 129/4/129
f 129/5/129 113/6/113 112/7/112 128/8/128
f 128/9/128 112/10/112 111/11/111 127/12/127

and the only clear difference with Milkshape obj export is that ms3d supports smooth groups (look at that "S")



g default

s 1

f 63/1/1 1/1/2 994/1/2

f 994/1/2 1/1/2 2/1/3

f 994/1/2 2/1/3 993/1/3

f 993/1/3 2/1/3 3/1/4

As you see, the double slash "//" is indeed not very frequent…

bingo…many people use 3d exploration/or newer deep exploration…I have the old shareware 3d exploration 1.5, which did not canceled after 30 days…(only a remind me later message…)


f 342//342 376//376 350//350

Maybe magpie was converted with that one…

one of th emany pages about specs, but not finding a very good a compelte one I had long ago…

hey…at wostsit format vault…the pdf explains the difference… :

"B1 - 16 Object Files (.obj)

Referencing groups of vertices

Some elements, such as faces and surfaces, may have a triplet of

numbers that reference vertex data.These numbers are the reference

numbers for a geometric vertex, a texture vertex, and a vertex normal.

Each triplet of numbers specifies a geometric vertex, texture vertex,

and vertex normal. The reference numbers must be in order and must

separated by slashes (/).

• The first reference number is the geometric vertex.

• The second reference number is the texture vertex. It follows

the first slash.

• The third reference number is the vertex normal. It follows

the second slash.

There is no space between numbers and the slashes. There may be

more than one series of geometric vertex/texture vertex/vertex

normal numbers on a line.

The following is a portion of a sample file for a four-sided face


f 1/1/1 2/2/2 3/3/3 4/4/4

Using v, vt, and vn to represent geometric vertices, texture vertices,

and vertex normals, the statement would read:

f v/vt/vn v/vt/vn v/vt/vn v/vt/vn

If there are only vertices and vertex normals for a face element (no

texture vertices), you would enter two slashes (//). For example, to

specify only the vertex and vertex normal reference numbers, you

would enter:

f 1//1 2//2 3//3 4//4

When you are using a series of triplets, you must be consistent in the

way you reference the vertex data. For example, it is illegal to give

vertex normals for some vertices, but not all.

The following is an example of an illegal statement.

f 1/1/1 2/2/2 3//3 4//4

Object Files (.obj) B1 - 17



The following syntax statements are listed in order of complexity of


p v1 v2 v3 . . .

Polygonal geometry statement.

Specifies a point element and its vertex. You can specify multiple

points with this statement. Although points cannot be shaded or

rendered, they are used by other Advanced Visualizer programs.

v is the vertex reference number for a point element. Each point

element requires one vertex. Positive values indicate absolute

vertex numbers. Negative values indicate relative vertex


l v1/vt1 v2/vt2 v3/vt3 . . .

Polygonal geometry statement.

Specifies a line and its vertex reference numbers. You can

optionally include the texture vertex reference numbers.

Although lines cannot be shaded or rendered, they are used by

other Advanced Visualizer programs.

The reference numbers for the vertices and texture vertices must

be separated by a slash (/). There is no space between the number

and the slash.

v is a reference number for a vertex on the line. A minimum of two

vertex numbers are required. There is no limit on the maximum.

Positive values indicate absolute vertex numbers. Negative values

indicate relative vertex numbers.

vt is an optional argument.

vt is the reference number for a texture vertex in the line element.

It must always follow the first slash.

f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 . . .

Polygonal geometry statement.

Specifies a face element and its vertex reference number. You can

optionally include the texture vertex and vertex normal reference


The reference numbers for the vertices, texture vertices, and

vertex normals must be separated by slashes (/). There is no space

between the number and the slash.

v is the reference number for a vertex in the face element. A

minimum of three vertices are required."

Resuming all my span in two lines…

-or is a bad value in the MTL…as i explaiend first…which is causing an over-lit effect to kill th evolume…

-or is that…as says in the green text, from the obj specs…

…it’s just that the polygon tag, f, defines f v/vt/vn v/vt/vn v/vt/vn

being v = vertex, vt = texture vertex, vn = vertex normal

So, magpie maybe just lacking vt! That’s why the double slash…funny…

and then…

“If a face has a texture map assigned to it and no texture vertices are

assigned in the f statement, the texture map is ignored when the

element is rendered.”

hmmm…maybe not having the mtl really asigned to any vertex it can’t take the mtl settings? hmmm…no…it says texture map, clearly, not mtl…

Well, enough brain storming for me…was curious…

vt is an optional argument.

vt is the reference number for a texture vertex in the face element.

It always follows the first slash.

vn is an optional argument.

vn is the reference number for a vertex normal in the face element.

It must always follow the second slash.

Face elements use surface normals to indicate their orientation. If

vertices are ordered counterclockwise around the face, both the

face and the normal will point toward the viewer. If the vertex

ordering is clockwise, both will point away from the viewer. If

vertex normals are assigned, they should point in the general

direction of the surface normal, otherwise unpredictable results

may occur.

If a face has a texture map assigned to it and no texture vertices are

assigned in the f statement, the texture map is ignored when the

element is rendered.

NOTE: Any references to fo (face outline) are no longer valid as of

version 2.11. You can use f (face) to get the same results.

References to fo in existing .obj files will still be read, however,

they will be written out as f when the file is saved.

well, maggie does not have a texture applied, just materials defining hair, face, eye, pacifier color, etc. So, that must account for the //

I’ll look at the obj tonight. With any luck, the solution won’t be too difficult.

yup, that’s why there does not appear vt coords.

< lol… that sounded too redundant… >

i don’t think it’s much about the material, because i tried to modify ObjToJme so it does not apply any material/texture at all … but it didn’t change anything … (except that it wasn’t blue anymore of course … but still no reaction on lights)

Something’s not letting it do normals. I didn’t have time last night to look at it, but I’ll try tonight. If you could do me a favor, convert the .jme to XML and either post the XML or link it so I could look at it. From looking at the XML I can tell what it is or isn’t loading correctly.