Right settings in Blender to properly export? [And fracturing!]

I got this strange bug that makes my models made in Blender (only the complex ones, simple box seem to work properly) missing some faces. After some reading and testing I came to conclusion that some normals are flipped but the funny thing is that:

  • When I export to .obj and load it either directly to my app or to jMe SDK importer I have faces missing.
  • When I load .blend file to jMe SDK importer I get instead (same model) model distorsion (deeper crack here, no crack at all there, etc.).

So how to properly export models so that I can write down settings and never bother again?

P.S. I also had trouble with black models at some point but it seemed to be Blender default black ambient color. After changing it to grey this works fine - would be nice to include this information in tutorials though - took me some time to google this out.

A) Model in Blender.
B) Same Model Loaded through obj in SDK (but looks the same in my app).
C) Same Model Loaded through .blend in SDK.

Did you looked at the wiki ? There is an entire section on how to work with blender.
Also, bether to fix the normals before importing into sdk. If its too complex to fix manually, try some software like MeshLab.

I did click “recalculate normals” in Blender if that’s what You mean. Also have checked “write normals” while exporting. Not sure about Y and Z directions.

http://wiki.jmonkeyengine.org/doku.php/jme3:external:blender

I did look this. Nothing about normals and strange effects I got.

You will need to check face by face to do the “flip normals” in those are wrong.

Ok, this is exactly opposite to what I’m looking for. Is there a way to automate exporting-importing process?

I mean jMonkey is a 3d engine so it has to have some dedicated way of creating assets right? Don’t tell me that such hassle (checking every face separately or slipping assets through several other apps to make them work etc.) is natural… It’s sick…

Additional questions:

  • Is it natural that jMonkey don’t deal well with polygons other than triangles (I have some strange distortions if I don’t transfom my models in Blender into triangle-based ones).
  • Is there a way to modify model “live”? I mean for example I have a box and I want to cut hole through it programmaticaly after being shot (let’s say simple box-shaped hole for the sake of example). Can I do that? Without loading new model with hole in place of one without it of course…

Having a proper method when creating the mesh helps. A good modeler doesn’t end up with faces pointing in all kinds of directions in the first place.

If you edit a model that has been imported as j3o and update the original model (i.e. press save in Blender) the SDK asks you if you want to update the mesh in the j3o file.

See this for some tips on modeling, import etc.

I mean jMonkey is a 3d engine so it has to have some dedicated way of creating assets right?

Jm3 is an game engine, not an 3d modeler, use blender or 3d studio or such software to build your 3d modeler and import in Jm3 in the same way you make music use reason or such software that makes music to import in jm3.
Alternatively you can make 2d games and use appropriate software to build your 2d sprites.

To be honest in the beginning I hoped for completely avoiding jMonkey SDK (I work in JetBrains IDEA anyway - wouldn’t trade this for anything else). But somewhere in Your tutorials I read something about .obj being good only for testing and .j3o being the only REALLY SUPPORTED (like end-user production supported) format so I started using jMe SDK for exporting. It generally works well except for some strange cases when models look like they have dark-grey material right after import (disclaimer - I didn’t make such material) or they deform (which looks like triangulation issue - jMonkey seems to dislike quad+ polygons that Blender on the contrary loves) or they loose faces (which I have absolutely no idea what caused).

As for creating good model… Well literally every high-poly model will have faces pointing in every possible direction. I would even take the bet that no two faces has exact same direction in good detailed model (and Yes, I know high-poly is good only for static stuff).

In the end what bothers me is not having an exact rule of “what goes wrong in what situation” so sometimes I have no idea which thing I forgot.

In the end: What is THE BEST (safest, issue-less, simplest) way of placing models in my application?

  • Blender → .obj → MyApp?
  • Blender → .OGRE → MyApp?
  • Blender → .blend → j3o → MyApp?
  • Blender → .OGRE → j3o → MyApp?
  • Blender → .obj → j3o → MyApp?

And what parameters in Blender I need to take care of?

  • World Ambient Color (that one I know)!
  • Triangulation (that one I 99% suspect)!
  • Some axis switching in .obj export (found some suggestion around here about changing Y Z axis in .obj exporter but didn’t understand a word of it)?
  • Anything else?

The thing with triangles is that all video card will use triangles internally, so any game engines/export use it pre-rendered.
You can use any import process, I use blender → j3o almost every time, I just dont use it when I have animations, if you read in the wiki, you will see what is supported and what is not supported in blender direct import, and when you need to use obj/ogre.
What normen said about better models is that your models probably has lost vertices outside the model or worse problems, if you build an good model, you will not have this kind of problem, I mean, the problem in your model is not the number of faces or where its pointing, but common problem with modeling.

[quote=“wagfeliz, post:9, topic:33281, full:true”]
The thing with triangles is that all video card will use triangles internally, so any game engines/export use it pre-rendered.
You can use any import process, I use blender → j3o almost every time[/quote]
You mean:

  • Blender → .blend → j3o → MyApp?
  • Blender → .OGRE → j3o → MyApp?
  • Blender → .obj → j3o → MyApp?
    In case it matters… And I start to believe everything matters…

What You use in that cases instead?

Actually WIKI tutorials gave me the fake impression that everything I mentioned above is 100% supported. But all those tutorials in wiki also seem to be outdated (some syntax changed from the time WIKI tutorials were created and they are surely not meant for beginners).

Btw. by Blender direct import You mean:

  • Blender → .obj → MyApp?
  • Blender → .OGRE → MyApp?

How can I loose vertice outside the model? I’d have to literally drag some vertex inside-out through some backface of the model. That thing actually happen to people? Would that explain loosing faces in random places (like in my image B few posts above)? There are like few dozen lost faces there if You compare it to A and B (B being deformed because of triangulation which I got rid of now).

P.S. Can You tell me this second thing too (the one about deforming/cuting models inside application programmatically to have some kind of destruction modelling)?

Read the wiki more carefully :

http://wiki.jmonkeyengine.org/doku.php/jme3:external:blender :
Animations for jME3 have to be bone animations, simple object movement is supported by the blender importer, mesh deformation or other forms of animation are not supported.

So, if you use animations, export using ogre for example.

About the modelling, its very possible to have invalid vertices in blender if you delete neighbor vertices for example. This is not the only thing that can happens, you can have duplicate vertices, duplicate faces ( I had problems with this myself at the beginning ), and much other problems. Doing an good 3d modelling for games can be trick, the model cant have any problem with vertices/faces, and you need to care about the number of vertices/faces in order to have an good fps.

About how to deform / change meshs in Jm3, its possible, I have done it myself, there is a few examples here in the forum, also in the wiki, start with http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:custom_meshes

By destruction modelling I thought of something like "cut the shape of model A in model B in position (X,Y,Z).

As for animations, You’re right - I didn’t read that part too carefully, my bad. Although I hoped animating Shoggoth - Wikipedia this guy would be possible. Looks like not really…

I dont know how the model or animation of Shoggoth is, but I can guarantee, with Jm3 anything is possible, actually since you have more freedom, you can do more stuff in Jm3 than the other game engines. I just wrote in my game some stuff that I could not have done in Unit for example.
About destruction, I am doing this in my current dev game myself, some proc generated asteroids, break in also proc generated peaces when the ship shot on it, I will release a demo after 1 month, if you want you can take a look.

If “destruction modelling” means fracturing, it’s definitely possible - After creating the Cubes plugin, I did another one for fracturing, but never decided to publish it since there wasn’t any free time and too much stuff with other projects around…

It’s based on Voronoi points, basically the points that seperate each part. You can then just traverse the models vertices (no “predestructed” meshes, the original solid model as it comes out of blender or w/e you’re using) and calculate new partmeshes, interpolate the UVs etc. etc. It’s doable, but it takes a fair portion of math and abstract thinking in terms of triangulation, plane orientations, 2D->3D etc.

destroflyer
Awesome, that’s exactly (to the letter) what I was talking about when I said “destruction model”. Can You point to some place where I can read more about this fracturing in jMe? Check some demos or something? Or at least some TestCase to reverse-engineer?

wagfeliz
I kinda hoped You’ll check the monster description. Shapeless, Amoeba-like, can generate any number of limbs/organs of any kind just right out of its goo-like body. Seems to me like deformation or won’t happen.

No, because there is no “fracturing in jme” site or demo. Otherwise I wouldn’t have wrote my code^^ And since I never published it, there’s no code available. The principle behind the whole thing are voronoi points, the wikipedia articles give a pretty good idea of how it works:

I see what you said about your monster.
Anyway, the Voronoi algorithm @destroflyer showed is the same I am using with my asteroids.
Also, you may be able to use the same algorithm for your mosnter, since the basic of it is to generate meshes.
There is a lot of info in the internet about it, and its easy to understand it really.

Well math side, doesn’t seem too hard here. Just finding (try and error way if nothing else works) the points in 3d space that will split my model.

But what about the code? How can split model of any kind in jMonkey? Simplest case: I have a cube importet from Blender of size 1 in every dimension and I want to cut it in half:

  • I know the points where I want to cut it (let’s say cut would be in Y=whatever plane) so relative to my object size it would be (0, 0.5, 0), (1, 0.5, 0), (0, 0.5, 1), (1, 0.5, 1).
  • How do I actually make this model split now?
  • How do I set the color/texture of newfly created faces?
  • How do I refer to newly created objects, sinse they are not a whole now?

Didt you find those anwsers in the http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:custom_meshes ?
Just create the vertices/faces for the new object and add they to the scene.

I have a cube importet from Blender of size 1 in every dimension and I want to cut it in half:

  • I know the points where I want to cut it (let’s say cut would be in Y=whatever plane) so relative to my object size it would be (0, 0.5, 0), (1, 0.5, 0), (0, 0.5, 1), (1, 0.5, 1).

Please read at least the introduction of the link I gave you - Splitting an object in half means you have two voronoi points, not four.

How do I refer to newly created objects, sinse they are not a whole now?

If this is a problem, please start with something simpler and don’t rush into some cool-looking destructable models application, but learn jme basics like meshes (and how to create custom ones, see wagfelizs link) first.

Sorry if I sound rude, but asking for code without understanding the basic principles behind the algorithms won’t help you. This is something a bit larger than a usual “code snippet” you can ask for in a forum - Really learning stuff doesn’t mean to play around with demos. You will have to do the math, sketches and researching by yourself if you really want to come up with something useful.