|
From: <tre...@us...> - 2007-10-17 23:49:50
|
Revision: 505
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=505&view=rev
Author: trevorolio
Date: 2007-10-17 16:49:54 -0700 (Wed, 17 Oct 2007)
Log Message:
-----------
THIS CHECKIN BREAKS THE DB FORMAT. Drop and rebuild upon update.
Added several fields to templates to hold information about whether avatars can sit on them.
(not that the UI reflects this or the client actually supports it yet)
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/TemplateDocument.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/WebAPIClient.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-10-17 20:45:00 UTC (rev 504)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-10-17 23:49:54 UTC (rev 505)
@@ -287,7 +287,7 @@
}
public TemplateDocument createTemplate(String templateName) throws IOException {
- TemplateDocument templateDoc = new TemplateDocument(-1, templateName, authenticator.getUsername(), null, null);
+ TemplateDocument templateDoc = new TemplateDocument(-1, templateName, authenticator.getUsername(), null, null, false, 0, 0, 0, 1, 0, 0, 0);
XMLElement templateXML = wire.postAuthenticatedXML(descriptor.getTemplatesURI(authenticator.getUsername()), templateDoc.toString(), authenticator.getAuthCookie());
return new TemplateDocument(templateXML);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java 2007-10-17 20:45:00 UTC (rev 504)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java 2007-10-17 23:49:54 UTC (rev 505)
@@ -13,6 +13,9 @@
limitations under the License. */
package com.ogoglio.client.model;
+import javax.vecmath.Point3d;
+import javax.vecmath.Quat4d;
+
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.xml.TemplateDocument;
@@ -25,18 +28,27 @@
private String ownerUsername = null;
private String displayName = null;
+
+ private boolean isASeat = false;
- public Template(long templateID, String ownerUsername, String displayName) {
+ private Point3d seatPosition = new Point3d();
+
+ private Quat4d seatRotation = new Quat4d();
+
+ public Template(long templateID, String ownerUsername, String displayName, boolean isASeat, Point3d seatPosition, Quat4d seatRotation) {
ArgumentUtils.assertNotNegative(templateID);
this.templateID = templateID;
ArgumentUtils.assertNotNull(ownerUsername);
this.ownerUsername = ownerUsername;
ArgumentUtils.assertNotEmpty(displayName);
this.displayName = displayName;
+ this.isASeat = isASeat;
+ this.seatPosition.set(seatPosition);
+ this.seatRotation.set(seatRotation);
}
public Template(TemplateDocument templateDoc) {
- this(templateDoc.getTemplateID(), templateDoc.getOwnerUsername(), templateDoc.getDisplayName());
+ this(templateDoc.getTemplateID(), templateDoc.getOwnerUsername(), templateDoc.getDisplayName(), templateDoc.isSeat(), templateDoc.getSeatPosition(), templateDoc.getSeatRotation());
}
public long getTemplateID() {
@@ -50,4 +62,16 @@
public String getOwnerUsername() {
return ownerUsername;
}
+
+ public boolean isASeat(){
+ return isASeat;
+ }
+
+ public Point3d getSeatPosition(){
+ return seatPosition;
+ }
+
+ public Quat4d getSeatRotation(){
+ return seatRotation;
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/TemplateDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/TemplateDocument.java 2007-10-17 20:45:00 UTC (rev 504)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/TemplateDocument.java 2007-10-17 23:49:54 UTC (rev 505)
@@ -16,6 +16,9 @@
import java.util.Iterator;
import java.util.Set;
+import javax.vecmath.Point3d;
+import javax.vecmath.Quat4d;
+
import nanoxml.XMLElement;
import com.ogoglio.util.ArgumentUtils;
@@ -28,66 +31,84 @@
public static final String OWNER_USERNAME = "ownerusername";
public static final String DISPLAY_NAME = "displayname";
-
+
public static final String DESCRIPTION = "description";
- public static final String SCRIPT_TAG="scriptfile";
+ public static final String SCRIPT_TAG = "scriptfile";
- public static final String LAST_MODIFIED="lastmodifiedUTC";
+ public static final String LAST_MODIFIED = "lastmodifiedUTC";
- private static final String GEOMETRY_TAG = "geometry";
+ private static final String GEOMETRY_TAG = "geometry";
- private static final String LEVEL_OF_DETAIL = "levelofdetail";
+ private static final String LEVEL_OF_DETAIL = "levelofdetail";
- private static final String SUPPORT_TAG= "supportfile";
+ private static final String SUPPORT_TAG = "supportfile";
- private static final String SUPPORT_FILE_NAME= "filename";
+ private static final String SUPPORT_FILE_NAME = "filename";
+ private static final String IS_SEAT = "seat";
-
+ private static final String SEAT_X = "seatx";
+
+ private static final String SEAT_Y = "seaty";
+
+ private static final String SEAT_Z = "seatz";
+
+ private static final String SEAT_RW = "seatrw";
+
+ private static final String SEAT_RX = "seatrx";
+
+ private static final String SEAT_RY = "seatry";
+
+ private static final String SEAT_RZ = "seatrz";
+
XMLElement data = null;
//for convenience of people who are creating this dynamically via the mock system
public TemplateDocument(Long templateID, String displayName, String ownerUsername, String description) {
- this(templateID.longValue(),displayName,ownerUsername,description, null);
+ this(templateID.longValue(), displayName, ownerUsername, description, null, false, 0, 0, 0, 1, 0, 0, 0);
}
- public TemplateDocument(long templateID, String displayName, String ownerUsername, String description, Set supportFiles) {
+
+ public TemplateDocument(long templateID, String displayName, String ownerUsername, String description, Set supportFiles, boolean isASeat, double seatX, double seatY, double seatZ, double seatRW, double seatRX, double seatRY, double seatRZ) {
data = new XMLElement(NAME);
data.setAttribute(TEMPLATE_ID, templateID);
ArgumentUtils.assertNotNull(displayName);
data.setAttribute(DISPLAY_NAME, displayName);
ArgumentUtils.assertNotNull(OWNER_USERNAME);
data.setAttribute(OWNER_USERNAME, ownerUsername);
- if(description != null && description.trim().length() > 0) {
+ if (description != null && description.trim().length() > 0) {
data.setAttribute(DESCRIPTION, description);
}
- if (supportFiles!=null) {
- //script tag
- Iterator iter=supportFiles.iterator();
- while (iter.hasNext()) {
- TemplateSupportFileDocument element = (TemplateSupportFileDocument) iter.next();
- if (element.getScript()) {
- XMLElement script=new XMLElement(SCRIPT_TAG);
- script.setAttribute(LAST_MODIFIED, element.getLastChangedAsUTC());
- data.addChild(script);
- continue;
- }
- if (element.getLevelOfDetail()!=TemplateSupportFileDocument.NO_LOD) {
- XMLElement script=new XMLElement(GEOMETRY_TAG);
- script.setAttribute(LAST_MODIFIED, element.getLastChangedAsUTC());
- script.setAttribute(LEVEL_OF_DETAIL, element.getLevelOfDetail());
- data.addChild(script);
- continue;
- }
- if (element.getSupportFile()!=null) {
- XMLElement support = new XMLElement(SUPPORT_TAG);
- support.setAttribute(SUPPORT_FILE_NAME, element.getSupportFile());
- support.setAttribute(LAST_MODIFIED, element.getLastChangedAsUTC());
- data.addChild(support);
- continue;
- }
- }
+ if (supportFiles != null) {
+ //script tag
+ Iterator iter = supportFiles.iterator();
+ while (iter.hasNext()) {
+ TemplateSupportFileDocument element = (TemplateSupportFileDocument) iter.next();
+ if (element.getScript()) {
+ XMLElement script = new XMLElement(SCRIPT_TAG);
+ script.setAttribute(LAST_MODIFIED, element.getLastChangedAsUTC());
+ data.addChild(script);
+ continue;
+ }
+ if (element.getLevelOfDetail() != TemplateSupportFileDocument.NO_LOD) {
+ XMLElement script = new XMLElement(GEOMETRY_TAG);
+ script.setAttribute(LAST_MODIFIED, element.getLastChangedAsUTC());
+ script.setAttribute(LEVEL_OF_DETAIL, element.getLevelOfDetail());
+ data.addChild(script);
+ continue;
+ }
+ if (element.getSupportFile() != null) {
+ XMLElement support = new XMLElement(SUPPORT_TAG);
+ support.setAttribute(SUPPORT_FILE_NAME, element.getSupportFile());
+ support.setAttribute(LAST_MODIFIED, element.getLastChangedAsUTC());
+ data.addChild(support);
+ continue;
+ }
+ }
}
+ setSeat(isASeat);
+ setSeatPosition(seatX, seatY, seatZ);
+ setSeatRotation(seatRW, seatRX, seatRY, seatRZ);
}
public TemplateDocument(XMLElement data) {
@@ -101,11 +122,11 @@
ArgumentUtils.assertNotEmpty(data.getStringAttribute(OWNER_USERNAME));
this.data = data;
}
-
+
public long getTemplateID() {
return data.getLongAttribute(TEMPLATE_ID);
}
-
+
public String getDisplayName() {
return data.getStringAttribute(DISPLAY_NAME);
}
@@ -122,72 +143,113 @@
public String getDescription() {
return data.getStringAttribute(DESCRIPTION);
}
-
+
public XMLElement toElement() {
return data;
}
-
+
public String toString() {
return data.toString();
}
- public boolean hasScriptFile() {
- return data.getChild(SCRIPT_TAG)!=null;
- }
- public String getScriptModifiedTime() {
- if (!hasScriptFile()) {
- return null;
- }
- return (String) data.getChild(SCRIPT_TAG).getAttribute(LAST_MODIFIED);
- }
- public XMLElement findSupportFileChild(String name) {
- XMLElement elem[] = data.getChildren(SUPPORT_TAG);
- for (int i=0; i<elem.length; ++i) {
- XMLElement candidate = elem[i];
- String filename=candidate.getStringAttribute(SUPPORT_FILE_NAME,null);
- if (filename.equals(name)) {
- return candidate;
- }
- }
- return null;
- }
+ public boolean hasScriptFile() {
+ return data.getChild(SCRIPT_TAG) != null;
+ }
- public XMLElement findGeometryChildWithLOD(int LOD) {
- XMLElement elem[] = data.getChildren(GEOMETRY_TAG);
- for (int i=0; i<elem.length; ++i) {
- XMLElement candidate = elem[i];
- if (candidate.getAttribute(LEVEL_OF_DETAIL).equals("0")) {
- return candidate;
- }
- }
- return null;
- }
-
- public boolean hasGeometryFileWithLOD(int LOD) {
- return findGeometryChildWithLOD(LOD)!=null;
- }
- public String getGeometryModifiedTime(int LOD) {
- XMLElement elem = findGeometryChildWithLOD(LOD);
- if (elem==null) {
- return null;
- }
- return (String)elem.getAttribute(LAST_MODIFIED);
- }
+ public String getScriptModifiedTime() {
+ if (!hasScriptFile()) {
+ return null;
+ }
+ return (String) data.getChild(SCRIPT_TAG).getAttribute(LAST_MODIFIED);
+ }
- public String getSupportFileModifiedTime(String name) {
- XMLElement elem = findSupportFileChild(name);
- if (elem==null) {
- return null;
- }
- return (String)elem.getAttribute(LAST_MODIFIED);
- }
+ public XMLElement findSupportFileChild(String name) {
+ XMLElement elem[] = data.getChildren(SUPPORT_TAG);
+ for (int i = 0; i < elem.length; ++i) {
+ XMLElement candidate = elem[i];
+ String filename = candidate.getStringAttribute(SUPPORT_FILE_NAME, null);
+ if (filename.equals(name)) {
+ return candidate;
+ }
+ }
+ return null;
+ }
+
+ public XMLElement findGeometryChildWithLOD(int LOD) {
+ XMLElement elem[] = data.getChildren(GEOMETRY_TAG);
+ for (int i = 0; i < elem.length; ++i) {
+ XMLElement candidate = elem[i];
+ if (candidate.getAttribute(LEVEL_OF_DETAIL).equals("0")) {
+ return candidate;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasGeometryFileWithLOD(int LOD) {
+ return findGeometryChildWithLOD(LOD) != null;
+ }
+
+ public String getGeometryModifiedTime(int LOD) {
+ XMLElement elem = findGeometryChildWithLOD(LOD);
+ if (elem == null) {
+ return null;
+ }
+ return (String) elem.getAttribute(LAST_MODIFIED);
+ }
+
+ public String getSupportFileModifiedTime(String name) {
+ XMLElement elem = findSupportFileChild(name);
+ if (elem == null) {
+ return null;
+ }
+ return (String) elem.getAttribute(LAST_MODIFIED);
+ }
+
public String[] getAllSupportFileNames() {
XMLElement elem[] = data.getChildren(SUPPORT_TAG);
- String[] result=new String[elem.length];
- for (int i=0; i<elem.length; ++i) {
+ String[] result = new String[elem.length];
+ for (int i = 0; i < elem.length; ++i) {
XMLElement candidate = elem[i];
- result[i]=elem[i].getStringAttribute(SUPPORT_FILE_NAME,null);
+ result[i] = elem[i].getStringAttribute(SUPPORT_FILE_NAME, null);
}
return result;
}
+
+ public boolean isSeat() {
+ return data.getBooleanAttribute(IS_SEAT);
+ }
+
+ public Point3d getSeatPosition() {
+ return new Point3d(data.getDoubleAttribute(SEAT_X, 0), data.getDoubleAttribute(SEAT_Y, 0), data.getDoubleAttribute(SEAT_Z, 0));
+ }
+
+ public void setSeatRotation(Quat4d quat){
+ setSeatRotation(quat.w, quat.x, quat.y, quat.z);
+ }
+
+ public void setSeatRotation(double seatRW, double seatRX, double seatRY, double seatRZ) {
+ data.setAttribute(SEAT_RW, seatRW);
+ data.setAttribute(SEAT_RX, seatRX);
+ data.setAttribute(SEAT_RY, seatRY);
+ data.setAttribute(SEAT_RZ, seatRZ);
+ }
+
+ public Quat4d getSeatRotation() {
+ return new Quat4d(data.getDoubleAttribute(SEAT_RX, 0), data.getDoubleAttribute(SEAT_RY, 0), data.getDoubleAttribute(SEAT_RZ, 0), data.getDoubleAttribute(SEAT_RW, 1));
+ }
+
+ public void setSeat(boolean isASeat) {
+ data.setAttribute(IS_SEAT, isASeat);
+ }
+
+ public void setSeatPosition(Point3d seatPosition) {
+ setSeatPosition(seatPosition.x, seatPosition.y, seatPosition.z);
+ }
+
+ public void setSeatPosition(double seatX, double seatY, double seatZ) {
+ data.setAttribute(SEAT_X, seatX);
+ data.setAttribute(SEAT_Y, seatY);
+ data.setAttribute(SEAT_Z, seatZ);
+ }
}
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-10-17 20:45:00 UTC (rev 504)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-10-17 23:49:54 UTC (rev 505)
@@ -154,7 +154,7 @@
String username = "kurt";
String description = "This thing rocks out with it's cupcake out.";
- TemplateDocument templateDoc = new TemplateDocument(1, displayName, username, description, null);
+ TemplateDocument templateDoc = new TemplateDocument(1, displayName, username, description, null, false, 0, 0, 0, 1, 0, 0, 0);
assertEquals(1, templateDoc.getTemplateID());
assertEquals(displayName, templateDoc.getDisplayName());
assertEquals(username, templateDoc.getOwnerUsername());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|