This is literally the entire thing it would seem, @pspeed:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.MaterialKey;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
/**
* This is the Main Class of your Game. You should only do initialization here.
* Move your Logic into AppStates or Controls
* @author normenhansen
*/
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
Spatial asphaltCube = assetManager.loadModel("Models/AsphaltCube2.j3o");
Material material = assetManager.loadAsset(
new MaterialKey("Materials/AsphaltMaterial.j3m"));
asphaltCube.setMaterial(material);
rootNode.attachChild(asphaltCube);
/**
* A white, directional light source
*/
DirectionalLight sun = new DirectionalLight();
sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.addLight(sun);
flyCam.setMoveSpeed(10);
}
@Override
public void simpleUpdate(float tpf) {
}
@Override
public void simpleRender(RenderManager rm) {
}
}
Doesn’t seem like there are any ambient lights at all, though they are listed under imports.
My theory is that the j3o file containing the model may have a light attached to it that could’ve been in the scene back in Blender since some moron decided it would be great for the blend to j3o importer to not filter out random shit like lights and cameras.
@LaPsicopata You could try exporting your 3D model in some other format and see if that works.
Ah, usually when someone posts a link to a project then I assume it was something that wouldn’t fit in a post.
A post is always better for all involved… including the person reading this thread three years from now with the same issue. So always preferred when possible.
@MoffKalast I tried your suggestions. There were a camera and a light source from the .blend file. I deleted them, but nothing changed.
When I tried to use other formats, I got some other issues:
.obj:
Trying to load the .obj file or to convert it to .j3o: java.lang.ClassCastException: com.jme3.asset.AssetKey cannot be cast to com.jme3.asset.TextureKey
.dae:
Trying to load it: com.jme3.asset.AssetLoadException: No loader registered for type “dae”
I searched in the forum, and the suggestion was to download a plugin in
Plugins → available plugins… but it doesn’t exist.
Ogre formats: I could never get it installed properly. When I try to export a model, I got errors in blender’s console.
@mitm I also tried your suggestion. I changed the geometry material from the properties window on Scene Editor. But it didn’t work.
Okay I see you have the blend file in the repo as well. Here’s a zip containing the export of that cube and its UVs in ogre.xml. Loading up Cube.mesh.xml should give you a node with one child geom.
I used Ogre also and it looks fine when I generated the material, set the images in the material using (repeat) and used an ambient light in the scene.
This is the material as default generated,
Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
Diffuse : 0.64000005 0.64000005 0.64000005 1.0
UseMaterialColors : true
ParallaxHeight : 0.05
Ambient : 0.8 0.8 0.8 1.0
GlowColor : 0.0 0.0 0.0 1.0
BackfaceShadows : false
DiffuseMap : Repeat Models/TexturesCom_2x2_Asphalt4_1024_albedo.png
Specular : 0.21782178 0.21782178 0.21782178 1.0
Shininess : 12.5
NormalMap : Repeat Models/TexturesCom_2x2_Asphalt4_1024_normal.png
SpecularMap : Repeat Models/TexturesCom_2x2_Asphalt4_1024_height.png
}
AdditionalRenderState {
PointSprite On
FaceCull Back
AlphaTestFalloff 0.0
DepthWrite On
ColorWrite On
PolyOffset 0.0 0.0
DepthTest On
Blend Off
Wireframe Off
}
}
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;
/**
* This is the Main Class of your Game. You should only do initialization here.
* Move your Logic into AppStates or Controls
* @author normenhansen
*/
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
viewPort.setBackgroundColor(ColorRGBA.Gray);
Node geom = (Node) assetManager.loadModel("Models/Cube.mesh.j3o");
/** A white, directional light source */
DirectionalLight sun = new DirectionalLight();
sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
sun.setColor(ColorRGBA.White);
/** A white ambient light source. */
AmbientLight ambient = new AmbientLight();
ambient.setColor(ColorRGBA.White);
rootNode.addLight(ambient);
rootNode.addLight(sun);
rootNode.attachChild(geom);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
@MoffKalast I tried just using the ogre files, I didn’t worked.
It seems the problem was the .j3m file, since I pasted @mitm material’s code and the model looked as good as in his screenshot. You both deserve a beer. <3