本文整理匯總了Java中com.jme3.math.FastMath.FLT_EPSILON屬性的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.FLT_EPSILON屬性的具體用法?Java FastMath.FLT_EPSILON怎麽用?Java FastMath.FLT_EPSILON使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.jme3.math.FastMath
的用法示例。
在下文中一共展示了FastMath.FLT_EPSILON屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rotateAxial
/**
* Rotate the billboard towards the camera, but keeping a given axis fixed.
*
* @param camera
* Camera
*/
private void rotateAxial(Camera camera, Vector3f axis) {
// Compute the additional rotation required for the billboard to face
// the camera. To do this, the camera must be inverse-transformed into
// the model space of the billboard.
look.set(camera.getLocation()).subtractLocal(
spatial.getWorldTranslation());
spatial.getParent().getWorldRotation().mult(look, left); // coopt left for our own
// purposes.
left.x *= 1.0f / spatial.getWorldScale().x;
left.y *= 1.0f / spatial.getWorldScale().y;
left.z *= 1.0f / spatial.getWorldScale().z;
// squared length of the camera projection in the xz-plane
float lengthSquared = left.x * left.x + left.z * left.z;
if (lengthSquared < FastMath.FLT_EPSILON) {
// camera on the billboard axis, rotation not defined
return;
}
// unitize the projection
float invLength = FastMath.invSqrt(lengthSquared);
if (axis.y == 1) {
left.x *= invLength;
left.y = 0.0f;
left.z *= invLength;
// compute the local orientation matrix for the billboard
orient.set(0, 0, left.z);
orient.set(0, 1, 0);
orient.set(0, 2, left.x);
orient.set(1, 0, 0);
orient.set(1, 1, 1);
orient.set(1, 2, 0);
orient.set(2, 0, -left.x);
orient.set(2, 1, 0);
orient.set(2, 2, left.z);
} else if (axis.z == 1) {
left.x *= invLength;
left.y *= invLength;
left.z = 0.0f;
// compute the local orientation matrix for the billboard
orient.set(0, 0, left.y);
orient.set(0, 1, left.x);
orient.set(0, 2, 0);
orient.set(1, 0, -left.y);
orient.set(1, 1, left.x);
orient.set(1, 2, 0);
orient.set(2, 0, 0);
orient.set(2, 1, 0);
orient.set(2, 2, 1);
}
// The billboard must be oriented to face the camera before it is
// transformed into the world.
spatial.setLocalRotation(orient);
spatial.updateGeometricState();
}
示例2: update
/**
* <code>update</code> recalulates the frame rate based on the previous
* call to update. It is assumed that update is called each frame.
*/
public void update() {
long newTime = Sys.getTime();
long oldTime = this.oldTime;
this.oldTime = newTime;
if ( oldTime == -1 ) {
// For the first frame use 60 fps. This value will not be counted in further averages.
// This is done so initialization code between creating the timer and the first
// frame is not counted as a single frame on it's own.
lastTPF = 1 / 60f;
lastFPS = 1f / lastTPF;
return;
}
long frameDiff = newTime - oldTime;
long lastFrameDiff = this.lastFrameDiff;
if ( lastFrameDiff > 0 && frameDiff > lastFrameDiff *100 ) {
frameDiff = lastFrameDiff *100;
}
this.lastFrameDiff = frameDiff;
tpf[smoothIndex] = frameDiff;
smoothIndex--;
if ( smoothIndex < 0 ) {
smoothIndex = tpf.length - 1;
}
lastTPF = 0.0f;
if (!allSmooth) {
int smoothCount = 0;
for ( int i = tpf.length; --i >= 0; ) {
if ( tpf[i] != -1 ) {
lastTPF += tpf[i];
smoothCount++;
}
}
if (smoothCount == tpf.length)
allSmooth = true;
lastTPF *= ( INV_LWJGL_TIMER_RES / smoothCount );
} else {
for ( int i = tpf.length; --i >= 0; ) {
if ( tpf[i] != -1 ) {
lastTPF += tpf[i];
}
}
lastTPF *= invTimerRezSmooth;
}
if ( lastTPF < FastMath.FLT_EPSILON ) {
lastTPF = FastMath.FLT_EPSILON;
}
lastFPS = 1f / lastTPF;
}