JME, NiftyGUI Questions

JME:

How do i set a new Material to a Node? setMaterial(mat); and updateGeometricState() inst working.



When does methods return a copy of an instance?

For example: spatial.getLocalTranslation() returns only a reference.



NIftyGUI 1.2:

How to change the position of an element after it was created and added to an panel, …?

how to remove an element an add it to an other screen?

it is possible to put a screen over a screen?



light problem:

after ive updated the jme the light becomes a lot darker, why?



Thanks in advacne.

Please don’t do that kind of post with several unrelated questions, try to always do 1 post = 1 question, because it’s a lot easier for other users to search the forum if they have the same questions as you.

I’m gonna answer anyway, but remember that next time.


Mr.Sir said:
JME:
How do i set a new Material to a Node? setMaterial(mat); and updateGeometricState() inst working.

setMaterial should work, don't call updateGeometricState. There must be another issue in your code, could you post it?


Mr.Sir said:
When does methods return a copy of an instance?
For example: spatial.getLocalTranslation() returns only a reference.

In java, objects are always used as reference, if you want a copy you have to explicitly ask for it by using the clone() method on the object

Mr.Sir said:
light problem:
after ive updated the jme the light becomes a lot darker, why?

The way ambient lighting is used as been changed recently, maybe it's an issue with this. could you post a screen/code?
Also you may have to add an Ambient light to your scene.

Mr.Sir said:
NIftyGUI 1.2:
How to change the position of an element after it was created and added to an panel, ...?
how to remove an element an add it to an other screen?
it is possible to put a screen over a screen?

For this I don't really know, but I once see a drag n drop implementation for nifty on the nifty gui blog, so there must be a way of moving panels, maybe you should look in nifty blog/doc/wiki

Hi,

For the Nifty questions I can answer:



to move an element:

for instance change its Y position.

element.setConstraintY(new SizeValue(value));

element.getParent().layoutElements();



To remove an element I am using the following code:

el.markForRemoval();

el.getParent().layoutElements();



If anybody has better ways I will be more than happy to use them :slight_smile:

“Please don’t do that kind of post with several unrelated questions, try to always do 1 post = 1 question, because it’s a lot easier for other users to search the forum if they have the same questions as you.

I’m gonna answer anyway, but remember that next time.”



Sry, i know that, it was a little bit annoyed because that something works in the one version and in the oter not.



“In java, objects are always used as reference, if you want a copy you have to explicitly ask for it by using the clone() method on the object”

i know that. but sometimes methods return a copy of an objects because they dont want that sombody manipulates them while something is already in progress or for ohter reasons…





“The way ambient lighting is used as been changed recently, maybe it’s an issue with this. could you post a screen/code?

Also you may have to add an Ambient light to your scene.”

thank you.



“for instance change its Y position.

element.setConstraintY(new SizeValue(value));

element.getParent().layoutElements();”



Ive tried this, its not working.

Maybe its because Ive created the Control from Code.



“el.markForRemoval();

el.getParent().layoutElements();”



ive used screeen.removeLayerElement… and than parent.layoutElements().

maybe it will work with the markForRemoval, thx.

For moving Element: Have you defined container as childLayout=“absolute”.

I am using that to position my control once created too, based on user profile.

Mr.Sir said:
i know that. but sometimes methods return a copy of an objects because they dont want that sombody manipulates them while something is already in progress or for ohter reasons....

Oh ok i misunderstood your question, every get...() method return a reference, the methods that return a new instance of an object are methods that change it ie (verctor3f.mult(vector), verctor3f.add(vector) etc...).