You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(7) |
Jul
(26) |
Aug
(85) |
Sep
(141) |
Oct
(85) |
Nov
(60) |
Dec
(29) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(38) |
Feb
(78) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tre...@us...> - 2007-12-10 22:50:42
|
Revision: 624
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=624&view=rev
Author: trevorolio
Date: 2007-12-10 14:50:47 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
Fixed a couple of bugs in CometProto so it no longer throws NullPointerExceptions in routine failure cases seen in tests. Added mutable background colors to spaces.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-12-10 22:50:35 UTC (rev 623)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-12-10 22:50:47 UTC (rev 624)
@@ -304,7 +304,8 @@
checkAuthDoc(advancedAuth, basicAuth);
spaceDocument = checkSpaceSeaLevel(advancedClient, spaceDocument);
-
+ spaceDocument = checkBackgroundColor(advancedClient, spaceDocument);
+
checkSettings(spaceDocument.getSpaceID(), advancedClient);
TemplateDocument newTemplateDoc = checkTemplateScriptAPI(advancedClient);
@@ -599,6 +600,17 @@
}
+ private SpaceDocument checkBackgroundColor(WebAPIClient advancedClient, SpaceDocument spaceDocument) throws IOException {
+ advancedClient.setSpaceBackgroundColor(spaceDocument.getSpaceID(), new float[]{ 0.5f, 0.5f, 0.5f });
+
+ spaceDocument = advancedClient.getSpaceDocument(spaceDocument.getSpaceID(), false);
+ assertEquals(0.5, spaceDocument.getBackgroundColor()[0], 0.0001);
+ assertEquals(0.5, spaceDocument.getBackgroundColor()[1], 0.0001);
+ assertEquals(0.5, spaceDocument.getBackgroundColor()[2], 0.0001);
+
+ return spaceDocument;
+ }
+
private SpaceDocument checkSpaceSeaLevel(WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
assertFalse(spaceDocument.getDisplaySea());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-10 22:50:33
|
Revision: 623
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=623&view=rev
Author: trevorolio
Date: 2007-12-10 14:50:35 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
Fixed a couple of bugs in CometProto so it no longer throws NullPointerExceptions in routine failure cases seen in tests. Added mutable background colors to spaces.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/UIConstants.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceDocument.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.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-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -23,6 +23,7 @@
import java.util.zip.ZipInputStream;
import javax.media.j3d.Transform3D;
+import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import com.ogoglio.client.model.BodyConfiguration;
@@ -108,7 +109,9 @@
}
SpaceDocument spaceDoc = webClient.getSpaceDocument(spaceID, true);
- space = new Space(this, spaceDoc.getSpaceID(), spaceDoc.getDisplayName(), spaceDoc.getOwnerUsername(), spaceDoc.getDisplaySea(), spaceDoc.getSeaLevel());
+ float[] bgColor = spaceDoc.getBackgroundColor();
+ Color3f backgroundColor = new Color3f(bgColor[0], bgColor[1], bgColor[2]);
+ space = new Space(this, spaceDoc.getSpaceID(), spaceDoc.getDisplayName(), spaceDoc.getOwnerUsername(), spaceDoc.getDisplaySea(), spaceDoc.getSeaLevel(), backgroundColor);
//create the event channel and start queuing events
messageChannel = new TCPChannel(AsyncProtoFactory.getDefaultClient(descriptor, true), messenger, true, new ChannelListener(), true, "space-client");
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-12-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -28,6 +28,7 @@
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.Log;
import com.ogoglio.util.StreamUtils;
+import com.ogoglio.util.UIConstants;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
@@ -71,7 +72,7 @@
}
public SpaceDocument createSpace(String spaceName) {
- SpaceDocument spaceDoc = new SpaceDocument(-1, spaceName, authenticator.getUsername(), false, 0, false, 0, -1, null);
+ SpaceDocument spaceDoc = new SpaceDocument(-1, spaceName, authenticator.getUsername(), false, 0, false, 0, -1, null, UIConstants.SKY_COLOR_ARRAY);
try {
return new SpaceDocument(wire.sendAuthenticatedXML(descriptor.getSpacesURI(), spaceDoc.toString(), "POST", authenticator.getAuthCookie()));
} catch (IOException e) {
@@ -204,6 +205,12 @@
wire.postAuthenticatedXML(descriptor.getSpaceURI(spaceID), spaceDoc.toString(), authenticator.getAuthCookie());
}
+ public void setSpaceBackgroundColor(long spaceID, float[] backgroundColor) throws IOException {
+ SpaceDocument spaceDoc = new SpaceDocument(wire.fetchAuthenticatedXML(descriptor.getSpaceURI(spaceID), authenticator.getAuthCookie()));
+ spaceDoc.setBackgroundColor(backgroundColor[0], backgroundColor[1], backgroundColor[2]);
+ wire.postAuthenticatedXML(descriptor.getSpaceURI(spaceID), spaceDoc.toString(), authenticator.getAuthCookie());
+ }
+
public void setSpaceMaxGuests(long spaceID, int maxGuests) throws IOException {
if (maxGuests < 0 || maxGuests > 100) {
throw new IllegalArgumentException("Cannot have less than 0 or more than 100 guests: " + maxGuests);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-12-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -22,6 +22,7 @@
import java.util.Vector;
import javax.media.j3d.Transform3D;
+import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
@@ -58,7 +59,9 @@
private Context spaceContext = null;
- public Space(Context spaceContext, long spaceID, String displayName, String ownerUsername, boolean displaySea, double seaLevel) {
+ private Color3f backgroundColor = null;
+
+ public Space(Context spaceContext, long spaceID, String displayName, String ownerUsername, boolean displaySea, double seaLevel, Color3f backgroundColor) {
ArgumentUtils.assertNotNull(spaceContext);
this.spaceContext = spaceContext;
ArgumentUtils.assertNotNegative(spaceID);
@@ -72,7 +75,14 @@
this.displaySea = displaySea;
this.seaLevel = seaLevel;
+
+ ArgumentUtils.assertNotNull(backgroundColor);
+ this.backgroundColor = backgroundColor;
}
+
+ public Color3f getBackgroundColor(){
+ return backgroundColor;
+ }
public boolean shouldDisplaySea() {
return displaySea;
@@ -535,4 +545,5 @@
listeners[i].userStood(user, seat);
}
}
+
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java 2007-12-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometClient.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -112,7 +112,13 @@
public static int pullOutCommandPart(StringBuffer buff) {
String command=buff.substring(0,buff.indexOf("$"));
+ if(command == null){
+ return BAD_CMD;
+ }
String msg=buff.substring(buff.indexOf("$")+1);
+ if(msg == null){
+ return BAD_CMD;
+ }
String lenPart=command.substring(Command.MESSAGE.length()+1);
int len=-1;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/UIConstants.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/UIConstants.java 2007-12-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/UIConstants.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -46,6 +46,8 @@
public static Color3f LIGHT_BLUE = new Color3f(0.1015f, 0.5976f, 0.8476f);
+ public static float[] SKY_COLOR_ARRAY = new float[]{ LIGHT_BLUE.x, LIGHT_BLUE.y, LIGHT_BLUE.z };
+
public static Color3f BROWN = new Color3f(0.5468f, 0.3867f, 0.0664f);
public static Color3f ORANGE = new Color3f(0.8476f, 0.4726f, 0.1015f);
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-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -202,7 +202,7 @@
directional3.setInfluencingBounds(DEFAULT_SPACE_BOUNDS);
sceneRoot.addChild(directional3);
- background = new Background(UIConstants.LIGHT_BLUE);
+ background = new Background(getSpace().getBackgroundColor());
background.setCapability(Background.ALLOW_COLOR_WRITE);
background.setApplicationBounds(DEFAULT_SPACE_BOUNDS);
sceneRoot.addChild(background);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceDocument.java 2007-12-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceDocument.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -13,11 +13,12 @@
limitations under the License. */
package com.ogoglio.xml;
-import java.text.ParseException;
+import java.awt.Color;
import nanoxml.XMLElement;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.UIConstants;
public class SpaceDocument {
@@ -39,13 +40,19 @@
public static final String SIM_ID = "simid";
- public static final String LAST_MODIFIED="lastmodified";
+ public static final String LAST_MODIFIED = "lastmodified";
+ public static final String BACKGROUND_COLOR_RED = "bgred";
+
+ public static final String BACKGROUND_COLOR_GREEN = "bggreen";
+
+ public static final String BACKGROUND_COLOR_BLUE = "bgblue";
+
public static final int MAX_SETTING_VALUE_SIZE = 10240;
- XMLElement data = null;
+ private XMLElement data = null;
- public SpaceDocument(long spaceID, String displayName, String ownerUsername, boolean published, int maxGuests, boolean displaySea, double seaLevel, long simID, String lastModifiedGMT) {
+ public SpaceDocument(long spaceID, String displayName, String ownerUsername, boolean published, int maxGuests, boolean displaySea, double seaLevel, long simID, String lastModifiedGMT, float[] backgroundColor) {
data = new XMLElement(NAME);
if (spaceID != -1) {
@@ -67,13 +74,17 @@
data.setAttribute(DISPLAY_SEA, displaySea);
data.setAttribute(SEA_LEVEL, seaLevel);
- if (lastModifiedGMT!=null) {
+ if (lastModifiedGMT != null) {
data.setAttribute(LAST_MODIFIED, lastModifiedGMT);
}
-
+
if (simID != -1) {
data.setAttribute(SIM_ID, simID);
}
+
+ data.setAttribute(BACKGROUND_COLOR_RED, backgroundColor[0]);
+ data.setAttribute(BACKGROUND_COLOR_GREEN, backgroundColor[1]);
+ data.setAttribute(BACKGROUND_COLOR_BLUE, backgroundColor[2]);
}
public SpaceDocument(XMLElement data) {
@@ -117,13 +128,13 @@
public TemplateDocument getTemplateDocument(long templateID) {
TemplateDocument[] docs = getTemplateDocuments();
for (int i = 0; i < docs.length; i++) {
- if(docs[i].getTemplateID() == templateID) {
+ if (docs[i].getTemplateID() == templateID) {
return docs[i];
}
}
return null;
}
-
+
public TemplateDocument[] getTemplateDocuments() {
XMLElement[] elements = data.getChildren(TemplateDocument.NAME);
TemplateDocument[] results = new TemplateDocument[elements.length];
@@ -232,6 +243,31 @@
}
public String getLastModifiedAsUTC() {
- return data.getStringAttribute(LAST_MODIFIED,null);
+ return data.getStringAttribute(LAST_MODIFIED, null);
}
+
+ public void setBackgroundColor(float red, float green, float blue) {
+ if (!isValidColor(red) || !isValidColor(green) || !isValidColor(blue)) {
+ throw new IllegalArgumentException("Bad background rgb: " + red + "," + green + "," + blue);
+ }
+ data.setAttribute(BACKGROUND_COLOR_RED, red);
+ data.setAttribute(BACKGROUND_COLOR_GREEN, green);
+ data.setAttribute(BACKGROUND_COLOR_BLUE, blue);
+ }
+
+ public float[] getBackgroundColor() {
+ float red = data.getFloatAttribute(BACKGROUND_COLOR_RED);
+ float green = data.getFloatAttribute(BACKGROUND_COLOR_GREEN);
+ float blue = data.getFloatAttribute(BACKGROUND_COLOR_BLUE);
+ if (!isValidColor(red) || !isValidColor(green) || !isValidColor(blue)) {
+ float[] result = { UIConstants.LIGHT_BLUE.x, UIConstants.LIGHT_BLUE.y, UIConstants.LIGHT_BLUE.z };
+ return result;
+ }
+ float[] result = { red, green, blue };
+ return result;
+ }
+
+ public static boolean isValidColor(float color) {
+ return color >= 0 && color <= 1;
+ }
}
\ No newline at end of file
Modified: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-12-10 22:50:26 UTC (rev 622)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-12-10 22:50:35 UTC (rev 623)
@@ -13,6 +13,7 @@
import nanoxml.XMLElement;
import com.ogoglio.client.model.SplinePath;
+import com.ogoglio.util.UIConstants;
import com.ogoglio.viewer.j3d.J3DSplineKeyFrame;
import com.ogoglio.viewer.j3d.J3DSplinePath;
import com.ogoglio.xml.AccountDocument;
@@ -224,7 +225,7 @@
Date now=new Date();
Date aSecondAgo=new Date(now.getTime()-1000);
- SpaceDocument doc1 = new SpaceDocument(spaceID1, displayName1, ownerUsername1, true, 23, false, 0, 44, fmt.format(aSecondAgo));
+ SpaceDocument doc1 = new SpaceDocument(spaceID1, displayName1, ownerUsername1, true, 23, false, 0, 44, fmt.format(aSecondAgo), UIConstants.SKY_COLOR_ARRAY);
assertEquals(spaceID1, doc1.getSpaceID());
assertEquals(displayName1, doc1.getDisplayName());
assertEquals(ownerUsername1, doc1.getOwnerUsername());
@@ -244,7 +245,7 @@
assertEquals(0, doc2.getSeaLevel(), 0.001);
assertEquals(44, doc2.getSimID());
- SpaceDocument doc3 = new SpaceDocument(spaceID1, displayName1, ownerUsername1, true, 23, true, -2, 44, null);
+ SpaceDocument doc3 = new SpaceDocument(spaceID1, displayName1, ownerUsername1, true, 23, true, -2, 44, null, UIConstants.SKY_COLOR_ARRAY);
assertTrue(doc3.getDisplaySea());
assertEquals(-2, doc3.getSeaLevel(), 0.00001);
SpaceDocument doc4 = new SpaceDocument(XMLElement.parseElementFromString(doc3.toElement().toString()));
@@ -252,14 +253,14 @@
assertEquals(-2, doc4.getSeaLevel(), 0.00001);
try {
- new SpaceDocument(spaceID1, displayName1, null, true, 4, true, 0, -1,null);
+ new SpaceDocument(spaceID1, displayName1, null, true, 4, true, 0, -1,null, UIConstants.SKY_COLOR_ARRAY);
fail("Should not allow null ownerURI");
} catch (IllegalArgumentException e) {
//this should happen
}
try {
- new SpaceDocument(spaceID1, null, ownerUsername1, true, 0, true, 0, -1,null);
+ new SpaceDocument(spaceID1, null, ownerUsername1, true, 0, true, 0, -1,null, UIConstants.SKY_COLOR_ARRAY);
fail("Should not allow null display name");
} catch (IllegalArgumentException e) {
//this should happen
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-10 22:50:13
|
Revision: 621
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=621&view=rev
Author: trevorolio
Date: 2007-12-10 14:50:15 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
Fixed a couple of bugs in CometProto so it no longer throws NullPointerExceptions in routine failure cases seen in tests. Added mutable background colors to spaces.
Modified Paths:
--------------
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-12-10 13:34:35 UTC (rev 620)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/PopulateMojo.java 2007-12-10 22:50:15 UTC (rev 621)
@@ -133,7 +133,8 @@
client.setSpacePublished(realSpaceID, fakeSpaceDoc.isPublished());
client.setSpaceSeaLevel(realSpaceID, fakeSpaceDoc.getSeaLevel());
client.setSpaceDisplaySea(realSpaceID, fakeSpaceDoc.getDisplaySea());
-
+ client.setSpaceBackgroundColor(realSpaceID, fakeSpaceDoc.getBackgroundColor());
+
ThingDocument things[] = fakeSpaceDoc.getThingDocuments();
for (int j = 0; j < things.length; ++j) {
ThingDocument thing = things[j];
Modified: maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java
===================================================================
--- maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java 2007-12-10 13:34:35 UTC (rev 620)
+++ maven/trunk/dev-plugins/src/main/java/com/ogoglio/plugin/ReverseMojo.java 2007-12-10 22:50:15 UTC (rev 621)
@@ -65,7 +65,7 @@
long localThingId = 1;
long localPossId = 1;
- SpaceDocument result = new SpaceDocument(localSpaceId, origSpaceDoc.getDisplayName(), origSpaceDoc.getOwnerUsername(), true /*origSpaceDoc.getPublished()*/, origSpaceDoc.getMaxGuests(), origSpaceDoc.getDisplaySea(), origSpaceDoc.getSeaLevel(), origSpaceDoc.getSimID(), null);
+ SpaceDocument result = new SpaceDocument(localSpaceId, origSpaceDoc.getDisplayName(), origSpaceDoc.getOwnerUsername(), true /*origSpaceDoc.getPublished()*/, origSpaceDoc.getMaxGuests(), origSpaceDoc.getDisplaySea(), origSpaceDoc.getSeaLevel(), origSpaceDoc.getSimID(), null, origSpaceDoc.getBackgroundColor());
ThingDocument[] thingDocs = origSpaceDoc.getThingDocuments();
for (int i = 0; i < thingDocs.length; ++i) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-04 17:00:49
|
Revision: 619
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=619&view=rev
Author: trevorolio
Date: 2007-12-04 09:00:52 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Added a fix for the sad case where the viewer does not get a message that it lost focus so it loses keyboard state, causing people to continue on whatever motion they were on. Now when we press a key for motion in one direction it negates the oposite motion, so if you do start spinning out of control and you try to spin in the oposite direction then the right thing happens.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-12-04 16:58:14 UTC (rev 618)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-12-04 17:00:52 UTC (rev 619)
@@ -143,41 +143,55 @@
if (moveForward == false) {
dirty = true;
moveForward = true;
+ moveBackward = false;
}
} else if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_S) {
if (moveBackward == false) {
dirty = true;
+ moveForward = false;
moveBackward = true;
}
} else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_Q) {
if (turnLeft == false) {
dirty = true;
turnLeft = true;
+ turnRight = false;
}
} else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_E) {
if (turnRight == false) {
dirty = true;
+ turnLeft = false;
turnRight = true;
}
} else if (e.getKeyCode() == KeyEvent.VK_A) {
if (strafeLeft == false) {
dirty = true;
strafeLeft = true;
+ strafeRight = false;
}
} else if (e.getKeyCode() == KeyEvent.VK_D) {
if (strafeRight == false) {
dirty = true;
+ strafeLeft = false;
strafeRight = true;
}
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
cameraDirty = true;
cameraReset = true;
cameraZoom = 0;
+ moveForward = false;
+ moveBackward = false;
+ turnLeft = false;
+ turnRight = false;
+ strafeLeft = false;
+ strafeRight = false;
} else if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_SLASH) {
if (moveBackward || moveForward || strafeLeft || strafeRight) {
dirty = true;
+ moveForward = false;
moveBackward = false;
- moveForward = false;
+ turnLeft = false;
+ turnRight = false;
strafeLeft = false;
strafeRight = false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-04 16:58:14
|
Revision: 618
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=618&view=rev
Author: trevorolio
Date: 2007-12-04 08:58:14 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Added a /debugChatter command which endlessly says inane things.
Modified Paths:
--------------
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-12-04 15:53:45 UTC (rev 617)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-12-04 16:58:14 UTC (rev 618)
@@ -29,12 +29,12 @@
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Random;
import java.util.Vector;
import java.util.regex.Pattern;
import javax.media.j3d.Transform3D;
import javax.swing.JLabel;
-import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.vecmath.Vector3d;
@@ -246,12 +246,30 @@
playIncomingChatAudio = true;
} else if ("/help".equals(message) && helpMessage != null) {
chatPanel.displayMessage(null, helpMessage);
+ } else if("/debugChatter".equals(message)){
+ new ChatterBoxThread().start();
} else {
spaceClient.userIssuedCommand(message);
}
}
}
+ private class ChatterBoxThread extends Thread {
+ Random random = new Random();
+
+ String[] colors = { "blue", "red", "yellow", "green" };
+
+ public void run(){
+ while(true){
+ try {
+ sleep(3000);
+ } catch (InterruptedException e) {
+ }
+ spaceClient.userIssuedCommand("I feel " + colors[Math.abs(random.nextInt() % colors.length)]);
+ }
+ }
+ }
+
public void sendChatMessage(String message) {
spaceClient.userIssuedCommand(message);
}
@@ -418,7 +436,7 @@
long nonce;
int x = 0, y = 0;
-
+
public ThingGeneratedPopup(Thing theThing, long theNonce, int x, int y) {
super(trimName(theThing.getName(), 15, "..."));
thing = theThing;
@@ -426,7 +444,7 @@
startTime = System.currentTimeMillis();
this.x = x;
this.y = y;
-
+
boolean needSeparator = false;
if (theThing.getTemplate().isASeat()) {
seatItem = new MenuItem("Sit Here");
@@ -476,7 +494,7 @@
}
});
}
- if(items.size() == 0){
+ if (items.size() == 0) {
MenuItem noItemsItem = new MenuItem("No available actions");
noItemsItem.setEnabled(false);
add(noItemsItem);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-04 14:21:49
|
Revision: 614
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=614&view=rev
Author: trevorolio
Date: 2007-12-04 06:21:54 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Added user role to space model.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-12-04 14:21:46 UTC (rev 613)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-12-04 14:21:54 UTC (rev 614)
@@ -96,13 +96,13 @@
WebAPIDescriptor descriptor1 = null;
String mikeBodyTextureResourcePath = "sample-art3d/TestBodyTexture-Mike.jpg";
-
+
public void setUp() {
try {
- PropStorage ps=new PropStorage();
- if (!ps.loadPropertySet(PropStorage.BASIC_PROPS)) {
- fail("couldn't load property set (BASIC)");
- }
+ PropStorage ps = new PropStorage();
+ if (!ps.loadPropertySet(PropStorage.BASIC_PROPS)) {
+ fail("couldn't load property set (BASIC)");
+ }
serviceURI1 = new URI(ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseUrl"));
mediaURI = new URI(ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mediaUrl"));
simURI = new URI(ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseSimUrl"));
@@ -125,7 +125,7 @@
checkCantReachURI(simURI);
checkCantReachURI(mediaURI);
try {
- new Socket(serviceURI1.getHost(),3306/*mysql port*/);
+ new Socket(serviceURI1.getHost(), 3306/*mysql port*/);
fail("Shouldn't be able to connect to the MySql server!");
} catch (IOException e) {
//pass
@@ -136,12 +136,12 @@
private void checkCantReachURI(URI uri) {
try {
uri.toURL().openConnection();
- fail("should not be able to see the URI"+uri+"!");
+ fail("should not be able to see the URI" + uri + "!");
} catch (IOException e) {
//pass
}
}
-
+
public void testAppletsCanBeDownloaded() throws IOException, URISyntaxException {
checkSupportFile("ogoglio-viewer-applet.jar");
checkSupportFile("ogoglio-test-applet.jar");
@@ -150,17 +150,17 @@
}
private void checkSupportFile(String name) throws URISyntaxException, IOException {
- URI supportURI=new URI(serviceURI1.toString()+name);
- InputStream is=null;
- try {
- is=wire1.performGET(supportURI, null);
- } catch (IOException e) {
- fail("unable to get the support URI:"+supportURI+" (exception:"+e.getMessage()+")");
- }
- assertNotNull(is);
- is.close();
+ URI supportURI = new URI(serviceURI1.toString() + name);
+ InputStream is = null;
+ try {
+ is = wire1.performGET(supportURI, null);
+ } catch (IOException e) {
+ fail("unable to get the support URI:" + supportURI + " (exception:" + e.getMessage() + ")");
+ }
+ assertNotNull(is);
+ is.close();
}
-
+
public void testWebAdmin() throws AuthenticationFailedException, IOException {
PropStorage ps = new PropStorage();
if (ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
@@ -235,7 +235,6 @@
assertNull(ac2.getFrozenUntil());
assertEquals(AccountDocument.ACCOUNT_LEVEL_BASIC, accountDoc.getAccountLevel());
-
BodyDataDocument bodyDataDoc = adminWebClient.createBodyData("Super Puppy", "ogoglio-body-superpuppy.jar");
assertNotNull(bodyDataDoc);
assertFalse(bodyDataDoc.getBodyDataID() == -1);
@@ -263,7 +262,7 @@
assertEquals(0, configDoc.getBodySettingDocuments().length);
configDoc = basicWebClient.updateBodyConfiguration(configDoc);
assertEquals(0, configDoc.getBodySettingDocuments().length);
-
+
assertNull(configDoc.getBaseTextureName());
configDoc.setBaseTextureName("La Texture Base.jpg");
configDoc = basicWebClient.updateBodyConfiguration(configDoc);
@@ -271,7 +270,7 @@
configDoc.setBaseTextureName(null);
configDoc = basicWebClient.updateBodyConfiguration(configDoc);
assertNull(configDoc.getBaseTextureName());
-
+
InputStream textureData = UIConstants.getResource(mikeBodyTextureResourcePath);
assertNotNull(textureData);
basicWebClient.setBodyTexture(basicAuthenticator.getUsername(), configDoc.getBodyConfigurationID(), textureData, "image/jpeg");
@@ -292,14 +291,14 @@
SpaceDocument spaceDocument = advancedClient.createSpace("Susan's Space");
assertNotNull(spaceDocument);
checkSpaceDocumentCreateTime(spaceDocument);
-
+
assertNotNull(spaceDocument);
advancedClient.setSpacePublished(spaceDocument.getSpaceID(), true);
-
+
WebAPIAuthenticator basicAuth = new WebAPIAuthenticator(wire1, descriptor1, USERNAME2, PASSWORD1);
WebAPIClient basicClient = new WebAPIClient(descriptor1, basicAuth, wire1);
assertNull(basicClient.createSpace("Tina's Illegal Space Which She Should Not Be Able To Create"));
-
+
checkNoConnectionToSpaceWithoutAuth(spaceDocument.getSpaceID());
checkAuthDoc(advancedAuth, basicAuth);
@@ -339,10 +338,9 @@
guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), advancedClient, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
checkUserSitting(spaceDocument, thingDocs, spaceClient1, guestSpaceClient1);
-
+
checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), advancedClient, USERNAME1);
-
-
+
} finally {
if (spaceClient1 != null) {
spaceClient1.cleanup();
@@ -362,7 +360,7 @@
User remoteUser = guestSpaceClient1.getSpace().getUser(spaceClient1.getUsername());
long startTime = System.currentTimeMillis();
- while(System.currentTimeMillis() - startTime < 30000 && remoteUser.getSeat() == null){
+ while (System.currentTimeMillis() - startTime < 30000 && remoteUser.getSeat() == null) {
try {
Thread.sleep(500);
} catch (Exception e) {
@@ -375,14 +373,14 @@
private void checkSpaceDocumentCreateTime(SpaceDocument spaceDocument) {
try {
- long now=new Date().getTime();
- long lastMod=TemplateSupportFileDocument.fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
- assertTrue(now-lastMod < 2000); //1 sec seems pretty safe
- assertTrue(now-lastMod > 0); // asked for now AFTER we created the space
+ long now = new Date().getTime();
+ long lastMod = TemplateSupportFileDocument.fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
+ assertTrue(now - lastMod < 2000); //1 sec seems pretty safe
+ assertTrue(now - lastMod > 0); // asked for now AFTER we created the space
} catch (ParseException e) {
fail("can't parse the server's timestamp on last modified time of the space");
}
-
+
}
public void testApplet() throws AuthenticationFailedException, IOException {
@@ -422,7 +420,7 @@
BodyAppletTestWindow bodyWindow = openBodyAppletTestWindow(basicAuthenticator);
bodyWindow.cleanup();
-
+
basicWebClient.deleteSpace(spaceDocument.getSpaceID());
}
@@ -529,16 +527,23 @@
assertEquals(numMemberships, membershipDocs.length);
}
- private ThingDocument tryToUpdateThing(long spaceID, ThingDocument thingDocument, WebAPIClient client) throws IOException{
+ private ThingDocument tryToUpdateThing(long spaceID, ThingDocument thingDocument, WebAPIClient client) throws IOException {
Vector3d scale = thingDocument.getScale();
scale.x += 0.5;
thingDocument.setScale(scale);
return client.updateThing(spaceID, thingDocument);
}
-
+
private void checkSpaceMembership(long spaceID, WebAPIClient advancedClient, WebAPIClient basicClient) throws IOException {
advancedClient.addSpaceMember(spaceID, basicClient.getAuthenticator().getUsername(), SpaceMemberDocument.MEMBER);
-
+
+ TestSpaceClientListener scListener = new TestSpaceClientListener();
+ SpaceClient spaceClient = new SpaceClient(spaceID, basicClient.getDescriptor().getServiceURI(), basicClient.getAuthenticator().getAuthCookie(), scListener);
+ User user = spaceClient.getSpace().getUser(basicClient.getAuthenticator().getUsername());
+ assertNotNull(user);
+ assertEquals(SpaceMemberDocument.MEMBER, user.getRole());
+ spaceClient.cleanup();
+
ThingDocument[] thingDocuments = basicClient.getThingDocuments(spaceID);
assertTrue(thingDocuments.length > 0);
assertNotNull(tryToUpdateThing(spaceID, thingDocuments[0], advancedClient));
@@ -549,7 +554,7 @@
assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
assertNull(tryToUpdateThing(spaceID, thingDocuments[0], basicClient));
-
+
membershipDocs[0].setRole(SpaceMemberDocument.EDITOR);
assertNotNull(advancedClient.updateSpaceMember(spaceID, membershipDocs[0]));
membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
@@ -558,7 +563,13 @@
assertEquals(SpaceMemberDocument.EDITOR, membershipDocs[0].getRole());
assertNotNull(tryToUpdateThing(spaceID, thingDocuments[0], basicClient));
thingDocuments = basicClient.getThingDocuments(spaceID);
-
+
+ spaceClient = new SpaceClient(spaceID, basicClient.getDescriptor().getServiceURI(), basicClient.getAuthenticator().getAuthCookie(), scListener);
+ user = spaceClient.getSpace().getUser(basicClient.getAuthenticator().getUsername());
+ assertNotNull(user);
+ assertEquals(SpaceMemberDocument.EDITOR, user.getRole());
+ spaceClient.cleanup();
+
advancedClient.removeSpaceMember(spaceID, USERNAME2);
membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
assertEquals(0, membershipDocs.length);
@@ -592,7 +603,7 @@
assertFalse(spaceDocument.getDisplaySea());
//redefine this here b/c we don't want linkage against internal server code
- DateFormat fmt=TemplateSupportFileDocument.fmt;
+ DateFormat fmt = TemplateSupportFileDocument.fmt;
try {
long lastUpdateBeforeSet = fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
@@ -603,8 +614,8 @@
spaceDocument = webClient1.getSpaceDocument(spaceDocument.getSpaceID(), false);
//side test, make sure update time changes
long lastUpdateAfterSet = fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
- assertTrue(lastUpdateAfterSet-lastUpdateBeforeSet>=1000);
-
+ assertTrue(lastUpdateAfterSet - lastUpdateBeforeSet >= 1000);
+
assertEquals(-2, spaceDocument.getSeaLevel(), 0.000001);
webClient1.setSpaceDisplaySea(spaceDocument.getSpaceID(), true);
spaceDocument = webClient1.getSpaceDocument(spaceDocument.getSpaceID(), false);
@@ -675,11 +686,11 @@
//now connect as a guest
SpaceClient guestSpaceClient1 = new SpaceClient(spaceID, serviceURI1, guestCookie1, new TestSpaceClientListener());
long startTime = System.currentTimeMillis();
- while(System.currentTimeMillis() - startTime < 60000){
+ while (System.currentTimeMillis() - startTime < 60000) {
try {
Thread.sleep(1000);
- if(webClient1.getUserDocuments(spaceID).length == 2){
- break;
+ if (webClient1.getUserDocuments(spaceID).length == 2) {
+ break;
}
} catch (InterruptedException e) {
e.printStackTrace();
@@ -924,7 +935,7 @@
newTemplateDoc = webClient1.updateTemplate(newTemplateDoc);
assertEquals(templateName, newTemplateDoc.getDisplayName());
assertTrue(newTemplateDoc.isSeat());
-
+
assertEquals(false, newTemplateDoc.hasScriptFile());
assertNull(newTemplateDoc.getScriptModifiedTime());
@@ -956,7 +967,7 @@
newTemplateDoc = webClient1.getTemplateDocument(webClient1.getAuthenticator().getUsername(), newTemplateDoc.getTemplateID());
assertEquals(false, newTemplateDoc.hasScriptFile());
-
+
newTemplateDoc.setSeat(true);
Point3d seatPosition = new Point3d(3, 4, 5);
newTemplateDoc.setSeatPosition(seatPosition);
@@ -972,34 +983,33 @@
}
private XMLElement getStatusXML() throws IOException, URISyntaxException {
- InputStream s=new URI(serviceURI1.toString()+"status?format=xml").toURL().openConnection().getInputStream();
- XMLElement result=XMLElement.parseElementFromString(StreamUtils.readInput(s));
+ InputStream s = new URI(serviceURI1.toString() + "status?format=xml").toURL().openConnection().getInputStream();
+ XMLElement result = XMLElement.parseElementFromString(StreamUtils.readInput(s));
s.close();
return result;
}
-
+
public void testStatus() throws IOException, URISyntaxException {
try {
-
- InputStream forEffect=new URI(serviceURI1.toString()+"status?clear=true").toURL().openConnection().getInputStream();
+
+ InputStream forEffect = new URI(serviceURI1.toString() + "status?clear=true").toURL().openConnection().getInputStream();
forEffect.close();
//it's pretty hard to know what *should* be in the status message unless you dummy
//up a bunch of stuff in /proc ....this test, thus, is very weak
checkStatusReportChildren(1);
-
+
getStatusXML();
getStatusXML();
checkStatusReportChildren(4);
- forEffect=new URI(serviceURI1.toString()+"status?clear=true").toURL().openConnection().getInputStream();
+ forEffect = new URI(serviceURI1.toString() + "status?clear=true").toURL().openConnection().getInputStream();
forEffect.close();
checkStatusReportChildren(1);//make sure clear works and wasn't lucky above
-
-
+
} catch (IOException e) {
if (e.getMessage().startsWith("Server returned HTTP response code: 412")) {
Log.info("Ignoring response code 412 for status URL. You probably aren't on linux.");
@@ -1010,25 +1020,26 @@
}
private XMLElement checkStatusReportChildren(int n) throws IOException, URISyntaxException {
- XMLElement element=getStatusXML();
- assertEquals(element.getName(),"statusreports");
- assertEquals(n,element.getChildren().size());
+ XMLElement element = getStatusXML();
+ assertEquals(element.getName(), "statusreports");
+ assertEquals(n, element.getChildren().size());
return element;
}
+
private void assertStreamsEqual(InputStream input1, InputStream input2) throws IOException {
- if(input1 == null || input2 == null){
+ if (input1 == null || input2 == null) {
fail("Not equal, null inputs: " + input1 + ", " + input2);
return;
}
- while(true){
+ while (true) {
int read = input1.read();
assertEquals(read, input2.read());
- if(read == -1){
+ if (read == -1) {
return;
}
}
}
-
+
private void consume(InputStream input) throws IOException {
byte[] buffer = new byte[2048];
while (input.read(buffer) != -1) {
@@ -1093,7 +1104,7 @@
Vector thingMotionStops = new Vector();
Vector userSats = new Vector();
-
+
public void userAdded(User person) {
if (person == null) {
fail();
@@ -1217,14 +1228,16 @@
}
public void userSat(User user, Thing seatThing) {
- if(user == null) fail();
- if(seatThing == null) fail();
+ if (user == null)
+ fail();
+ if (seatThing == null)
+ fail();
userSats.add(user);
}
public void userStood(User user, Thing seat) {
// TODO Auto-generated method stub
-
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-04 14:21:25
|
Revision: 612
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=612&view=rev
Author: trevorolio
Date: 2007-12-04 06:21:20 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Added user role to space model.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/UserDocument.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.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:27 UTC (rev 611)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-12-04 14:21:20 UTC (rev 612)
@@ -184,7 +184,7 @@
if (userDocs[i].getSeatThingID() != -1) {
seatThing = space.getThing(userDocs[i].getSeatThingID());
}
- User user = new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), bodyConfig, seatThing);
+ User user = new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), bodyConfig, seatThing, userDocs[i].getRole());
bodyConfig.setUser(user);
space.addUser(user);
}
@@ -333,7 +333,8 @@
if (SpaceEvent.ADD_USER_EVENT.equals(event.getName())) {
BodyConfigurationDocument bodyConfigDoc = event.getBodyConfigurationDocument();
BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfigDoc);
- User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform(), bodyConfig, null);
+ String role = event.getStringProperty(SpaceEvent.USER_ROLE);
+ User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform(), bodyConfig, null, role);
space.addUser(user);
} else if (SpaceEvent.REMOVE_USER_EVENT.equals(event.getName())) {
User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-12-01 00:21:27 UTC (rev 611)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-12-04 14:21:20 UTC (rev 612)
@@ -17,6 +17,7 @@
import javax.media.j3d.Transform3D;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.xml.SpaceMemberDocument;
public class User {
@@ -34,7 +35,9 @@
private Thing seatThing = null;
- public User(Space space, String username, Transform3D position, BodyConfiguration bodyConfiguration, Thing seatThing) {
+ private String role = null;
+
+ public User(Space space, String username, Transform3D position, BodyConfiguration bodyConfiguration, Thing seatThing, String role) {
ArgumentUtils.assertNotNull(space);
this.space = space;
ArgumentUtils.assertNotNull(username);
@@ -45,6 +48,10 @@
this.bodyConfiguration = bodyConfiguration;
bodyConfiguration.setUser(this);
this.seatThing = seatThing;
+ if(role != null && !SpaceMemberDocument.isValidRole(role)){
+ throw new IllegalArgumentException("Invalid role: " + role);
+ }
+ this.role = role;
}
public void startMotion(SplinePath path) {
@@ -122,4 +129,11 @@
space.notifyUserSat(this, seatThing);
}
}
+
+ /**
+ * @return null or one of the roles from SpaceMemberDocument: editor, member, builder
+ */
+ public String getRole() {
+ return role;
+ }
}
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:27 UTC (rev 611)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2007-12-04 14:21:20 UTC (rev 612)
@@ -97,7 +97,9 @@
public static final String SHAPE_NAME = "shapeName";
public static final String ADD_USER_EVENT = "addUser";
-
+
+ public static final String USER_ROLE = "role";
+
public static final String REMOVE_USER_EVENT = "removeUser";
public static final String USER_START_MOTION_EVENT = "userStartMotion";
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java 2007-12-01 00:21:27 UTC (rev 611)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceMemberDocument.java 2007-12-04 14:21:20 UTC (rev 612)
@@ -82,6 +82,18 @@
}
}
+ public static String getRoleString(int role){
+ if(role == MEMBER_ROLE){
+ return MEMBER;
+ } else if(role == EDITOR_ROLE){
+ return EDITOR;
+ } else if(role == BUILDER_ROLE){
+ return BUILDER;
+ } else {
+ return null;
+ }
+ }
+
public XMLElement toElement() {
return data;
}
@@ -116,4 +128,11 @@
}
data.setAttribute(ROLE, role);
}
+
+ public static boolean isValidRole(String role) {
+ if(role == null){
+ return false;
+ }
+ return MEMBER.equals(role) || EDITOR.equals(role) || BUILDER.equals(role);
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/UserDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/UserDocument.java 2007-12-01 00:21:27 UTC (rev 611)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/UserDocument.java 2007-12-04 14:21:20 UTC (rev 612)
@@ -27,14 +27,16 @@
public static final String USERNAME = "username";
public static final String BODY_CONFIGURATION_ID = "bodyconfigurationid";
-
+
public static final String SEAT_THING_ID = "seatthingid";
-
+
+ public static final String ROLE = "role";
+
public UserDocument(User user) {
- this(user.getUsername(), user.getPosition(), user.getSplinePath(), user.getBodyConfiguration().getBodyConfigurationID(), user.getSeat() == null ? -1 : user.getSeat().getThingID());
+ this(user.getUsername(), user.getPosition(), user.getSplinePath(), user.getBodyConfiguration().getBodyConfigurationID(), user.getSeat() == null ? -1 : user.getSeat().getThingID(), user.getRole());
}
- public UserDocument(String username, Transform3D transform, SplinePath splinePath, long bodyConfigurationID, long seatThingID) {
+ public UserDocument(String username, Transform3D transform, SplinePath splinePath, long bodyConfigurationID, long seatThingID, String role) {
super(NAME, transform, splinePath);
ArgumentUtils.assertNotNull(username);
getData().setAttribute(USERNAME, username);
@@ -42,8 +44,18 @@
getData().setAttribute(BODY_CONFIGURATION_ID, bodyConfigurationID);
}
getData().setAttribute(SEAT_THING_ID, seatThingID);
+ if(!isValidRole(role)){
+ throw new IllegalArgumentException("Invalid role: " + role);
+ }
+ if (role != null) {
+ getData().setAttribute(ROLE, role);
+ }
}
+ public static boolean isValidRole(String role){
+ return role == null || SpaceMemberDocument.isValidRole(role);
+ }
+
public UserDocument(XMLElement data) {
super(data);
if (!NAME.equals(getData().getName())) {
@@ -59,8 +71,12 @@
public long getBodyConfigurationID() {
return getData().getLongAttribute(BODY_CONFIGURATION_ID);
}
-
- public long getSeatThingID(){
+
+ public long getSeatThingID() {
return getData().getLongAttribute(SEAT_THING_ID);
}
+
+ public String getRole(){
+ return getData().getStringAttribute(ROLE);
+ }
}
Modified: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-12-01 00:21:27 UTC (rev 611)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-12-04 14:21:20 UTC (rev 612)
@@ -190,16 +190,20 @@
assertEquals(0, shapeMove1.getSplinePath().getSplineKeyFrames()[1].getKnot(), keyFrames[1].getKnot());
assertEquals(shapeMove1.getShapeName(), "a_shape");
- UserDocument userDoc = new UserDocument(username, new Transform3D(), null, 23, 24);
+ UserDocument userDoc = new UserDocument(username, new Transform3D(), null, 23, 24, null);
assertEquals(username, userDoc.getUsername());
assertEquals(23, userDoc.getBodyConfigurationID());
assertEquals(24, userDoc.getSeatThingID());
+ assertEquals(null, userDoc.getRole());
userDoc = new UserDocument(XMLElement.parseElementFromString(userDoc.toString()));
assertEquals(username, userDoc.getUsername());
assertEquals(23, userDoc.getBodyConfigurationID());
assertEquals(24, userDoc.getSeatThingID());
+ userDoc = new UserDocument(username, new Transform3D(), null, 23, 24, SpaceMemberDocument.EDITOR);
+ assertEquals(SpaceMemberDocument.EDITOR, userDoc.getRole());
+
DoorDocument door1 = new DoorDocument(1, displayName, 2, "susan", uri1, new Transform3D());
assertEquals(1, door1.getDoorID());
assertEquals(2, door1.getTemplateID());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-01 00:24:48
|
Revision: 610
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=610&view=rev
Author: trevorolio
Date: 2007-11-30 16:21:24 -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-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptPoint.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePath.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
Added Paths:
-----------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePathInterpolator.java
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-27 13:00:25 UTC (rev 609)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -232,7 +232,7 @@
}
user.startMotion(event.getSplinePath());
listener.generatedSpaceEvent(event, SpaceSimulator.this);
- //TODO save motion to sim, lazily updating upon query
+ scriptEngine.handleSpaceEvent(event);
} else if (SpaceEvent.USER_STOP_MOTION_EVENT.equals(event.getName())) {
String username = event.getStringProperty(SpaceEvent.USERNAME);
@@ -243,6 +243,8 @@
}
user.stopMotion(event.getTransform());
listener.generatedSpaceEvent(event, SpaceSimulator.this);
+ scriptEngine.handleSpaceEvent(event);
+
} else if (SpaceEvent.USER_SAT_EVENT.equals(event.getName())) {
String username = event.getStringProperty(SpaceEvent.USERNAME);
User user = space.getUser(username);
@@ -373,6 +375,10 @@
}
page.setContentType(event.getStringProperty(SpaceEvent.CONTENT_TYPE));
listener.generatedSpaceEvent(event, SpaceSimulator.this);
+ } else if(SpaceEvent.ANNOUNCE_EVENT.equals(event.getName())){
+ //TODO limit who can announce
+ listener.generatedSpaceEvent(event, SpaceSimulator.this);
+
} else if (SpaceEvent.TEXT_SAY_EVENT.equals(event.getName())) {
String username = event.getStringProperty(SpaceEvent.USERNAME);
User user = space.getUser(username);
@@ -383,8 +389,7 @@
String chatMessage = event.getStringProperty(SpaceEvent.TSE_MESSAGE);
- // this is a hack to play pre-baked animations
- // TODO create a user animation record and a method to dl and play them
+ // this is a hack to play animations defined by the body data
if (chatMessage.startsWith("/") && chatMessage.length() > 1) {
String command = chatMessage.substring(1);
SpaceEvent playAnimationEvent = new SpaceEvent(SpaceEvent.PLAY_ANIMATION_EVENT);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptPoint.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptPoint.java 2007-11-27 13:00:25 UTC (rev 609)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptPoint.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -14,6 +14,7 @@
package com.ogoglio.sim.script;
+import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import org.mozilla.javascript.ScriptableObject;
@@ -55,6 +56,13 @@
this.z += z;
}
+ public double jsFunction_getDistance(ScriptPoint remotePoint){
+ if(remotePoint == null){
+ return 0;
+ }
+ return new Point3d(x, y, z).distance(new Point3d(remotePoint.x, remotePoint.y, remotePoint.z));
+ }
+
public double jsGet_x() {
return x;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java 2007-11-27 13:00:25 UTC (rev 609)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptQuaternion.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -21,6 +21,8 @@
import org.mozilla.javascript.ScriptableObject;
+import com.ogoglio.viewer.j3d.J3DRenderer;
+
public class ScriptQuaternion extends ScriptableObject {
private double w = 1, x = 0, y = 0, z = 0;
@@ -89,6 +91,16 @@
setQuat(quat);
}
+ public double[] jsFunction_getEulerOrientation(){
+ Vector3d euler = new Vector3d();
+ J3DRenderer.getEuler(new Quat4d(x, y, z, w), euler);
+ double[] results = new double[3];
+ results[0] = euler.x;
+ results[1] = euler.y;
+ results[2] = euler.z;
+ return results;
+ }
+
public void jsFunction_setEulerOrientation(double x, double y, double z) {
Transform3D transform = new Transform3D();
transform.setEuler(new Vector3d(x, y, z));
@@ -115,18 +127,19 @@
}
public void jsFunction_rotatePoint(ScriptPoint pointOfRotation, ScriptPoint pointToRotate){
- Vector3d vectorOfRot = new Vector3d(); //new Vector3d(pointOfRotation.jsGet_x(), pointOfRotation.jsGet_y(), pointOfRotation.jsGet_z());
- Transform3D rotTransform = new Transform3D(new Quat4d(x, y, z, w), vectorOfRot, 1);
+ Vector3d translation = new Vector3d(0,0,0); //new Vector3d(pointOfRotation.jsGet_x(), pointOfRotation.jsGet_y(), pointOfRotation.jsGet_z());
+ Quat4d quat = new Quat4d(x, y, z, w);
+ Transform3D rotTransform = new Transform3D(quat, translation, 1);
Point3d workingPoint = new Point3d(pointToRotate.jsGet_x(), pointToRotate.jsGet_y(), pointToRotate.jsGet_z());
rotTransform.transform(workingPoint);
pointToRotate.jsSet_x(workingPoint.x);
pointToRotate.jsSet_y(workingPoint.y);
pointToRotate.jsSet_z(workingPoint.z);
}
-
+
public void jsFunction_set(double w, double x, double y, double z) {
this.w = w;
- this.x = w;
+ this.x = x; //ZOMG! this was this.x = w and it just about killed me - TFS
this.y = y;
this.z = z;
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java 2007-11-27 13:00:25 UTC (rev 609)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSpace.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -101,6 +101,31 @@
return result;
}
+ public ScriptPoint jsFunction_getUserPosition(String username){
+ User user = spaceSimulator.getSpace().getUser(username);
+ if(user == null){
+ return null;
+ }
+ ScriptPoint point = (ScriptPoint) Context.getCurrentContext().newObject(getParentScope(), "Point", new Object[0]);
+ Vector3d position = new Vector3d();
+ user.getPosition().get(position);
+ point.jsConstructor(position.x, position.y, position.z);
+ return point;
+ }
+
+ public ScriptQuaternion jsFunction_getUserOrientation(String username){
+ User user = spaceSimulator.getSpace().getUser(username);
+ if(user == null){
+ return null;
+ }
+ Quat4d quat = new Quat4d();
+ Transform3D position = user.getPosition();
+ position.get(quat);
+ ScriptQuaternion orientation = (ScriptQuaternion) Context.getCurrentContext().newObject(getParentScope(), "Quaternion", new Object[0]);
+ orientation.jsFunction_set(quat.w, quat.x, quat.y, quat.z);
+ return orientation;
+ }
+
public String jsFunction_getSetting(String key) {
return spaceSimulator.getSetting(key);
}
@@ -117,6 +142,15 @@
spaceSimulator.showInfoPanelToUser((long)sourceThingID, username, nonce);
}
+ public void jsFunction_announce(String message){
+ if(message == null || message.trim().length() == 0){
+ return;
+ }
+ SpaceEvent event = new SpaceEvent(SpaceEvent.ANNOUNCE_EVENT);
+ event.setProperty(SpaceEvent.ANNOUNCE_MESSAGE, message);
+ spaceSimulator.handleSpaceEvent(event);
+ }
+
public void jsFunction_log(String message) {
spaceSimulator.log(message);
}
@@ -263,10 +297,10 @@
}
public void jsFunction_startThingMotion(double thingID, ScriptSplinePath path) {
- if (thingID < 0 || path == null || path.getKeyFrames().length == 0 || path.jsGet_duration() < 100) {
+ if (thingID < 0 || path == null || path.jsFunction_getKeyFrames().length == 0 || path.jsGet_duration() < 100) {
return;
}
- J3DSplinePath newPath = new J3DSplinePath(transcribeKeyFrames(path.getKeyFrames()), (long) path.jsGet_duration(), path.jsGet_looping(), path.jsGet_followsPlatform(), path.jsGet_distanceFromPlatform());
+ J3DSplinePath newPath = new J3DSplinePath(path.getJ3DSplineKeyFrames(), (long) path.jsGet_duration(), path.jsGet_looping(), path.jsGet_followsPlatform(), path.jsGet_distanceFromPlatform());
SpaceEvent event = new SpaceEvent(SpaceEvent.THING_START_MOTION_EVENT);
event.setProperty(SpaceEvent.THING_ID, new Long((long) thingID));
@@ -276,10 +310,10 @@
}
public void jsFunction_startShapeMotion(double thingID, String shapeName, ScriptSplinePath path) {
- if (thingID < 0 || path == null || shapeName == null || path.getKeyFrames().length == 0 || path.jsGet_duration() < 100) {
+ if (thingID < 0 || path == null || shapeName == null || path.jsFunction_getKeyFrames().length == 0 || path.jsGet_duration() < 100) {
return;
}
- J3DSplinePath newPath = new J3DSplinePath(transcribeKeyFrames(path.getKeyFrames()), (long) path.jsGet_duration(), path.jsGet_looping(), path.jsGet_followsPlatform(), path.jsGet_distanceFromPlatform());
+ J3DSplinePath newPath = new J3DSplinePath(path.getJ3DSplineKeyFrames(), (long) path.jsGet_duration(), path.jsGet_looping(), path.jsGet_followsPlatform(), path.jsGet_distanceFromPlatform());
SpaceEvent event = new SpaceEvent(SpaceEvent.SHAPE_START_MOTION_EVENT);
event.setProperty(SpaceEvent.THING_ID, new Long((long) thingID));
@@ -313,10 +347,10 @@
}
public void jsFunction_startUserMotion(String username, ScriptSplinePath path) {
- if (username == null || path == null || path.getKeyFrames().length == 0 || path.jsGet_duration() < 100) {
+ if (username == null || path == null || path.jsFunction_getKeyFrames().length == 0 || path.jsGet_duration() < 100) {
return;
}
- J3DSplinePath newPath = new J3DSplinePath(transcribeKeyFrames(path.getKeyFrames()), (long) path.jsGet_duration(), path.jsGet_looping(), path.jsGet_followsPlatform(), path.jsGet_distanceFromPlatform());
+ J3DSplinePath newPath = new J3DSplinePath(path.getJ3DSplineKeyFrames(), (long) path.jsGet_duration(), path.jsGet_looping(), path.jsGet_followsPlatform(), path.jsGet_distanceFromPlatform());
SpaceEvent event = new SpaceEvent(SpaceEvent.USER_START_MOTION_EVENT);
event.setProperty(SpaceEvent.USERNAME, username);
@@ -325,18 +359,6 @@
spaceSimulator.handleSpaceEvent(event);
}
- private J3DSplineKeyFrame[] transcribeKeyFrames(ScriptSplineKeyFrame[] keyFrames) {
- Point3f position = new Point3f();
- Point3f scale = new Point3f();
- J3DSplineKeyFrame[] newFrames = new J3DSplineKeyFrame[keyFrames.length];
- for (int i = 0; i < newFrames.length; i++) {
- position.set((float) keyFrames[i].jsGet_x(), (float) keyFrames[i].jsGet_y(), (float) keyFrames[i].jsGet_z());
- scale.set((float) keyFrames[i].jsGet_scaleX(), (float) keyFrames[i].jsGet_scaleY(), (float) keyFrames[i].jsGet_scaleZ());
- newFrames[i] = new J3DSplineKeyFrame((float) keyFrames[i].jsGet_knot(), keyFrames[i].jsGet_linear(), position, (float) keyFrames[i].jsGet_heading(), (float) keyFrames[i].jsGet_pitch(), (float) keyFrames[i].jsGet_bank(), scale, (float) keyFrames[i].jsGet_tension(), (float) keyFrames[i].jsGet_continuity(), (float) keyFrames[i].jsGet_bias());
- }
- return newFrames;
- }
-
public void jsFunction_rotateThing(double thingID, double radiansX, double radiansY, double radiansZ) {
Thing thing = spaceSimulator.getSpace().getThing((long) thingID);
if (thing == null) {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePath.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePath.java 2007-11-27 13:00:25 UTC (rev 609)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePath.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -15,20 +15,25 @@
import java.util.Vector;
+import javax.vecmath.Point3f;
+
import org.mozilla.javascript.ScriptableObject;
+import com.ogoglio.client.model.SplineKeyFrame;
+import com.ogoglio.viewer.j3d.J3DSplineKeyFrame;
+
public class ScriptSplinePath extends ScriptableObject {
private double duration = 1000;
-
+
private boolean looping = false;
-
+
private Vector keyFrames = new Vector();
private boolean followsPlatform = false;
private double distanceFromPlatform = 0;
-
+
public ScriptSplinePath() {
}
@@ -37,23 +42,23 @@
this.looping = looping;
this.followsPlatform = followsPlatform;
}
-
+
public void jsFunction_addKeyFrame(ScriptSplineKeyFrame keyFrame) {
keyFrames.add(keyFrame);
}
-
- public ScriptSplineKeyFrame[] getKeyFrames() {
- return (ScriptSplineKeyFrame[])keyFrames.toArray(new ScriptSplineKeyFrame[0]);
+
+ public ScriptSplineKeyFrame[] jsFunction_getKeyFrames() {
+ return (ScriptSplineKeyFrame[]) keyFrames.toArray(new ScriptSplineKeyFrame[0]);
}
-
+
public int jsGet_length() {
return keyFrames.size();
}
-
+
public String getClassName() {
return "SplinePath";
}
-
+
public Object getDefaultValue(java.lang.Class hint) {
return toString();
}
@@ -81,15 +86,30 @@
public void jsSet_followsPlatform(boolean fp) {
followsPlatform = fp;
}
-
+
public boolean jsGet_followsPlatform() {
return followsPlatform;
}
public void jsSet_distanceFromPlatform(double distanceFromPlatform) {
- this.distanceFromPlatform = distanceFromPlatform;
+ this.distanceFromPlatform = distanceFromPlatform;
}
+
public double jsGet_distanceFromPlatform() {
return distanceFromPlatform;
}
+
+ public J3DSplineKeyFrame[] getJ3DSplineKeyFrames() {
+ ScriptSplineKeyFrame[] keyFrames = jsFunction_getKeyFrames();
+ Point3f position = new Point3f();
+ Point3f scale = new Point3f();
+ J3DSplineKeyFrame[] newFrames = new J3DSplineKeyFrame[keyFrames.length];
+ for (int i = 0; i < newFrames.length; i++) {
+ position.set((float) keyFrames[i].jsGet_x(), (float) keyFrames[i].jsGet_y(), (float) keyFrames[i].jsGet_z());
+ scale.set((float) keyFrames[i].jsGet_scaleX(), (float) keyFrames[i].jsGet_scaleY(), (float) keyFrames[i].jsGet_scaleZ());
+ newFrames[i] = new J3DSplineKeyFrame((float) keyFrames[i].jsGet_knot(), keyFrames[i].jsGet_linear(), position, (float) keyFrames[i].jsGet_heading(), (float) keyFrames[i].jsGet_pitch(), (float) keyFrames[i].jsGet_bank(), scale, (float) keyFrames[i].jsGet_tension(), (float) keyFrames[i].jsGet_continuity(), (float) keyFrames[i].jsGet_bias());
+ }
+ return newFrames;
+ }
+
}
Added: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePathInterpolator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePathInterpolator.java (rev 0)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptSplinePathInterpolator.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -0,0 +1,92 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+package com.ogoglio.sim.script;
+
+import javax.media.j3d.Transform3D;
+import javax.media.j3d.TransformGroup;
+import javax.vecmath.Quat4d;
+import javax.vecmath.Vector3d;
+
+import org.mozilla.javascript.ScriptableObject;
+
+import com.ogoglio.viewer.j3d.RangedAlpha;
+import com.sun.j3d.utils.behaviors.interpolators.KBRotPosScaleSplinePathInterpolator;
+
+public class ScriptSplinePathInterpolator extends ScriptableObject {
+
+ public static final String CLASS_NAME = "SplinePathInterpolator";
+
+ private ScriptSplinePath splinePath = null;
+
+ private KBRotPosScaleSplinePathInterpolator interpolator = null;
+
+ private TransformGroup transformGroup = new TransformGroup();
+
+ private Transform3D transform = new Transform3D();
+
+ private Vector3d vector = new Vector3d();
+
+ private Quat4d quaternion = new Quat4d();
+
+ public ScriptSplinePathInterpolator() {
+ }
+
+ public void jsConstructor(ScriptSplinePath splinePath) {
+ this.splinePath = splinePath;
+ RangedAlpha alpha = new RangedAlpha(1, 1000);
+ interpolator = new KBRotPosScaleSplinePathInterpolator(alpha, transformGroup, transform, splinePath.getJ3DSplineKeyFrames());
+ interpolator.setEnable(true);
+ }
+
+ /**
+ * @param alphaValue must be [0-1]
+ * @param quat
+ */
+ public void jsFunction_interpolateOrientation(double alphaValue, ScriptQuaternion quat){
+ if (interpolator == null) {
+ return;
+ }
+ interpolator.computeTransform((float) alphaValue, transform);
+ transform.get(quaternion);
+ quat.jsFunction_set(quaternion.w, quaternion.x, quaternion.y, quaternion.z);
+ }
+
+ /**
+ * @param alphaValue must be [0-1]
+ * @param point
+ */
+ public void jsFunction_interpolatePosition(double alphaValue, ScriptPoint point) {
+ if (interpolator == null) {
+ return;
+ }
+ interpolator.computeTransform((float) alphaValue, transform);
+ transform.get(vector);
+ point.jsSet_x(vector.x);
+ point.jsSet_y(vector.y);
+ point.jsSet_z(vector.z);
+ }
+
+ public String getClassName() {
+ return toString();
+ }
+
+ public Object getDefaultValue(java.lang.Class hint) {
+ return toString();
+ }
+
+ public String toString() {
+ return CLASS_NAME;
+ }
+
+}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-11-27 13:00:25 UTC (rev 609)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-12-01 00:21:24 UTC (rev 610)
@@ -19,6 +19,9 @@
import java.util.Vector;
import javax.media.j3d.Transform3D;
+import javax.vecmath.Point3f;
+import javax.vecmath.Quat4d;
+import javax.vecmath.Vector3d;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.EcmaError;
@@ -30,6 +33,7 @@
import com.ogoglio.client.model.Page;
import com.ogoglio.client.model.Shape;
import com.ogoglio.client.model.Space;
+import com.ogoglio.client.model.SplineKeyFrame;
import com.ogoglio.client.model.SplinePath;
import com.ogoglio.client.model.Template;
import com.ogoglio.client.model.Thing;
@@ -59,12 +63,22 @@
public static final String ONSERVICE_FUNCTION_NAME = "onService";
- private static final String ONCLICK_FUNCTION_NAME = "onClick";
+ public static final String ONCLICK_FUNCTION_NAME = "onClick";
- private static final String ONCONTEXTCLICK_FUNCTION_NAME = "onContextClick";
+ public static final String ONCONTEXTCLICK_FUNCTION_NAME = "onContextClick";
- private static final String ONCONTEXTMENUITEMCHOSEN_FUNCTION_NAME = "onContextMenuItemChosen";
+ public static final String ONCONTEXTMENUITEMCHOSEN_FUNCTION_NAME = "onContextMenuItemChosen";
+ public static final String ONUSERMOTIONSTART_FUNCTION_NAME = "onUserMotionStart";
+
+ private static final String ONUSERSTOPPED_FUNCTION_NAME = "onUserStopped";
+
+ private Vector3d workingPosition = new Vector3d();
+
+ private Quat4d workingOrientation = new Quat4d();
+
+ private Transform3D workingTransform = new Transform3D();
+
public SpaceScriptEngine(SpaceSimulator spaceSimulator) {
ArgumentUtils.assertNotNull(spaceSimulator);
this.spaceSimulator = spaceSimulator;
@@ -77,6 +91,7 @@
ScriptableObject.defineClass(globalScope, ScriptQuaternion.class);
ScriptableObject.defineClass(globalScope, ScriptSplineKeyFrame.class);
ScriptableObject.defineClass(globalScope, ScriptSplinePath.class);
+ ScriptableObject.defineClass(globalScope, ScriptSplinePathInterpolator.class);
ScriptableObject.defineClass(globalScope, ScriptSpace.class);
ScriptableObject.defineClass(globalScope, ScriptMath.class);
ScriptableObject.defineClass(globalScope, ScriptHTTPRequest.class);
@@ -150,7 +165,62 @@
}
public void handleSpaceEvent(SpaceEvent event) {
- if (SpaceEvent.THING_CLICKED_EVENT.equals(event.getName())) {
+ if (SpaceEvent.USER_START_MOTION_EVENT.equals(event.getName())) {
+ String username = event.getStringProperty(SpaceEvent.USERNAME);
+ SplinePath path = event.getSplinePath();
+ if (username == null || path == null) {
+ Log.warn("Got user motion start event in script engine with no username (" + username + ") or path: " + path);
+ return;
+ }
+ Context context = Context.enter();
+ try {
+ ScriptSplinePath scriptPath = (ScriptSplinePath) context.newObject(globalScope, "SplinePath", new Object[0]);
+ scriptPath.jsConstructor(path.getDuration(), path.isLooping(), path.followsPlatform());
+ SplineKeyFrame[] frames = path.getSplineKeyFrames();
+ for (int i = 0; i < frames.length; i++) {
+ ScriptSplineKeyFrame frame = (ScriptSplineKeyFrame) context.newObject(globalScope, "SplineKeyFrame", new Object[0]);
+ Point3f position = frames[i].getPosition();
+ frame.jsConstructor(position.x, position.y, position.z, frames[i].getHeading(), frames[i].getKnot());
+ scriptPath.jsFunction_addKeyFrame(frame);
+ }
+
+ Object[] args = { username, scriptPath };
+ Object[] scopeObjs = thingScopes.getValues();
+ for (int i = 0; i < scopeObjs.length; i++) {
+ callJavascriptFunction(context, (ScriptableObject) scopeObjs[i], ONUSERMOTIONSTART_FUNCTION_NAME, args);
+ }
+ } finally {
+ Context.exit();
+ }
+ } else if (SpaceEvent.USER_STOP_MOTION_EVENT.equals(event.getName())) {
+ String username = event.getStringProperty(SpaceEvent.USERNAME);
+ event.getTransform(workingTransform);
+ if (username == null) {
+ Log.warn("Got user stop event in script engine with no username (" + username + ")");
+ return;
+ }
+
+ Context context = Context.enter();
+ try {
+ workingTransform.get(workingPosition);
+ ScriptPoint scriptPosition = (ScriptPoint) context.newObject(globalScope, "Point", new Object[0]);
+ scriptPosition.jsSet_x(workingPosition.x);
+ scriptPosition.jsSet_y(workingPosition.y);
+ scriptPosition.jsSet_z(workingPosition.z);
+
+ workingTransform.get(workingOrientation);
+ ScriptQuaternion scriptQuat = (ScriptQuaternion)context.newObject(globalScope, "Quaternion", new Object[0]);
+ scriptQuat.jsFunction_set(workingOrientation.w, workingOrientation.x, workingOrientation.y, workingOrientation.z);
+
+ Object[] args = { username, scriptPosition, scriptQuat };
+ Object[] scopeObjs = thingScopes.getValues();
+ for (int i = 0; i < scopeObjs.length; i++) {
+ callJavascriptFunction(context, (ScriptableObject) scopeObjs[i], ONUSERSTOPPED_FUNCTION_NAME, args);
+ }
+ } finally {
+ Context.exit();
+ }
+ } else if (SpaceEvent.THING_CLICKED_EVENT.equals(event.getName())) {
Long thingID = event.getLongProperty(SpaceEvent.THING_ID);
if (thingID == null) {
return;
@@ -191,7 +261,6 @@
return;
}
-
String functionName = ONCONTEXTCLICK_FUNCTION_NAME;
Object[] functionArgs = new Object[2];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <tre...@us...> - 2007-11-27 13:00:25
|
Revision: 609
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=609&view=rev
Author: trevorolio
Date: 2007-11-27 05:00:25 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
Added a help message to the viewer applet. It is displayed at start and can be shown again with /help.
Third party apps can set their own help messages via javascript.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2007-11-27 13:00:21 UTC (rev 608)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2007-11-27 13:00:25 UTC (rev 609)
@@ -36,6 +36,8 @@
public class AppletTestWindow extends Frame {
+ public static final String TEST_HELP_MESSAGE = "This is the help message.\nDo you feel helped?";
+
Dimension appDimension = new Dimension(500, 500);
public ViewerApplet applet = null;
@@ -62,6 +64,8 @@
parameters1.put("spaceID", "" + spaceID);
parameters1.put("serviceURI", serviceURI.toString());
+ parameters1.put("helpMessage", TEST_HELP_MESSAGE);
+
//parameters1.put("x", "0");
//parameters1.put("y", "1000");
//parameters1.put("z", "0");
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-11-27 13:00:21 UTC (rev 608)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-11-27 13:00:25 UTC (rev 609)
@@ -377,7 +377,7 @@
try {
long now=new Date().getTime();
long lastMod=TemplateSupportFileDocument.fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
- assertTrue(now-lastMod < 1000); //1 sec seems pretty safe
+ assertTrue(now-lastMod < 2000); //1 sec seems pretty safe
assertTrue(now-lastMod > 0); // asked for now AFTER we created the space
} catch (ParseException e) {
fail("can't parse the server's timestamp on last modified time of the space");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-27 13:00:16
|
Revision: 608
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=608&view=rev
Author: trevorolio
Date: 2007-11-27 05:00:21 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
Added a help message to the viewer applet. It is displayed at start and can be shown again with /help.
Third party apps can set their own help messages via javascript.
Modified Paths:
--------------
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
maven/trunk/ogoglio-viewer-applet/src/test/java/com/ogoglio/viewer/test/AppletTestWindow.java
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-11-27 13:00:14 UTC (rev 607)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-11-27 13:00:21 UTC (rev 608)
@@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
+import java.util.regex.Pattern;
import javax.media.j3d.Transform3D;
import javax.swing.JLabel;
@@ -71,8 +72,10 @@
private boolean playIncomingChatAudio = true;
- AudioClip incomingChatAudioClip = null;
+ private AudioClip incomingChatAudioClip = null;
+ private String helpMessage = null;
+
public ViewerApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
@@ -106,6 +109,11 @@
boolean movable = !"false".equals(getParameter("movable"));
showChat = !"false".equals(getParameter("showChat"));
+ helpMessage = getParameter("helpMessage");
+ if (helpMessage != null) {
+ helpMessage = helpMessage.replaceAll(Pattern.quote("<br/>"), "\r\n");
+ }
+
try {
serviceURI = new URI(getParameter("serviceURI"));
long spaceID = Long.parseLong(getParameter("spaceID"));
@@ -131,6 +139,9 @@
renderer.getCanvas().setSize(getWidth(), getHeight() - chatPanel.getPreferredSize().height);
renderer.getCanvas().setPreferredSize(new Dimension(getWidth(), getHeight() - chatPanel.getPreferredSize().height));
add(chatPanel, BorderLayout.SOUTH);
+ if (helpMessage != null) {
+ chatPanel.displayMessage(null, helpMessage);
+ }
add(renderer.getCanvas(), BorderLayout.CENTER);
} else {
renderer.getCanvas().setSize(getWidth(), getHeight());
@@ -230,6 +241,8 @@
playIncomingChatAudio = false;
} else if ("/loud".equals(message)) {
playIncomingChatAudio = true;
+ } else if ("/help".equals(message) && helpMessage != null) {
+ chatPanel.displayMessage(null, helpMessage);
} else {
spaceClient.userIssuedCommand(message);
}
Modified: maven/trunk/ogoglio-viewer-applet/src/test/java/com/ogoglio/viewer/test/AppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/test/java/com/ogoglio/viewer/test/AppletTestWindow.java 2007-11-27 13:00:14 UTC (rev 607)
+++ maven/trunk/ogoglio-viewer-applet/src/test/java/com/ogoglio/viewer/test/AppletTestWindow.java 2007-11-27 13:00:21 UTC (rev 608)
@@ -55,22 +55,19 @@
if (fullScreen) {
this.setUndecorated(true);
}
- PropStorage ps=new PropStorage();
+ PropStorage ps = new PropStorage();
if (!ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS)) {
- Log.error("Can't find bootstrap properties!");
- System.exit(1);
+ Log.error("Can't find bootstrap properties!");
+ System.exit(1);
}
if (!ps.loadPropertySet(PropStorage.BASIC_PROPS)) {
- Log.error("Can't find basic properties!");
- System.exit(1);
+ Log.error("Can't find basic properties!");
+ System.exit(1);
}
- String serviceURI=ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseURL");
+ String serviceURI = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseURL");
HashMap parameters1 = new HashMap();
try {
- WebAPIAuthenticator authenticator = new WebAPIAuthenticator(new WebAPIClientWire(),
- new WebAPIDescriptor(new URI(serviceURI)),
- ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"),
- ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
+ WebAPIAuthenticator authenticator = new WebAPIAuthenticator(new WebAPIClientWire(), new WebAPIDescriptor(new URI(serviceURI)), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
parameters1.put(WebConstants.AUTH_COOKIE, authenticator.getAuthCookie());
} catch (Exception e) {
e.printStackTrace();
@@ -91,7 +88,6 @@
clientStub1 = new EnvironmentStub(parameters1);
applet = new ViewerApplet();
- //applet = new BodyEditorApplet();
applet.setStub(clientStub1);
add(applet, BorderLayout.CENTER);
}
@@ -112,12 +108,12 @@
}
public URL getCodeBase() {
- PropStorage ps=new PropStorage();
+ PropStorage ps = new PropStorage();
if (!ps.loadPropertySet(PropStorage.BASIC_PROPS)) {
- Log.error("Can't find basic properties!");
- System.exit(1);
+ Log.error("Can't find basic properties!");
+ System.exit(1);
}
- String serviceURI=ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseURL");
+ String serviceURI = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseURL");
return getURL(serviceURI);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-27 13:00:10
|
Revision: 607
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=607&view=rev
Author: trevorolio
Date: 2007-11-27 05:00:14 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
Added a help message to the viewer applet. It is displayed at start and can be shown again with /help.
Third party apps can set their own help messages via javascript.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-11-27 01:55:25 UTC (rev 606)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-11-27 13:00:14 UTC (rev 607)
@@ -12,6 +12,12 @@
var spaceDiv = null;
var signinURL = "signin.html";
+var viewerHelpMessage = "Movement: Click in the 3D view and use your arrow keys to explore.<br/>";
+viewerHelpMessage += "Chat: Click in the text field below, type a chat message, then press \"return\".<br/>";
+viewerHelpMessage += "Camera: Drag your mouse to pan the camera left, right, up and down. ESC to reset.<br/>"
+viewerHelpMessage += "Zoom: Use your scroll wheel to zoom the camera in and out.<br/>";
+viewerHelpMessage += "<br/>Type \"/help\" to see this message again.";
+
function handleSpaceDoc(xml){
if(xml == null){
spaceDiv.innerHTML = "That space is not public or does not exist.";
@@ -90,6 +96,9 @@
html += "<param name='serviceURI' value='" + serviceURI + "' />";
html += "<param name='spaceID' value='" + locationParameters['spaceID'] + "' />";
html += "<param name='image' value='" + appletLoadingImagePath + "' />";
+ if(viewerHelpMessage != null){
+ html += "<param name='helpMessage' value='" + escapeHTML(viewerHelpMessage) + "' />";
+ }
html += "<param name='showChat' value='" + showChat + "' />";
if(startX != 0){
html += "<param name='x' value='" + startX + "' />";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-27 01:55:22
|
Revision: 605
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=605&view=rev
Author: trevorolio
Date: 2007-11-26 17:55:23 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Added a little tink noise to incoming chat messages.
This can be disabled using /quiet and enabled using /loud
Added Paths:
-----------
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/incomingChat.wav
Added: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/incomingChat.wav
===================================================================
(Binary files differ)
Property changes on: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/incomingChat.wav
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-27 01:55:22
|
Revision: 606
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=606&view=rev
Author: trevorolio
Date: 2007-11-26 17:55:25 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Added a little tink noise to incoming chat messages.
This can be disabled using /quiet and enabled using /loud
Modified Paths:
--------------
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-11-27 01:55:23 UTC (rev 605)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-11-27 01:55:25 UTC (rev 606)
@@ -14,6 +14,7 @@
package com.ogoglio.viewer.applet;
import java.applet.Applet;
+import java.applet.AudioClip;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@@ -66,6 +67,12 @@
private ChatPanel chatPanel = new ChatPanel(new ChatPanelListener());
+ private boolean showChat = true;
+
+ private boolean playIncomingChatAudio = true;
+
+ AudioClip incomingChatAudioClip = null;
+
public ViewerApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
@@ -97,7 +104,7 @@
float ry = getFloatParameter("ry", 0);
float rz = getFloatParameter("rz", 0);
boolean movable = !"false".equals(getParameter("movable"));
- boolean showChat = !"false".equals(getParameter("showChat"));
+ showChat = !"false".equals(getParameter("showChat"));
try {
serviceURI = new URI(getParameter("serviceURI"));
@@ -115,7 +122,12 @@
removeAll();
validate();
- if(showChat){
+ if (showChat) {
+ try {
+ incomingChatAudioClip = getAudioClip(getCodeBase(), WebConstants.INCOMING_CHAT_SOUND_PATH);
+ } catch (NullPointerException e) {
+ Log.warn("Could not load incoming chat sound, which happens in the test window, for some reason");
+ }
renderer.getCanvas().setSize(getWidth(), getHeight() - chatPanel.getPreferredSize().height);
renderer.getCanvas().setPreferredSize(new Dimension(getWidth(), getHeight() - chatPanel.getPreferredSize().height));
add(chatPanel, BorderLayout.SOUTH);
@@ -208,13 +220,19 @@
private class ChatPanelListener implements ChatPanel.Listener {
public void userReleasedFocus() {
- if(renderer != null && renderer.getCanvas() != null){
+ if (renderer != null && renderer.getCanvas() != null) {
renderer.getCanvas().requestFocus();
}
}
public void userSentMessage(String message) {
- spaceClient.userIssuedCommand(message);
+ if ("/quiet".equals(message)) {
+ playIncomingChatAudio = false;
+ } else if ("/loud".equals(message)) {
+ playIncomingChatAudio = true;
+ } else {
+ spaceClient.userIssuedCommand(message);
+ }
}
}
@@ -310,11 +328,16 @@
}
public void receivedChatMessage(String username, String message) {
+ if (!showChat) {
+ return;
+ }
if (username != null && username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
username = J3DUserRenderable.convertGuestCookieToDisplayName(username);
}
-
chatPanel.displayMessage(username, message);
+ if (playIncomingChatAudio && incomingChatAudioClip != null) {
+ incomingChatAudioClip.play();
+ }
}
public void receivedSpaceTransfer(URI link) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-27 01:55:15
|
Revision: 604
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=604&view=rev
Author: trevorolio
Date: 2007-11-26 17:55:19 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Added a little tink noise to incoming chat messages.
This can be disabled using /quiet and enabled using /loud
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/WebConstants.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/WebConstants.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/WebConstants.java 2007-11-26 18:30:26 UTC (rev 603)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/WebConstants.java 2007-11-27 01:55:19 UTC (rev 604)
@@ -17,4 +17,6 @@
public static final String GUEST_DISPLAY_NAME_PREFIX = "Guest";
public static final String GUEST_BODY_FILE_NAME = "ogoglio-body-guest.jar";
-}
+
+ public static final String INCOMING_CHAT_SOUND_PATH = "incomingChat.wav";
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2007-11-26 18:30:22
|
Revision: 603
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=603&view=rev
Author: iansmith
Date: 2007-11-26 10:30:26 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
Added some Log messages so we have a hope of finding the "empty space bug" in a triumvirate.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceDuplicator.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -36,12 +36,14 @@
throw new IllegalArgumentException("Cannot copy a space to itself: " + destinationSpaceID);
}
+ Log.info("DUP:Creating new client:"+destinationSpaceID+","+emptyFirst+", from "+originSpaceID);
WebAPIClient client = new WebAPIClient(descriptor, auth, wire);
if (emptyFirst) {
emptySpace(destinationSpaceID, client);
}
+ Log.info("DUP: Getting space document and setting simple properties");
SpaceDocument spaceDoc1 = client.getSpaceDocument(originSpaceID, false);
SpaceDocument spaceDoc2 = client.getSpaceDocument(destinationSpaceID, false);
@@ -52,7 +54,9 @@
client.setSpacePublished(destinationSpaceID, spaceDoc1.isPublished());
ThingDocument[] thingDocs = client.getThingDocuments(originSpaceID);
+ Log.info("DUP: setting up possessions and things:"+thingDocs.length);
for (int i = 0; i < thingDocs.length; i++) {
+ Log.info("DUP: Setting up thing "+i+":"+thingDocs[i].getDisplayName());
PossessionDocument[] possDocuments = client.getPossessionDocuments();
PossessionDocument possToUse = null;
for (int j = 0; j < possDocuments.length; j++) {
@@ -81,10 +85,12 @@
}
DoorDocument[] doorDocs = client.getDoorDocuments(spaceDoc1.getSpaceID());
+ Log.info("DUP: Setting up doors:"+doorDocs.length);
for (int i = 0; i < doorDocs.length; i++) {
client.createDoor(spaceDoc2.getSpaceID(), doorDocs[i].getTemplateID(), doorDocs[i].getTemplateOwner(), doorDocs[i].getDisplayName(), doorDocs[i].getLink(), doorDocs[i].getTransform());
}
+ Log.info("DUP: copying space settings ");
Map settings = client.getSpaceSettings(spaceDoc1.getSpaceID());
String[] keys = (String[]) settings.keySet().toArray(new String[0]);
for (int i = 0; i < keys.length; i++) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -13,7 +13,6 @@
limitations under the License. */
package com.ogoglio.client;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -27,6 +26,7 @@
import nanoxml.XMLElement;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
@@ -382,6 +382,7 @@
XMLElement list = wire.fetchAuthenticatedXML(descriptor.getThingsURI(spaceID), authenticator.getAuthCookie());
XMLElement[] children = (XMLElement[]) list.getChildren().toArray(new XMLElement[0]);
+ Log.info("CLIENT: Fetched thing document for space "+spaceID+" and found "+children.length+" children");
for (int i = 0; i < children.length; i++) {
results.add(new ThingDocument(children[i]));
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -26,6 +26,7 @@
import javax.vecmath.Vector3d;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.Log;
public class Space {
@@ -372,6 +373,7 @@
}
public synchronized Thing[] getThings() {
+ Log.info("SPACE: query of things content:"+ things.values().size()+" of space "+spaceID);
return (Thing[]) things.values().toArray(new Thing[0]);
}
@@ -416,6 +418,7 @@
}
public void addThing(Thing thing) {
+ Log.info("Space: adding thing:"+thing.getName()+" to space "+spaceID);
synchronized (this) {
if (thing.getThingID() == -1) {
thing.setThingID(getNewThingID());
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/proto/CometProto.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -105,15 +105,17 @@
} catch (IOException e) {
Log.error("Problem attempting to flush comet proto buffers:" + e.getMessage());
}
- //again, a horrible modularity break: we *know* that needs chunking implies we are on the
- //client side
- if (needsChunking) {
- try {
- Log.info("Closing client-side connection to server since we are shutting down.");
+ }
+ //again, a horrible modularity break: we *know* that needs chunking implies we are on the
+ //client side
+ if (needsChunking) {
+ try {
+ Log.info("Closing client-side connection to server since we are shutting down. ("+(writer==null)+")");
+ if (writer!=null) {
writer.close();
- } catch (IOException e) {
- Log.error("Unable to close connection to server:" + e.getMessage());
}
+ } catch (IOException e) {
+ Log.error("Unable to close connection to server:"+e.getMessage());
}
}
input = null;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/Sim.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -266,20 +266,26 @@
}
public SpaceSimulator getOrCreateSpaceSimulator(SpaceRecord record) {
+ Log.debug("Sim.getOrCreateSpaceSim:"+record.getDisplayName()+","+record.getSpaceID());
synchronized (spaceSimulators) {
SpaceSimulator simulator = (SpaceSimulator) spaceSimulators.getForward(new Long(record.getSpaceID()));
if (simulator != null) {
return simulator;
}
+ Log.debug("Sim.getOrCreateSpaceSim: don't have space doc cached.");
SpaceDocument spaceDoc = null;
try {
+ Log.debug("Sim.getOrCreateSpaceSim: about to read it from the media service!");
spaceDoc = getSpaceDocument(record.getSpaceID());
+ Log.debug("Sim.getOrCreateSpaceSim: Media service:"+(spaceDoc==null));
} catch (IOException e) {
}
if (spaceDoc == null) {
+ Log.debug("Sim.getOrCreateSpaceSim:Now trying to get it from the DocumentFactory.");
spaceDoc = DocumentFactory.documentFromRecord(record);
} else {
+ Log.debug("Sim.getOrCreateSpaceSim: Setting basic properties... why aren't these there before?");
spaceDoc.setDisplayName(record.getDisplayName());
spaceDoc.setMaxGuests(record.getMaxGuests());
spaceDoc.setSimID(record.getSimID());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -98,6 +98,7 @@
renderer.setSimCamera(); //Sigh, you have to add a view before it will schedule the behavior
ThingDocument[] thingDocs = spaceDocument.getThingDocuments();
+ Log.debug("Initialization SpaceSimulator on space "+spaceDocument.getSpaceID()+" with "+thingDocs.length);
for (int i = 0; i < thingDocs.length; i++) {
TemplateDocument templateDoc = listener.getTemplateDocument(thingDocs[i].getTemplateID());
if (templateDoc == null) {
@@ -705,6 +706,7 @@
public ThingDocument[] getThingDocuments() {
Thing[] things = space.getThings();
+ Log.debug("SpaceSimulator: asked space object how many things:"+things.length);
ThingDocument[] results = new ThingDocument[things.length];
for (int i = 0; i < results.length; i++) {
results[i] = new ThingDocument(things[i]);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/ScriptHTTPRequest.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -228,6 +228,7 @@
method.setFollowRedirects(false);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false));
method.getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
+ Log.info("About to invoke an HTTP "+methodType+" on "+url+" from a sim script...");
try {
httpCode = client.executeMethod(method);
if (scriptSpace != null && destinationThingID != -1 && destinationPageID != -1) {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -38,6 +38,7 @@
import com.ogoglio.client.WebAPIDescriptor;
import com.ogoglio.media.MediaService;
import com.ogoglio.persist.AccountRecord;
+import com.ogoglio.persist.PossessionPersistTasks;
import com.ogoglio.persist.ServiceInitializationPersistTasks;
import com.ogoglio.persist.SimPersistTasks;
import com.ogoglio.persist.SimRecord;
@@ -480,9 +481,11 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+ Log.debug("GET on SimServlet.ThingsResource: "+requestedSpaceID+" --- how many possessions?"+
+ (PossessionPersistTasks.findPossessionsBySpaceID(requestedSpaceID, getSessionFactory())));
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
ThingDocument[] thingDocs = simulator.getThingDocuments();
+ Log.debug("SimServlet, Thing request:"+thingDocs.length);
XMLElement list = new XMLElement("list");
for (int i = 0; i < thingDocs.length; i++) {
list.addChild(thingDocs[i].toElement());
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/OgoglioServletBase.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -28,6 +28,10 @@
initBaseUrl();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
String mediaUrl = (String) envCtx.lookup("ogoglio/mediaURL");
+ if (!mediaUrl.endsWith("/")) {
+ Log.warn("mediaURL doesn't end with a '/': patching from "+mediaUrl+" to " + mediaUrl+"/");
+ mediaUrl=mediaUrl+"/";
+ }
boolean simsAllowRemoteAccess = "true".equals(envCtx.lookup("ogoglio/simsAllowRemoteAccess"));
File mailDir = null;
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -66,8 +66,11 @@
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
- messageProxy = new MessageProxy(getSessionFactory(),new WebAPIDescriptor(new URI(baseUrl)));
- config.getServletContext().setAttribute(MESSAGE_PROXY_KEY, messageProxy);
+ //don't bother running a proxy with no space resources!
+ if (servletNeeded) {
+ messageProxy = new MessageProxy(getSessionFactory(),new WebAPIDescriptor(new URI(baseUrl)));
+ config.getServletContext().setAttribute(MESSAGE_PROXY_KEY, messageProxy);
+ }
} catch (URISyntaxException e) {
throw new ServletException("Could not start the message proxy (bad URI for service):" + e);
} catch (IOException e) {
@@ -454,6 +457,7 @@
proxyURI += pathElements[i] + "/";
}
proxyURI += "?" + request.getQueryString();
+ Log.debug("DoProxy SpaceServlet: proxying request for thing:"+proxyURI+" with "+method);
proxy(new URI(proxyURI), method, request, response);
} catch (PersistException e) {
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2007-11-24 15:41:41 UTC (rev 602)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/StatusServlet.java 2007-11-26 18:30:26 UTC (rev 603)
@@ -34,6 +34,8 @@
private static final int MAX_RECENT_CHECKS = 10;
+ public static final int NO_SPACE_SERVLET = -7911;
+
public SiteResource createBaseResource(ServletConfig servletConfig) {
return new StatusResource();
}
@@ -243,9 +245,14 @@
}
private void addSpaceInfo(StatusData data) throws IOException {
- XMLElement space = frontDoorGetXML(getBaseUrl(),"space");
- data.simCount = space.getIntAttribute("simcount");
- data.userCount = space.getIntAttribute("usercount");
+ try {
+ XMLElement space = frontDoorGetXML(getBaseUrl(),"space");
+ data.simCount = space.getIntAttribute("simcount");
+ data.userCount = space.getIntAttribute("usercount");
+ } catch (IOException e) {
+ data.simCount=NO_SPACE_SERVLET;
+ data.userCount=NO_SPACE_SERVLET;
+ }
}
@@ -348,8 +355,12 @@
buffer.append(sd.fs[j].root + ":" + per + "% full\n");
}
}
- buffer.append("User count :" + sd.userCount + "\n");
- buffer.append("Sim count :" + sd.simCount + "\n");
+ if (sd.userCount!=NO_SPACE_SERVLET) {
+ buffer.append("User count :" + sd.userCount + "\n");
+ buffer.append("Sim count :" + sd.simCount + "\n");
+ } else {
+ buffer.append("Space servlet not present\n");
+ }
buffer.append("-----------------------------------------------\n");
}
@@ -566,14 +577,19 @@
}
private String dodgyConversionOfSimURI(String simURI) {
+ return dodgyConversionOfURI(simURI, "/og/sim/");
+ }
+ private String dodgyConversionOfMediaURI(String mediaURI) {
+ return dodgyConversionOfURI(mediaURI, "/og/media/");
+ }
+ private String dodgyConversionOfURI(String URI, String suffix) {
String result;
- String standardSIMSuffix="/og/sim/";
- if (!simURI.endsWith(standardSIMSuffix)) {
- Log.error("Don't understand the sim URI we got, so we can't convert to a status URI:"+simURI);
- return simURI; //not a great answer, but it'll cause IOExceptions elsewhere
+ if (!URI.endsWith(suffix)) {
+ Log.error("Don't understand the URI we got, so we can't convert to a a better URI:"+URI);
+ return URI; //not a great answer, but it'll cause IOExceptions elsewhere
}
- result=simURI.substring(0,simURI.length()-standardSIMSuffix.length()) + "/og/status";
- Log.warn("Somewhat dodgy: Converting the URI "+simURI +" to "+result+" for status report!");
+ result=URI.substring(0,URI.length()-suffix.length()) + "/og/";
+ Log.warn("Somewhat dodgy: Converting the URI "+URI+" to "+result+" for status report!");
return result;
}
private void formatForHuman(StringBuffer buffer) {
@@ -590,7 +606,9 @@
buffer.append("Sim Server:" + sim.getDisplayName() + " [" + sim.getSimID() + "] " + sim.getSimURI() + "\n");
buffer.append("===============================================\n");
if (!isOnLocalhost(sim)) {
- statusReports = frontDoorGetText(dodgyConversionOfSimURI(sim.getSimURI().toString()),STATUS_HUMAN);
+ String hackedURI=dodgyConversionOfSimURI(sim.getSimURI().toString());
+ buffer.append("Hacked sim status URI:"+hackedURI+"\n");
+ statusReports = frontDoorGetText(hackedURI,STATUS_HUMAN);
buffer.append(statusReports);
}
} catch (IOException e) {
@@ -601,11 +619,13 @@
buffer.append("Media Server:" + mediaURI+"\n");
buffer.append("===============================================\n");
if (!mediaURI.startsWith("file:")) {
- statusReports = frontDoorGetText(mediaURI,STATUS_HUMAN);
+ String patchedURI=dodgyConversionOfMediaURI(mediaURI);
+ buffer.append("Hacked media status URI:"+patchedURI+"\n");
+ statusReports = frontDoorGetText(patchedURI,STATUS_HUMAN);
buffer.append(statusReports);
}
} catch (IOException e) {
- buffer.append("Could not contact other status applet:" + e.getMessage());
+ buffer.append("Could not contact other status servlet:" + e.getMessage());
} catch (PersistException e) {
buffer.append("Unable to contact database [PersistException]:" + e.getMessage());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-24 15:41:36
|
Revision: 602
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=602&view=rev
Author: trevorolio
Date: 2007-11-24 07:41:41 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Added a little randomness to the location you land in a space, so that you don't always land on top of someone.
This is done in the javascript for the space UI and the landing position can be set if it's not wanted.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-11-24 12:43:06 UTC (rev 601)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-11-24 15:41:41 UTC (rev 602)
@@ -1,7 +1,7 @@
var viewerWidth = 700;
var viewerHeight = 500;
var appletLoadingImagePath = appPath + "/icons/32x32/face-monkey.png";
-var startX = 0;
+var startX = Math.floor(Math.random() * 5) * (Math.random() > 0.5 ? 1 : -1);
var startY = 0;
var startZ = 0;
var startRX = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-24 12:43:17
|
Revision: 601
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=601&view=rev
Author: trevorolio
Date: 2007-11-24 04:43:06 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Now the camera motion imitates many games:
Left-mouse-drag pans and tilts the camera, rotating around the head.
Escape key resets camera position.
Scroll-wheel zooms in and out.
Modified Paths:
--------------
maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
Modified: maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
===================================================================
--- maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-11-24 12:43:01 UTC (rev 600)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-11-24 12:43:06 UTC (rev 601)
@@ -18,6 +18,8 @@
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Panel;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
@@ -51,7 +53,6 @@
import com.ogoglio.util.UIConstants;
import com.ogoglio.viewer.j3d.J3DBodyData;
import com.ogoglio.viewer.j3d.J3DCamera;
-import com.ogoglio.viewer.j3d.J3DCameraMotionBehavior;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DDataManager;
import com.ogoglio.viewer.j3d.J3DRenderer;
@@ -67,7 +68,7 @@
* NOTE: String arrays don't function in LiveConnect in IE, so we use the getXXXCount and getXXX(index) pattern
*/
-public class BodyEditorApplet extends Applet {
+public class BodyEditorApplet extends Applet{
private URI serviceURI = null;
@@ -127,9 +128,9 @@
return bodyPanel.bodyData.getMorphDeltaMaps().length;
}
- public String getMorphName(int index){
+ public String getMorphName(int index) {
String[] names = getMorphNames();
- if(index < 0 || index > names.length - 1){
+ if (index < 0 || index > names.length - 1) {
return null;
}
return names[index];
@@ -162,18 +163,18 @@
bodyPanel.renderable.updateMorphs();
}
- public int getAnimationCount(){
+ public int getAnimationCount() {
return getAnimationNames().length;
}
- public String getAnimationName(int index){
+ public String getAnimationName(int index) {
String[] names = getAnimationNames();
- if(index < 0 || index > names.length - 1){
+ if (index < 0 || index > names.length - 1) {
return null;
}
return names[index];
}
-
+
public String[] getAnimationNames() {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return new String[0];
@@ -200,18 +201,18 @@
return new BodyConfigurationDocument(user.getBodyConfiguration()).toElement().toString();
}
- public int getBaseTextureCount(){
+ public int getBaseTextureCount() {
return getBaseTextureNames().length;
}
-
- public String getBaseTextureName(int index){
+
+ public String getBaseTextureName(int index) {
String[] names = getBaseTextureNames();
- if(index < 0 || index > names.length - 1){
+ if (index < 0 || index > names.length - 1) {
return null;
}
return names[index];
}
-
+
public String[] getBaseTextureNames() {
if (user == null || bodyPanel == null || bodyPanel.bodyData == null) {
return null;
@@ -297,7 +298,7 @@
}
- private class BodyPanel extends Panel {
+ private class BodyPanel extends Panel implements MouseWheelListener {
Dimension dimension = new Dimension(300, 400);
private J3DUniverse universe = null;
@@ -326,6 +327,7 @@
universe = new J3DUniverse();
canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), false);
+ canvas.addMouseWheelListener(this);
camera = new J3DCamera();
camera.setCanvas(canvas);
@@ -337,6 +339,8 @@
try {
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
renderable = new J3DUserRenderable(user, bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
+ renderable.setCamera(camera);
+ renderable.getCameraBehavior().setAllowXRotation(false);
userGroup.addChild(renderable);
return true;
} catch (Exception e) {
@@ -379,20 +383,26 @@
userGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
userGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- J3DCameraMotionBehavior zoomBehavior = new J3DCameraMotionBehavior(camera.getTransformGroup(), 1.1);
- zoomBehavior.setTransformGroup(camera.getTransformGroup());
- camera.getTransformGroup().addChild(zoomBehavior);
- zoomBehavior.setSchedulingBounds(bounds);
-
canvas.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
canvas.getView().setSceneAntialiasingEnable(true);
- camera.setRotation(-0, Math.PI, 0);
- camera.setLocation(new Vector3f(0f, 1.5f, -1.1f));
- userGroup.addChild(camera.getNode());
-
+ camera.setDefaultLocation(0, 0, 0);
+ camera.setRelativePosition(0, 1.5f, 1f);
+ Transform3D rotTransform = new Transform3D();
+ rotTransform.rotY(Math.PI);
+ camera.getTransformGroup().setTransform(rotTransform);
universe.makeLive();
}
+
+ public void mouseWheelMoved(MouseWheelEvent event) {
+ int zoomDelta = event.getWheelRotation();
+ if (zoomDelta == 0) {
+ return;
+ }
+ int cameraZoom = zoomDelta > 0 ? 1 : -1;
+ camera.changeRelativePosition(0, 0, cameraZoom);
+ }
+
}
public void start() {
@@ -498,4 +508,5 @@
add(errorLabel);
}
}
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-24 12:43:17
|
Revision: 600
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=600&view=rev
Author: trevorolio
Date: 2007-11-24 04:43:01 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Now the camera motion imitates many games:
Left-mouse-drag pans and tilts the camera, rotating around the head.
Escape key resets camera position.
Scroll-wheel zooms in and out.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCamera.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/viewer/j3d/J3DUserRenderable.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Camera.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCamera.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCamera.java 2007-11-22 14:44:20 UTC (rev 599)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCamera.java 2007-11-24 12:43:01 UTC (rev 600)
@@ -38,8 +38,12 @@
private TransformGroup rootTransformGroup = new TransformGroup();
private Transform3D defaultLocation = new Transform3D();
+
+ private Transform3D workingTransform = new Transform3D();
+
+ private Vector3d workingVector = new Vector3d();
- private Transform3D location = new Transform3D();
+ private TransformGroup viewGroup = new TransformGroup();
private ViewPlatform platform = new ViewPlatform();
@@ -53,59 +57,64 @@
public J3DCamera() {
hudGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND);
- rootTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- rootTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
- rootTransformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
- rootTransformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
- rootTransformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
- rootTransformGroup.setTransform(location);
- rootTransformGroup.addChild(platform);
- rootTransformGroup.addChild(hudGroup);
+ setTransformCapabilities(rootTransformGroup);
+ viewGroup.addChild(platform);
+ viewGroup.addChild(hudGroup);
+ setTransformCapabilities(viewGroup);
+ rootTransformGroup.addChild(viewGroup);
+
view.setBackClipDistance(BACK_CLIP_DISTANCE);
view.setPhysicalBody(body);
view.setPhysicalEnvironment(env);
view.attachViewPlatform(platform);
}
- public TransformGroup getTransformGroup() {
- return rootTransformGroup;
+ private void setTransformCapabilities(TransformGroup transformGroup) {
+ transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+ transformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
+ transformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
+ transformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
}
- public void setCanvas(Canvas3D canvas) {
- this.canvas = canvas;
- view.addCanvas3D(canvas);
+ public void changeRelativePosition(double x, double y, double z){
+ viewGroup.getTransform(workingTransform);
+ workingTransform.get(workingVector);
+ workingVector.x += x;
+ workingVector.y += y;
+ workingVector.z += z;
+ workingVector.z = Math.max(1, workingVector.z);
+ workingTransform.setTranslation(workingVector);
+ viewGroup.setTransform(workingTransform);
}
- public Canvas3D getCanvas() {
- return canvas;
+ public void setRelativePosition(double x, double y, double z) {
+ workingTransform.setIdentity();
+ workingTransform.setTranslation(new Vector3d(x, y, z));
+ viewGroup.setTransform(workingTransform);
}
- public void getPosition(Transform3D transform) {
- rootTransformGroup.getTransform(transform);
+ public void setDefaultLocation(double x, double y, double z) {
+ defaultLocation.setIdentity();
+ defaultLocation.setTranslation(new Vector3d(x, y, z));
}
- public void setPosition(Transform3D transform) {
- location.set(transform);
- rootTransformGroup.setTransform(location);
+ public void setToDefaultLocation() {
+ rootTransformGroup.setTransform(defaultLocation);
}
- public void setLocation(Vector3f loc) {
- location.setTranslation(loc);
- rootTransformGroup.setTransform(location);
+ public TransformGroup getTransformGroup() {
+ return rootTransformGroup;
}
- public void setRotation(double xRot, double yRot, double zRot) {
- Vector3d position = new Vector3d();
- location.get(position);
- location.setEuler(new Vector3d(xRot, yRot, zRot));
- location.setTranslation(position);
- rootTransformGroup.setTransform(location);
+ public void setCanvas(Canvas3D canvas) {
+ this.canvas = canvas;
+ view.addCanvas3D(canvas);
}
-
- public void setOrientation(AxisAngle4f angle) {
- location.setRotation(angle);
- rootTransformGroup.setTransform(location);
+
+ public Canvas3D getCanvas() {
+ return canvas;
}
public void addHUDObject(Node geom) {
@@ -115,13 +124,4 @@
public Node getNode() {
return rootTransformGroup;
}
-
- public void setDefaultLocation(Vector3f location) {
- defaultLocation.setIdentity();
- defaultLocation.setTranslation(location);
- }
-
- public void setToDefaultLocation(){
- rootTransformGroup.setTransform(defaultLocation);
- }
}
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-11-22 14:44:20 UTC (rev 599)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCameraMotionBehavior.java 2007-11-24 12:43:01 UTC (rev 600)
@@ -9,6 +9,7 @@
import javax.media.j3d.WakeupCriterion;
import javax.media.j3d.WakeupOnAWTEvent;
import javax.media.j3d.WakeupOnBehaviorPost;
+import javax.vecmath.Quat4d;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3d;
@@ -19,21 +20,26 @@
double x_factor = 0.01;
- double z_factor = 0.04;
+ double y_factor = 0.01;
+ Vector3d euler = new Vector3d();
+
Vector3d translation = new Vector3d();
- Quat4f orientation = new Quat4f();
+ Quat4d orientation = new Quat4d();
Transform3D orientationTransform = new Transform3D();
+
+ boolean allowXRotation = true;
- double minDistance = 0;
-
- public J3DCameraMotionBehavior(TransformGroup transformGroup, double minDistance) {
+ public J3DCameraMotionBehavior(TransformGroup transformGroup) {
super(transformGroup);
- this.minDistance = minDistance;
}
+ public void setAllowXRotation(boolean allow){
+ this.allowXRotation = allow;
+ }
+
public void processStimulus(Enumeration criteria) {
WakeupCriterion wakeup;
AWTEvent[] events;
@@ -85,27 +91,18 @@
if (!reset) {
y_angle = dx * x_factor;
+ x_angle = allowXRotation ? dy * y_factor : 0;
+
+ euler.x -= x_angle;
+ euler.x = Math.max(-Math.PI / 5, euler.x);
+ euler.x = Math.min(Math.PI / 5, euler.x);
+ euler.y -= y_angle;
+ euler.z = 0;
+
transformGroup.getTransform(currXform);
-
currXform.get(translation);
- translation.y = 0;
- if (translation.length() > minDistance || dy > 0) {
- // First zoom
- currXform.get(orientation);
- translation.x = 0;
- translation.y = 0;
- translation.z = 0;
- orientationTransform.set(orientation, translation, 1);
- translation.z = dy * z_factor;
- orientationTransform.transform(translation);
- transformX.set(translation);
- currXform.mul(transformX, currXform);
- }
-
- //Now rotate
- transformY.rotY(y_angle);
- currXform.mul(transformY, currXform);
-
+ currXform.setEuler(euler);
+ currXform.setTranslation(translation);
transformGroup.setTransform(currXform);
} else {
reset = false;
@@ -114,9 +111,37 @@
x_last = x;
y_last = y;
} else if (id == MouseEvent.MOUSE_PRESSED) {
+ transformGroup.getTransform(currXform);
+ currXform.get(orientation);
+ 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-11-22 14:44:20 UTC (rev 599)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-11-24 12:43:01 UTC (rev 600)
@@ -694,9 +694,8 @@
if (isLocalUser) {
float cameraHeight = (float) (renderable.getHeight() - renderable.getHeight() / 5);
- Vector3f defaultCameraLocation = new Vector3f(0f, cameraHeight, 3f);
- camera.setDefaultLocation(defaultCameraLocation);
- camera.setLocation(defaultCameraLocation);
+ camera.setDefaultLocation(0, 0, 0);
+ camera.setRelativePosition(0, cameraHeight, 3f);
renderable.setCamera(camera);
motionHandler = new MotionInputHandler(this, renderable, userInputListener);
@@ -720,7 +719,7 @@
public void setSimCamera() {
BranchGroup cameraBranch = new BranchGroup();
- camera.setLocation(new Vector3f(0f, 2f, 2f));
+ camera.setRelativePosition(0f, 2f, 2f);
cameraBranch.addChild(camera.getNode());
worldGroup.addChild(cameraBranch);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-11-22 14:44:20 UTC (rev 599)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-11-24 12:43:01 UTC (rev 600)
@@ -78,6 +78,8 @@
private boolean playDefaultAnimationWhenComplete = true;
+ private J3DCameraMotionBehavior cameraBehavior = null;
+
public J3DUserRenderable(User user, J3DBodyData bodyData, BufferedImage customSkin) {
ArgumentUtils.assertNotNull(user);
this.user = user;
@@ -185,11 +187,10 @@
this.camera = (J3DCamera) camera;
transformGroup.addChild(this.camera.getNode());
- TransformGroup cameraTransformGroup = ((J3DCamera)camera).getTransformGroup();
- J3DCameraMotionBehavior zoomBehavior = new J3DCameraMotionBehavior(cameraTransformGroup, 1.1);
- zoomBehavior.setTransformGroup(cameraTransformGroup);
- cameraTransformGroup.addChild(zoomBehavior);
- zoomBehavior.setSchedulingBounds(new BoundingSphere());
+ TransformGroup cameraTransformGroup = ((J3DCamera) camera).getTransformGroup();
+ cameraBehavior = new J3DCameraMotionBehavior(cameraTransformGroup);
+ cameraTransformGroup.addChild(cameraBehavior);
+ cameraBehavior.setSchedulingBounds(J3DRenderer.DEFAULT_SPACE_BOUNDS);
}
@@ -289,7 +290,7 @@
}
public static String convertGuestCookieToDisplayName(String displayName) {
- if(displayName == null || !displayName.startsWith(WebConstants.GUEST_COOKIE_PREFIX)){
+ if (displayName == null || !displayName.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
return displayName;
}
displayName = displayName.substring(WebConstants.GUEST_COOKIE_PREFIX.length() + 1);
@@ -301,4 +302,8 @@
}
return result.toString();
}
+
+ public J3DCameraMotionBehavior getCameraBehavior() {
+ return cameraBehavior;
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-22 14:44:20 UTC (rev 599)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-24 12:43:01 UTC (rev 600)
@@ -30,6 +30,7 @@
import com.ogoglio.client.model.SplinePath;
import com.ogoglio.client.model.Thing;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.viewer.render.Camera;
import com.ogoglio.viewer.render.ClickTarget;
import com.ogoglio.viewer.render.DoorRenderable;
import com.ogoglio.viewer.render.PageRenderable;
@@ -77,8 +78,6 @@
private Quat4d orientation = new Quat4d();
- private Vector3d translation = new Vector3d();
-
public MotionInputHandler(Renderer renderer, UserRenderable userGroup, UserInputListener inputListener) {
ArgumentUtils.assertNotNull(renderer);
this.renderer = renderer;
@@ -100,22 +99,8 @@
renderer.getCamera().setToDefaultLocation();
return;
}
- J3DCamera camera = ((J3DCamera) renderer.getCamera());
- camera.getTransformGroup().getTransform(currentTransform);
- currentTransform.get(translation);
- translation.y = 0;
- if (translation.length() > 1 || cameraZoom > 0) {
- currentTransform.get(orientation);
- translation.x = 0;
- translation.y = 0;
- translation.z = 0;
- orientationTransform.set(orientation, translation, 1);
- translation.z = cameraZoom;
- orientationTransform.transform(translation);
- transformX.set(translation);
- currentTransform.mul(transformX, currentTransform);
- camera.getTransformGroup().setTransform(currentTransform);
- }
+ Camera camera = renderer.getCamera();
+ camera.changeRelativePosition(0, 0, cameraZoom);
}
if (!dirty) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Camera.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Camera.java 2007-11-22 14:44:20 UTC (rev 599)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/Camera.java 2007-11-24 12:43:01 UTC (rev 600)
@@ -14,7 +14,12 @@
package com.ogoglio.viewer.render;
public interface Camera {
- public void setRotation(double xRot, double yRot, double zRot);
+ public void setRelativePosition(double x, double y, double z);
+ public void changeRelativePosition(double x, double y, double cameraZoom);
+
+ public void setDefaultLocation(double x, double y, double z);
+
public void setToDefaultLocation();
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-22 14:44:16
|
Revision: 599
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=599&view=rev
Author: trevorolio
Date: 2007-11-22 06:44:20 -0800 (Thu, 22 Nov 2007)
Log Message:
-----------
This time without debug printing.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-22 14:42:26 UTC (rev 598)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-22 14:44:20 UTC (rev 599)
@@ -112,7 +112,6 @@
orientationTransform.set(orientation, translation, 1);
translation.z = cameraZoom;
orientationTransform.transform(translation);
- System.out.println("z " + translation.z);
transformX.set(translation);
currentTransform.mul(transformX, currentTransform);
camera.getTransformGroup().setTransform(currentTransform);
@@ -353,7 +352,6 @@
public void mouseWheelMoved(MouseWheelEvent event) {
int zoomDelta = event.getWheelRotation();
- System.out.println("Zoom " + zoomDelta);
if (zoomDelta == 0) {
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-22 14:42:22
|
Revision: 598
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=598&view=rev
Author: trevorolio
Date: 2007-11-22 06:42:26 -0800 (Thu, 22 Nov 2007)
Log Message:
-----------
In the interest of satisfying the legions of gamers who freak out when camera controls aren't exactly like WoW, the scroll wheel now zooms the camera.
Modified Paths:
--------------
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/viewer/j3d/MotionInputHandler.java
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-11-21 17:17:05 UTC (rev 597)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DCameraMotionBehavior.java 2007-11-22 14:42:26 UTC (rev 598)
@@ -47,9 +47,7 @@
mouseEvent = (MouseEvent) events[events.length - 1];
doProcess(mouseEvent);
}
- }
-
- else if (wakeup instanceof WakeupOnBehaviorPost) {
+ } else if (wakeup instanceof WakeupOnBehaviorPost) {
while (true) {
synchronized (mouseq) {
if (mouseq.isEmpty())
@@ -74,8 +72,9 @@
processMouseEvent(evt);
+ id = evt.getID();
+
if (((buttonPress) && ((flags & MANUAL_WAKEUP) == 0)) || ((wakeUp) && ((flags & MANUAL_WAKEUP) != 0))) {
- id = evt.getID();
if ((id == MouseEvent.MOUSE_DRAGGED) && !evt.isAltDown() && !evt.isMetaDown()) {
x = evt.getX();
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-11-21 17:17:05 UTC (rev 597)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-11-22 14:42:26 UTC (rev 598)
@@ -16,8 +16,9 @@
import java.awt.Canvas;
import java.awt.GraphicsConfigTemplate;
import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Enumeration;
@@ -701,6 +702,7 @@
motionHandler = new MotionInputHandler(this, renderable, userInputListener);
getCanvas().addMouseListener(motionHandler);
getCanvas().addMouseMotionListener(motionHandler);
+ getCanvas().addMouseWheelListener(motionHandler);
} else if (!offScreen) {
String displayName = user.getUsername();
if (displayName.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-21 17:17:05 UTC (rev 597)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-22 14:42:26 UTC (rev 598)
@@ -18,10 +18,13 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
import javax.media.j3d.Transform3D;
import javax.vecmath.Point3d;
import javax.vecmath.Quat4d;
+import javax.vecmath.Vector3d;
import com.ogoglio.client.UserInputListener;
import com.ogoglio.client.model.SplinePath;
@@ -36,8 +39,7 @@
import com.ogoglio.viewer.render.ThingRenderable;
import com.ogoglio.viewer.render.UserRenderable;
-public class MotionInputHandler implements MouseMotionListener, MouseListener {
- //TODO right now we only support arrow key based walking, strafing and turning
+public class MotionInputHandler implements MouseMotionListener, MouseListener, MouseWheelListener {
public double maxRadiansPerSecond = Math.PI / 60;
@@ -53,20 +55,30 @@
private boolean turnRight = false;
- private float cameraTilt = 0;
+ private float cameraZoom = 0;
private boolean dirty = false;
private boolean cameraDirty = false;
+ private boolean cameraReset = false;
+
private Renderer renderer = null;
private UserInputListener userInputListener = null;
private UserRenderable userRenderable = null;
- private boolean cameraReset = false;
+ private Transform3D currentTransform = new Transform3D();
+ private Transform3D transformX = new Transform3D();
+
+ private Transform3D orientationTransform = new Transform3D();
+
+ private Quat4d orientation = new Quat4d();
+
+ private Vector3d translation = new Vector3d();
+
public MotionInputHandler(Renderer renderer, UserRenderable userGroup, UserInputListener inputListener) {
ArgumentUtils.assertNotNull(renderer);
this.renderer = renderer;
@@ -88,7 +100,23 @@
renderer.getCamera().setToDefaultLocation();
return;
}
- renderer.getCamera().setRotation(cameraTilt, 0, 0);
+ J3DCamera camera = ((J3DCamera) renderer.getCamera());
+ camera.getTransformGroup().getTransform(currentTransform);
+ currentTransform.get(translation);
+ translation.y = 0;
+ if (translation.length() > 1 || cameraZoom > 0) {
+ currentTransform.get(orientation);
+ translation.x = 0;
+ translation.y = 0;
+ translation.z = 0;
+ orientationTransform.set(orientation, translation, 1);
+ translation.z = cameraZoom;
+ orientationTransform.transform(translation);
+ System.out.println("z " + translation.z);
+ transformX.set(translation);
+ currentTransform.mul(transformX, currentTransform);
+ camera.getTransformGroup().setTransform(currentTransform);
+ }
}
if (!dirty) {
@@ -157,15 +185,10 @@
dirty = true;
strafeRight = true;
}
- } else if (e.getKeyCode() == KeyEvent.VK_PAGE_UP) {
- cameraDirty = true;
- cameraTilt += 0.1;
- } else if (e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) {
- cameraDirty = true;
- cameraTilt -= 0.1;
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
cameraDirty = true;
cameraReset = true;
+ cameraZoom = 0;
} else if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_SLASH) {
if (moveBackward || moveForward || strafeLeft || strafeRight) {
dirty = true;
@@ -255,7 +278,6 @@
private void clickedOnAThing(MouseEvent event, Thing thing, String name, Point3d intersection) {
userInputListener.mouseClickedThing(thing, name, intersection);
-
}
public void mouseDragged(MouseEvent e) {
@@ -328,4 +350,15 @@
reevaluate();
}
}
+
+ public void mouseWheelMoved(MouseWheelEvent event) {
+ int zoomDelta = event.getWheelRotation();
+ System.out.println("Zoom " + zoomDelta);
+ if (zoomDelta == 0) {
+ return;
+ }
+ cameraDirty = true;
+ cameraZoom = zoomDelta > 0 ? 1 : -1;
+ reevaluate();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-21 17:17:18
|
Revision: 597
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=597&view=rev
Author: trevorolio
Date: 2007-11-21 09:17:05 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Sadly, this breaks with idea of using the applet only for 3D view because browsers can't reliably pass focus between DOM text field and java panel, which we tried to make work for the movement/chat cycle but it failed and made it unacceptably slow to switch between the two actions. So, I added the chat history and command line to the applet and rewhacked all of the relevant HTML pages.
While moving in the 3D view press enter or / to move to the command line. Enter or escape will switch focus back to 3D view.
Also, fixed the bug in which losing focus while moving would make you lose control, endlessly walking or turning. Now the 3D view catched the focus change and stops any active movement.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/main/java/com/ogoglio/amazon/test/CometTest.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/main/java/com/ogoglio/amazon/test/CometTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/main/java/com/ogoglio/amazon/test/CometTest.java 2007-11-21 17:16:57 UTC (rev 596)
+++ maven/trunk/ogoglio-integration-test/src/main/java/com/ogoglio/amazon/test/CometTest.java 2007-11-21 17:17:05 UTC (rev 597)
@@ -83,7 +83,7 @@
public void receivedChatMessage(String username, String message) {
}
- public void receivedCommandFocusRequest() {
+ public void receivedCommandFocusRequest(String preloadedText) {
}
public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-11-21 17:16:57 UTC (rev 596)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-11-21 17:17:05 UTC (rev 597)
@@ -1050,7 +1050,7 @@
public void receivedLink(String displayName, String link) {
}
- public void receivedCommandFocusRequest() {
+ public void receivedCommandFocusRequest(String preloadedText) {
}
public void receivedBrowserMessage(long sourceThingID, String message) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-21 17:17:00
|
Revision: 596
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=596&view=rev
Author: trevorolio
Date: 2007-11-21 09:16:57 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Sadly, this breaks with idea of using the applet only for 3D view because browsers can't reliably pass focus between DOM text field and java panel, which we tried to make work for the movement/chat cycle but it failed and made it unacceptably slow to switch between the two actions. So, I added the chat history and command line to the applet and rewhacked all of the relevant HTML pages.
While moving in the 3D view press enter or / to move to the command line. Enter or escape will switch focus back to 3D view.
Also, fixed the bug in which losing focus while moving would make you lose control, endlessly walking or turning. Now the 3D view catched the focus change and stops any active movement.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/space.html
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceEmbed.html
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-21 17:16:47 UTC (rev 595)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-11-21 17:16:57 UTC (rev 596)
@@ -1089,7 +1089,7 @@
public void viewpointMotionStopped(Transform3D position) {
}
- public void focusCommandField() {
+ public void focusCommandField(String preloadedText) {
}
public void mouseContextClickedThing(Thing thing, String name, int x, int y) {
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/space.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/space.html 2007-11-21 17:16:47 UTC (rev 595)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/space.html 2007-11-21 17:16:57 UTC (rev 596)
@@ -17,35 +17,11 @@
#spaceDiv {
width: 758px;
- height: 500px;
+ height: 600px;
border: solid 1px #CCD;
color: #AAA;
}
-#chatHistory {
- width: 752px;
- height: 100px;
- border: solid 1px #CCD;
- border-top: 0px;
- overflow: auto;
- padding: 0px 3px 0px 3px;
-}
-
-#chatForm {
- margin: 0px 0px 0px 0px;
- padding: 0px;
-}
-
-#commandInput {
- padding: 3px;
- width: 650px;
- border: solid 1px #CCD;
-}
-
-#sendCommandButton {
- width: 90px;
-}
-
#infoDiv {
float:right;
padding: 10px 0px 10px 0px;
@@ -68,7 +44,7 @@
function init(){
populateMemberMenuItem();
viewerWidth = 758;
- viewerHeight = 500;
+ viewerHeight = 700;
initSpaceUI();
}
</script>
@@ -97,12 +73,6 @@
<div id="spaceDiv">
<noscript><div style="width: 100%; text-align: center; color: #911;">You must enable javascript to view this page.</div></noscript>
</div>
-
- <div id="chatHistory"></div>
- <form id="chatForm" onsubmit="goChatForm(); return false;">
- <input id="commandInput" type="text" />
- <input id="sendCommandButton" type="submit" value="send" />
- </form>
<div id="messages">
</div>
</div><!-- end main -->
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceEmbed.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceEmbed.html 2007-11-21 17:16:47 UTC (rev 595)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceEmbed.html 2007-11-21 17:16:57 UTC (rev 596)
@@ -9,42 +9,17 @@
}
#spaceDiv {
width: 758px;
- height: 500px;
+ height: 600px;
color: #AAA;
}
-
-#chatHistory {
- width: 752px;
- height: 100px;
- border: solid 1px #CCD;
- border-top: 0px;
- overflow: auto;
- padding: 0px 3px 0px 3px;
-}
-
-#chatForm {
- margin: 0px 0px 0px 0px;
- padding: 0px;
-}
-
-#commandInput {
- padding: 3px;
- width: 650px;
- border: solid 1px #CCD;
-}
-
-#sendCommandButton {
- width: 90px;
-}
</style>
<script type="text/javascript" src="/og/ogoglio.js"></script>
<script type="text/javascript" src="/og/browserTests.js"></script>
<script type="text/javascript" src="/og/spaceui.js"></script>
<script type="text/javascript">
-var chatHistoryHeight = 50;
var viewerWidth = getIntParameter('width', 758);
-var viewerHeight = getIntParameter('height', 500);
+var viewerHeight = getIntParameter('height', 600);
var showChat = locationParameters['showChat'] != 'false';
var autoGuest = locationParameters['autoGuest'] == 'true';
var movable = locationParameters['movable'] != 'false';
@@ -64,17 +39,6 @@
spaceDiv.style.width = viewerWidth + "px";
spaceDiv.style.height = viewerHeight + "px";
- var chatForm = document.getElementById('chatForm');
- var chatHistory = document.getElementById('chatHistory');
- var commandInput = document.getElementById('commandInput');
- if(showChat){
- chatHistory.style.width = (viewerWidth - 6) + "px";
- chatHistory.style.height = chatHistoryHeight + "px";
- commandInput.style.width = (viewerWidth - 110) + "px";
- } else {
- chatForm.style.visibility = "hidden";
- chatForm.innerHTML = "";
- }
initSpaceUI();
}
@@ -92,12 +56,6 @@
<noscript><div style="width: 100%; text-align: center; color: #911;">You must enable javascript to view this page.</div></noscript>
</div>
- <div id="chatHistory"></div>
- <form id="chatForm" onsubmit="goChatForm(); return false;">
- <input id="commandInput" type="text" />
- <input id="sendCommandButton" type="submit" value="send" />
- </form>
-
<!-- Copyright 2007 Transmutable (http://transmutable.com/) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.-->
</body>
</html>
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-11-21 17:16:47 UTC (rev 595)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/spaceui.js 2007-11-21 17:16:57 UTC (rev 596)
@@ -8,8 +8,8 @@
var startRY = 0;
var startRZ = 0;
var movable = true;
+var showChat = true;
var spaceDiv = null;
-var chatHistory = null;
var signinURL = "signin.html";
function handleSpaceDoc(xml){
@@ -90,6 +90,7 @@
html += "<param name='serviceURI' value='" + serviceURI + "' />";
html += "<param name='spaceID' value='" + locationParameters['spaceID'] + "' />";
html += "<param name='image' value='" + appletLoadingImagePath + "' />";
+ html += "<param name='showChat' value='" + showChat + "' />";
if(startX != 0){
html += "<param name='x' value='" + startX + "' />";
}
@@ -116,75 +117,6 @@
spaceDiv.innerHTML = html;
}
-function displayLink(displayName, link){
- displayName = displayName + "";
- link = link + "";
-
- displayChatMessage("Link: <a onclick='popUp(\"" + link + "\", true); return false;' href='javascript:void(0);'>" + escapeHTML(displayName) + "</a>");
-}
-
-//called by the viewer applet
-function focusCommandField(){
- var commandInput = document.getElementById("commandInput");
- if(typeof commandInput != 'undefined'){
- commandInput.focus();
- }
-}
-
-function displayChatMessage(message){
- message = message + ""; //makes message into a js string instead of a (buggy on safari) string
- var username = null;
- var text = null;
- if(message.indexOf(":") != -1){
- username = message.substring(0, message.indexOf(":"));
- if(username.indexOf(guestCookiePrefix) == 0){
- username = convertGuestCookieToDisplayName(username);
- }
-
- text = message.substring(message.indexOf(":") + 1);
- } else {
- username = "system";
- text = message;
- }
-
- chatHistory.innerHTML += "<span class='chatUsername'>" + username + "</span>: " + markupChatMessage(text) + "<br />";
- chatHistory.scrollTop = chatHistory.scrollHeight;
- focusCommandField();
-}
-
-var emoteIconBase = appPath + "/icons/16x16/";
-
-var emotePatterns = new Array();
-var emoteImageNames = new Array();
-
-emotePatterns[emotePatterns.length] = "0:-)"; emoteImageNames[emoteImageNames.length] = "face-angel.png";
-emotePatterns[emotePatterns.length] = ":'("; emoteImageNames[emoteImageNames.length] = "face-crying.png";
-emotePatterns[emotePatterns.length] = ">:-)"; emoteImageNames[emoteImageNames.length] = "face-devil-grin.png";
-emotePatterns[emotePatterns.length] = "B-)"; emoteImageNames[emoteImageNames.length] = "face-glasses.png";
-emotePatterns[emotePatterns.length] = ":-*"; emoteImageNames[emoteImageNames.length] = "face-kiss.png";
-emotePatterns[emotePatterns.length] = ":-(|)"; emoteImageNames[emoteImageNames.length] = "face-monkey.png";
-emotePatterns[emotePatterns.length] = ":-|"; emoteImageNames[emoteImageNames.length] = "face-plain.png";
-emotePatterns[emotePatterns.length] = ":-("; emoteImageNames[emoteImageNames.length] = "face-sad.png";
-emotePatterns[emotePatterns.length] = ":-)"; emoteImageNames[emoteImageNames.length] = "face-smile.png";
-emotePatterns[emotePatterns.length] = ":-D"; emoteImageNames[emoteImageNames.length] = "face-smile-big.png";
-emotePatterns[emotePatterns.length] = ":-0"; emoteImageNames[emoteImageNames.length] = "face-surprise.png";
-emotePatterns[emotePatterns.length] = ";-)"; emoteImageNames[emoteImageNames.length] = "face-wink.png";
-
-function markupChatMessage(messageText){
- for(var i = 0; i < emotePatterns.length; i++){
- messageText = emotify(messageText, emotePatterns[i], emoteIconBase + emoteImageNames[i]);
- }
- return messageText;
-}
-
-function emotify(messageText, emotePattern, imageURL){
- var workingText = messageText;
- while(workingText.indexOf(emotePattern) != -1){
- workingText = workingText.substring(0, workingText.indexOf(emotePattern)) + "<img src='" + imageURL +"' width='16' height='16' />" + workingText.substring(workingText.indexOf(emotePattern) + emotePattern.length);
- }
- return workingText;
-}
-
function handleTestResults(success){
if(!success){
//we leave the error message there
@@ -194,31 +126,8 @@
writeApplet();
}
-function goChatForm(){
- var form = document.getElementById("chatForm");
- var commandValue = form.commandInput.value;
- if(commandValue == null || trim(commandValue).length == 0){
- return;
- }
- form.commandInput.value = "";
- if(commandValue == "/help"){
- displayChatMessage(getHelpMessage());
- return;
- }
- document.viewer.sendChatMessage(commandValue);
-}
-
-function getHelpMessage(){
- var helpMessage = "Help: Click the 3D scene and use your arrow keys to explore.<br/>"
- helpMessage += "Drag the mouse up/down and left/right to move your camera.<br/>";
- helpMessage += "Press the escape key to reset your camera.<br/>"
- helpMessage += "PageUp/PageDown tilts your camera.";
- return helpMessage;
-}
-
function initSpaceUI(){
spaceDiv = document.getElementById('spaceDiv');
- chatHistory = document.getElementById('chatHistory');
addAuthListeners(spaceHandleAuth, spaceHandleAuth);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-21 17:16:54
|
Revision: 595
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=595&view=rev
Author: trevorolio
Date: 2007-11-21 09:16:47 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Sadly, this breaks with idea of using the applet only for 3D view because browsers can't reliably pass focus between DOM text field and java panel, which we tried to make work for the movement/chat cycle but it failed and made it unacceptably slow to switch between the two actions. So, I added the chat history and command line to the applet and rewhacked all of the relevant HTML pages.
While moving in the 3D view press enter or / to move to the command line. Enter or escape will switch focus back to 3D view.
Also, fixed the bug in which losing focus while moving would make you lose control, endlessly walking or turning. Now the 3D view catched the focus change and stops any active movement.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/UserInputListener.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/PhysicsBehavior.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.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-11-21 17:16:32 UTC (rev 594)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-11-21 17:16:47 UTC (rev 595)
@@ -295,8 +295,8 @@
sendSpaceEvent(event);
}
- public void focusCommandField() {
- listener.receivedCommandFocusRequest();
+ public void focusCommandField(String preloadedText) {
+ listener.receivedCommandFocusRequest(preloadedText);
}
private void sendSpaceEvent(SpaceEvent event) {
@@ -746,7 +746,7 @@
public void disconnected();
- public void receivedCommandFocusRequest();
+ public void receivedCommandFocusRequest(String preloadedText);
}
public void cleanup() {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/UserInputListener.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/UserInputListener.java 2007-11-21 17:16:32 UTC (rev 594)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/UserInputListener.java 2007-11-21 17:16:47 UTC (rev 595)
@@ -22,7 +22,7 @@
public void mouseClickedPage(Page page, Point3d intersection);
- public void focusCommandField();
+ public void focusCommandField(String preloadedText);
public void mouseContextClickedThing(Thing thing, String name, int x, int y);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-21 17:16:32 UTC (rev 594)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-11-21 17:16:47 UTC (rev 595)
@@ -55,8 +55,6 @@
private float cameraTilt = 0;
- private boolean run = false;
-
private boolean dirty = false;
private boolean cameraDirty = false;
@@ -130,16 +128,14 @@
// called from within PhysicsBehavior
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_W) {
- if (moveForward == false || run == true) {
+ if (moveForward == false) {
dirty = true;
moveForward = true;
- run = false;
}
} else if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_S) {
- if (moveBackward == false || run == true) {
+ if (moveBackward == false) {
dirty = true;
moveBackward = true;
- run = false;
}
} else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_Q) {
if (turnLeft == false) {
@@ -170,6 +166,16 @@
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
cameraDirty = true;
cameraReset = true;
+ } else if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_SLASH) {
+ if (moveBackward || moveForward || strafeLeft || strafeRight) {
+ dirty = true;
+ moveBackward = false;
+ moveForward = false;
+ strafeLeft = false;
+ strafeRight = false;
+ }
+ String preloadedText = e.getKeyCode() == KeyEvent.VK_SLASH ? "/" : null;
+ userInputListener.focusCommandField(preloadedText);
}
reevaluate();
}
@@ -211,13 +217,6 @@
}
public void keyTyped(KeyEvent e) {
- if (e.getKeyChar() == 'r') {
- dirty = true;
- run = !run;
- } else if (e.getKeyChar() == '\n') {
- userInputListener.focusCommandField();
- }
- reevaluate();
}
public void mouseClicked(MouseEvent event) {
@@ -247,7 +246,6 @@
} else if (clickTarget.getRenderable() instanceof DoorRenderable) {
userInputListener.mouseClickedDoor(((DoorRenderable) clickTarget.getRenderable()).getDoor(), null, clickTarget.getIntersection());
} else if (clickTarget.getRenderable() instanceof PageRenderable) {
- System.out.println("Clicked page: " + ((PageRenderable) clickTarget.getRenderable()).getPage());
userInputListener.mouseClickedPage(((PageRenderable) clickTarget.getRenderable()).getPage(), clickTarget.getIntersection());
} else {
throw new IllegalStateException("Clicked on a type of renderable we don't understand");
@@ -286,8 +284,8 @@
ShapeRenderable shape = (ShapeRenderable) clickTarget.getRenderable();
renderable = (ThingRenderable) shape.getRenderable();
name = shape.getName();
- } else if(clickTarget.getRenderable() instanceof PageRenderable){
- PageRenderable pageRenderable = (PageRenderable)clickTarget.getRenderable();
+ } else if (clickTarget.getRenderable() instanceof PageRenderable) {
+ PageRenderable pageRenderable = (PageRenderable) clickTarget.getRenderable();
renderable = pageRenderable.getThingRenderable();
} else {
return;
@@ -319,4 +317,15 @@
userInputListener.mouseContextClickedThing(renderable.getThing(), name, event.getX(), event.getY());
}
}
+
+ public void focusChanged() {
+ if (moveBackward || moveForward || strafeLeft || strafeRight) {
+ dirty = true;
+ moveBackward = false;
+ moveForward = false;
+ strafeLeft = false;
+ strafeRight = false;
+ reevaluate();
+ }
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/PhysicsBehavior.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/PhysicsBehavior.java 2007-11-21 17:16:32 UTC (rev 594)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/PhysicsBehavior.java 2007-11-21 17:16:47 UTC (rev 595)
@@ -15,6 +15,7 @@
package com.ogoglio.viewer.j3d;
import java.awt.AWTEvent;
+import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.util.Enumeration;
import java.util.Vector;
@@ -39,13 +40,15 @@
private WakeupOnAWTEvent keyEventCriteria = new WakeupOnAWTEvent(AWTEvent.KEY_EVENT_MASK);
+ private WakeupOnAWTEvent focusEventCriteria = new WakeupOnAWTEvent(AWTEvent.FOCUS_EVENT_MASK);
+
private WakeupOnElapsedTime elapsedTimeCriteria = new WakeupOnElapsedTime(50);
- private WakeupCriterion[] activeCrits = { elapsedFramesCriteria, keyEventCriteria };
+ private WakeupCriterion[] activeCrits = { elapsedFramesCriteria, keyEventCriteria, focusEventCriteria };
private WakeupOr activeWakeupCriteria = new WakeupOr(activeCrits);
- private WakeupCriterion[] dormantCrits = { elapsedTimeCriteria, keyEventCriteria };
+ private WakeupCriterion[] dormantCrits = { elapsedTimeCriteria, keyEventCriteria, focusEventCriteria };
private WakeupOr dormantWakeupCriteria = new WakeupOr(dormantCrits);
@@ -56,7 +59,7 @@
private RenderableMotion[] workingMotions = new RenderableMotion[2048];
private boolean cleaned = false;
-
+
public PhysicsBehavior(J3DRenderer renderer) {
this.renderer = renderer;
}
@@ -86,12 +89,14 @@
public void processStimulus(Enumeration criteria) {
while (criteria.hasMoreElements()) {
WakeupCriterion criterion = (WakeupCriterion) criteria.nextElement();
- if (criterion == keyEventCriteria) {
- try {
+ try {
+ if (criterion == keyEventCriteria) {
handleKeyEventCriterion();
- } catch (Throwable e) {
- e.printStackTrace();
+ } else if (criterion == focusEventCriteria && renderer.getMotionInputHandler() != null) {
+ renderer.getMotionInputHandler().focusChanged();
}
+ } catch (Throwable e) {
+ e.printStackTrace();
}
}
workingMotions = (RenderableMotion[]) renderableMotions.toArray(workingMotions);
@@ -107,7 +112,7 @@
if (!cleaned && !renderer.isOffScreen() && renderableMotions.size() > 0) {
wakeupOn(activeWakeupCriteria);
- } else if(!cleaned){
+ } else if (!cleaned) {
wakeupOn(dormantWakeupCriteria);
}
}
@@ -119,7 +124,7 @@
removeMotion(motions[i]);
}
}
-
+
private void removeMotion(RenderableMotion motion) {
renderableMotions.remove(motion);
motion.cleanup();
@@ -141,7 +146,7 @@
}
public void stopRenderableMotion(Renderable renderable) {
- if(cleaned) {
+ if (cleaned) {
return;
}
RenderableMotion motion = getMotion(renderable);
Modified: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java 2007-11-21 17:16:32 UTC (rev 594)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java 2007-11-21 17:16:47 UTC (rev 595)
@@ -58,7 +58,7 @@
public void receivedLink(String displayName, String link) {
}
- public void receivedCommandFocusRequest() {
+ public void receivedCommandFocusRequest(String preloadedText) {
}
public void receivedBrowserMessage(long sourceThingID, String message) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-21 17:16:54
|
Revision: 594
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=594&view=rev
Author: trevorolio
Date: 2007-11-21 09:16:32 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Sadly, this breaks with idea of using the applet only for 3D view because browsers can't reliably pass focus between DOM text field and java panel, which we tried to make work for the movement/chat cycle but it failed and made it unacceptably slow to switch between the two actions. So, I added the chat history and command line to the applet and rewhacked all of the relevant HTML pages.
While moving in the 3D view press enter or / to move to the command line. Enter or escape will switch focus back to 3D view.
Also, fixed the bug in which losing focus while moving would make you lose control, endlessly walking or turning. Now the 3D view catched the focus change and stops any active movement.
Modified Paths:
--------------
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
Added Paths:
-----------
maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ChatPanel.java
Added: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ChatPanel.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ChatPanel.java (rev 0)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ChatPanel.java 2007-11-21 17:16:32 UTC (rev 594)
@@ -0,0 +1,164 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. */
+
+package com.ogoglio.viewer.applet;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class ChatPanel extends Panel {
+
+ private Dimension totalDimension = new Dimension(800, 150);
+
+ private HistoryPanel historyPanel = new HistoryPanel();
+
+ private CommandPanel commandPanel = new CommandPanel();
+
+ private Listener listener = null;
+
+ public ChatPanel(Listener listener) {
+ ArgumentUtils.assertNotNull(listener);
+ this.listener = listener;
+ setBackground(Color.white);
+ setPreferredSize(totalDimension);
+ setLayout(new BorderLayout());
+ add(historyPanel, BorderLayout.CENTER);
+ add(commandPanel, BorderLayout.SOUTH);
+ }
+
+ public interface Listener {
+ public void userSentMessage(String message);
+
+ public void userReleasedFocus();
+ }
+
+ public void displayMessage(String heading, String message) {
+ heading = heading == null ? "" : heading + ": ";
+ if (historyPanel.getText().length() != 0) {
+ historyPanel.append("\r\n");
+ }
+ historyPanel.append(heading + message);
+ }
+
+ public void focusOnCommandField(String preloadedText) {
+ commandPanel.commandField.requestFocus();
+ if (preloadedText != null) {
+ commandPanel.commandField.setText(preloadedText);
+ commandPanel.commandField.setCaretPosition(commandPanel.commandField.getText().length());
+ }
+ }
+
+ private void attemptMessageSend() {
+ String text = commandPanel.commandField.getText();
+ if (text == null || text.trim().length() == 0) {
+ return;
+ }
+ commandPanel.commandField.setText(null);
+ listener.userSentMessage(text.trim());
+ listener.userReleasedFocus();
+ }
+
+ private class HistoryPanel extends TextArea {
+ public HistoryPanel() {
+ super("", 5, 1, TextArea.SCROLLBARS_VERTICAL_ONLY);
+ }
+ }
+
+ private class CommandPanel extends Panel implements ActionListener, KeyListener {
+ Button sendButton = new Button("Send");
+
+ TextField commandField = new TextField();
+
+ public CommandPanel() {
+ setBackground(Color.white);
+ setLayout(new BorderLayout(10, 0));
+
+ commandField.setBackground(getBackground());
+ commandField.addActionListener(this);
+ commandField.addKeyListener(this);
+ add(commandField, BorderLayout.CENTER);
+
+ sendButton.setBackground(getBackground());
+ sendButton.addActionListener(this);
+ add(sendButton, BorderLayout.EAST);
+ }
+
+ public void actionPerformed(ActionEvent event) {
+ if (event.getSource() == sendButton) {
+ attemptMessageSend();
+ } else if (event.getSource() == commandField) {
+ attemptMessageSend();
+ }
+ }
+
+ public void keyPressed(KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ listener.userReleasedFocus();
+ }
+ }
+
+ public void keyReleased(KeyEvent event) {
+ }
+
+ public void keyTyped(KeyEvent event) {
+ }
+ }
+}
+
+/*
+var emoteIconBase = appPath + "/icons/16x16/";
+
+var emotePatterns = new Array();
+var emoteImageNames = new Array();
+
+emotePatterns[emotePatterns.length] = "0:-)"; emoteImageNames[emoteImageNames.length] = "face-angel.png";
+emotePatterns[emotePatterns.length] = ":'("; emoteImageNames[emoteImageNames.length] = "face-crying.png";
+emotePatterns[emotePatterns.length] = ">:-)"; emoteImageNames[emoteImageNames.length] = "face-devil-grin.png";
+emotePatterns[emotePatterns.length] = "B-)"; emoteImageNames[emoteImageNames.length] = "face-glasses.png";
+emotePatterns[emotePatterns.length] = ":-*"; emoteImageNames[emoteImageNames.length] = "face-kiss.png";
+emotePatterns[emotePatterns.length] = ":-(|)"; emoteImageNames[emoteImageNames.length] = "face-monkey.png";
+emotePatterns[emotePatterns.length] = ":-|"; emoteImageNames[emoteImageNames.length] = "face-plain.png";
+emotePatterns[emotePatterns.length] = ":-("; emoteImageNames[emoteImageNames.length] = "face-sad.png";
+emotePatterns[emotePatterns.length] = ":-)"; emoteImageNames[emoteImageNames.length] = "face-smile.png";
+emotePatterns[emotePatterns.length] = ":-D"; emoteImageNames[emoteImageNames.length] = "face-smile-big.png";
+emotePatterns[emotePatterns.length] = ":-0"; emoteImageNames[emoteImageNames.length] = "face-surprise.png";
+emotePatterns[emotePatterns.length] = ";-)"; emoteImageNames[emoteImageNames.length] = "face-wink.png";
+
+function markupChatMessage(messageText){
+for(var i = 0; i < emotePatterns.length; i++){
+ messageText = emotify(messageText, emotePatterns[i], emoteIconBase + emoteImageNames[i]);
+}
+return messageText;
+}
+
+function emotify(messageText, emotePattern, imageURL){
+var workingText = messageText;
+while(workingText.indexOf(emotePattern) != -1){
+ workingText = workingText.substring(0, workingText.indexOf(emotePattern)) + "<img src='" + imageURL +"' width='16' height='16' />" + workingText.substring(workingText.indexOf(emotePattern) + emotePattern.length);
+}
+return workingText;
+}
+*/
+
Modified: maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java
===================================================================
--- maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-11-20 20:28:39 UTC (rev 593)
+++ maven/trunk/ogoglio-viewer-applet/src/main/java/com/ogoglio/viewer/applet/ViewerApplet.java 2007-11-21 17:16:32 UTC (rev 594)
@@ -16,6 +16,7 @@
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
@@ -40,7 +41,9 @@
import com.ogoglio.client.model.Thing;
import com.ogoglio.util.ContextMenuItemInfo;
import com.ogoglio.util.Log;
+import com.ogoglio.util.WebConstants;
import com.ogoglio.viewer.j3d.J3DRenderer;
+import com.ogoglio.viewer.j3d.J3DUserRenderable;
import com.ogoglio.viewer.render.Renderer;
public class ViewerApplet extends Applet {
@@ -60,7 +63,9 @@
private String authCookie = null;
private Map popupMap = new HashMap();
-
+
+ private ChatPanel chatPanel = new ChatPanel(new ChatPanelListener());
+
public ViewerApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
@@ -92,6 +97,7 @@
float ry = getFloatParameter("ry", 0);
float rz = getFloatParameter("rz", 0);
boolean movable = !"false".equals(getParameter("movable"));
+ boolean showChat = !"false".equals(getParameter("showChat"));
try {
serviceURI = new URI(getParameter("serviceURI"));
@@ -109,8 +115,15 @@
removeAll();
validate();
- renderer.getCanvas().setSize(getWidth(), getHeight());
- add(renderer.getCanvas(), BorderLayout.CENTER);
+ if(showChat){
+ renderer.getCanvas().setSize(getWidth(), getHeight() - chatPanel.getPreferredSize().height);
+ renderer.getCanvas().setPreferredSize(new Dimension(getWidth(), getHeight() - chatPanel.getPreferredSize().height));
+ add(chatPanel, BorderLayout.SOUTH);
+ add(renderer.getCanvas(), BorderLayout.CENTER);
+ } else {
+ renderer.getCanvas().setSize(getWidth(), getHeight());
+ add(renderer.getCanvas(), BorderLayout.CENTER);
+ }
validate();
renderer.startRenderer();
renderer.getCanvas().requestFocus();
@@ -138,8 +151,8 @@
}
private void performAShutdown(String method) {
-
- Log.info("Destroying " + this + ": " + renderer + ", " + spaceClient+" b/c "+method+" called on applet");
+
+ Log.info("Destroying " + this + ": " + renderer + ", " + spaceClient + " b/c " + method + " called on applet");
if (renderer != null) {
renderer.stopRenderer();
}
@@ -193,22 +206,22 @@
renderer.getCanvas().requestFocus();
}
- private void focusCommandField() {
- try {
- JSObject win = JSObject.getWindow(this); // get handle to a window.
- if (win == null) {
- Log.error("Could not do live connect. Check that mayscript is true in the applet tag.");
- return;
+ private class ChatPanelListener implements ChatPanel.Listener {
+ public void userReleasedFocus() {
+ if(renderer != null && renderer.getCanvas() != null){
+ renderer.getCanvas().requestFocus();
}
- win.call("focusCommandField", null); // Call a JavaScript function
- } catch (Exception e) {
- if (!printedLiveConnectErrorMessage) {
- Log.error("Could not use LiveConnect (ignoring future errors): " + e);
- printedLiveConnectErrorMessage = true;
- }
}
+
+ public void userSentMessage(String message) {
+ spaceClient.userIssuedCommand(message);
+ }
}
+ public void sendChatMessage(String message) {
+ spaceClient.userIssuedCommand(message);
+ }
+
private void showPopup(Thing thing, int x, int y, long nonce) {
ThingGeneratedPopup popup = new ThingGeneratedPopup(thing, nonce);
popup.show(this, x, y);
@@ -286,27 +299,6 @@
}
}
- private void addChatMessage(String message) {
- try {
- JSObject win = JSObject.getWindow(this); // get handle to a window.
- if (win == null) {
- Log.warn("Could not do live connect. Check that mayscript is true in the applet tag.");
- return;
- }
- String[] args = { message };
- win.call("displayChatMessage", args); // Call a JavaScript function
- } catch (Exception e) {
- if (!printedLiveConnectErrorMessage) {
- Log.warn("Could not use LiveConnect (ignoring future errors): " + e);
- printedLiveConnectErrorMessage = true;
- }
- }
- }
-
- public void sendChatMessage(String message) {
- spaceClient.userIssuedCommand(message);
- }
-
public String getUsername() {
return spaceClient.getUsername();
}
@@ -314,11 +306,15 @@
private class SpaceClientListener implements SpaceClient.Listener {
public void disconnected() {
- addChatMessage("Disconnected.");
+ chatPanel.displayMessage(null, "Disconnected.");
}
public void receivedChatMessage(String username, String message) {
- addChatMessage(username + ":" + message);
+ if (username != null && username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
+ username = J3DUserRenderable.convertGuestCookieToDisplayName(username);
+ }
+
+ chatPanel.displayMessage(username, message);
}
public void receivedSpaceTransfer(URI link) {
@@ -326,10 +322,10 @@
String[] pathElements = link.getPath().split("/");
switchToSpace(Long.parseLong(pathElements[pathElements.length - 1]));
} catch (IOException e) {
- addChatMessage("system: That space could not be reached");
+ chatPanel.displayMessage("system", "That space could not be reached");
e.printStackTrace();
} catch (Exception e) {
- addChatMessage("system: That spaceID is unusable (" + e.getMessage() + "): " + link);
+ chatPanel.displayMessage("system", "That spaceID is unusable (" + e.getMessage() + "): " + link);
}
}
@@ -337,8 +333,8 @@
showLink(displayName, link);
}
- public void receivedCommandFocusRequest() {
- focusCommandField();
+ public void receivedCommandFocusRequest(String preloadedText) {
+ chatPanel.focusOnCommandField(preloadedText);
}
public void receivedBrowserMessage(long sourceThingID, String message) {
@@ -367,7 +363,7 @@
JMenuItem moveItem = null;
JMenuItem seatItem = null;
-
+
Thing thing = null;
long startTime;
@@ -379,15 +375,15 @@
nonce = theNonce;
startTime = System.currentTimeMillis();
- if(theThing.getTemplate().isASeat()){
+ if (theThing.getTemplate().isASeat()) {
seatItem = add("Sit Here");
- seatItem.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
+ seatItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
spaceClient.userRequestedSeat(thing);
}
});
}
-
+
moveItem = add("Move");
moveItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|