Dragging and dropping code snippets from the Palette

@snareoj2 said:
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... ;),
i dont know what i do in that snippet.... the model rotates somehow, but not correctly....


Hi snare, I haven't tested your code (writing from phone) but if you just want to rotate you can also try reading this short page https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:math
And see whether you find answers?
You can piece together one destination Quaternion out of three rotation quaternions around each axis.
You can also rotate *by* a certain degree value (rotate() together with FastMath.DEG_TO_RAD)

There are 12 example quaternions in the palette by the way.

PS: the slerp() goes from 0.0f to 1.0f, if you put in tpf you don't really use the whole interval.
@zathras said:
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.)


Yes it does!, thank you very much Zathras... you know what, I remember a Babylon5 personage with that name...! anyway thanks a lot.

@zathras: If we find a solution for “CharacterControl entities can walk through each other - http://hub.jmonkeyengine.org/groups/physics/forum/topic/charactercontrol-entities-can-walk-through-each-other/”, can you add a code snippet for this too ?

@zathras just a minor thing, i noticed you updated the DirectionalLight in the palette, but it uses normalize() now not normalizeLocal().



This is what I had before i updated:

[java]sun.setDirection(new Vector3f(1, 0, -2).normalizeLocal());[/java]



and this is what it is now:



[java]sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalize());[/java]



I suggest that you change it to:

[java]sun.setDirection(new Vector3f(-0.5f, -0.5f, -0.5f).normalizeLocal());[/java]



Its a bit cleaner and avoids an unnecessary object creation. Thanks :slight_smile:

@wezrule said:
[java]sun.setDirection(new Vector3f(-0.5f, -0.5f, -0.5f).normalizeLocal());[/java]


Makes sense, I committed that change. Thanks for the feedback!