tnx for the advice, i've tryed with a jpg but
sadly i get the same output in jme.
i could provide blender project …maybe i clicked something i shouldn't have somewhere in blender?
but basicaly, i've just launched blender, and assigned a texture on the default cube, default material.
test on blender 2.46 and 2.48. i use ubuntu 8.10. gfx card is nvidia 9600gt (nvidia driver)
the full source for this class is here:
import java.io.FileInputStream;
import java.net.URL;
import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.Mouse;
import com.jme.light.PointLight;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Spatial;
import com.jme.scene.Text;
import com.jme.scene.state.LightState;
import com.jme.scene.state.MaterialState;
import com.jme.scene.state.MaterialState.ColorMaterial;
import com.jme.system.DisplaySystem;
import com.jme.util.export.xml.XMLImporter;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.game.state.CameraGameState;
import com.jmex.game.state.GameState;
import com.jmex.game.state.GameStateManager;
public class MenuState extends CameraGameState {
private DisplaySystem display;
private Text start,control,load,save,exit;
private InputHandler input;
private Mouse mouse;
private Spatial map;
private LightState lightstate;
private GameState myState;
public MenuState(String name) {
super(name);
initInput();
initText();
try {
URL folder= IngameState.class.getClassLoader().getResource("data/");
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(folder));
FileInputStream fis = new FileInputStream("data/blob.xml");
map = (Spatial) XMLImporter.getInstance().load(fis);
//map.setLocalScale(.4f);
map.setLocalTranslation(0, 0, 5);
map.getLocalRotation().set(new Quaternion()
.fromAngleAxis( - FastMath.PI/2, new Vector3f(8,5,1)) );
rootNode.attachChild(map);
rootNode.updateGeometricState(0, true);
rootNode.updateRenderState();
} catch (Exception e) {
System.out.println("Damn exceptions! O_o n" + e);
e.printStackTrace();
System.exit(0);
}
PointLight light = new PointLight();
light.setEnabled(true);
lightstate = display.getRenderer().createLightState();
lightstate.setEnabled(true);
lightstate.attach(light);
rootNode.setRenderState(lightstate);
}
public void onActivate() {
display.setTitle("Dungeon 3D - Title screen");
super.onActivate();
}
protected void initInput() {
display = DisplaySystem.getDisplaySystem();
KeyBindingManager.getKeyBindingManager().set("up", KeyInput.KEY_UP);
KeyBindingManager.getKeyBindingManager().set("down", KeyInput.KEY_DOWN);
}
private void initText() {
start = Text.createDefaultTextLabel( "info" );
start.setTextColor(ColorRGBA.green);
start.print( "Start game" );
start.getLocalTranslation().set(
display.getWidth()/2-100,
display.getHeight()-200, 0 );
control = Text.createDefaultTextLabel( "info" );
control.print( "Controls" );
control.getLocalTranslation().set(
display.getWidth()/2-100,
display.getHeight()-220, 0 );
load = Text.createDefaultTextLabel( "info" );
load.print( "Load" );
load.getLocalTranslation().set(
display.getWidth()/2-100,
display.getHeight()-240, 0 );
save = Text.createDefaultTextLabel( "info" );
save.print( "Save" );
save.getLocalTranslation().set(
display.getWidth()/2-100,
display.getHeight()-260, 0 );
exit = Text.createDefaultTextLabel( "info" );
exit.print( "Exit" );
exit.getLocalTranslation().set(
display.getWidth()/2-100,
display.getHeight()-280, 0 );
rootNode.attachChild( start );
rootNode.attachChild( control );
rootNode.attachChild( load );
rootNode.attachChild( save );
rootNode.attachChild( exit );
MaterialState ms = display.getRenderer().createMaterialState();
ms.setColorMaterial(ColorMaterial.Emissive);
rootNode.setRenderState(ms);
}
protected void stateUpdate(float tpf) {
//input.update(tpf);
if (KeyBindingManager.getKeyBindingManager().isValidCommand("up", false)) {
GameState ingame = new IngameState("ingame");
ingame.setActive(true);
GameStateManager.getInstance().attachChild(ingame);
this.setActive(false);
}
if (KeyBindingManager.getKeyBindingManager().isValidCommand("down", false)) {
TestGameStateSystem.exit();
}
rootNode.updateRenderState();//updateGeometricState(tpf, true);
}
}
the xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<com.jme.scene.Node name="Blender Exported Scene">
<children size="1">
<com.jme.scene.Node reference_ID="ID_1" name="Cube" >
<children size="1">
<com.jme.scene.TriMesh name="Cube.nocull" reference_ID="ID_0">
<vertBuf data="1.0000000 0.9999999 -1.0000000 1.0000000 -1.0000000 -1.0000000 -1.0000001 -0.9999998 -1.0000000 -0.9999996 1.0000004 -1.0000000 1.0000005 0.9999995 1.0000000 -0.9999999 1.0000000 1.0000000 -1.0000004 -0.9999996 1.0000000 0.9999993 -1.0000006 1.0000000" size="24"/>
<normBuf data="0.5773492 0.5773492 -0.5773492 0.5773492 -0.5773492 -0.5773492 -0.5773492 -0.5773492 -0.5773492 -0.5773492 0.5773492 -0.5773492 0.5773492 0.5773492 0.5773492 -0.5773492 0.5773492 0.5773492 -0.5773492 -0.5773492 0.5773492 0.5773492 -0.5773492 0.5773492" size="24"/>
<indexBuffer data="0 1 2 2 3 0 4 5 6 6 7 4 0 4 7 7 1 0 1 7 6 6 2 1 2 6 5 5 3 2 4 0 3 3 5 4" size="36"/>
<renderStateList>
<com.jme.scene.state.MaterialState class="com.jme.scene.state.lwjgl.LWJGLMaterialState" shininess="12.5244618395">
<diffuse r="0.8000000" g="0.8000000" b="0.8000000" a="1.0000000"/>
<ambient r="0.0000000" g="0.0000000" b="0.0000000" a="1.0000000"/>
<emissive r="0.0000000" g="0.0000000" b="0.0000000" a="1.0000000"/>
<specular r="0.2500000" g="0.2500000" b="0.2500000" a="1.0000000"/>
</com.jme.scene.state.MaterialState>
<com.jme.scene.state.TextureState class="com.jme.scene.state.lwjgl.LWJGLTextureState">
<texture size="1">
<com.jme.image.Texture2D>
<textureKey class="com.jme.util.TextureKey" protocol="file" file="catwarrior.jpg"/>
</com.jme.image.Texture2D>
</texture>
</com.jme.scene.state.TextureState>
</renderStateList>
</com.jme.scene.TriMesh>
</children>
<localTranslation x="0.0000000" y="0.0000000" z="0.0000000"/>
<localRotation x="0.0000000" y="0.0000000" z="0.0000000" w="1.0000000"/>
<localScale x="1.0000000" y="1.0000000" z="1.0000000"/>
</com.jme.scene.Node>
</children>
</com.jme.scene.Node>
the image used:
result in jme:
for the sake of testing i removed all the gamestate class, and went with barebone simpleGame.
here's the code:
import java.io.FileInputStream;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme.app.SimpleGame;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Spatial;
import com.jme.scene.state.LightState;
import com.jme.util.export.xml.XMLImporter;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
public class TestGameStateSystem extends SimpleGame {
private LightState lightState;
private Spatial map;
public static void main(String[] args) {
TestGameStateSystem app = new TestGameStateSystem();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
Logger.getLogger("").setLevel(Level.SEVERE);
app.start();
}
protected void simpleInitGame() {
display.setTitle("test dungeon");
try {
URL folder= IngameState.class.getClassLoader().getResource("data/");
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(folder));
FileInputStream fis = new FileInputStream("data/lol.xml");
map = (Spatial) XMLImporter.getInstance().load(fis);
map.setLocalTranslation(0, 0, 0);
rootNode.attachChild(map);
rootNode.updateGeometricState(0, true);
rootNode.updateRenderState();
} catch (Exception e) {
System.out.println("Damn exceptions! O_o n" + e);
e.printStackTrace();
System.exit(0);
}
PointLight light = new PointLight();
light.setDiffuse( new ColorRGBA( 255f, 255f, 255f, 255f ) );
light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
light.setLocation( new Vector3f( 200, 200, 200 ) );
light.setEnabled( true );
lightState = display.getRenderer().createLightState();
lightState.setEnabled( true );
lightState.attach( light );
rootNode.setRenderState( lightState );
}
protected void simpleUpdate() { }
}
and here's what i got:
the texture seems to never get applied.
my texture, objects and xml files are all in
Workspace/druaga3/data/
the source is in Workspace/druaga3/src
and i did added "data" directory as a source dir in eclipse menu>project>properties>javabuildpath
the complete output is:
Nov 24, 2008 4:16:40 PM com.jme.app.BaseGame start
INFO: Application started.
Nov 24, 2008 4:16:40 PM com.jme.system.PropertiesGameSettings <init>
INFO: PropertiesGameSettings created
Nov 24, 2008 4:16:40 PM com.jme.system.PropertiesGameSettings load
INFO: Read properties
(<unknown>:23924): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)
(<unknown>:23924): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(<unknown>:23924): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
(<unknown>:23924): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
(<unknown>:23924): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
(<unknown>:23924): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed
Nov 24, 2008 4:16:42 PM com.jme.system.PropertiesGameSettings save
INFO: Saved properties
Nov 24, 2008 4:16:42 PM com.jme.app.BaseSimpleGame initSystem
INFO: jME version 2.0 dev build 2
Nov 24, 2008 4:16:42 PM com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
Nov 24, 2008 4:16:42 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLRenderer <init>
INFO: LWJGLRenderer created. W: 640H: 480
Nov 24, 2008 4:16:42 PM com.jme.app.BaseSimpleGame initSystem
INFO: Running on: null
Driver version: null
NVIDIA Corporation - GeForce 9600 GT/PCI/SSE2 - 2.1.2 NVIDIA 177.80
Nov 24, 2008 4:16:42 PM com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
Nov 24, 2008 4:16:42 PM com.jme.util.lwjgl.LWJGLTimer <init>
INFO: Timer resolution: 1000 ticks per second
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node attachChild
INFO: Child (Graph node) attached to this node (Stats node)
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLTextureRenderer <init>
INFO: FBO support detected.
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLTextureRenderer initCamera
INFO: Init RTT camera
Nov 24, 2008 4:16:42 PM com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Line <init>
INFO: Line created.
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLTextureRenderer setupTexture
INFO: setup fbo tex with id 2: 640,360
Nov 24, 2008 4:16:42 PM com.jme.scene.Node attachChild
INFO: Child (lineGraph) attached to this node (Graph node)
Nov 24, 2008 4:16:42 PM com.jme.scene.Node attachChild
INFO: Child (f4) attached to this node (Graph node)
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLTextureRenderer <init>
INFO: FBO support detected.
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLTextureRenderer initCamera
INFO: Init RTT camera
Nov 24, 2008 4:16:42 PM com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.renderer.lwjgl.LWJGLTextureRenderer setupTexture
INFO: setup fbo tex with id 3: 640,120
Nov 24, 2008 4:16:42 PM com.jme.scene.Node attachChild
INFO: Child (labelGraph) attached to this node (Graph node)
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node <init>
INFO: Node created.
Nov 24, 2008 4:16:42 PM com.jme.scene.Node attachChild
INFO: Child (Blender Exported Scene) attached to this node (rootNode)
Nov 24, 2008 4:16:45 PM com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
Nov 24, 2008 4:16:45 PM com.jme.app.BaseGame start
INFO: Application ending.