hi,
im having the problem that when i load a model, it is just shown in black. first i thought it was the issue described in one of the tutorials, where you have to “recalculate normals inside” in blender, but it figured out to just inverse the culling.
in my game, i can open an inventory and selecting some items while drawing a selection box around these items. meanwhile the flybycamera is disabled and mousecursor is enabled. while im selecting and deselecting items, some of the textures appear and disappear from the model in the background depending on wich item i select. (just one wall with texture, then 2 walls, then one wall with less light)
i really have no clue why it is behaving like this. all menu items are attached to the guinode and the world with models is located in the rootnode.
maybe im missing an update function?
thx for help
In blender and many other modeling tools you don’t really see if the normals point outside or inside the model because they render the front and backface. Make sure your normals point outside in the modeling tool already.
i really don’t know how to work with blender. i downloaded a model and exported it in wavefront. i guess i can make sure that the normals point outside if i use the function swap normals. am i right there? both ways don’t work. but why do the textures show up when i’m in my menu ?
Thing is, without any hint at how to reproduce that its kinda hard to fix… Could be your code, could be jME. To really make sure what it is and that we can fix it, try and create a test case for it. This will allow you to isolate the problem and see if it actually happens in a small simple application too.
ok, with a blank program it seems to work. so the fault is in my code. even if i don’t know what the info panel wants from me.
[java]
Information: Child (house) attached to this node (Root Node)
Okt 25, 2011 9:54:52 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
Information: Uniform m_VertexColor is not declared in shader [ShaderSource[name=Common/MatDefs/Misc/Unshaded.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Misc/Unshaded.frag, defines, type=Fragment]].
Okt 25, 2011 9:54:55 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
Information: Uniform g_CameraPosition is not declared in shader [ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment]].
Okt 25, 2011 9:54:55 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
Information: Uniform g_WorldMatrix is not declared in shader [ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment]].
Okt 25, 2011 9:54:55 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
Information: Uniform m_ParallaxHeight is not declared in shader [ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment]].
Okt 25, 2011 9:54:55 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
Information: Uniform m_UseMaterialColors is not declared in shader [ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment]].
Okt 25, 2011 9:54:59 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
[/java]
i’m going to extract responsible code from my program toshow, needs a bit since it became quite big
Yeah, just try and put everything graphics related (like UI, post processors etc) in a simple version in the test case, then at some point the issue should crop up… Then try to isolate back down again.
so, i’m getting nearer to the problem. when i disable my hud and my menu, the textures are shown. when i go into ingame menu or enable hud, they disappear. so i guess the hud mechanism should show the error inside since menu has the same main class.
the interface:
[java]
public interface ViewInterface {
public void initialize();
public void keyEvent(KeyInputEvent event);
public void mouseEvent(MouseButtonEvent event);
}
[/java]
the view class:
[java]
public class View implements ViewInterface{
public GameManager manager;
public Main main;
public int spaceX;
public int spaceY;
public int textSize = 30;
public Node node = new Node();
public Node text = new Node();
public Node backGround = new Node();
public BitmapFont guiFont;
public View(GameManager manager, Main main){
this.manager = manager;
this.main = main;
spaceY = (main.getHeight() - 600) / 2;
spaceX = main.getWidth() / 2;
guiFont = main.getAssetManager().loadFont(“Interface/Fonts/Default.fnt”);
main.getGuiNode().attachChild(backGround);
main.getGuiNode().attachChild(node);
main.getGuiNode().attachChild(text);
}
public void initialize() {
}
public void keyEvent(KeyInputEvent event) {
}
public void mouseEvent(MouseButtonEvent event) {
}
public Picture createPicture(String path, String name, int width, int height, int x, int y){
Picture pic = new Picture(name);
pic.setImage(main.getAssetManager(), path, true);
pic.setWidth(width);
pic.setHeight(height);
pic.setPosition(x, y);
return pic;
}
public BitmapText createText(String text, String name, int x, int y){
BitmapText line = new BitmapText(guiFont, false);
line.setText(text);
line.setName(name);
line.setColor(ColorRGBA.Blue);
line.setSize(textSize);
line.setLocalTranslation(x, y, 0);
return line;
}
public void closeView(){
main.getGuiNode().detachChild(backGround);
main.getGuiNode().detachChild(node);
main.getGuiNode().detachChild(text);
}
public void clearView(){
backGround.detachAllChildren();
node.detachAllChildren();
text.detachAllChildren();
}
}
[/java]
the hud class:
[java]
public class HUD extends View{
public HUD(GameManager manager, Main main){
super(manager, main);
initialize();
}
public void initialize() {
node.detachAllChildren();
node.attachChild(createPicture(“Textures/HUD/HUDstats.png”, “”, 250, 50, 0, main.getHeight()-50));
node.attachChild(createPicture(“Textures/HUD/HUDitems.png”, “”, 150, 50, main.getWidth()-150, 0));
node.attachChild(createPicture(“Textures/HUD/Red.png”, “Life”, 200, 10, 5, main.getHeight()-15));
node.attachChild(createPicture(“Textures/HUD/Green.png”, “Hunger”, 200, 10, 5, main.getHeight()-30));
node.attachChild(createPicture(“Textures/HUD/Blue.png”, “Thirst”, 200, 10, 5, main.getHeight()-45));
BitmapText crossHair = createText("+", “”, 200, 200);
crossHair.setLocalTranslation(
main.getWidth()/2 - guiFont.getCharSet().getRenderedSize()/3*2,
main.getHeight()/2 + crossHair.getLineHeight()/2, 0);
node.attachChild(crossHair);
}
public void update() {
Player player = manager.getPlayer();
if(node.getChild(“Life”) != null){
Picture p = (Picture) node.getChild(“Life”);
p.setWidth(2 * manager.getPlayer().getCurHealth());
p = (Picture) node.getChild(“Hunger”);
p.setWidth(2 * manager.getPlayer().getCurHunger());
p = (Picture) node.getChild(“Thirst”);
p.setWidth(2 * manager.getPlayer().getCurThirst());
}
if(player.getForeHand() != null){
node.detachChildNamed(“Forehand”);
if(player.getInventory().containsKey(player.getForeHand().getItemName()))
node.attachChild(createPicture(“Textures/Items/”+player.getForeHand().getItemName()+".png", “Forehand”, 40, 40, main.getWidth()-90, 5));
else player.setForeHand(null);
}
if(player.getOffHand() != null){
node.detachChildNamed(“Offhand”);
if(player.getInventory().containsKey(player.getOffHand().getItemName()))
node.attachChild(createPicture(“Textures/Items/”+player.getOffHand().getItemName()+".png", “Offhand”, 40, 40, main.getWidth()-45, 5));
else player.setOffHand(null);
}
}
}
[/java]
code from gamemanager:
[java]
public void executeCommand(String com){
if (com.equals(“exit”)) {
IO.get().savePlayer(“Character1”, player);
main.getGuiNode().detachAllChildren();
main.getRootNode().detachAllChildren();
main.stop();
}else if(com.equals(“start”)){
map = new Map(main, this);
map.generateTerrain();
main.getMouseInput().setCursorVisible(false);
playerControl.setPhysicsLocation(new Vector3f(0, map.getHeightAt(0, 0)+6, 0));
physic.getPhysicsSpace().add(playerControl);
main.getFlyByCamera().setEnabled(true);
hud = new HUD(this, main);
initLight();
view.closeView();
}
}
// mechanism for changing the the menu page or to turn menu off
public void changeView(int view){
if(this.view != null) this.view.closeView();
switch(view){
case ViewIDs.CLOSE_VIEW : this.view = null;
main.getFlyByCamera().setEnabled(true);
main.getMouseInput().setCursorVisible(false);
return;
case ViewIDs.INVENTORY : this.view = new Inventory(this, main);
main.getFlyByCamera().setEnabled(false);
main.getMouseInput().setCursorVisible(true);
break;
case ViewIDs.SKILLS_INGAME : this.view = new SkillsIngame(this, main);
main.getFlyByCamera().setEnabled(false);
main.getMouseInput().setCursorVisible(true);
break;
case ViewIDs.CRAFTING : this.view = new Crafting(this, main);
main.getFlyByCamera().setEnabled(false);
main.getMouseInput().setCursorVisible(true);
break;
}
this.view.initialize();
}
[/java]
so, it’s definitely the guiNode. my testcase has just the model and one picture in the guiNode and it doesnt work. when i dont add the picture, it works. is there a reason that i’m not allowed to add pictures in the guiNode?