use of org.jwildfire.create.tina.base.Stereo3dEye in project JWildfire by thargor6.
the class FlameRenderer method renderImageStereo3d.
private RenderedFlame renderImageStereo3d(RenderInfo pRenderInfo) {
Stereo3dEye storedEye = eye;
double storedAngle = flame.getStereo3dAngle();
double storedEyeDist = flame.getStereo3dEyeDist();
try {
switch(pRenderInfo.getRenderMode()) {
case PREVIEW:
switch(flame.getStereo3dPreview()) {
case SIDE_BY_SIDE:
{
RenderedFlame result = renderStereo3dSideBySide(pRenderInfo);
ScaleTransformer scaleTransformer = new ScaleTransformer();
scaleTransformer.setAspect(ScaleAspect.IGNORE);
scaleTransformer.setScaleWidth(pRenderInfo.getImageWidth() * renderScale);
scaleTransformer.setScaleHeight(pRenderInfo.getImageHeight() * renderScale);
scaleTransformer.transformImage(result.getImage());
return result;
}
case SIDE_BY_SIDE_FULL:
{
int oldWidth = pRenderInfo.getImageWidth();
pRenderInfo.setImageWidth(oldWidth / 2);
RenderedFlame result = renderStereo3dSideBySide(pRenderInfo);
pRenderInfo.setImageWidth(oldWidth);
return result;
}
case ANAGLYPH:
{
return renderStereo3dAnaglyph(pRenderInfo);
}
case NONE:
return renderImageNormal(pRenderInfo, 1, 0);
default:
throw new IllegalStateException(pRenderInfo.getRenderMode().toString());
}
case PRODUCTION:
switch(flame.getStereo3dMode()) {
case ANAGLYPH:
return renderStereo3dAnaglyph(pRenderInfo);
case INTERPOLATED_IMAGES:
{
RenderInfo localRenderInfo = pRenderInfo.makeCopy();
localRenderInfo.setRenderHDR(false);
localRenderInfo.setRenderZBuffer(false);
RenderedFlame[] leftRenders = new RenderedFlame[flame.getStereo3dInterpolatedImageCount()];
double dAngle = storedAngle / (double) leftRenders.length;
double dEyeDist = storedEyeDist / (double) leftRenders.length;
int totalImageCount = 2 * leftRenders.length;
int totalImageIdx = 0;
for (int i = 0; i < leftRenders.length; i++) {
eye = Stereo3dEye.LEFT;
flame.setStereo3dAngle((i + 1) * dAngle);
flame.setStereo3dEyeDist((i + 1) * dEyeDist);
leftRenders[i] = renderImageNormal(localRenderInfo, totalImageCount, totalImageIdx++);
}
RenderedFlame[] rightRenders = new RenderedFlame[flame.getStereo3dInterpolatedImageCount()];
for (int i = 0; i < rightRenders.length; i++) {
eye = Stereo3dEye.RIGHT;
flame.setStereo3dAngle((i + 1) * dAngle);
flame.setStereo3dEyeDist((i + 1) * dEyeDist);
rightRenders[i] = renderImageNormal(localRenderInfo, totalImageCount, totalImageIdx++);
}
if (flame.isStereo3dSwapSides()) {
RenderedFlame[] tmp = leftRenders;
leftRenders = rightRenders;
rightRenders = tmp;
}
RenderedFlame mergedRender = new RenderedFlame();
localRenderInfo.setImageWidth(2 * pRenderInfo.getImageWidth());
localRenderInfo.setImageHeight(leftRenders.length * pRenderInfo.getImageHeight());
mergedRender.init(localRenderInfo, flame);
SimpleImage mergedImg = mergedRender.getImage();
ComposeTransformer composeTransformer = new ComposeTransformer();
composeTransformer.setHAlign(HAlignment.OFF);
composeTransformer.setVAlign(VAlignment.OFF);
int yOff = 0;
for (int i = 0; i < leftRenders.length; i++) {
composeTransformer.setLeft(0);
composeTransformer.setTop(yOff);
composeTransformer.setForegroundImage(leftRenders[i].getImage());
composeTransformer.transformImage(mergedImg);
yOff += pRenderInfo.getImageHeight();
}
yOff = 0;
for (int i = 0; i < rightRenders.length; i++) {
composeTransformer.setLeft(pRenderInfo.getImageWidth());
composeTransformer.setTop(yOff);
composeTransformer.setForegroundImage(rightRenders[i].getImage());
composeTransformer.transformImage(mergedImg);
yOff += pRenderInfo.getImageHeight();
}
return mergedRender;
}
case SIDE_BY_SIDE:
return renderStereo3dSideBySide(pRenderInfo);
case NONE:
return renderImageNormal(pRenderInfo, 1, 0);
default:
throw new IllegalStateException(flame.getStereo3dMode().toString());
}
default:
throw new IllegalStateException(pRenderInfo.getRenderMode().toString());
}
} finally {
eye = storedEye;
flame.setStereo3dAngle(storedAngle);
flame.setStereo3dEyeDist(storedEyeDist);
}
}
Aggregations