My mouse has a funky texture on it

https://jme.dev.java.net/source/browse/jme/src/jmetest/TutorialGuide/HelloMousePick.java?rev=1.1&content-type=text/vnd.viewcvs-markup



I want my mouse to be above the objects in rootNode, so I figure I could render it sepretly in simpleRender. Can’t figure out what’s wrong with it though. I’ll see either strange text or a white square where my mouse texture should be.

I believe you haven’t called updateRenderStates() on it. Try that and see



So it would be:



Texture t=TextureManager.loadTexture(cursorLoc,Texture.MM_LINEAR, Texture.FM_LINEAR, true);
ts.setTexture(t);
ts.setEnabled(true);
am.setRenderState(ts);
am.updateRenderStates();



DP

I call it near the end of simpleInitGame() just before I assign it to input.

If I change

    protected void simpleRender(){
        display.getRenderer().draw(am);
    }



to

    protected void simpleRender(){
//        display.getRenderer().draw(am);
        am.draw(display.getRenderer());
    }



it works like expected, but I don't understand why the first doens't work.

Mouse has it’s own render method in the renderer, so it goes directly to drawing the mouse without calling any of the render states set on it. The second way (the one that works) allows render states to get called before the call to the renderer.

Which is the proper way to display things? renderer.draw(spatial) or spatial.draw(renderer). It kind of seems repeditive at first glance. SimpleGame uses renderer.draw() Why? And then there’s onDraw… why the division?

Proper way to render things is to pass a Spatial to the Renderer.



display.getRenderer().draw(spatial)



Spatial’s draw/onDraw handles node specific setup for a rendering (applying states, culling, etc).



Renderer’s draw handles displaying data to the screen.[/quote]

If that’s the proper way, then how come I have to do it the “wrong” way to get my mouse to render correctly? Am I missing something in my code?

If that's the proper way, then how come I have to do it the "wrong" way to get my mouse to render correctly? Am I missing something in my code?


I don't know, I was a little suprised that it would work that way, to tell you the truth.

Well, after talking with Renanse it seems something has changed in the design of the system somewhere along the way. Probably one of those domino effect deals, but because of the way it is now, it looks like calling onDraw on the node (any level, root to render whole scene, trimesh to render just that, etc), is the way to go. So, that should probably become standard practice:



rootNode.onDraw(renderer);



instead of



renderer.draw(rootNode);



But now we have the problem of onDraw being a very unintuitive name for the user to call.

And a very unintuitive way to do it. It seems backwards to have an object draw itself with a renderer. Makes more sense for the renderer to draw with the object. Is this "onDraw" standard to go into the tutorial guide, or will renderer.draw() become a fixed standard again?

This needs investigation, because I agree Cep21, asking the node to draw is backwards (and it wasn’t originally designed like that). You should be able to call renderer.draw(node) at any level of the scene graph and have it render properly. Something should be done to bring it back to renderer.draw(node) being standard and proper, we just have to figure out what.