|
From: <tre...@us...> - 2007-12-01 00:24:48
|
Revision: 611
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=611&view=rev
Author: trevorolio
Date: 2007-11-30 16:21:27 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
Added a spline interpolator to the scripting API, the better to do things like test for whether a thrown ball would hit a person without breaking out the hard maths.
Added a announcement function to the script API so scripts can show messages to all people in a space.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCameraMotionBehavior.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-12-01 00:21:24 UTC (rev 610)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-12-01 00:21:27 UTC (rev 611)
@@ -564,6 +564,10 @@
}
shape.stopMotion(event.getTransform());
+ } else if (SpaceEvent.ANNOUNCE_EVENT.equals(event.getName())) {
+ String announcement = event.getStringProperty(SpaceEvent.ANNOUNCE_MESSAGE);
+ listener.receivedChatMessage(null, announcement);
+
} else if (SpaceEvent.TEXT_SAY_EVENT.equals(event.getName())) {
User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
if (user == null) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCameraMotionBehavior.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCameraMotionBehavior.java 2007-12-01 00:21:24 UTC (rev 610)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCameraMotionBehavior.java 2007-12-01 00:21:27 UTC (rev 611)
@@ -113,35 +113,10 @@
} else if (id == MouseEvent.MOUSE_PRESSED) {
transformGroup.getTransform(currXform);
currXform.get(orientation);
- getEuler(orientation, euler);
+ J3DRenderer.getEuler(orientation, euler);
x_last = evt.getX();
y_last = evt.getY();
}
}
}
-
- private void getEuler(Quat4d quat, Vector3d euler) {
- double heading = 0, bank = 0, attitude = 0;
-
- double sqw = quat.w * quat.w;
- double sqx = quat.x * quat.x;
- double sqy = quat.y * quat.y;
- double sqz = quat.z * quat.z;
- double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
- double test = quat.x * quat.y + quat.z * quat.w;
- if (test > 0.499 * unit) { // singularity at north pole
- heading = 2 * Math.atan2(quat.x, quat.w);
- bank = Math.PI / 2;
- attitude = 0;
- } else if (test < -0.499 * unit) { // singularity at south pole
- heading = -2 * Math.atan2(quat.x, quat.w);
- bank = -Math.PI / 2;
- attitude = 0;
- } else {
- heading = Math.atan2(2 * quat.y * quat.w - 2 * quat.x * quat.z, sqx - sqy - sqz + sqw);
- bank = Math.asin(2 * test / unit);
- attitude = Math.atan2(2 * quat.x * quat.w - 2 * quat.y * quat.z, -sqx + sqy - sqz + sqw);
- }
- euler.set(attitude, heading, bank);
- }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-12-01 00:21:24 UTC (rev 610)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-12-01 00:21:27 UTC (rev 611)
@@ -35,6 +35,7 @@
import javax.media.j3d.View;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
+import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;
@@ -835,4 +836,29 @@
public boolean completedInitialLoad() {
return completedInitialLoad;
}
+
+ public static void getEuler(Quat4d quat, Vector3d euler) {
+ double heading = 0, bank = 0, attitude = 0;
+
+ double sqw = quat.w * quat.w;
+ double sqx = quat.x * quat.x;
+ double sqy = quat.y * quat.y;
+ double sqz = quat.z * quat.z;
+ double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
+ double test = quat.x * quat.y + quat.z * quat.w;
+ if (test > 0.499 * unit) { // singularity at north pole
+ heading = 2 * Math.atan2(quat.x, quat.w);
+ bank = Math.PI / 2;
+ attitude = 0;
+ } else if (test < -0.499 * unit) { // singularity at south pole
+ heading = -2 * Math.atan2(quat.x, quat.w);
+ bank = -Math.PI / 2;
+ attitude = 0;
+ } else {
+ heading = Math.atan2(2 * quat.y * quat.w - 2 * quat.x * quat.z, sqx - sqy - sqz + sqw);
+ bank = Math.asin(2 * test / unit);
+ attitude = Math.atan2(2 * quat.x * quat.w - 2 * quat.y * quat.z, -sqx + sqy - sqz + sqw);
+ }
+ euler.set(attitude, heading, bank);
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2007-12-01 00:21:24 UTC (rev 610)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2007-12-01 00:21:27 UTC (rev 611)
@@ -224,6 +224,10 @@
public static final String USER_SAT_EVENT = "UserSat";
+ public static final String ANNOUNCE_EVENT = "Announce";
+
+ public static final String ANNOUNCE_MESSAGE = "message";
+
private String name = null;
private HashMap properties = new HashMap();
@@ -422,7 +426,7 @@
return transform;
}
- private void getTransform(Transform3D transform) {
+ public void getTransform(Transform3D transform) {
Vector3d vector = new Vector3d(getDoubleProperty(SpaceEvent.X).doubleValue(), getDoubleProperty(SpaceEvent.Y).doubleValue(), getDoubleProperty(SpaceEvent.Z).doubleValue());
Quat4d quaternion = new Quat4d(getDoubleProperty(SpaceEvent.RX).doubleValue(), getDoubleProperty(SpaceEvent.RY).doubleValue(), getDoubleProperty(SpaceEvent.RZ).doubleValue(), getDoubleProperty(SpaceEvent.RW).doubleValue());
transform.set(quaternion, vector, 1);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|