Why normal data for vertex is lost when loading model in 3ds format?

I am trying to use JMonkey to do one of my project for my university. I tried to load a 3ds format model to just get started. This is what I have done, I created a simplest cube ever in 3dmax 9 without even applying any material, and export the cube into 3ds format. And I used following code to load the 3ds file


MaxToJme jme = new MaxToJme();
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
try {
   jme.convert(new FileInputStream("cyl.3ds"), arrayOutputStream);
   model = arrayOutputStream.toByteArray();
} catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   System.exit(-1);
}
BinaryImporter binaryImporter = new BinaryImporter();
node = (Spatial) binaryImporter.load(model);





And find out that directional light is not working but ambients seems working okay, so the vertices data is intact. So I try to inspect the normal buffer for the TriMesh of my object, and find out that the NormalBuffer is null. So I figure there must be something wrong with my loading the 3ds file. 

Then I tried to export the same object in obj format, and loaded with jme, than everthing seems working soundly, any reason why 3ds is not working in this case? Thanks very much!

:? Was it just me who run into this situation ?? Well than…

We have had the same problem here at work, and seem to be opting for the same solution as you describe. I have not found a reason why it is this way though, other then that if you export the 3ds file with materials those materials with be loaded with the file in JMe and work with the lighting. This is not a good option for us since we want to change the colour and material properties dynamically.

I haven't been having any troubles with my use of the MaxToJme converter, could it be that your model didn't export right?



Or, have you done anything to your model after you load it from the binary importer? (ie changed the scale, but forgot to update the model bound?).

It turns out that it is a simple thing really. :slight_smile: As most of you probably know already the loading of the 3ds model in JMe gives not one node, but a node hierarchy (I assume this is so you can import files with more then one model, or with skeletons and such). Trying to set material properties on the top level node in the tree generated from the 3ds file will obviously not change the material properties of the model; you have to traverse the tree to the node containing the model. Upon realizing this I successfully changed the material properties of the loaded model as desired.



To me though, it still seems to be mandatory to export the 3ds model with a material to start with in order to get any normals.



Hopefully guruqu solved this on his own a long time ago, being a newbie my self I did not pay attention to the age of the original post, nor that guruqu has never posted more then twice.



Anyway, this will hopefully be of value to some other newbie in the future. :slight_smile:

Ooh, thanks for the info. I am gonna use .3ds to make my game graphics and levels, so this will definitely help.  :smiley:

Wyrlin said:

Hopefully guruqu solved this on his own a long time ago, being a newbie my self I did not pay attention to the age of the original post, nor that guruqu has never posted more then twice.


Here I am  :D. Yes, i kinda solve this problem by using OBJ in the end long time ago. But now I would suggest using OGRE XML format and use OGRE XML Reader to import models exported. Since there are plenty OGRE exporter out there and OGRE XML format is pretty open and neat, and since there is also a OGER XML reader out there for JME already, so , why not.  ;)