use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowFilter 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 AbstractShadowRenderer method init.
private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) {
this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md");
shadowFB = new FrameBuffer[nbShadowMaps];
shadowMaps = new Texture2D[nbShadowMaps];
dispPic = new Picture[nbShadowMaps];
lightViewProjectionsMatrices = new Matrix4f[nbShadowMaps];
shadowMapStringCache = new String[nbShadowMaps];
lightViewStringCache = new String[nbShadowMaps];
//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
dummyTex = new Texture2D(shadowMapSize, shadowMapSize, Format.RGBA8);
preshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md");
postshadowMat.setFloat("ShadowMapSize", shadowMapSize);
for (int i = 0; i < nbShadowMaps; i++) {
lightViewProjectionsMatrices[i] = new Matrix4f();
shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1);
shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth);
shadowFB[i].setDepthTexture(shadowMaps[i]);
//DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
shadowFB[i].setColorTexture(dummyTex);
shadowMapStringCache[i] = "ShadowMap" + i;
lightViewStringCache[i] = "LightViewProjectionMatrix" + i;
postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]);
//quads for debuging purpose
dispPic[i] = new Picture("Picture" + i);
dispPic[i].setTexture(assetManager, shadowMaps[i], false);
}
setShadowCompareMode(shadowCompareMode);
setEdgeFilteringMode(edgeFilteringMode);
setShadowIntensity(shadowIntensity);
initForcedRenderState();
}
use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.
the class InstancedGeometry method updateInstances.
public void updateInstances() {
FloatBuffer fb = (FloatBuffer) transformInstanceData.getData();
fb.limit(fb.capacity());
fb.position(0);
TempVars vars = TempVars.get();
{
float[] temp = vars.matrixWrite;
for (int i = 0; i < firstUnusedIndex; i++) {
Geometry geom = geometries[i];
if (geom == null) {
geom = geometries[firstUnusedIndex - 1];
if (geom == null) {
throw new AssertionError();
}
swap(i, firstUnusedIndex - 1);
while (geometries[firstUnusedIndex - 1] == null) {
firstUnusedIndex--;
}
}
Matrix4f worldMatrix = geom.getWorldMatrix();
updateInstance(worldMatrix, temp, 0, vars.tempMat3, vars.quat1);
fb.put(temp);
}
}
vars.release();
fb.flip();
if (fb.limit() / INSTANCE_SIZE != firstUnusedIndex) {
throw new AssertionError();
}
transformInstanceData.updateData(fb);
}
use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.
the class OSVR method getHMDMatrixProjectionLeftEye.
@Override
public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam) {
if (eyeLeftInfo == null)
return cam.getProjectionMatrix();
if (eyeMatrix[EYE_LEFT] == null) {
FloatBuffer tfb = FloatBuffer.allocate(16);
com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte) EYE_LEFT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short) 0, tfb);
eyeMatrix[EYE_LEFT] = new Matrix4f();
eyeMatrix[EYE_LEFT].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_LEFT];
}
use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.
the class OpenVR method getSeatedToAbsolutePosition.
@Override
public Vector3f getSeatedToAbsolutePosition() {
if (environment.isSeatedExperience() == false)
return Vector3f.ZERO;
if (hmdSeatToStand == null) {
hmdSeatToStand = new Vector3f();
HmdMatrix34_t mat = vrsystemFunctions.GetSeatedZeroPoseToStandingAbsoluteTrackingPose.apply();
Matrix4f tempmat = new Matrix4f();
VRUtil.convertSteamVRMatrix3ToMatrix4f(mat, tempmat);
tempmat.toTranslationVector(hmdSeatToStand);
}
return hmdSeatToStand;
}
Aggregations