summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-04-01 23:43:43 +0000
committerKenneth Russel <[email protected]>2007-04-01 23:43:43 +0000
commit340ef879cdeaebdce644351cfddf90c032cf5d56 (patch)
treef40d01f0f01e998973dce10524553946770a6811 /src
parent5b543c792f28e79e1b15da6747e68d9e0f5c8ce9 (diff)
Added PerspectiveCamera.getWidthAngle(). Removed commented-out code
from Camera. Added error checking code to Group. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@54 83d24430-9974-4f80-8418-2cc3294053b9
Diffstat (limited to 'src')
-rw-r--r--src/net/java/joglutils/msg/nodes/Camera.java7
-rw-r--r--src/net/java/joglutils/msg/nodes/Group.java8
-rw-r--r--src/net/java/joglutils/msg/nodes/PerspectiveCamera.java12
3 files changed, 24 insertions, 3 deletions
diff --git a/src/net/java/joglutils/msg/nodes/Camera.java b/src/net/java/joglutils/msg/nodes/Camera.java
index 5333f81..04380f1 100644
--- a/src/net/java/joglutils/msg/nodes/Camera.java
+++ b/src/net/java/joglutils/msg/nodes/Camera.java
@@ -79,7 +79,6 @@ public abstract class Camera extends Node {
public Camera() {
position = new Vec3f(0, 0, 1);
orientation = new Rotf();
- // orientation = new Rotf(new Vec3f(0, 1, 0), (float) (Math.PI));
projMatrix = new Mat4f();
viewMatrix = new Mat4f();
@@ -109,13 +108,15 @@ public abstract class Camera extends Node {
return orientation;
}
- /** Sets the aspect ratio of the camera. */
+ /** Sets the aspect ratio of the camera -- the width of the viewport
+ divided by the height of the viewport. */
public void setAspectRatio(float aspectRatio) {
this.aspectRatio = aspectRatio;
projDirty = true;
}
- /** Returns the aspect ratio of the camera. */
+ /** Returns the aspect ratio of the camera -- the width of the
+ viewport divided by the height of the viewport. */
public float getAspectRatio() {
return aspectRatio;
}
diff --git a/src/net/java/joglutils/msg/nodes/Group.java b/src/net/java/joglutils/msg/nodes/Group.java
index df3232d..ccf06f0 100644
--- a/src/net/java/joglutils/msg/nodes/Group.java
+++ b/src/net/java/joglutils/msg/nodes/Group.java
@@ -48,11 +48,15 @@ public class Group extends Node {
/** Append a child node to the list of children nodes this group node is managing. */
public void addChild(Node child) {
+ if (child == null)
+ throw new IllegalArgumentException("child may not be null");
children.add(child);
}
/** Adds a child so that it becomes the one with the given index. */
public void insertChild(int index, Node child) {
+ if (child == null)
+ throw new IllegalArgumentException("child may not be null");
children.add(index, child);
}
@@ -102,6 +106,8 @@ public class Group extends Node {
greater than the number of children
*/
public void replaceChild(int index, Node newChild) throws IndexOutOfBoundsException {
+ if (newChild == null)
+ throw new IllegalArgumentException("child may not be null");
removeChild(index);
insertChild(index, newChild);
}
@@ -111,6 +117,8 @@ public class Group extends Node {
oldChild as argument, and call replaceChild(int, SoNode*) if the
child is found. */
public void replaceChild(Node oldChild, Node newChild) {
+ if (newChild == null)
+ throw new IllegalArgumentException("child may not be null");
int idx = findChild(oldChild);
if (idx >= 0)
replaceChild(idx, newChild);
diff --git a/src/net/java/joglutils/msg/nodes/PerspectiveCamera.java b/src/net/java/joglutils/msg/nodes/PerspectiveCamera.java
index 96ce717..0bffd88 100644
--- a/src/net/java/joglutils/msg/nodes/PerspectiveCamera.java
+++ b/src/net/java/joglutils/msg/nodes/PerspectiveCamera.java
@@ -93,6 +93,18 @@ public class PerspectiveCamera extends Camera {
return vertFOVScale * DEFAULT_HEIGHT_ANGLE;
}
+ /** Returns the width angle, in radians, of this perspective
+ camera, assuming the passed-in aspect ratio. */
+ public float getWidthAngle(float aspectRatio) {
+ return (float) Math.atan(aspectRatio * Math.tan(getHeightAngle()));
+ }
+
+ /** Returns the width angle, in radians, of this perspective camera,
+ assuming the camera's currently-set aspect ratio. */
+ public float getWidthAngle() {
+ return getWidthAngle(getAspectRatio());
+ }
+
public void render(GLRenderAction action) {
// FIXME: unclear whether we should be doing this, or whether we
// should have a mechanism which doesn't require mutation of the