use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOSVR method setupFinalFullTexture.
private void setupFinalFullTexture(Camera cam) {
if (environment != null) {
if (environment.getApplication() != null) {
// create offscreen framebuffer
FrameBuffer out = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
//offBuffer.setSrgb(true);
//setup framebuffer's texture
dualEyeTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear);
logger.config("Dual eye texture " + dualEyeTex.getName() + " (" + dualEyeTex.getImage().getId() + ")");
logger.config(" Type: " + dualEyeTex.getType());
logger.config(" Size: " + dualEyeTex.getImage().getWidth() + "x" + dualEyeTex.getImage().getHeight());
logger.config(" Image depth: " + dualEyeTex.getImage().getDepth());
logger.config(" Image format: " + dualEyeTex.getImage().getFormat());
logger.config(" Image color space: " + dualEyeTex.getImage().getColorSpace());
//setup framebuffer to use texture
out.setDepthBuffer(Image.Format.Depth);
out.setColorTexture(dualEyeTex);
ViewPort viewPort = environment.getApplication().getViewPort();
viewPort.setClearFlags(true, true, true);
viewPort.setBackgroundColor(ColorRGBA.Black);
viewPort.setOutputFrameBuffer(out);
} else {
throw new IllegalStateException("This VR environment is not attached to any application.");
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOSVR method postRender.
/**
* Send the textures to the two eyes.
*/
public void postRender() {
if (environment != null) {
if (environment.isInVR()) {
VRAPI api = environment.getVRHardware();
if (api.getCompositor() != null) {
// using the compositor...
int errl = 0, errr = 0;
if (environment.isInstanceRendering()) {
if (leftTextureType.handle == -1 || leftTextureType.handle != getFullTexId()) {
leftTextureType.handle = getFullTexId();
if (leftTextureType.handle != -1) {
leftTextureType.write();
if (api instanceof OSVR) {
osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = leftTextureType.handle;
osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = dualEyeTex.getImage().getId();
osvr_renderBuffer[OSVR.EYE_LEFT].write();
registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_LEFT]);
}
}
} else {
if (api instanceof OSVR) {
((OSVR) api).handleRenderBufferPresent(osvr_viewDescLeft, osvr_viewDescRight, osvr_renderBuffer[OSVR.EYE_LEFT], osvr_renderBuffer[OSVR.EYE_LEFT]);
}
}
} else if (leftTextureType.handle == -1 || rightTextureType.handle == -1 || leftTextureType.handle != getLeftTexId() || rightTextureType.handle != getRightTexId()) {
leftTextureType.handle = getLeftTexId();
if (leftTextureType.handle != -1) {
logger.fine("Writing Left texture to native memory at " + leftTextureType.getPointer());
leftTextureType.write();
if (api instanceof OSVR) {
osvr_renderBuffer[OSVR.EYE_LEFT].colorBufferName = leftTextureType.handle;
if (leftEyeDepth != null)
osvr_renderBuffer[OSVR.EYE_LEFT].depthStencilBufferName = leftEyeDepth.getImage().getId();
osvr_renderBuffer[OSVR.EYE_LEFT].write();
registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_LEFT]);
}
}
rightTextureType.handle = getRightTexId();
if (rightTextureType.handle != -1) {
logger.fine("Writing Right texture to native memory at " + leftTextureType.getPointer());
rightTextureType.write();
if (api instanceof OSVR) {
osvr_renderBuffer[OSVR.EYE_RIGHT].colorBufferName = rightTextureType.handle;
if (rightEyeDepth != null)
osvr_renderBuffer[OSVR.EYE_RIGHT].depthStencilBufferName = rightEyeDepth.getImage().getId();
osvr_renderBuffer[OSVR.EYE_RIGHT].write();
registerOSVRBuffer(osvr_renderBuffer[OSVR.EYE_RIGHT]);
}
}
} else {
if (api instanceof OSVR) {
((OSVR) api).handleRenderBufferPresent(osvr_viewDescFull, osvr_viewDescFull, osvr_renderBuffer[OSVR.EYE_LEFT], osvr_renderBuffer[OSVR.EYE_RIGHT]);
}
}
if (errl != 0) {
logger.severe("Submit to left compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl) + " (" + Integer.toString(errl) + ")");
logger.severe(" Texture color space: " + OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace));
logger.severe(" Texture type: " + OpenVRUtil.getETextureTypeString(leftTextureType.eType));
logger.severe(" Texture handle: " + leftTextureType.handle);
logger.severe(" Left eye texture " + leftEyeTexture.getName() + " (" + leftEyeTexture.getImage().getId() + ")");
logger.severe(" Type: " + leftEyeTexture.getType());
logger.severe(" Size: " + leftEyeTexture.getImage().getWidth() + "x" + leftEyeTexture.getImage().getHeight());
logger.severe(" Image depth: " + leftEyeTexture.getImage().getDepth());
logger.severe(" Image format: " + leftEyeTexture.getImage().getFormat());
logger.severe(" Image color space: " + leftEyeTexture.getImage().getColorSpace());
}
if (errr != 0) {
logger.severe("Submit to right compositor error: " + OpenVRUtil.getEVRCompositorErrorString(errl) + " (" + Integer.toString(errl) + ")");
logger.severe(" Texture color space: " + OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace));
logger.severe(" Texture type: " + OpenVRUtil.getETextureTypeString(rightTextureType.eType));
logger.severe(" Texture handle: " + rightTextureType.handle);
logger.severe(" Right eye texture " + rightEyeTexture.getName() + " (" + rightEyeTexture.getImage().getId() + ")");
logger.severe(" Type: " + rightEyeTexture.getType());
logger.severe(" Size: " + rightEyeTexture.getImage().getWidth() + "x" + rightEyeTexture.getImage().getHeight());
logger.severe(" Image depth: " + rightEyeTexture.getImage().getDepth());
logger.severe(" Image format: " + rightEyeTexture.getImage().getFormat());
logger.severe(" Image color space: " + rightEyeTexture.getImage().getColorSpace());
}
}
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class VRViewManagerOpenVR method initTextureSubmitStructs.
/**
* Initialize the system binds of the textures.
*/
private void initTextureSubmitStructs() {
leftTextureType = new Texture_t();
rightTextureType = new Texture_t();
if (environment != null) {
if (environment.getVRHardware() instanceof OpenVR) {
leftTextureBounds = new VRTextureBounds_t();
rightTextureBounds = new VRTextureBounds_t();
// left eye
leftTextureBounds.uMax = 0.5f;
leftTextureBounds.uMin = 0f;
leftTextureBounds.vMax = 1f;
leftTextureBounds.vMin = 0f;
leftTextureBounds.setAutoSynch(false);
leftTextureBounds.setAutoRead(false);
leftTextureBounds.setAutoWrite(false);
leftTextureBounds.write();
// right eye
rightTextureBounds.uMax = 1f;
rightTextureBounds.uMin = 0.5f;
rightTextureBounds.vMax = 1f;
rightTextureBounds.vMin = 0f;
rightTextureBounds.setAutoSynch(false);
rightTextureBounds.setAutoRead(false);
rightTextureBounds.setAutoWrite(false);
rightTextureBounds.write();
// texture type
leftTextureType.eColorSpace = JOpenVRLibrary.EColorSpace.EColorSpace_ColorSpace_Gamma;
leftTextureType.eType = JOpenVRLibrary.ETextureType.ETextureType_TextureType_OpenGL;
leftTextureType.setAutoSynch(false);
leftTextureType.setAutoRead(false);
leftTextureType.setAutoWrite(false);
leftTextureType.handle = -1;
rightTextureType.eColorSpace = JOpenVRLibrary.EColorSpace.EColorSpace_ColorSpace_Gamma;
rightTextureType.eType = JOpenVRLibrary.ETextureType.ETextureType_TextureType_OpenGL;
rightTextureType.setAutoSynch(false);
rightTextureType.setAutoRead(false);
rightTextureType.setAutoWrite(false);
rightTextureType.handle = -1;
logger.config("Init eyes native texture binds");
logger.config(" Left eye texture");
logger.config(" address: " + leftTextureType.getPointer());
logger.config(" size: " + leftTextureType.size() + " bytes");
logger.config(" color space: " + OpenVRUtil.getEColorSpaceString(leftTextureType.eColorSpace));
logger.config(" type: " + OpenVRUtil.getETextureTypeString(leftTextureType.eType));
logger.config(" auto read: " + leftTextureType.getAutoRead());
logger.config(" auto write: " + leftTextureType.getAutoWrite());
logger.config(" handle address: " + leftTextureType.handle);
logger.config(" handle value: " + leftTextureType.handle);
logger.config("");
logger.config(" Right eye texture");
logger.config(" address: " + rightTextureType.getPointer());
logger.config(" size: " + rightTextureType.size() + " bytes");
logger.config(" color space: " + OpenVRUtil.getEColorSpaceString(rightTextureType.eColorSpace));
logger.config(" type: " + OpenVRUtil.getETextureTypeString(rightTextureType.eType));
logger.config(" auto read: " + rightTextureType.getAutoRead());
logger.config(" auto write: " + rightTextureType.getAutoWrite());
logger.config(" handle address: " + rightTextureType.handle);
logger.config(" handle value: " + rightTextureType.handle);
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class ShaderNodeDefinition method read.
/**
* jme serialization (not used)
*
* @param im the importer
* @throws IOException
*/
@Override
public void read(JmeImporter im) throws IOException {
InputCapsule ic = (InputCapsule) im.getCapsule(this);
name = ic.readString("name", "");
String[] str = ic.readStringArray("shadersLanguage", null);
if (str != null) {
shadersLanguage = Arrays.asList(str);
} else {
shadersLanguage = new ArrayList<String>();
}
str = ic.readStringArray("shadersPath", null);
if (str != null) {
shadersPath = Arrays.asList(str);
} else {
shadersPath = new ArrayList<String>();
}
type = ic.readEnum("type", Shader.ShaderType.class, null);
inputs = (List<ShaderNodeVariable>) ic.readSavableArrayList("inputs", new ArrayList<ShaderNodeVariable>());
outputs = (List<ShaderNodeVariable>) ic.readSavableArrayList("outputs", new ArrayList<ShaderNodeVariable>());
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class ShaderNodeVariable method write.
/**
* jme serialization (not used)
*
* @param ex the exporter
* @throws IOException
*/
@Override
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = (OutputCapsule) ex.getCapsule(this);
oc.write(name, "name", "");
oc.write(type, "type", "");
oc.write(nameSpace, "nameSpace", "");
oc.write(condition, "condition", null);
oc.write(shaderOutput, "shaderOutput", false);
oc.write(multiplicity, "multiplicity", null);
}
Aggregations