Skip to content

Commit

Permalink
adding poor orthogonal lens camera
Browse files Browse the repository at this point in the history
  • Loading branch information
skrat committed Nov 23, 2010
1 parent 801a49b commit dfeed72
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/org/sunflow/PluginRegistry.java
Expand Up @@ -25,6 +25,7 @@
import org.sunflow.core.bucket.RowBucketOrder;
import org.sunflow.core.bucket.SpiralBucketOrder;
import org.sunflow.core.camera.FisheyeLens;
import org.sunflow.core.camera.OrthogonalLens;
import org.sunflow.core.camera.PinholeLens;
import org.sunflow.core.camera.SphericalLens;
import org.sunflow.core.camera.ThinLens;
Expand All @@ -51,13 +52,13 @@
import org.sunflow.core.modifiers.BumpMappingModifier;
import org.sunflow.core.modifiers.NormalMapModifier;
import org.sunflow.core.modifiers.PerlinModifier;
import org.sunflow.core.parser.DAEParser;
import org.sunflow.core.parser.RA2Parser;
import org.sunflow.core.parser.RA3Parser;
import org.sunflow.core.parser.SCAsciiParser;
import org.sunflow.core.parser.SCBinaryParser;
import org.sunflow.core.parser.SCParser;
import org.sunflow.core.parser.ShaveRibParser;
import org.sunflow.core.parser.DAEParser;
import org.sunflow.core.photonmap.CausticPhotonMap;
import org.sunflow.core.photonmap.GlobalPhotonMap;
import org.sunflow.core.photonmap.GridPhotonMap;
Expand Down Expand Up @@ -114,8 +115,8 @@
import org.sunflow.core.shader.ViewIrradianceShader;
import org.sunflow.core.shader.WireframeShader;
import org.sunflow.core.tesselatable.BezierMesh;
import org.sunflow.core.tesselatable.FileMesh;
import org.sunflow.core.tesselatable.ColladaGeometry;
import org.sunflow.core.tesselatable.FileMesh;
import org.sunflow.core.tesselatable.Gumbo;
import org.sunflow.core.tesselatable.Teapot;
import org.sunflow.image.BitmapReader;
Expand All @@ -129,9 +130,9 @@
import org.sunflow.image.writers.EXRBitmapWriter;
import org.sunflow.image.writers.HDRBitmapWriter;
import org.sunflow.image.writers.IGIBitmapWriter;
import org.sunflow.image.writers.JPGBitmapWriter;
import org.sunflow.image.writers.PNGBitmapWriter;
import org.sunflow.image.writers.TGABitmapWriter;
import org.sunflow.image.writers.JPGBitmapWriter;
import org.sunflow.system.Plugins;

/**
Expand Down Expand Up @@ -258,6 +259,7 @@ public final class PluginRegistry {
cameraLensPlugins.registerPlugin("thinlens", ThinLens.class);
cameraLensPlugins.registerPlugin("fisheye", FisheyeLens.class);
cameraLensPlugins.registerPlugin("spherical", SphericalLens.class);
cameraLensPlugins.registerPlugin("ortho", OrthogonalLens.class);
}

static {
Expand Down
20 changes: 20 additions & 0 deletions src/org/sunflow/core/camera/OrthogonalLens.java
@@ -0,0 +1,20 @@
package org.sunflow.core.camera;

import org.sunflow.SunflowAPI;
import org.sunflow.core.CameraLens;
import org.sunflow.core.ParameterList;
import org.sunflow.core.Ray;

public class OrthogonalLens implements CameraLens {

public boolean update(ParameterList pl, SunflowAPI api) {
return true;
}

public Ray getRay(float x, float y, int imageWidth, int imageHeight, double lensX, double lensY, double time) {
float du = (2f * x) / (imageWidth - 1.0f);
float dv = (2f * y) / (imageHeight - 1.0f);
return new Ray(0, 0, 0, du, dv, -1);
}

}
31 changes: 17 additions & 14 deletions src/org/sunflow/core/parser/DAEParser.java
@@ -1,34 +1,36 @@
package org.sunflow.core.parser;

import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Iterator;
import java.util.LinkedList;

import javax.xml.xpath.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.sunflow.SunflowAPI;
import org.sunflow.SunflowAPIInterface;
import org.sunflow.core.SceneParser;
import org.sunflow.system.Timer;
import org.sunflow.system.UI;
import org.sunflow.system.UI.Module;
import org.sunflow.image.Color;
import org.sunflow.math.Matrix4;
import org.sunflow.math.Point3;
import org.sunflow.math.Vector3;
import org.sunflow.image.Color;
import org.sunflow.system.Timer;
import org.sunflow.system.UI;
import org.sunflow.system.UI.Module;
import org.sunflow.util.FastHashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class DAEParser implements SceneParser {

Expand Down Expand Up @@ -418,7 +420,6 @@ private void setCamera(Matrix4 transform) {
if (yfov != null) { fov += yfov; }
if (xfov != null && yfov != null)
{ fov = fov/2.0f; }
if (fov == 0.0f) { fov = 45.0f; } // default value

try {
znear = ((float[]) optics.get("znear"))[0];
Expand Down Expand Up @@ -451,6 +452,8 @@ private void setCamera(Matrix4 transform) {
api.parameter("focus.distance", fdist);
api.parameter("lens.radius", lensr);
api.camera(cameraId, "thinlens");
} else if (fov == 0f) {
api.camera(cameraId, "ortho");
} else {
api.camera(cameraId, "pinhole");
}
Expand Down

0 comments on commit dfeed72

Please sign in to comment.