As you may have noticed, the SDK has a Java code palette. Open a Java file, then choose Windows>Palette if you don’t see it. It contains common code snippets that you can drag and drop into a method (or into the class, it depends) and adjust to your application’s needs.
For example, there are code snippets for light sources, some particle and post-processor effects, Node and Material code, some common input handlers, quaternions, HUD text, load and save a Node as j3o…
Does anyone use it yet? I just added some new snippets, but maybe you can think of other useful things that you would like to see there. You know, THAT one line of code that you keep in a text file and copy all the time, because it’s so powerful but you always forget it? 8)
I don’t want to fill it just for the heck of it, it has to be something useful. A palette only makes sense for self-contained kinds of code samples. (It can’t be code that needs to be added in two, three different places, for example.)
Well, try it, and tell us whether it works for you.
i always use it for quaternions and lights, and sometimes the particles. Im sure theres much more it will be useful for, but i cant think off the top of my head
yeah, this is very useful.
Btw the code snippets are out of date.
I use the quaternions frequently. I will try and think of some useful code snippets I know I have used a lot that would be beneficial to others.
I think having a few of the popular materials setup with each of their fields set would be helpful… Lighting and Unshaded I guess would be the two big ones.
I’d like to ask if it is possible change the palette. I’d like to set there my own code snippets.
@darkeye said:
I'd like to ask if it is possible change the palette. I'd like to set there my own code snippets.
not really but you can set macros in the settings that expand to full code snippets.
@normen said:
not really but you can set macros in the settings that expand to full code snippets.
Are the snippets there hardcoded into the app?
@sbook said:
Are the snippets there hardcoded into the app?
They are basically intelligent scripts that could do much more than just insert text in the editor but also change names according to the existing code etc.
Cool… so it wouldn’t be totally far-fetched to see an SDK plugin that let the user “drag” highlighted text in the editor to the palette (or something along those lines?)
Could be a fun project for me to become more intimate with the NetBeans API
I think I even saw some plugin like that…
Gaaah. I didn’t set this thread up to send me email alerts, duh. Thanks for your answers!
@glaucomardano: Which ones are out of date? I updated a few of them, but editing this code in the sources is like open heart surgery with a playstation controller :o
@sbook When you open an HTML file in the SDK together with the Palette, you can drag an drop HTML code snippets into it… @Normen, can you reuse this existing Platform code? (Maybe related? http://platform.netbeans.org/tutorials/nbm-palette-api1.html) Adding stuff by drag&drop would be super awesome.
Macros (Options> Editor>Macros) are another option to insert custom code, true!
@zathras said:
@glaucomardano: Which ones are out of date? I updated a few of them, but editing this code in the sources is like open heart surgery with a playstation controller :o ;)
If I remember well, there's a particle emitter snippet with reference problems, it calls methods that doesn't exist anymore.
@glaucomardano Good catch, the effects API changed months ago… The fix should be in the next nightly build.
I also noticed that the InputListener snippet never reacted to being dropped, hopefully also fixed now.
@sbook Did you try the snippets under “Material”? You are saying the examples should be more extensive?
What about camera settings? like top/left/right bottom? viewports?
@xquake Do you mean cam.getLeft() etc? Aren’t these faster to find by using code completion on the cam object?
Something like viewPort.setBackgroundColor(ColorRGBA.Blue); however is a good idea, so that people who don’t recall that the object is called “viewPort” find where that setting is at all.
I added that one (and an additional AppSettings example) to the upcoming nightly build. I also updated two of the material examples.
xquake, if I misunderstood you, paste some examples.
Hello Zathras.
Well I was talking about cam views like “top view” or “left view” etc. I’m working in a game and I was looking for a “Top view” cam, but may be it was already there sorry for this silly question i’m a Newbie with JME3…
Hi,
what about some math things? Like calculate the normalized dir between two points, the angle between two vectors etc?
Exspecially the whole rotation thingies with quaternions would be great.
I would like to see a snippet for Roating a quaternion to a specific Position in space with tpf interpolating… ;), sth like:
[java]
TempVars vars = TempVars.get();
Vector3f currentDirection = vars.vect1;
sourceQuaternion.getRotationColumn(2, currentDirection);
Vector3f direction= vars.vect2.set(pointToLookAt);
direction.subtractLocal(currentDirection);
direction.normalizeLocal();
Quaternion destinationRotation = vars.quat2.set(sourceQuaternion);
destinationRotation.lookAt(direction, Vector3f.UNIT_Y);
sourceQuaternion.slerp(destinationRotation, tpf);
vars.release();
[/java]
Attention: Acutally i dont know what i do in that snippet… the model rotates somehow, but not correctly…
Good night, good fight,
snare
@xquake said:
Well I was talking about cam views like "top view" or "left view" etc. I'm working in a game and I was looking for a "Top view" cam, but may be it was already there sorry for this silly question :) i'm a Newbie with JME3... :)
I see, that's indeed not there yet.
Viewing the scene from the top-down would be:
cam.setLocation(new Vector3f(0,10,0));
cam.lookAt(new Vector3f(0,0,0),new Vector3f(0,1,0));
Does that do what you want? (writing from phone, can't test it.)