I have some problem loading a .obj tree model. The model have an .obj, an .mtl file and all the textures in the same folder.
When I load the object without assigning to it any material, it have his textures on it but the leaves have black where there is supposed to be nothing but transparency:
There is my code when I added the default material:
and this is what happen
It’s not my model and it’s not only one texture so I don’t know how to put the Blendmode.alpha on the material of my object.
If anyone have an idea of what I can do help me please
My problem is that when I load directly the object with assetManager.loadModel(“path.obj”); it loads the model and the textures correctly but the leaves on the tree are black when there is supposed to be transparency so all over the tree there is black squares. I thinks the problem is the .obj or .mtl transparency is not correctly loaded or displayed
Thanks but I think it didn’t resolve the problem because I can’t access the Material from my Spatial and I can’t set a new one because it will erase the old one with all the textures so I think I can’t do material.getAdditionalRenderState() because I just don’t have access.
Old code:
tree = lifer.getAssetManager().loadModel(“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.obj”);
tree.rotate(-90, 0, 0);
//Material matTree = new Material(lifer.getAssetManager(), “Common/MatDefs/Light/Lighting.j3md”);
//Material matTree = new Material(lifer.getAssetManager(),“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.mtl”); //mat1.setTexture(“m_ColorMap”, lifer.getAssetManager().loadTexture(“Models/warriorgirl300pxtall.png”));
//matTree.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
tree.setQueueBucket(Bucket.Transparent);
//tree.setMaterial(matTree);
DirectionalLight light = new DirectionalLight();
lifer.getRootNode().addLight(light);
new code:
tree = lifer.getAssetManager().loadModel(“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.obj”);
tree.rotate(-90, 0, 0);
SceneGraphVisitorAdapter sgva = new SceneGraphVisitorAdapter();
tree.depthFirstTraversal(sgva);
NO_MATERIAL_ACCESS.getAdditionalRenderState();
renderState.setBlendMode…
//Material matTree = new Material(lifer.getAssetManager(), “Common/MatDefs/Light/Lighting.j3md”);
//Material matTree = new Material(lifer.getAssetManager(),“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.mtl”); //mat1.setTexture(“m_ColorMap”, lifer.getAssetManager().loadTexture(“Models/warriorgirl300pxtall.png”));
//matTree.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
tree.setQueueBucket(Bucket.Transparent);
//tree.setMaterial(matTree);
DirectionalLight light = new DirectionalLight();
lifer.getRootNode().addLight(light);
@jojolepro said:
Thanks but I think it didn't resolve the problem because I can't access the Material from my Spatial and I can't set a new one because it will erase the old one with all the textures so I think I can't do material.getAdditionalRenderState() because I just don't have access.
Old code:
tree = lifer.getAssetManager().loadModel(“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.obj”);
tree.rotate(-90, 0, 0);
//Material matTree = new Material(lifer.getAssetManager(), “Common/MatDefs/Light/Lighting.j3md”);
//Material matTree = new Material(lifer.getAssetManager(),“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.mtl”); //mat1.setTexture(“m_ColorMap”, lifer.getAssetManager().loadTexture(“Models/warriorgirl300pxtall.png”));
//matTree.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
tree.setQueueBucket(Bucket.Transparent);
//tree.setMaterial(matTree);
DirectionalLight light = new DirectionalLight();
lifer.getRootNode().addLight(light);
new code:
tree = lifer.getAssetManager().loadModel(“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.obj”);
tree.rotate(-90, 0, 0);
SceneGraphVisitorAdapter sgva = new SceneGraphVisitorAdapter();
tree.depthFirstTraversal(sgva);
NO_MATERIAL_ACCESS.getAdditionalRenderState();
renderState.setBlendMode…
//Material matTree = new Material(lifer.getAssetManager(), “Common/MatDefs/Light/Lighting.j3md”);
//Material matTree = new Material(lifer.getAssetManager(),“EA02_Aesculus_glabra_Ohio_Buckeye_OBJ/EA02a.mtl”); //mat1.setTexture(“m_ColorMap”, lifer.getAssetManager().loadTexture(“Models/warriorgirl300pxtall.png”));
//matTree.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
tree.setQueueBucket(Bucket.Transparent);
//tree.setMaterial(matTree);
DirectionalLight light = new DirectionalLight();
lifer.getRootNode().addLight(light);
Did I miss something?
sorry if I’m a noob
-jojolepro
The scene graph visitor adapter is designed to be EXTENDED. I thought that would kind of be obvious since it doesn’t actually do anything on its own.
So, try to figure out from that hint… or search the forum for SceneGraphVisitorAdapter for probably a dozen examples where it has been pasted in response to someone else.