use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method computeUnionBound.
/**
* Compute bounds of a geomList
* @param list
* @param transform
* @return
*/
public static BoundingBox computeUnionBound(GeometryList list, Transform transform) {
BoundingBox bbox = new BoundingBox();
TempVars tempv = TempVars.get();
for (int i = 0; i < list.size(); i++) {
BoundingVolume vol = list.get(i).getWorldBound();
BoundingVolume newVol = vol.transform(transform, tempv.bbox);
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(newVol.getCenter().x) && !Float.isInfinite(newVol.getCenter().x)) {
bbox.mergeLocal(newVol);
}
}
tempv.release();
return bbox;
}
use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.
the class GeometryBatchFactory method doTransformVerts.
private static void doTransformVerts(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
Vector3f pos = new Vector3f();
// offset is given in element units
// convert to be in component units
offset *= 3;
for (int i = 0; i < inBuf.limit() / 3; i++) {
pos.x = inBuf.get(i * 3 + 0);
pos.y = inBuf.get(i * 3 + 1);
pos.z = inBuf.get(i * 3 + 2);
transform.mult(pos, pos);
outBuf.put(offset + i * 3 + 0, pos.x);
outBuf.put(offset + i * 3 + 1, pos.y);
outBuf.put(offset + i * 3 + 2, pos.z);
}
}
use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.
the class GeometryBatchFactory method doTransformTangents.
private static void doTransformTangents(FloatBuffer inBuf, int offset, int components, FloatBuffer outBuf, Matrix4f transform) {
Vector3f tan = new Vector3f();
// offset is given in element units
// convert to be in component units
offset *= components;
for (int i = 0; i < inBuf.limit() / components; i++) {
tan.x = inBuf.get(i * components + 0);
tan.y = inBuf.get(i * components + 1);
tan.z = inBuf.get(i * components + 2);
transform.multNormal(tan, tan);
outBuf.put(offset + i * components + 0, tan.x);
outBuf.put(offset + i * components + 1, tan.y);
outBuf.put(offset + i * components + 2, tan.z);
if (components == 4) {
outBuf.put(offset + i * components + 3, inBuf.get(i * components + 3));
}
}
}
use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.
the class GeometryBatchFactory method doTransformNorms.
private static void doTransformNorms(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
Vector3f norm = new Vector3f();
// offset is given in element units
// convert to be in component units
offset *= 3;
for (int i = 0; i < inBuf.limit() / 3; i++) {
norm.x = inBuf.get(i * 3 + 0);
norm.y = inBuf.get(i * 3 + 1);
norm.z = inBuf.get(i * 3 + 2);
transform.multNormal(norm, norm);
outBuf.put(offset + i * 3 + 0, norm.x);
outBuf.put(offset + i * 3 + 1, norm.y);
outBuf.put(offset + i * 3 + 2, norm.z);
}
}
use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.
the class Constraint method apply.
/**
* Applies the constraint to owner (and in some cases can alter other bones of the skeleton).
* @param frame
* the frame of the animation
*/
public void apply(int frame) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "Applying constraint: {0} for frame {1}", new Object[] { name, frame });
}
Transform targetTransform = targetOMA != null ? constraintHelper.getTransform(targetOMA, subtargetName, targetSpace) : null;
constraintDefinition.bake(ownerSpace, targetSpace, targetTransform, (float) ipo.calculateValue(frame));
}
Aggregations