Guys, after many recommended I finally converted my objects from .obj to .j3o and I am having now a flickering issues with these objects. It is noticed more the more I zoom out. What should I do??
thanks
If your are using Lighting material the problem is probably missing tangents for your mesh…
Search for TangentBinormalGenerator
or while in the SDK you can right-click on the spatial in the scene explorer, and select Tools->Generate Tangents
? didn’t know you could do that from the SDK, I right clicked nothing happened (only when I left click I see the mesh polygons) and tools deoes not have generate tangents
I tried the function:
TangentBinormalGenerator.generate()
in my code but didn’t work nothing changed
You exported .obj files with normals?
yes my first try was .obj withg normals and it was working fine till I converted the obj size from mm to m (shouldn’t affect anything as I changed the cam positions but it shows the object without material - white).
second try was to convert to .j3o now I got the mateirals however I have flickering
how did you do your model? maybe you have Z-fighting on the faces because you scale the model down.
post a picture, or the model…or both.
i’ll upload a quick video when I get home, but the issue is that simple, if I create a two attached cubes in Blender with two different colors (say blue and black) and with sine (1000, 1000, 1000) - assuming millimeters, and if I convert them to j3o and try to visualize it, the more u zoom out the black color starts flickering
edit:
and doing the same with .obj gives you a white object EVEN THOUGH I did check the Normals check box
and also what I don’t understand is why this only happens when the object size increased and not at a smaller size?
It has nothing to do with the size, you just don’t have tangents generated on it. If it has normals and it flickers: no tangents.
@Sploreg said
It has nothing to do with the size, you just don’t have tangents generated on it. If it has normals and it flickers: no tangents.
but I did generate them using TangentBinormalGenerator.generate(mySpatial);
Confirm that with this code, take a screenshot and post:
[java]
Material mat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
Geometry debug = new Geometry( "Debug " + name,
TangentBinormalGenerator.genTbnLines(mySpatial.getMesh(), 0.8f));
rootNode.attachChild(debug);
debug.setLocalTranslation(child.getLocalTranslation());
debug.setCullHint(CullHint.Never);
debug.setMaterial(mat);
[/java]
well since I am loading the model as obj my code is:
[java]
mySpatial = assetManager.loadModel("/Models/" + type + ".j3o");
mySpatial.setLocalTranslation(x, y, z);
mySpatial.setName(id);
// generate tangents to avoid z fighting
TangentBinormalGenerator.generate(mySpatial);
rootNode.attachChild(mySpatial);[/java]
no please use the debug code I provided and show a screenshot of it.
but I can’t cast a Node to a Geometry:
[java]com.jme3.scene.Node cannot be cast to com.jme3.scene.Geometry[/java] and mySpatial is a spatial so I Can’t use getMesh()
Find the geometry of it and pass that in. You node has a geometry somewhere as a child, so get it.
[java] Material mat = assetManager().loadMaterial("Common/Materials/VertexColor.j3m");
Node de = (Node) mySpatial;
Geometry dede = (Geometry) de.getChild(1);
Geometry debug = new Geometry( "Debug ", TangentBinormalGenerator.genTbnLines(dede.getMesh(), 0.8f));
rootNode.attachChild(debug);
debug.setLocalTranslation(0,0,0);
debug.setCullHint(CullHint.Never);
debug.setMaterial(mat);
[/java]
same thing
post a screenshot of the vectors it generates
the link isn’t working (or imgur is having issues)