Importing Blender .obj with material

Hi,

Currently Im trying to import a .obj model  made in Blender, however Im having some difficulty with the

Not sure about the material part, but the reason it is something a trimesh and sometimes a node depends on how many meshes are in your model file.  Normally the importer creates a Node and attaches all of the meshes to it, but if there is only one mesh, it will skip creating the node and just return that one mesh.  Where it might seem confusing is that you may think you only have 1 mesh when in truth, your exporter will usually create a mesh per material/texture used.  (So in this case it's probably creating a mesh for the red portion and a mesh for the purple portion of your model.)

renanse said:

Not sure about the material part, but the reason it is something a trimesh and sometimes a node depends on how many meshes are in your model file.  Normally the importer creates a Node and attaches all of the meshes to it, but if there is only one mesh, it will skip creating the node and just return that one mesh.  Where it might seem confusing is that you may think you only have 1 mesh when in truth, your exporter will usually create a mesh per material/texture used.  (So in this case it's probably creating a mesh for the red portion and a mesh for the purple portion of your model.)


You're correct! I "accidently" found out while continuing to fix my "inside-out-material"-problem

I've discovered something else too. When I create a Mesh, like the default box or plane and add a colour(material) to it, it shows the materials correctly in JME.

However! Whenever I remove all vertices but one and add my own vertices (for instance, to draw my own custom model) and fill up the vertices with a face, the face shows the material in Blender but doesnt show in JME. I have a hunch, creating your own mesh from scratch causes it to be inside out for some strange reason. When I extend the default mesh (and make sure the original face is preserved) the problem appears to be gone. Im still guessing im doing something wrong though :P

I think that your normals might be flipped, or the material is only applied to FRONT_FACE so it appears inside out.

You need to either flip the normals or change the material settings to be applied to both front and back faces.

Momoko_Fan said:

I think that your normals might be flipped, or the material is only applied to FRONT_FACE so it appears inside out.
You need to either flip the normals or change the material settings to be applied to both front and back faces.


You win the jackpot!  :D

Flipping normals seems to fix it. A shame the Blender tutorial didn't handle this.


One last question, the tutorial that imports a obj model uses a boundingbox as modelbound. My model has alot of curves but a boundingsphere is too inaccurate. Does JME also supply some kind of boundingobject that fits arround the model?

Maybe just try creating your own low-poly mesh and using that as the bounding mesh (I think this is possible for jME).



Hint: careful about normals from the beginning, normals on complex models can sometimes be a pain to correct.

basixs said:

Maybe just try creating your own low-poly mesh and using that as the bounding mesh (I think this is possible for jME).

Hint: careful about normals from the beginning, normals on complex models can sometimes be a pain to correct.


Hint noted! Unfortunatly I had to find out the hard way.

Creating my own low-poly mesh sounds perfect. I'll look into the examples, when I find something i'll update my post for anyone that might also be interested in it.

Edit: Found an article on the wiki about models and boundingvolume but the article only speaks of BoundingBox of BoundingSphere, nothing about a custom BoundingModel. As far as a I can tell JMETest doesnt contain anything usefull either. Am I just plain blind or does this mean I'd have to extend my own BoundingVolume class which uses a low-poly mesh? If at all possible...

You can view the normals in Blender using an option in the edit buttons menu, then you wouldn't have to experience the pains of fixing them after you find that the model doesn't work :stuck_out_tongue:

In general it is quite important to make sure your normals are facing the correct way, are functional, etc, when making models for games/realtime rendering as issues might not appear during renders and previews in the modeling tool.


One last question, the tutorial that imports a obj model uses a boundingbox as modelbound. My model has alot of curves but a boundingsphere is too inaccurate.

That's usually not an issue. The bounding volume is used mostly for determining if the model is inside the camera frustum or not. If you need a more accurate method of collision detection you can use triangle-accurate collision detection in jME.
Am I just plain blind or does this mean I'd have to extend my own BoundingVolume class which uses a low-poly mesh?

That actually would probably be a pretty slick solution, you could send the mesh (it would have to be a single trimesh) in the constructor; HOWEVER there might be some rather large ramifications to other areas.  Could a developer step in and answer if this is possible (or even recommended)?

I would like to know that too, yes! :slight_smile:

Still curious!  :smiley:

Actually, me too.  I think it may be a dumb idea on my part though.  If the bounding geometry is too complex, then just trying to find if it lies inside the camera frustum may be a non-trivial task.

Well the reason im interested in it because of colission detection. My model has multiple area's which require a "unique" bounding box. A sphere can't be used because some area's are bigger than others and overlap smaller ones. I haven't tested this yet, so maybe im talking bs but as far as I can see with BoundingBoxes enabled,is that everything is one big block of boundingbox terror! :stuck_out_tongue:

For that, I would just create a (very low-poly) physics model; and attach the real model to it.  You will have to use DynamicPhysicsNode.generateGeometry( true ) but it should be okay, remember though that generally the bigger and fewer number of triangles the better when using trimesh physics geometry.

basixs said:

For that, I would just create a (very low-poly) physics model; and attach the real model to it.  You will have to use DynamicPhysicsNode.generateGeometry( true ) but it should be okay, remember though that generally the bigger and fewer number of triangles the better when using trimesh physics geometry.


I fail to see the connection between physics and colission detection/Alternative to a primitive boundingvollume. Could you please elaborate? :)

Well, I guess I made an assumption that you were using jME_Physics for your collisions.  Physics there are based on the bounding volume or on a single trimesh.

I was just saying, if you were using jME_Physics, that you could create a low-poly model for the collisions, rather than using the bounding volume.

basixs said:

Well, I guess I made an assumption that you were using jME_Physics for your collisions.  Physics there are based on the bounding volume or on a single trimesh.
I was just saying, if you were using jME_Physics, that you could create a low-poly model for the collisions, rather than using the bounding volume.


You assumed correctly that I'm using jME_physics however It hadn't occured to me that it could be used for colission as well.While your idea sounds (to me atleast! :P ) exotic,it's always worth the try.