use of com.jme3.math.Matrix4f 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.Matrix4f 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.Matrix4f 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.Matrix4f in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowFilterVR method preFrame.
@Override
protected void preFrame(float tpf) {
shadowRenderer.preFrame(tpf);
material.setMatrix4("ViewProjectionMatrixInverse", viewPort.getCamera().getViewProjectionMatrix().invert());
Matrix4f m = viewPort.getCamera().getViewProjectionMatrix();
material.setVector4("ViewProjectionMatrixRow2", tmpv.set(m.m20, m.m21, m.m22, m.m23));
}
use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.
the class OSVR method getHMDMatrixProjectionRightEye.
@Override
public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) {
if (eyeRightInfo == null)
return cam.getProjectionMatrix();
if (eyeMatrix[EYE_RIGHT] == null) {
FloatBuffer tfb = FloatBuffer.allocate(16);
com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte) EYE_RIGHT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short) 0, tfb);
eyeMatrix[EYE_RIGHT] = new Matrix4f();
eyeMatrix[EYE_RIGHT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15));
}
return eyeMatrix[EYE_RIGHT];
}
Aggregations