In course of my actions i've changed a number jME classes, some changes might be worth including in CVS.
Change i needed to allow subclassing the LWJGLRenderer, a simple change from "private" to "protected":
***************
*** 140,146 ****
private FloatBuffer[] prevTex;
! private ContextCapabilities capabilities;
private int prevTextureNumber = 0;
--- 140,146 ----
private FloatBuffer[] prevTex;
! protected ContextCapabilities capabilities;
private int prevTextureNumber = 0;
***************
*** 1061,1067 ****
* @param t
* the geometry to process.
*/
! private void predrawGeometry(Geometry t) {
// set world matrix
if (!generatingDisplayList || (t.getLocks() & Spatial.LOCKED_TRANSFORMS) != 0) {
doTransforms(t);
--- 1061,1067 ----
* @param t
* the geometry to process.
*/
! protected void predrawGeometry(Geometry t) {
// set world matrix
if (!generatingDisplayList || (t.getLocks() & Spatial.LOCKED_TRANSFORMS) != 0) {
doTransforms(t);
Change needed for SharedMesh's target to decide, how it should be drawn:
SharedMesh.java
***************
*** 485,491 ****
target.setLocalTranslation(worldTranslation);
target.setLocalRotation(worldRotation);
target.setLocalScale(worldScale);
! r.draw(target);
}
/**
--- 485,493 ----
target.setLocalTranslation(worldTranslation);
target.setLocalRotation(worldRotation);
target.setLocalScale(worldScale);
! // call draw of target
! target.draw(r);
! //r.draw(target);
}
/**
FastMath.java
// The base n logarithm:
public static float log(float value, float base) {
return (float)(Math.log10((double)value)/Math.log10((double)base));
}
Quaternion.java
This i found on the net and tested so that Q.fromAngles(Q.toAngles()) gives back the same rotation.
// Convert to Euler angles
public float[] toAngles(float[] angles)
{
if(angles==null)
angles=new float[3];
else if (angles.length != 3)
throw new IllegalArgumentException(
"Angles array must have three elements");
float sqw = w*w;
float sqx = x*x;
float sqy = y*y;
float sqz = z*z;
float unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
float test = x*y + z*w;
if (test > 0.499*unit) { // singularity at north pole
angles[1] = 2 * FastMath.atan2(x,w);
angles[2] = FastMath.HALF_PI;
angles[0] = 0;
} else if (test < -0.499*unit) { // singularity at south pole
angles[1] = -2 * FastMath.atan2(x,w);
angles[2] = -FastMath.HALF_PI;
angles[0] = 0;
} else {
angles[1] = FastMath.atan2(2*y*w-2*x*z , sqx - sqy - sqz + sqw);
angles[2] = FastMath.asin(2*test/unit);
angles[0] = FastMath.atan2(2*x*w-2*y*z , -sqx + sqy - sqz + sqw);
}
return angles;
}
DiscreteLodNode generates 2 Vector3f and a Float garbage each update cycle. After changing it will still generate that Float garbage.
Index: DiscreteLodNode.java
*** C:jmesrccomjmescenelodDiscreteLodNode.java Base (1.7)
--- C:jmesrccomjmescenelodDiscreteLodNode.java Locally Modified (Based On 1.7)
***************
*** 46,55 ****
public class DiscreteLodNode extends SwitchNode {
private static final long serialVersionUID = 1L;
private Vector3f modelCenter;
! private Vector3f worldCenter;
-
private float lastUpdate;
private SwitchModel model;
--- 46,58 ----
public class DiscreteLodNode extends SwitchNode {
private static final long serialVersionUID = 1L;
private Vector3f modelCenter;
! private Vector3f worldCenter=new Vector3f();
+ private static Vector3f tmpVs=new Vector3f();
private float lastUpdate;
private SwitchModel model;
***************
*** 65,76 ****
{
super.updateWorldData(lastUpdate);
// compute world LOD center
! worldCenter = worldTranslation.add(worldRotation.mult(modelCenter).multLocal(worldScale));
// compute world squared distance intervals
! float worldSqrScale = worldScale.mult(worldScale).length();
! model.set(worldCenter.subtract(camera.getLocation()));
model.set(new Float(worldSqrScale));
setActiveChild(model.getSwitchChild());
--- 65,79 ----
{
super.updateWorldData(lastUpdate);
+
+
// compute world LOD center
! worldCenter = worldRotation.multLocal(worldCenter.set(modelCenter)).multLocal(worldScale).addLocal(worldTranslation);
// compute world squared distance intervals
!
! float worldSqrScale = tmpVs.set(worldScale).multLocal(worldScale).length();
! model.set(worldCenter.subtractLocal(camera.getLocation()));
model.set(new Float(worldSqrScale));
setActiveChild(model.getSwitchChild());
Two minor enhancements to LittleEndien.java
// read an unsigned int as a long
public final long readUInt() throws IOException{
return (long)(
(in.read()&0xff) |
((in.read()&0xff) << 8) |
((in.read()&0xff) << 16) |
(((long)(in.read()&0xff)) << 24)
);
}
public final int available() throws IOException{
return in.available();
}
To be continued...