3DS file exported to OBJ from Blender… materials not showing

I have a 3DS model which I imported into Blender and then successfully exported as a .mesh.xml file and a .material file.

However, in my scene, the model only has the flat color of the single AmbientLight in my scene.

If I set the light red, I get a red model. If I set it white, I get a white model. If I omit the light, the model is pitch black.

I know that the .material file was found and read by JME, as if I rename that file, I see a new error message appear claiming that it cannot be found.

I see that my materials all have Ambient settings as 1,1,1,1 as follows:

material deck

{

receive_shadows on

technique

{

pass

{

ambient 1.000000 1.000000 1.000000 1.000000

diffuse 0.624314 0.520784 0.106667 1.000000

specular 0.500000 0.500000 0.500000 1.000000 12.500000

emissive 0.000000 0.000000 0.000000 1.000000

}

}

}

I have this code to load my model:



AssetManager a = getAssetManager();

Node n = (Node) a.loadModel(Sim.ASSET_MODEL_DIR + filename + “.mesh.xml”);

Material mat = new Material(a, “Common/MatDefs/Light/Lighting.j3md”);

mat.setBoolean(“UseMaterialColors”, true);

/* I’ve tried various combinations of these… not sure I should even be using the lighting material at all

these should be coming from the LIGHTs, yes?

mat.setColor(“Ambient”, ColorRGBA.White);

mat.setColor(“Diffuse”, ColorRGBA.White);

mat.setColor(“Specular”, ColorRGBA.White);

*/

for (Spatial s : n.getChildren()) {

if (s instanceof Geometry) {

Geometry g = (Geometry)s;

TangentBinormalGenerator.generate(g.getMesh(), true);

g.setMaterial(mat);

}

}

return n;



How do I create a Spatial of my mesh that shows its materials properly?

tone

What’s definitely your problem?I can’t see anything wrong in your that code. Any screeshot? Also, why are you generating tangent binormals to that model, it has some normal/parallex map map?..I think it’s not needed.

You talk about OBJ in your topic title, yet you don’t mention it anywhere else; instead you’re talking about what I can only assume is OgreXML exports. Try to export your 3DS model with the free version of OgreMax instead of adding Blender to the mix.

I see you have some diffuse color specified as well so that couldn’t be a problem. Also you’re not using normal mapping so there’s no need to generate tangents/binormals.

Probably you want to make sure your normals is correct

I know nothing of what the model has/lacks as regards normals. I have not opened a 3D editor on any of my models in years and hardly have the know-how (I modeled in Rhino3D long ago… this 3DS model is actually from someone else – I only know that I did see it with materials in place in my ancient runtime based on WildTangent Web Driver). It DOES have the material on it when seen in Blender OR in SketchUp. I just need to know how to export it from either tool so it works.



Here is a version derived from this .3ds years ago in Web Driver:

http://dreadnoughtproject.org/tfs/images/9/94/SimBattleshipUnderFire_512.jpg

Here it is in JME3 (see from within … it is uniformly black throughout):

http://i.imgur.com/vbZ1T.png



OgreMax not an option, as I use a Mac and just want to convert my existing assets first.



tone

I uploaded a copy of this 3ds file to:



http://withthefleet.com/Kaiser/



if anyone cared to load it. If you can convert it to a form that displays correctly without using Windows, I’d love to know the “how to”. I have so far tried exporting from SketchUp and Blender without success.



if your means of doing this requires Windows and generates human-readable files (e.g., XML and OBJ), it might be conceivable that I could write a tool to convert what I can generate into these workable forms.



Thanks in advance.



tone

I just imported your .3ds file into blender 2.59, installed the BlenderSupport plugin for jmp, imported the .blend model into jmp by using the ModelImporter plugin, it was automatically converted to .j3o, and after that i loaded it in OpenGL Window(SceneViewer)…no problems here…

I tested it with Blender 2.49 and Blender 2.59 and it works fine for me. I used the appropriate OgreXML export scripts

Momoko_Fan, can you email me the output files exported from Blender?

I want to diff them against my own.



Is it also possible to paste in your JME code that places a properly-material-showing version of those output files?



Thanks.



tone

Should I be using Blender 2.49b or the latest?



JMP offers a means of installing OgreXML stuff suitable for an unstated version of Blender – and then fails to do the right thing although I finally found the pop-under window that can ultimately locate the Blender scripts window (note: the scripts window moves from Resources/.blender under 2.49b to MacOS/2.59 under 2.59).



However, then from within Blender 2.59, none of the documentation for having Blender actually update the menus appears applicable – the “Python console” (nee “Script Window”) has no menu and thus no “update menus” function. I am starting to see Blender 2.59 as not ready for this. I am going to try reverting to Blender 2.49b and try again from there.



BTW, my previously exported .mesh.xml version of the model which is pitch black in my app looks fine in JMP. I suspect that my model is fine, but I need to see someone’s minimalist but complete JME code that puts it into a scene with its material not showing as a flat color. For instance, I simply don’t understand why my app should be applying a “Lighting” material to the model – isn’t the color of the lighting supposed to be taken from the JME3 Lights within my scene?



tone

DulcetTone said:
Should I be using Blender 2.49b or the latest?

Both should work with the latest nightly.

DulcetTone said:
JMP offers a means of installing OgreXML stuff suitable for an unstated version of Blender -- and then fails to do the right thing

Remember that jMP follows a crash by design approach

DulcetTone said:
However, then from within Blender 2.59, none of the documentation for having Blender actually update the menus appears applicable -- the "Python console" (nee "Script Window") has no menu and thus no "update menus" function. I am starting to see Blender 2.59 as not ready for this. I am going to try reverting to Blender 2.49b and try again from there.

Look up on how to install add-ons/scripts for Blender 2.5, the docs are there.

DulcetTone said:
BTW, my previously exported .mesh.xml version of the model which is pitch black in my app looks fine in JMP. I suspect that my model is fine, but I need to see someone's minimalist but complete JME code that puts it into a scene with its material not showing as a flat color. For instance, I simply don't understand why my app should be applying a "Lighting" material to the model -- isn't the color of the lighting supposed to be taken from the JME3 Lights within my scene?

You aren't supposed to apply any material. To me it seems that the light you added isn't proper, or that you're using an outdated version of jME3

Ok, I have isolated the problem somewhat.



I removed all my use of adding materials to my object in code (this was a misapprehension on my part in reading a tutorial). This does not solve the issue, however, and I’d tried it before.



So I started methodical experiments.


  1. My scene accepts the stock Ninja nicely and he looks as he should when my object looks terrible.

    So I started looking at differences in the material file for both.


  2. Giving one of my object’s materials the same settings as the Ninja used gave parts of my model a green ninja- like look.


  3. Removing the Ninja.jpg texture from that material then gave that part of my model a different look, but it was NOT the same as the pure black model.


  4. By trial and error, I determined that any ambient value in a material OTHER than “0 0 0 1” or its floating point equivalents produces the defective all-black or all-white model (depending on lighting in the scene).


  5. Modifying all the materials for my model so that all their ambient maps read “0 0 0 1” produces a fairly dark, but properly colored model. There is some problem with JME materials reading this ambient line.



    I am using a single nightly from Aug 29 2011. Perhaps the issue is a short-lived defect in JME and I should refresh? I can work toward using regular nightlies, but will first try a single static refresh of JME3 to the most recent nightly and see if my material file can be restored to its “as exported” form.



    tone

The issue with the ambient color is really strange. Try some of the jME3 tests like TestUnshadedModel, this one uses AmbientLight and ambient color to shade the model. Another test that uses AmbientLight is TestSpotLight

Problem solved. I was setting the intensity of the ambient light way high – like to 50 50 50 50



I will read more about setting the RGBA color for the lights. I am converting code that used to regard these fields on 0-127 or 0-255 I think.



This would have been very difficult to figure out had the Ninja not had ambient values of “0 0 0”!



tone

1 Like

it was pain in the neck for me!
ride bood be asabam…