|
From: <tre...@us...> - 2007-09-02 17:22:52
|
Revision: 330
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=330&view=rev
Author: trevorolio
Date: 2007-09-02 10:22:42 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
Changed the name of ContextMenuInfo to ContextMenuItemInfo (for some reason) which required changes in: Java classes which are used in the script contexts, all of the javascripts that create said objects, and the ContextMenu[Item]Info classes themselves.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java
maven/trunk/ogoglio-common/src/test/resources/sample-art3d/TestCube.js
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuItemInfo.java
Removed Paths:
-------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuInfo.java
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuInfo.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuInfo.java 2007-09-02 15:13:20 UTC (rev 329)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuInfo.java 2007-09-02 17:22:42 UTC (rev 330)
@@ -1,23 +0,0 @@
-package com.ogoglio.util;
-
-public class ContextMenuInfo {
- private String userVisibleString;
- private String id;
- private boolean enabled;
-
- public String getUserVisibleString() {
- return userVisibleString;
- }
- public String getId() {
- return id;
- }
- public boolean getEnabled() {
- return enabled;
- }
- public void setValues(String textToShow, boolean notGrayedOut, String forCallback) {
- userVisibleString=textToShow;
- enabled=notGrayedOut;
- id=forCallback;
- }
-
-}
Copied: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuItemInfo.java (from rev 312, maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuInfo.java)
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuItemInfo.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ContextMenuItemInfo.java 2007-09-02 17:22:42 UTC (rev 330)
@@ -0,0 +1,23 @@
+package com.ogoglio.util;
+
+public class ContextMenuItemInfo {
+ private String userVisibleString;
+ private String id;
+ private boolean enabled;
+
+ public String getUserVisibleString() {
+ return userVisibleString;
+ }
+ public String getId() {
+ return id;
+ }
+ public boolean getEnabled() {
+ return enabled;
+ }
+ public void setValues(String textToShow, boolean notGrayedOut, String forCallback) {
+ userVisibleString=textToShow;
+ enabled=notGrayedOut;
+ id=forCallback;
+ }
+
+}
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-09-02 15:13:20 UTC (rev 329)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2007-09-02 17:22:42 UTC (rev 330)
@@ -26,7 +26,7 @@
import nanoxml.XMLElement;
import com.ogoglio.client.model.SplinePath;
-import com.ogoglio.util.ContextMenuInfo;
+import com.ogoglio.util.ContextMenuItemInfo;
import com.ogoglio.viewer.j3d.J3DSplinePath;
public class SpaceEvent {
@@ -280,7 +280,7 @@
String id = item.getStringAttribute(CONTEXT_MENU_DATA_ITEM_ID);
//go through front door!
- ContextMenuInfo info = new ContextMenuInfo();
+ ContextMenuItemInfo info = new ContextMenuItemInfo();
info.setValues(text, enabled, id);
result.add(info);
}
@@ -386,7 +386,7 @@
}
if (contextMenu!=null) {
for (int i=0; i<contextMenu.size();++i) {
- ContextMenuInfo info=(ContextMenuInfo)contextMenu.get(i);
+ ContextMenuItemInfo info=(ContextMenuItemInfo)contextMenu.get(i);
XMLElement item = new XMLElement();
item.setName(CONTEXT_MENU_DATA_ITEM);
item.setAttribute(CONTEXT_MENU_DATA_ITEM_TEXT, info.getUserVisibleString());
Modified: maven/trunk/ogoglio-common/src/test/resources/sample-art3d/TestCube.js
===================================================================
--- maven/trunk/ogoglio-common/src/test/resources/sample-art3d/TestCube.js 2007-09-02 15:13:20 UTC (rev 329)
+++ maven/trunk/ogoglio-common/src/test/resources/sample-art3d/TestCube.js 2007-09-02 17:22:42 UTC (rev 330)
@@ -20,10 +20,10 @@
function onContextClick(person, shapeName){
space.log(person + " context clicked " + thingID + " on its " + shapeName);
- i1 = new ContextMenuInfo("Google",true,"google");
- i2 = new ContextMenuInfo("Yahoo",true,"yahoo");
- i3 = new ContextMenuInfo("Altavista",false,"NOTUSED");
- i4 = new ContextMenuInfo("Transmutable",true,"transmutable");
+ i1 = new ContextMenuItemInfo("Google",true,"google");
+ i2 = new ContextMenuItemInfo("Yahoo",true,"yahoo");
+ i3 = new ContextMenuItemInfo("Altavista",false,"NOTUSED");
+ i4 = new ContextMenuItemInfo("Transmutable",true,"transmutable");
return new Array(i1,i2,i3,i4);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-18 16:03:15
|
Revision: 416
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=416&view=rev
Author: trevorolio
Date: 2007-09-18 09:03:11 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
Added the ability to choose a male or female avatar.
Both avatar models still need work.
Consolidated the two UIConstants classes into one.
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/Body.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/BodyConstants.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/viewer/j3d/J3DUserRenderable.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDocument.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/resources/avatar/female.obj
maven/trunk/ogoglio-common/src/main/resources/avatar/female.smap
maven/trunk/ogoglio-common/src/main/resources/avatar/female1.jpg
maven/trunk/ogoglio-common/src/main/resources/avatar/male.obj
maven/trunk/ogoglio-common/src/main/resources/avatar/male.smap
maven/trunk/ogoglio-common/src/main/resources/avatar/male1.jpg
Removed Paths:
-------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/UIConstants.java
maven/trunk/ogoglio-common/src/main/resources/avatar/avatar.jpg
maven/trunk/ogoglio-common/src/main/resources/avatar/avatar.obj
maven/trunk/ogoglio-common/src/main/resources/avatar/avatar.smap
maven/trunk/ogoglio-common/src/main/resources/avatar/avatar1.jpg
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -37,8 +37,9 @@
import com.ogoglio.message.PayloadFactory;
import com.ogoglio.message.TCPChannel;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.BodyConstants;
import com.ogoglio.util.Log;
-import com.ogoglio.viewer.render.UIConstants;
+import com.ogoglio.util.UIConstants;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyDocument;
import com.ogoglio.xml.DoorDocument;
@@ -721,15 +722,31 @@
}
public InputStream getUserGeometryStream(String username, String name) throws IOException {
- return UIConstants.getResource("avatar/avatar.obj");
+ User user = space.getUser(username);
+ if(user == null){
+ return null;
+ }
+ if(user.getBody().isMale()){
+ return UIConstants.getResource(BodyConstants.MALE_AVATAR_PATH);
+ } else {
+ return UIConstants.getResource(BodyConstants.FEMALE_AVATAR_PATH);
+ }
}
public InputStream getUserAnimationStream(String username, long animationID) throws IOException {
- return UIConstants.getUserAnimation((int) animationID);
+ return BodyConstants.getUserAnimation((int) animationID);
}
public InputStream getUserSkinMapStream(String username) throws IOException {
- return UIConstants.getResource("avatar/avatar.smap");
+ User user = space.getUser(username);
+ if(user == null){
+ return null;
+ }
+ if(user.getBody().isMale()){
+ return UIConstants.getResource(BodyConstants.MALE_SMAP_PATH);
+ } else {
+ return UIConstants.getResource(BodyConstants.FEMALE_SMAP_PATH);
+ }
}
public BodyDocument getBodyDocument(String username, long bodyID) throws IOException {
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -482,7 +482,7 @@
}
public BodyDocument createBody(String bodyName) throws IOException {
- BodyDocument bodyDoc = new BodyDocument(-1, authenticator.getUsername(), bodyName, 0, 0, 0, 0, 0);
+ BodyDocument bodyDoc = new BodyDocument(-1, authenticator.getUsername(), bodyName, 0, 0, 0, 0, 0, false, 2, 1);
XMLElement element = wire.postAuthenticatedXML(descriptor.getBodiesURI(authenticator.getUsername()), bodyDoc.toString(), authenticator.getAuthCookie());
if (element == null) {
return null;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java 2007-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -14,13 +14,22 @@
private int face = -1;
- public Body(long bodyID, int hair, int eyes, int nose, int mouth, int face) {
+ private boolean male = false;
+
+ private float height = 2;
+
+ private float girth = 1;
+
+ public Body(long bodyID, int hair, int eyes, int nose, int mouth, int face, boolean isMale, float height, float girth) {
this.bodyID = bodyID;
this.hair = hair;
this.eyes = eyes;
this.nose = nose;
this.mouth = mouth;
this.face = face;
+ this.male = isMale;
+ this.height = height;
+ this.girth = girth;
}
public long getBodyID() {
@@ -54,5 +63,20 @@
this.mouth = mouthIndex;
this.face = faceIndex;
}
+
+ public boolean isMale() {
+ return male;
+ }
+
+ public float getHeight(){
+ return height;
+ }
+ public float getGirth(){
+ return girth;
+ }
+
+ public void setMale(boolean male) {
+ this.male = male;
+ }
}
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -558,9 +558,9 @@
public Body getBody(String username, long bodyID) throws IOException {
if (bodyID < 0) {
- return new Body(-1, 0, 0, 0, 0, 0);
+ return new Body(-1, 0, 0, 0, 0, 0, false, 2, 0);
}
BodyDocument bodyDoc = spaceContext.getBodyDocument(username, bodyID);
- return new Body(bodyDoc.getBodyID(), bodyDoc.getHairIndex(), bodyDoc.getEyesIndex(), bodyDoc.getNoseIndex(), bodyDoc.getMouthIndex(), bodyDoc.getFaceIndex());
+ return new Body(bodyDoc.getBodyID(), bodyDoc.getHairIndex(), bodyDoc.getEyesIndex(), bodyDoc.getNoseIndex(), bodyDoc.getMouthIndex(), bodyDoc.getFaceIndex(), bodyDoc.isMale(), bodyDoc.getHeight(), bodyDoc.getGirth());
}
}
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -46,7 +46,7 @@
body = space.getBody(username, bodyID);
} catch (IOException e) {
e.printStackTrace();
- body = new Body(-1, 0, 0, 0, 0, 0);
+ body = new Body(-1, 0, 0, 0, 0, 0, false, 2, 1);
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/BodyConstants.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/BodyConstants.java 2007-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/BodyConstants.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -1,19 +1,24 @@
package com.ogoglio.util;
import java.awt.Image;
+import java.io.InputStream;
public class BodyConstants {
public static final String TEXTURE_RESOURCE_PATH = "avatar/";
- public static Image BASE_SKIN_TEXTURE1 = UIConstants.loadImageFromResource(TEXTURE_RESOURCE_PATH + "avatar1.jpg");
+ public static Image MALE_BASE_SKIN_TEXTURE1 = UIConstants.loadImageFromResource(TEXTURE_RESOURCE_PATH + "male1.jpg");
- public static final int BASE_SKIN_TEXTURE_WIDTH = BASE_SKIN_TEXTURE1.getWidth(null);
+ public static Image FEMALE_BASE_SKIN_TEXTURE1 = UIConstants.loadImageFromResource(TEXTURE_RESOURCE_PATH + "female1.jpg");
- public static final int BASE_SKIN_TEXTURE_HEIGHT = BASE_SKIN_TEXTURE1.getHeight(null);
+ public static final int BASE_SKIN_TEXTURE_WIDTH = MALE_BASE_SKIN_TEXTURE1.getWidth(null);
- public static final Image[] BASE_SKIN_TEXTURES = { BASE_SKIN_TEXTURE1 };
+ public static final int BASE_SKIN_TEXTURE_HEIGHT = MALE_BASE_SKIN_TEXTURE1.getHeight(null);
+ public static final Image[] MALE_BASE_SKIN_TEXTURES = { MALE_BASE_SKIN_TEXTURE1 };
+
+ public static final Image[] FEMALE_BASE_SKIN_TEXTURES = { FEMALE_BASE_SKIN_TEXTURE1 };
+
public static final Image EYES_1 = UIConstants.loadImageFromResource(TEXTURE_RESOURCE_PATH + "Eyes1.gif");
public static final Image EYES_2 = UIConstants.loadImageFromResource(TEXTURE_RESOURCE_PATH + "Eyes2.gif");
@@ -31,4 +36,45 @@
public static final Image MOUTH_2 = UIConstants.loadImageFromResource(TEXTURE_RESOURCE_PATH + "Mouth2.gif");
public static final Image[] MOUTHES = { MOUTH_1, MOUTH_2 };
+
+ public static final String DEFAULT_ANIMATION_PATH = "avatar/avatar.bvh";
+
+ public static final String WALK_ANIMATION_PATH = "avatar/avatar-walk.bvh";
+
+ public static final String WAVE_ANIMATION_PATH = "avatar/avatar-wave.bvh";
+
+ public static final String POINT_ANIMATION_PATH = "avatar/avatar-point.bvh";
+
+ public static final String LAUGH_ANIMATION_PATH = "avatar/avatar-laugh.bvh";
+
+ public static final String CLAP_ANIMATION_PATH = "avatar/avatar-clap.bvh";
+
+ public static final String[] USER_ANIMATION_COMMANDS = { "default", "walk", "wave", "point", "laugh", "clap" };
+
+ public static final String[] USER_ANIMATION_PATHS = { DEFAULT_ANIMATION_PATH, WALK_ANIMATION_PATH, WAVE_ANIMATION_PATH, POINT_ANIMATION_PATH, LAUGH_ANIMATION_PATH, CLAP_ANIMATION_PATH };
+
+ public static final String MALE_AVATAR_PATH = "avatar/male.obj";
+
+ public static final String MALE_SMAP_PATH = "avatar/male.smap";
+
+ public static final String FEMALE_AVATAR_PATH = "avatar/female.obj";
+
+ public static final String FEMALE_SMAP_PATH = "avatar/female.smap";
+
+ public static InputStream getUserAnimation(int animationID) {
+ if (animationID < 0 || animationID >= USER_ANIMATION_PATHS.length) {
+ return null;
+ }
+ return UIConstants.getResource(USER_ANIMATION_PATHS[animationID]);
+ }
+
+ public static InputStream getUserAnimation(String command) {
+ for (int i = 0; i < USER_ANIMATION_COMMANDS.length; i++) {
+ if (USER_ANIMATION_COMMANDS[i].equals(command)) {
+ return UIConstants.getResource(USER_ANIMATION_PATHS[i]);
+ }
+ }
+ return null;
+ }
+
}
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/UIConstants.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -21,9 +21,41 @@
import java.io.InputStream;
import javax.swing.ImageIcon;
+import javax.vecmath.Color3f;
public class UIConstants {
+ /*
+ * dark blue #10628B 16/98/139 0.0625f, 0.382f, 0.542
+ *
+ * light blue #1A99D9 26/153/217 0.1015f, 0.5976f, 0.8476f
+ *
+ * brown #8C6311 140/99/17 0.5468f, 0.3867f, 0.0664f
+ *
+ * orange #D9791A 217/121/26 0.8476f, 0.4726f, 0.1015f
+ *
+ * dark gray #737373 115/115/115 0.4492f, 0.4492f, 0.4492f
+ *
+ * light gray #8C8C8C 140/140/140 0.5468f, 0.5468f, 0.5468f
+ */
+ public static Color3f WHITE = new Color3f(1, 1, 1);
+
+ public static Color3f BLACK = new Color3f(0, 0, 0);
+
+ public static Color3f DARK_BLUE = new Color3f(0.0625f, 0.382f, 0.542f);
+
+ public static Color3f LIGHT_BLUE = new Color3f(0.1015f, 0.5976f, 0.8476f);
+
+ public static Color3f BROWN = new Color3f(0.5468f, 0.3867f, 0.0664f);
+
+ public static Color3f ORANGE = new Color3f(0.8476f, 0.4726f, 0.1015f);
+
+ public static Color3f DARK_GRAY = new Color3f(0.4492f, 0.4492f, 0.4492f);
+
+ public static Color3f LIGHT_GRAY = new Color3f(0.5468f, 0.5468f, 0.5468f);
+
+ public static Color3f DARK_GREEN = new Color3f(0.6468f, 0.7867f, 0.0664f);
+
public static Image loadImageFromResource(String resourcePath) {
return loadIconFromResource(resourcePath).getImage();
}
@@ -62,4 +94,13 @@
throw new IllegalStateException("Could not load resource: " + resourcePath);
}
}
+
+ public static InputStream getResource(String resourcePath) {
+ InputStream resource = UIConstants.class.getClassLoader().getResourceAsStream(resourcePath);
+ if (resource == null) {
+ resource = UIConstants.class.getResourceAsStream(resourcePath);
+ }
+ return resource;
+
+ }
}
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -48,6 +48,7 @@
import com.ogoglio.client.model.Thing;
import com.ogoglio.client.model.User;
import com.ogoglio.util.Log;
+import com.ogoglio.util.UIConstants;
import com.ogoglio.viewer.j3d.bvh.Bvh;
import com.ogoglio.viewer.j3d.bvh.BvhParseException;
import com.ogoglio.viewer.j3d.bvh.BvhParser;
@@ -62,7 +63,6 @@
import com.ogoglio.viewer.render.RenderableParseException;
import com.ogoglio.viewer.render.Renderer;
import com.ogoglio.viewer.render.ThingRenderable;
-import com.ogoglio.viewer.render.UIConstants;
import com.ogoglio.viewer.render.UserRenderable;
import com.sun.j3d.utils.picking.PickTool;
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-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -36,7 +36,6 @@
import com.ogoglio.viewer.j3d.body.SkinLoader;
import com.ogoglio.viewer.j3d.bvh.Bvh;
import com.ogoglio.viewer.j3d.bvh.BvhParseException;
-import com.ogoglio.viewer.j3d.bvh.BvhParser;
import com.ogoglio.viewer.j3d.obj.Obj;
import com.ogoglio.viewer.j3d.obj.ObjParseException;
import com.ogoglio.viewer.j3d.obj.ObjParser;
@@ -50,7 +49,7 @@
public class J3DUserRenderable extends BranchGroup implements UserRenderable {
private static final float MAGIC_SKELETON_SCALE = 2.5f;
-
+
public static float PERSON_HEIGHT = 2f;
private TransformGroup transformGroup = new TransformGroup();
@@ -60,7 +59,7 @@
private User user = null;
private Bvh defaultAnimation = null;
-
+
private J3DCamera camera = null;
private Skin skin = null;
@@ -74,62 +73,74 @@
private BodyAnimator animator = null;
private BodyAnimatorListener bodyAnimatorListener = new BodyAnimatorListener();
-
- float userHeight = 2; //meters
+ private float userHeight = 2; //meters
+
+ private boolean isVisible = true;
+
public J3DUserRenderable(User user, boolean setVisible, Bvh defaultAnimation) throws IOException, ObjParseException, BvhParseException, SkinMapParseException {
ArgumentUtils.assertNotNull(user);
this.user = user;
+ this.isVisible = setVisible;
ArgumentUtils.assertNotNull(defaultAnimation);
this.defaultAnimation = defaultAnimation;
-
- if (setVisible) {
+
+ setCapability(BranchGroup.ALLOW_DETACH);
+ setCapability(BranchGroup.ALLOW_BOUNDS_READ);
+ setCapabilities(transformGroup);
+ addChild(transformGroup);
+ setCapabilities(bodyGroup);
+ transformGroup.addChild(bodyGroup);
+
+ initBody();
+ }
+
+ private void initBody() throws IOException, ObjParseException, SkinMapParseException {
+ bodyGroup.removeAllChildren();
+ if (isVisible) {
ObjParser parser = new ObjParser(user, 0);
parser.setIgnoreMaterialsFiles(true);
Obj obj = parser.parse();
skin = new SkinLoader(obj, user.getBody()).generateSkin();
userHeight = skin.getHeight();
-
- SkinMapParser skinMapParser = new SkinMapParser(user);
- skinMap = skinMapParser.parse();
+ skinMap = new SkinMapParser(user).parse();
}
scaleBVH(defaultAnimation);
-
+
skeleton = new SkeletonLoader(defaultAnimation).generateSkeleton();
- //skeleton.addDebugAttachments();
- if(setVisible){
+ if (isVisible) {
skin.setSkeleton(skeleton, skinMap);
}
-
- setCapability(BranchGroup.ALLOW_DETACH);
- setCapability(BranchGroup.ALLOW_BOUNDS_READ);
- setCapabilities(transformGroup);
- addChild(transformGroup);
Transform3D rotationTransform = new Transform3D();
rotationTransform.rotY(Math.PI);
float hairHeight = defaultAnimation.getJointHeight("lFoot");
rotationTransform.setTranslation(new Vector3d(0, -1 * hairHeight, 0));
bodyGroup.setTransform(rotationTransform);
- if (setVisible) {
- bodyGroup.addChild(skin);
+ if (isVisible) {
+ BranchGroup skinBranch = new BranchGroup();
+ skinBranch.setCapability(BranchGroup.ALLOW_DETACH);
+ skinBranch.addChild(skin);
+ bodyGroup.addChild(skinBranch);
}
- bodyGroup.addChild(skeleton);
+ BranchGroup skeletonBranch = new BranchGroup();
+ skeletonBranch.setCapability(BranchGroup.ALLOW_DETACH);
+ skeletonBranch.addChild(skeleton);
+ bodyGroup.addChild(skeletonBranch);
- transformGroup.addChild(bodyGroup);
setPosition(user.getPosition());
playAnimation(defaultAnimation, false);
}
- private void scaleBVH(Bvh bvh){
+ private void scaleBVH(Bvh bvh) {
float bvhHeight = bvh.getHeight();
- if(bvhHeight != userHeight){
+ if (bvhHeight != userHeight) {
skeletonScale = userHeight / bvhHeight / MAGIC_SKELETON_SCALE; //TODO figure out why we need this magic scale number
bvh.scale(skeletonScale);
}
}
-
+
public void setNameTag(String nameTag) {
TransformGroup nameGroup = new TransformGroup();
nameGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
@@ -160,62 +171,6 @@
group.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
}
- /*
- private class SkinUpdater implements GeometryUpdater {
- Transform3D requestTransform = null;
-
- float[] coords = null;
-
- Point3f workingPoint = new Point3f();
-
- SkinUpdater(Transform3D requestTransform) {
- this.requestTransform = requestTransform;
- IndexedTriangleStripArray triArray = (IndexedTriangleStripArray) skin.getGeometry();
- coords = triArray.getCoordRefFloat();
- }
-
- public void updateData(Geometry geometry) {
- for (int i = 0; i < coords.length - 2; i += 3) {
- workingPoint.set(coords[i], coords[i + 1], coords[i + 2]);
- requestTransform.transform(workingPoint);
- coords[i] = workingPoint.x;
- coords[i + 1] = workingPoint.y;
- coords[i + 2] = workingPoint.z;
- }
- }
- }
- */
- /*
- private void fitSkin() {
- skin.setBoundsAutoCompute(true);
- BoundingBox bounds = (BoundingBox) skin.getBounds();
- Point3d upper = new Point3d();
- bounds.getUpper(upper);
- Point3d lower = new Point3d();
- bounds.getLower(lower);
- double originalHeight = upper.y - lower.y;
- skinScale = PERSON_HEIGHT / originalHeight;
-
- //Scale the skin
- Transform3D figureTransform = new Transform3D(new Quat4d(), new Vector3d(0, 0, 0), skinScale);
- Transform3D rotationTransform = new Transform3D();
- rotationTransform.rotY(Math.PI);
- figureTransform.mul(rotationTransform);
- SkinUpdater skinUpdater = new SkinUpdater(figureTransform);
- ((IndexedTriangleStripArray) skin.getGeometry()).updateData(skinUpdater);
-
- //Translate the skin so the feet are at Y == 0
- bounds = (BoundingBox) skin.getBounds();
- bounds.getLower(lower);
- if (lower.y != 0) {
- figureTransform = new Transform3D(new Quat4d(), new Vector3d(0, -lower.y, 0), 1);
- skinUpdater = new SkinUpdater(figureTransform);
- ((IndexedTriangleStripArray) skin.getGeometry()).updateData(skinUpdater);
- }
- bounds = (BoundingBox) skin.getBounds();
- }
- */
-
public void setCamera(Camera camera) {
if (camera == null) {
throw new IllegalArgumentException("Cannot set null camera");
@@ -261,7 +216,7 @@
public User getUser() {
return user;
}
-
+
public double getHeight() {
BoundingSphere bounds = (BoundingSphere) getBounds();
return Math.abs(bounds.getRadius() * 2);
@@ -276,7 +231,7 @@
return;
}
Body body = user.getBody();
- skin.updateTexture(body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace());
+ skin.updateTexture(body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale());
}
public synchronized void stopAnimation() {
@@ -289,13 +244,13 @@
private class BodyAnimatorListener implements BodyAnimator.Listener {
public void bodyAnimationCompleted(BodyAnimator animator) {
- if(animator.getBvh() == defaultAnimation){
+ if (animator.getBvh() == defaultAnimation) {
return;
}
playAnimation(defaultAnimation, false);
}
}
-
+
public synchronized void playAnimation(Bvh bvh, boolean loop) {
if (animator != null) {
animator.cleanup();
@@ -307,4 +262,19 @@
animator.animate(loop);
}
}
+
+ public void setMale(boolean male) {
+ try {
+ initBody();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ObjParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SkinMapParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2007-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -15,6 +15,7 @@
package com.ogoglio.viewer.j3d.body;
import java.awt.Graphics;
+import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.Vector;
@@ -37,7 +38,6 @@
import javax.vecmath.Vector3d;
import com.ogoglio.util.BodyConstants;
-import com.ogoglio.util.Log;
import com.ogoglio.viewer.j3d.body.Skeleton.Bone;
import com.ogoglio.viewer.j3d.smap.SkinMap;
import com.ogoglio.viewer.j3d.smap.SkinMap.Group;
@@ -53,7 +53,7 @@
private SkinUpdater skinUpdater = null;
- public Skin(int hair, int eyes, int nose, int mouth, int face) {
+ public Skin(int hair, int eyes, int nose, int mouth, int face, boolean isMale) {
setCapability(Skin.ALLOW_APPEARANCE_WRITE);
setCapability(Skin.ALLOW_PICKABLE_READ);
setCapability(Skin.ALLOW_GEOMETRY_READ);
@@ -69,7 +69,7 @@
texture.getImage(0).setCapability(ImageComponent.ALLOW_IMAGE_READ);
texture.getImage(0).setCapability(ImageComponent.ALLOW_IMAGE_WRITE);
- updateTexture(hair, eyes, nose, mouth, face);
+ updateTexture(hair, eyes, nose, mouth, face, isMale);
Appearance appearance = new Appearance();
TextureAttributes textureAtts = new TextureAttributes();
@@ -91,18 +91,22 @@
int hair, eyes, nose, mouth, face;
- public TextureUpdater(int hair, int eyes, int nose, int mouth, int face) {
+ boolean isMale = false;
+
+ public TextureUpdater(int hair, int eyes, int nose, int mouth, int face, boolean isMale) {
this.hair = hair;
this.eyes = eyes;
this.nose = nose;
this.mouth = mouth;
this.face = face;
+ this.isMale = isMale;
}
public void updateData(ImageComponent2D imageComp, int arg1, int arg2, int arg3, int arg4) {
Graphics g = imageComp.getImage().getGraphics();
- if (face >= 0 && face < BodyConstants.BASE_SKIN_TEXTURES.length) {
- g.drawImage(BodyConstants.BASE_SKIN_TEXTURES[face], 0, 0, null);
+ Image[] baseTextures = isMale ? BodyConstants.MALE_BASE_SKIN_TEXTURES : BodyConstants.FEMALE_BASE_SKIN_TEXTURES;
+ if (face >= 0 && face < baseTextures.length) {
+ g.drawImage(baseTextures[face], 0, 0, null);
}
if (eyes >= 0 && eyes < BodyConstants.EYES.length) {
g.drawImage(BodyConstants.EYES[eyes], 111, 90, 75, 37, null);
@@ -117,9 +121,9 @@
}
- public void updateTexture(int hair, int eyes, int nose, int mouth, int face) {
+ public void updateTexture(int hair, int eyes, int nose, int mouth, int face, boolean isMale) {
ImageComponent2D imageComp = (ImageComponent2D) texture.getImage(0);
- imageComp.updateData(new TextureUpdater(hair, eyes, nose, mouth, face), 0, 0, baseImage.getWidth(), baseImage.getHeight());
+ imageComp.updateData(new TextureUpdater(hair, eyes, nose, mouth, face, isMale), 0, 0, baseImage.getWidth(), baseImage.getHeight());
}
public void setGeometry(Geometry geo) {
@@ -268,12 +272,12 @@
}
public float getHeight() {
- BoundingBox bounds = (BoundingBox)getBounds();
+ BoundingBox bounds = (BoundingBox) getBounds();
Point3d upper = new Point3d();
bounds.getUpper(upper);
Point3d lower = new Point3d();
bounds.getLower(lower);
- return (float)(upper.y - lower.y);
+ return (float) (upper.y - lower.y);
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -73,7 +73,7 @@
normalArray[(i * 3) + 1] = normals[i].z;
}
- Skin skin = new Skin(body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace());
+ Skin skin = new Skin(body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale());
IndexedTriangleArray array = new IndexedTriangleArray(vertices.length, TriangleArray.COORDINATES | TriangleArray.NORMALS | TriangleArray.TEXTURE_COORDINATE_2 | TriangleArray.BY_REFERENCE, indicesTotal);
array.setCoordRefFloat(vertexArray);
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/UIConstants.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/UIConstants.java 2007-09-18 16:02:42 UTC (rev 415)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/UIConstants.java 2007-09-18 16:03:11 UTC (rev 416)
@@ -1,127 +0,0 @@
-/* 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 ...
[truncated message content] |
|
From: <tre...@us...> - 2007-09-28 19:40:13
|
Revision: 457
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=457&view=rev
Author: trevorolio
Date: 2007-09-28 12:40:06 -0700 (Fri, 28 Sep 2007)
Log Message:
-----------
Introducing morphs! Well, some foundations for morphs, anyway.
Added a data data format to save vertex deltas between two obj files, which we will eventually use to interpolate a mesh.
So, someone can tweak a body mesh (e.g. make the nose bigger) and generate a morph file which describes the change.
I still have to make the J3DBodyData read the morphs, arrange them in an ADG, read user prefs for how far to interpolate the morphs, and then apply them to the mesh. And it all needs to be tested and represented in the body editor UI. *whew*
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParseException.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java
maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.obj
maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph
maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest2.obj
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java 2007-09-28 19:40:06 UTC (rev 457)
@@ -0,0 +1,101 @@
+/* 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.j3d.body;
+
+import java.util.Vector;
+
+import javax.vecmath.Vector3f;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class MorphDeltaMap {
+
+ String name = null;
+
+ Vector ranges = new Vector();
+
+ public MorphDeltaMap(String name) {
+ this.name = name;
+ }
+
+ public void addRange(Range range) {
+ ranges.add(range);
+ }
+
+ public Range[] getRanges() {
+ return (Range[]) ranges.toArray(new Range[0]);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public static class Range {
+ int lower = -1;
+
+ Vector3f[] deltas = null;
+
+ public Range(int lower,Vector3f[] deltas) {
+ ArgumentUtils.assertNotNegative(lower);
+ this.lower = lower;
+ ArgumentUtils.assertNotNull(deltas);
+ this.deltas = deltas;
+ }
+
+ /**
+ * @return a ONE BASED vertex index for an Obj mesh
+ */
+ public int getLower() {
+ return lower;
+ }
+
+ public int getVertexCount() {
+ return deltas.length;
+ }
+
+ public Vector3f[] getDeltas() {
+ return deltas;
+ }
+ }
+
+ public int getVertexCount() {
+ Range[] ranges = getRanges();
+ int total = 0;
+ for (int i = 0; i < ranges.length; i++) {
+ total += ranges[i].getVertexCount();
+ }
+ return total;
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("# MorphDeltaMap\n");
+ result.append(name + "\n\n");
+ Range[] ranges = getRanges();
+ for (int i = 0; i < ranges.length; i++) {
+ result.append(ranges[i].lower);
+ for (int j = 0; j < ranges[i].getVertexCount(); j++) {
+ Vector3f delta = ranges[i].getDeltas()[j];
+ result.append("\t" + format(delta.x) + "," + format(delta.y) + "," + format(delta.z));
+ }
+ result.append("\n");
+ }
+ return result.toString();
+ }
+ private String format(float value){
+ Object[] args = { new Float(value) };
+ return String.format("%f", args);
+ }
+}
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParseException.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParseException.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParseException.java 2007-09-28 19:40:06 UTC (rev 457)
@@ -0,0 +1,20 @@
+/* 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.j3d.body;
+
+public class MorphDeltaMapParseException extends Exception {
+ public MorphDeltaMapParseException(String message) {
+ super(message);
+ }
+}
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java 2007-09-28 19:40:06 UTC (rev 457)
@@ -0,0 +1,85 @@
+/* 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.j3d.body;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Vector;
+import java.util.regex.Pattern;
+
+import javax.vecmath.Vector3f;
+
+import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.viewer.j3d.obj.LineTokenizer;
+
+public class MorphDeltaMapParser {
+
+ private InputStream input = null;
+
+ private LineTokenizer tokenizer = null;
+
+ private MorphDeltaMap map = null;
+
+ public MorphDeltaMapParser(InputStream input) {
+ ArgumentUtils.assertNotNull(input);
+ this.input = input;
+ tokenizer = new LineTokenizer(input);
+ }
+
+ public MorphDeltaMap parse() throws IOException, MorphDeltaMapParseException {
+ String[] tokens = null;
+
+ while ((tokens = tokenizer.readNextLine()) != null) {
+ if (tokens.length == 0 || tokens[0].startsWith("#")) {
+ continue;
+ } else if (map == null) {
+ parseName(tokens);
+ } else {
+ parseRange(tokens);
+ }
+ }
+
+ if (map == null) { //we never parsed a name!
+ throw new MorphDeltaMapParseException("No name defined in this morph file");
+ }
+ return map;
+ }
+
+ private void parseName(String[] tokens) throws MorphDeltaMapParseException {
+ map = new MorphDeltaMap(LineTokenizer.toString(tokens));
+ }
+
+ private void parseRange(String[] tokens) throws MorphDeltaMapParseException {
+ if(tokens.length < 2){
+ throw new MorphDeltaMapParseException("Bad range: " + LineTokenizer.toString(tokens));
+ }
+ int startingIndex = Integer.parseInt(tokens[0]);
+
+ Vector deltas = new Vector();
+ for (int i = 1; i < tokens.length; i++) {
+ deltas.add(parseVector3f(tokens[i]));
+ }
+
+ MorphDeltaMap.Range range = new MorphDeltaMap.Range(startingIndex, (Vector3f[])deltas.toArray(new Vector3f[0]));
+ map.addRange(range);
+ }
+
+ private Vector3f parseVector3f(String token) throws MorphDeltaMapParseException {
+ String[] subTokens = token.split(Pattern.quote(","));
+ if(subTokens.length != 3){
+ throw new MorphDeltaMapParseException("Bad vector parse: " + token);
+ }
+ return new Vector3f(Float.parseFloat(subTokens[0]), Float.parseFloat(subTokens[1]), Float.parseFloat(subTokens[2]));
+ }
+}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java 2007-09-28 19:39:59 UTC (rev 456)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java 2007-09-28 19:40:06 UTC (rev 457)
@@ -49,4 +49,12 @@
}
return results;
}
+
+ public static String toString(String[] tokens) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < tokens.length; i++) {
+ result.append(tokens[i] + " ");
+ }
+ return result.toString().trim();
+ }
}
\ No newline at end of file
Added: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java 2007-09-28 19:40:06 UTC (rev 457)
@@ -0,0 +1,44 @@
+package com.ogoglio.viewer.j3d.body.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import com.ogoglio.util.UIConstants;
+import com.ogoglio.viewer.j3d.body.MorphDeltaMap;
+import com.ogoglio.viewer.j3d.body.MorphDeltaMapParseException;
+import com.ogoglio.viewer.j3d.body.MorphDeltaMapParser;
+
+public class MorphTest extends TestCase {
+
+ public static final String MORPH1_RESOURCE_PATH = "sample-art3d/MorphTest1.ogmorph";
+
+ public void testMorphDeltaMapParse() throws IOException, MorphDeltaMapParseException {
+ MorphDeltaMap map1 = new MorphDeltaMapParser(UIConstants.getResource(MORPH1_RESOURCE_PATH)).parse();
+ assertNotNull(map1.getName());
+ assertTrue(map1.getName().length() > 0);
+ assertTrue(map1.getRanges().length > 0);
+ assertTrue(map1.getRanges()[0].getDeltas().length > 0);
+ assertTrue(map1.getRanges()[0].getLower() > 0); //indices are 1 based, like skinmaps and obj files
+ MorphDeltaMap map2 = new MorphDeltaMapParser(new ByteArrayInputStream(map1.toString().getBytes())).parse();
+ assertMapsEqual(map1, map2);
+ }
+
+ private void assertMapsEqual(MorphDeltaMap map1, MorphDeltaMap map2) {
+ assertEquals(map1.getName(), map2.getName());
+ assertEquals(map1.getVertexCount(), map2.getVertexCount());
+ assertEquals(map1.getRanges().length, map2.getRanges().length);
+ for (int i = 0; i < map1.getRanges().length; i++) {
+ assertRangesEqual(map1.getRanges()[i], map2.getRanges()[i]);
+ }
+ }
+
+ private void assertRangesEqual(MorphDeltaMap.Range range1, MorphDeltaMap.Range range2) {
+ assertEquals(range1.getLower(), range2.getLower());
+ assertEquals(range1.getDeltas().length, range2.getDeltas().length);
+ for (int i = 0; i < range1.getDeltas().length; i++) {
+ assertTrue(range1.getDeltas()[i].epsilonEquals(range2.getDeltas()[i], 0.00001f));
+ }
+ }
+}
Added: maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.obj
===================================================================
--- maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.obj (rev 0)
+++ maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.obj 2007-09-28 19:40:06 UTC (rev 457)
@@ -0,0 +1,483 @@
+o Grid
+v 1.000000 -1.000000 0.000000
+v 0.866667 -1.000000 0.000000
+v 0.733333 -1.000000 0.000000
+v 0.600000 -1.000000 0.000000
+v 0.466667 -1.000000 0.000000
+v 0.333333 -1.000000 0.000000
+v 0.200000 -1.000000 0.000000
+v 0.066667 -1.000000 0.000000
+v -0.066667 -1.000000 0.000000
+v -0.200000 -1.000000 0.000000
+v -0.333333 -1.000000 0.000000
+v -0.466667 -1.000000 0.000000
+v -0.600000 -1.000000 0.000000
+v -0.733333 -1.000000 0.000000
+v -0.866667 -1.000000 0.000000
+v -1.000000 -1.000000 0.000000
+v -1.000000 -0.866667 0.000000
+v -0.866667 -0.866667 0.000000
+v -0.733333 -0.866667 0.000000
+v -0.600000 -0.866667 0.000000
+v -0.466667 -0.866667 0.000000
+v -0.333333 -0.866667 0.000000
+v -0.200000 -0.866667 0.000000
+v -0.066667 -0.866667 0.000000
+v 0.066667 -0.866667 0.000000
+v 0.200000 -0.866667 0.000000
+v 0.333333 -0.866667 0.000000
+v 0.466667 -0.866667 0.000000
+v 0.600000 -0.866667 0.000000
+v 0.733333 -0.866667 0.000000
+v 0.866667 -0.866667 0.000000
+v 1.000000 -0.866667 0.000000
+v 1.000000 -0.733333 0.000000
+v 0.866667 -0.733333 0.000000
+v 0.733333 -0.733333 0.000000
+v 0.600000 -0.733333 0.000000
+v 0.466667 -0.733333 0.000000
+v 0.333333 -0.733333 0.000000
+v 0.200000 -0.733333 0.000000
+v 0.066667 -0.733333 0.000000
+v -0.066667 -0.733333 0.000000
+v -0.200000 -0.733333 0.000000
+v -0.333333 -0.733333 0.000000
+v -0.466667 -0.733333 0.000000
+v -0.600000 -0.733333 0.000000
+v -0.733333 -0.733333 0.000000
+v -0.866667 -0.733333 0.000000
+v -1.000000 -0.733333 0.000000
+v -1.000000 -0.600000 0.000000
+v -0.866667 -0.600000 0.000000
+v -0.733333 -0.600000 0.000000
+v -0.600000 -0.600000 0.000000
+v -0.466667 -0.600000 0.000000
+v -0.333333 -0.600000 0.000000
+v -0.200000 -0.600000 0.000000
+v -0.066667 -0.600000 0.000000
+v 0.066667 -0.600000 0.000000
+v 0.200000 -0.600000 0.000000
+v 0.333333 -0.600000 0.000000
+v 0.466667 -0.600000 0.000000
+v 0.600000 -0.600000 0.000000
+v 0.733333 -0.600000 0.000000
+v 0.866667 -0.600000 0.000000
+v 1.000000 -0.600000 0.000000
+v 1.000000 -0.466667 0.000000
+v 0.866667 -0.466667 0.000000
+v 0.733333 -0.466667 0.000000
+v 0.600000 -0.466667 0.000000
+v 0.466667 -0.466667 0.000000
+v 0.333333 -0.466667 0.000000
+v 0.200000 -0.466667 0.000000
+v 0.066667 -0.466667 0.000000
+v -0.066667 -0.466667 0.000000
+v -0.200000 -0.466667 0.000000
+v -0.333333 -0.466667 0.000000
+v -0.466667 -0.466667 0.000000
+v -0.600000 -0.466667 0.000000
+v -0.733333 -0.466667 0.000000
+v -0.866667 -0.466667 0.000000
+v -1.000000 -0.466667 0.000000
+v -1.000000 -0.333333 0.000000
+v -0.866667 -0.333333 0.000000
+v -0.733333 -0.333333 0.000000
+v -0.600000 -0.333333 0.000000
+v -0.466667 -0.333333 0.000000
+v -0.333333 -0.333333 0.000000
+v -0.200000 -0.333333 0.000000
+v -0.066667 -0.333333 0.000000
+v 0.066667 -0.333333 0.000000
+v 0.200000 -0.333333 0.000000
+v 0.333333 -0.333333 0.000000
+v 0.466667 -0.333333 0.000000
+v 0.600000 -0.333333 0.000000
+v 0.733333 -0.333333 0.000000
+v 0.866667 -0.333333 0.000000
+v 1.000000 -0.333333 0.000000
+v 1.000000 -0.200000 0.000000
+v 0.866667 -0.200000 0.000000
+v 0.733333 -0.200000 0.000000
+v 0.600000 -0.200000 0.000000
+v 0.466667 -0.200000 0.000000
+v 0.333333 -0.200000 0.000000
+v 0.200000 -0.200000 0.000000
+v 0.066667 -0.200000 0.000000
+v -0.066667 -0.200000 0.000000
+v -0.200000 -0.200000 0.000000
+v -0.333333 -0.200000 0.000000
+v -0.466667 -0.200000 0.000000
+v -0.600000 -0.200000 0.000000
+v -0.733333 -0.200000 0.000000
+v -0.866667 -0.200000 0.000000
+v -1.000000 -0.200000 0.000000
+v -1.000000 -0.066667 0.000000
+v -0.866667 -0.066667 0.000000
+v -0.733333 -0.066667 0.000000
+v -0.600000 -0.066667 0.000000
+v -0.466667 -0.066667 0.000000
+v -0.333333 -0.066667 0.000000
+v -0.200000 -0.066667 0.000000
+v -0.066667 -0.066667 0.000000
+v 0.066667 -0.066667 0.000000
+v 0.200000 -0.066667 0.000000
+v 0.333333 -0.066667 0.000000
+v 0.466667 -0.066667 0.000000
+v 0.600000 -0.066667 0.000000
+v 0.733333 -0.066667 0.000000
+v 0.866667 -0.066667 0.000000
+v 1.000000 -0.066667 0.000000
+v 1.000000 0.066667 0.000000
+v 0.866667 0.066667 0.000000
+v 0.733333 0.066667 0.000000
+v 0.600000 0.066667 0.000000
+v 0.466667 0.066667 0.000000
+v 0.333333 0.066667 0.000000
+v 0.200000 0.066667 0.000000
+v 0.066667 0.066667 0.000000
+v -0.066667 0.066667 0.000000
+v -0.200000 0.066667 0.000000
+v -0.333333 0.066667 0.000000
+v -0.466667 0.066667 0.000000
+v -0.600000 0.066667 0.000000
+v -0.733333 0.066667 0.000000
+v -0.866667 0.066667 0.000000
+v -1.000000 0.066667 0.000000
+v -1.000000 0.200000 0.000000
+v -0.866667 0.200000 0.000000
+v -0.733333 0.200000 0.000000
+v -0.600000 0.200000 0.000000
+v -0.466667 0.200000 0.000000
+v -0.333333 0.200000 0.000000
+v -0.200000 0.200000 0.000000
+v -0.066667 0.200000 0.000000
+v 0.066667 0.200000 0.000000
+v 0.200000 0.200000 0.000000
+v 0.333333 0.200000 0.000000
+v 0.466667 0.200000 0.000000
+v 0.600000 0.200000 0.000000
+v 0.733333 0.200000 0.000000
+v 0.866667 0.200000 0.000000
+v 1.000000 0.200000 0.000000
+v 1.000000 0.333333 0.000000
+v 0.866667 0.333333 0.000000
+v 0.733333 0.333333 0.000000
+v 0.600000 0.333333 0.000000
+v 0.466667 0.333333 0.000000
+v 0.333333 0.333333 0.000000
+v 0.200000 0.333333 0.000000
+v 0.066667 0.333333 0.000000
+v -0.066667 0.333333 0.000000
+v -0.200000 0.333333 0.000000
+v -0.333333 0.333333 0.000000
+v -0.466667 0.333333 0.000000
+v -0.600000 0.333333 0.000000
+v -0.733333 0.333333 0.000000
+v -0.866667 0.333333 0.000000
+v -1.000000 0.333333 0.000000
+v -1.000000 0.466667 0.000000
+v -0.866667 0.466667 0.000000
+v -0.733333 0.466667 0.000000
+v -0.600000 0.466667 0.000000
+v -0.466667 0.466667 0.000000
+v -0.333333 0.466667 0.000000
+v -0.200000 0.466667 0.000000
+v -0.066667 0.466667 0.000000
+v 0.066667 0.466667 0.000000
+v 0.200000 0.466667 0.000000
+v 0.333333 0.466667 0.000000
+v 0.466667 0.466667 0.000000
+v 0.600000 0.466667 0.000000
+v 0.733333 0.466667 0.000000
+v 0.866667 0.466667 0.000000
+v 1.000000 0.466667 0.000000
+v 1.000000 0.600000 0.000000
+v 0.866667 0.600000 0.000000
+v 0.733333 0.600000 0.000000
+v 0.600000 0.600000 0.000000
+v 0.466667 0.600000 0.000000
+v 0.333333 0.600000 0.000000
+v 0.200000 0.600000 0.000000
+v 0.066667 0.600000 0.000000
+v -0.066667 0.600000 0.000000
+v -0.200000 0.600000 0.000000
+v -0.333333 0.600000 0.000000
+v -0.466667 0.600000 0.000000
+v -0.600000 0.600000 0.000000
+v -0.733333 0.600000 0.000000
+v -0.866667 0.600000 0.000000
+v -1.000000 0.600000 0.000000
+v -1.000000 0.733333 0.000000
+v -0.866667 0.733333 0.000000
+v -0.733333 0.733333 0.000000
+v -0.600000 0.733333 0.000000
+v -0.466667 0.733333 0.000000
+v -0.333333 0.733333 0.000000
+v -0.200000 0.733333 0.000000
+v -0.066667 0.733333 0.000000
+v 0.066667 0.733333 0.000000
+v 0.200000 0.733333 0.000000
+v 0.333333 0.733333 0.000000
+v 0.466667 0.733333 0.000000
+v 0.600000 0.733333 0.000000
+v 0.733333 0.733333 0.000000
+v 0.866667 0.733333 0.000000
+v 1.000000 0.733333 0.000000
+v 1.000000 0.866667 0.000000
+v 0.866667 0.866667 0.000000
+v 0.733333 0.866667 0.000000
+v 0.600000 0.866667 0.000000
+v 0.466667 0.866667 0.000000
+v 0.333333 0.866667 0.000000
+v 0.200000 0.866667 0.000000
+v 0.066667 0.866667 0.000000
+v -0.066667 0.866667 0.000000
+v -0.200000 0.866667 0.000000
+v -0.333333 0.866667 0.000000
+v -0.466667 0.866667 0.000000
+v -0.600000 0.866667 0.000000
+v -0.733333 0.866667 0.000000
+v -0.866667 0.866667 0.000000
+v -1.000000 0.866667 0.000000
+v -1.000000 1.000000 0.000000
+v -0.866667 1.000000 0.000000
+v -0.733333 1.000000 0.000000
+v -0.600000 1.000000 0.000000
+v -0.466667 1.000000 0.000000
+v -0.333333 1.000000 0.000000
+v -0.200000 1.000000 0.000000
+v -0.066667 1.000000 0.000000
+v 0.066667 1.000000 0.000000
+v 0.200000 1.000000 0.000000
+v 0.333333 1.000000 0.000000
+v 0.466667 1.000000 0.000000
+v 0.600000 1.000000 0.000000
+v 0.733333 1.000000 0.000000
+v 0.866667 1.000000 0.000000
+v 1.000000 1.000000 0.000000
+s off
+f 16 15 18 17
+f 15 14 19 18
+f 14 13 20 19
+f 13 12 21 20
+f 12 11 22 21
+f 11 10 23 22
+f 10 9 24 23
+f 9 8 25 24
+f 8 7 26 25
+f 7 6 27 26
+f 6 5 28 27
+f 5 4 29 28
+f 4 3 30 29
+f 3 2 31 30
+f 2 1 32 31
+f 31 32 33 34
+f 30 31 34 35
+f 29 30 35 36
+f 28 29 36 37
+f 27 28 37 38
+f 26 27 38 39
+f 25 26 39 40
+f 24 25 40 41
+f 23 24 41 42
+f 22 23 42 43
+f 21 22 43 44
+f 20 21 44 45
+f 19 20 45 46
+f 18 19 46 47
+f 17 18 47 48
+f 48 47 50 49
+f 47 46 51 50
+f 46 45 52 51
+f 45 44 53 52
+f 44 43 54 53
+f 43 42 55 54
+f 42 41 56 55
+f 41 40 57 56
+f 40 39 58 57
+f 39 38 59 58
+f 38 37 60 59
+f 37 36 61 60
+f 36 35 62 61
+f 35 34 63 62
+f 34 33 64 63
+f 63 64 65 66
+f 62 63 66 67
+f 61 62 67 68
+f 60 61 68 69
+f 59 60 69 70
+f 58 59 70 71
+f 57 58 71 72
+f 56 57 72 73
+f 55 56 73 74
+f 54 55 74 75
+f 53 54 75 76
+f 52 53 76 77
+f 51 52 77 78
+f 50 51 78 79
+f 49 50 79 80
+f 80 79 82 81
+f 79 78 83 82
+f 78 77 84 83
+f 77 76 85 84
+f 76 75 86 85
+f 75 74 87 86
+f 74 73 88 87
+f 73 72 89 88
+f 72 71 90 89
+f 71 70 91 90
+f 70 69 92 91
+f 69 68 93 92
+f 68 67 94 93
+f 67 66 95 94
+f 66 65 96 95
+f 95 96 97 98
+f 94 95 98 99
+f 93 94 99 100
+f 92 93 100 101
+f 91 92 101 102
+f 90 91 102 103
+f 89 90 103 104
+f 88 89 104 105
+f 87 88 105 106
+f 86 87 106 107
+f 85 86 107 108
+f 84 85 108 109
+f 83 84 109 110
+f 82 83 110 111
+f 81 82 111 112
+f 112 111 114 113
+f 111 110 115 114
+f 110 109 116 115
+f 109 108 117 116
+f 108 107 118 117
+f 107 106 119 118
+f 106 105 120 119
+f 105 104 121 120
+f 104 103 122 121
+f 103 102 123 122
+f 102 101 124 123
+f 101 100 125 124
+f 100 99 126 125
+f 99 98 127 126
+f 98 97 128 127
+f 127 128 129 130
+f 126 127 130 131
+f 125 126 131 132
+f 124 125 132 133
+f 123 124 133 134
+f 122 123 134 135
+f 121 122 135 136
+f 120 121 136 137
+f 119 120 137 138
+f 118 119 138 139
+f 117 118 139 140
+f 116 117 140 141
+f 115 116 141 142
+f 114 115 142 143
+f 113 114 143 144
+f 144 143 146 145
+f 143 142 147 146
+f 142 141 148 147
+f 141 140 149 148
+f 140 139 150 149
+f 139 138 151 150
+f 138 137 152 151
+f 137 136 153 152
+f 136 135 154 153
+f 135 134 155 154
+f 134 133 156 155
+f 133 132 157 156
+f 132 131 158 157
+f 131 130 159 158
+f 130 129 160 159
+f 159 160 161 162
+f 158 159 162 163
+f 157 158 163 164
+f 156 157 164 165
+f 155 156 165 166
+f 154 155 166 167
+f 153 154 167 168
+f 152 153 168 169
+f 151 152 169 170
+f 150 151 170 171
+f 149 150 171 172
+f 148 149 172 173
+f 147 148 173 174
+f 146 147 174 175
+f 145 146 175 176
+f 176 175 178 177
+f 175 174 179 178
+f 174 173 180 179
+f 173 172 181 180
+f 172 171 182 181
+f 171 170 183 182
+f 170 169 184 183
+f 169 168 185 184
+f 168 167 186 185
+f 167 166 187 186
+f 166 165 188 187
+f 165 164 189 188
+f 164 163 190 189
+f 163 162 191 190
+f 162 161 192 191
+f 191 192 193 194
+f 190 191 194 195
+f 189 190 195 196
+f 188 189 196 197
+f 187 188 197 198
+f 186 187 198 199
+f 185 186 199 200
+f 184 185 200 201
+f 183 184 201 202
+f 182 183 202 203
+f 181 182 203 204
+f 180 181 204 205
+f 179 180 205 206
+f 178 179 206 207
+f 177 178 207 208
+f 208 207 210 209
+f 207 206 211 210
+f 206 205 212 211
+f 205 204 213 212
+f 204 203 214 213
+f 203 202 215 214
+f 202 201 216 215
+f 201 200 217 216
+f 200 199 218 217
+f 199 198 219 218
+f 198 197 220 219
+f 197 196 221 220
+f 196 195 222 221
+f 195 194 223 222
+f 194 193 224 223
+f 223 224 225 226
+f 222 223 226 227
+f 221 222 227 228
+f 220 221 228 229
+f 219 220 229 230
+f 218 219 230 231
+f 217 218 231 232
+f 216 217 232 233
+f 215 216 233 234
+f 214 215 234 235
+f 213 214 235 236
+f 212 213 236 237
+f 211 212 237 238
+f 210 211 238 239
+f 209 210 239 240
+f 240 239 242 241
+f 239 238 243 242
+f 238 237 244 243
+f 237 236 245 244
+f 236 235 246 245
+f 235 234 247 246
+f 234 233 248 247
+f 233 232 249 248
+f 232 231 250 249
+f 231 230 251 250
+f 230 229 252 251
+f 229 228 253 252
+f 228 227 254 253
+f 227 226 255 254
+f 226 225 256 255
Added: maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph
===================================================================
--- maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph (rev 0)
+++ maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph 2007-09-28 19:40:06 UTC (rev 457)
@@ -0,0 +1,9 @@
+# MorphDeltaMap
+testMorph1
+
+3 0.000000,0.000000,1.733333 0.000000,0.000000,1.600000 0.000000,0.000000,1.466667 0.000000,0.000000,1.333333 0.000000,0.000000,1.200000 0.000000,0.000000,1.066667 0.000000,0.000000,0.933333 0.000000,0.000000,0.800000 0.000000,0.000000,0.666667 0.000000,0.000000,0.533333 0.000000,0.000000,0.400000 0.000000,0.000000,0.266667
+18 0.000000,0.000000,0.000000 0.000000,0.000000,0.133334 0.000000,0.000000,0.266667 0.000000,0.000000,0.400000 0.000000,0.000000,0.533334 0.000000,0.000000,0.666667 0.000000,0.000000,0.800000 0.000000,0.000000,0.933334 0.000000,0.000000,1.066667 0.000000,0.000000,1.200000 0.000000,0.000000,1.333334 0.000000,0.000000,1.466667 0.000000,0.000000,1.600000 0.000000,0.000000,1.733334
+33 0.000000,0.000000,1.733333 0.000000,0.000000,1.600000 0.000000,0.000000,1.466666 0.000000,0.000000,1.333333 0.000000,0.000000,1.200000 0.000000,0.000000,1.066666 0.000000,0.000000,0.933333 0.000000,0.000000,0.800000 0.000000,0.000000,0.666666 0.000000,0.000000,0.533333 0.000000,0.000000,0.400000 0.000000,0.000000,0.266666 0.000000,0.000000,0.133333 0.000000,0.000000,0.000000 0.000000,0.000000,-0.133334 0.000000,0.000000,-0.266667 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.266667 0.000000,0.000000,-0.133333 0.000000,0.000000,0.000000 0.000000,0.000000,0.133333 0.000000,0.000000,0.266667 0.000000,0.000000,0.400000 0.000000,0.000000,0.533333 0.000000,0.000000,0.666667 0.000000,0.000000,0.800000 0.000000,0.000000,0.933333 0.000000,0.000000,1.066667 0.000000,0.000000,1.200000 0.000000,0.000000,1.333333 0.000000,0.000000,1.466667 0.000000,0.000000,1.600000 0.000000,0.000000,1.466667 0.000000,0.000000,1.333334 0.000000,0.000000,1.200000 0.000000,0.000000,1.066667 0.000000,0.000000,0.933334 0.000000,0.000000,0.800000 0.000000,0.000000,0.666667 0.000000,0.000000,0.533334 0.000000,0.000000,0.400000 0.000000,0.000000,0.266667 0.000000,0.000000,0.133334 0.000000,0.000000,0.000000 0.000000,0.000000,-0.133333 0.000000,0.000000,-0.266666 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.533333 0.000000,0.000000,-0.666667 0.000000,0.000000,-0.533334 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.266667 0.000000,0.000000,-0.133334 0.000000,0.000000,0.000000 0.000000,0.000000,0.133333 0.000000,0.000000,0.266666 0.000000,0.000000,0.400000 0.000000,0.000000,0.533333 0.000000,0.000000,0.666666 0.000000,0.000000,0.800000 0.000000,0.000000,0.933333 0.000000,0.000000,1.066666 0.000000,0.000000,1.200000 0.000000,0.000000,1.333333 0.000000,0.000000,1.200000 0.000000,0.000000,1.066667 0.000000,0.000000,0.933333 0.000000,0.000000,0.800000 0.000000,0.000000,0.666667 0.000000,0.000000,0.533333 0.000000,0.000000,0.400000 0.000000,0.000000,0.266667 0.000000,0.000000,0.133333 0.000000,0.000000,0.000000 0.000000,0.000000,-0.133333 0.000000,0.000000,-0.266667 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.533333 0.000000,0.000000,-0.666667 0.000000,0.000000,-0.800000 0.000000,0.000000,-0.933333 0.000000,0.000000,-0.800000 0.000000,0.000000,-0.666666 0.000000,0.000000,-0.533333 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.266666 0.000000,0.000000,-0.133333 0.000000,0.000000,0.000000 0.000000,0.000000,0.133334 0.000000,0.000000,0.266667 0.000000,0.000000,0.400000 0.000000,0.000000,0.533334 0.000000,0.000000,0.666667 0.000000,0.000000,0.800000 0.000000,0.000000,0.933334 0.000000,0.000000,1.066667 0.000000,0.000000,0.933333 0.000000,0.000000,0.800000 0.000000,0.000000,0.666666 0.000000,0.000000,0.533333 0.000000,0.000000,0.400000 0.000000,0.000000,0.266666 0.000000,0.000000,0.133333 0.000000,0.000000,0.000000 0.000000,0.000000,-0.133334 0.000000,0.000000,-0.266667 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.533334 0.000000,0.000000,-0.666667 0.000000,0.000000,-0.800000 0.000000,0.000000,-0.933334 0.000000,0.000000,-1.066667 0.000000,0.000000,-1.200000 0.000000,0.000000,-1.066667 0.000000,0.000000,-0.933333 0.000000,0.000000,-0.800000 0.000000,0.000000,-0.666667 0.000000,0.000000,-0.533333 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.266667 0.000000,0.000000,-0.133333 0.000000,0.000000,0.000000 0.000000,0.000000,0.133333 0.000000,0.000000,0.266667 0.000000,0.000000,0.400000 0.000000,0.000000,0.533333 0.000000,0.000000,0.666667 0.000000,0.000000,0.800000 0.000000,0.000000,0.666667 0.000000,0.000000,0.533334 0.000000,0.000000,0.400000 0.000000,0.000000,0.266667 0.000000,0.000000,0.133334 0.000000,0.000000,0.000000 0.000000,0.000000,-0.133333 0.000000,0.000000,-0.266666 0.000000,0.000000,-0.400000 0.000000,0.000000,-0.533333 0.000000,0.000000,-0.666666 0.000000,0.000000,-0.800000 0.000000,0.000000,-0.933333 0.000000,0.000000,-1.066666 0...
[truncated message content] |
|
From: <tre...@us...> - 2007-10-01 13:57:59
|
Revision: 462
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=462&view=rev
Author: trevorolio
Date: 2007-10-01 06:57:55 -0700 (Mon, 01 Oct 2007)
Log Message:
-----------
Now the body morphs are arranged in an ADG and applied to the body mesh in depth first order.
This implies that there is only one morph with no parent, and there are no cycles.
Both cases are detected, logged, and fail gracefully.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java
maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-10-01 13:57:55 UTC (rev 462)
@@ -150,9 +150,76 @@
} catch (MorphDeltaMapParseException e) {
throw new IllegalStateException("Trevor didn't implement an error body: " + e);
}
- return new J3DBodyData(array, (Bvh[]) animations.toArray(new Bvh[0]), skinMap, baseTexture, (MorphDeltaMap[])morphDeltas.toArray(new MorphDeltaMap[0]));
+
+ sortMorphDeltas(morphDeltas);
+
+ return new J3DBodyData(array, (Bvh[]) animations.toArray(new Bvh[0]), skinMap, baseTexture, (MorphDeltaMap[]) morphDeltas.toArray(new MorphDeltaMap[0]));
}
+ /**
+ * arranges the morph delta maps in depth first order
+ */
+ private void sortMorphDeltas(Vector morphDeltas) {
+ if(morphDeltas.size() == 0){
+ return;
+ }
+ MorphDeltaMap[] deltas = (MorphDeltaMap[]) morphDeltas.toArray(new MorphDeltaMap[0]);
+
+ HashMap nodeMap = new HashMap();
+ for (int i = 0; i < deltas.length; i++) {
+ nodeMap.put(deltas[i].getName(), new MorphTreeNode(deltas[i]));
+ }
+ MorphTreeNode rootNode = null;
+ for (int i = 0; i < deltas.length; i++) {
+ if(deltas[i].getParentName() == null){
+ if(rootNode == null){
+ rootNode = (MorphTreeNode)nodeMap.get(deltas[i].getName());
+ } else {
+ Log.warn("Found multiple morph delta maps with no parent, adding " + deltas[i].getName() + " to " + rootNode.map.getName());
+ rootNode.children.add(nodeMap.get(deltas[i].getName()));
+ }
+ } else {
+ MorphTreeNode parentNode = (MorphTreeNode)nodeMap.get(deltas[i].getParentName());
+ if(parentNode == null){
+ Log.warn("MorphDeltaMap (" + deltas[i].getName() + ") has unknown parent: " + deltas[i].getParentName() + ", ignoring.");
+ } else {
+ parentNode.children.add(nodeMap.get(deltas[i].getName()));
+ }
+ }
+ }
+ if(rootNode == null){
+ throw new IllegalStateException("Cannot have a morph tree with no root");
+ }
+
+ morphDeltas.clear();
+ serializeMorphTree(0, rootNode, morphDeltas);
+ }
+
+ /**
+ * depth first serialization of the ADG of MorphDeltaMaps
+ */
+ private void serializeMorphTree(int depth, MorphTreeNode node, Vector morphDeltas) {
+ depth++;
+ if(depth > 30){
+ Log.error("Morph tree depth was greater than 30, which probably indicates a cyclic tree. Aborting");
+ return;
+ }
+ for (int i = 0; i < node.children.size(); i++) {
+ serializeMorphTree(depth, (MorphTreeNode)node.children.get(i), morphDeltas);
+ }
+ morphDeltas.add(node.map);
+ }
+
+ private class MorphTreeNode {
+ MorphDeltaMap map = null;
+
+ Vector children = new Vector();
+
+ MorphTreeNode(MorphDeltaMap map) {
+ this.map = map;
+ }
+ }
+
private IndexedTriangleArray generateBodyGeometry(Obj obj) {
int indicesTotal = obj.faceCount() * 3;
int[] coordinateIndices = new int[indicesTotal];
@@ -234,7 +301,7 @@
private void fetchTemplateData(String username, long templateID, J3DTemplateData[] results) {
ArgumentUtils.assertNotNull(username);
ArgumentUtils.assertNotNegative(templateID);
-
+
Obj[] objs = getObjs(username, templateID);
HashMap textures = new HashMap();
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java 2007-10-01 13:57:55 UTC (rev 462)
@@ -23,11 +23,14 @@
public class MorphDeltaMap {
String name = null;
+
+ String parentName = null;
Vector ranges = new Vector();
- public MorphDeltaMap(String name) {
+ public MorphDeltaMap(String name, String parentName) {
this.name = name;
+ this.parentName = parentName;
}
public void addRange(Range range) {
@@ -38,6 +41,10 @@
return (Range[]) ranges.toArray(new Range[0]);
}
+ public String getParentName() {
+ return parentName;
+ }
+
public String getName() {
return name;
}
@@ -47,7 +54,7 @@
Vector3f[] deltas = null;
- public Range(int lower,Vector3f[] deltas) {
+ public Range(int lower, Vector3f[] deltas) {
ArgumentUtils.assertNotNegative(lower);
this.lower = lower;
ArgumentUtils.assertNotNull(deltas);
@@ -82,7 +89,10 @@
public String toString() {
StringBuffer result = new StringBuffer();
result.append("# MorphDeltaMap\n");
- result.append(name + "\n\n");
+ result.append("name: " + name + "\n\n");
+ if (parentName != null) {
+ result.append("parent: " + parentName + "\n\n");
+ }
Range[] ranges = getRanges();
for (int i = 0; i < ranges.length; i++) {
result.append(ranges[i].lower);
@@ -94,7 +104,8 @@
}
return result.toString();
}
- private String format(float value){
+
+ private String format(float value) {
Object[] args = { new Float(value) };
return String.format("%f", args);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java 2007-10-01 13:57:55 UTC (rev 462)
@@ -29,6 +29,10 @@
private LineTokenizer tokenizer = null;
+ private String name = null;
+
+ private String parentName = null;
+
private MorphDeltaMap map = null;
public MorphDeltaMapParser(InputStream input) {
@@ -43,8 +47,10 @@
while ((tokens = tokenizer.readNextLine()) != null) {
if (tokens.length == 0 || tokens[0].startsWith("#")) {
continue;
- } else if (map == null) {
+ } else if (map == null && tokens[0].equals("name:")) {
parseName(tokens);
+ } else if (map == null && tokens[0].equals("parent:")) {
+ parseParentName(tokens);
} else {
parseRange(tokens);
}
@@ -56,11 +62,25 @@
return map;
}
+ private void parseParentName(String[] tokens) throws MorphDeltaMapParseException {
+ if(tokens.length < 2){
+ throw new MorphDeltaMapParseException("Bad parent name definition: " + LineTokenizer.toString(tokens));
+ }
+ parentName = LineTokenizer.toString(tokens, 1);
+ }
+
private void parseName(String[] tokens) throws MorphDeltaMapParseException {
- map = new MorphDeltaMap(LineTokenizer.toString(tokens));
+ if(tokens.length < 2){
+ throw new MorphDeltaMapParseException("Bad name definition: " + LineTokenizer.toString(tokens));
+ }
+ name = LineTokenizer.toString(tokens, 1);
}
private void parseRange(String[] tokens) throws MorphDeltaMapParseException {
+ if(map == null){
+ map = new MorphDeltaMap(name, parentName);
+ }
+
if(tokens.length < 2){
throw new MorphDeltaMapParseException("Bad range: " + LineTokenizer.toString(tokens));
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-10-01 13:57:55 UTC (rev 462)
@@ -41,15 +41,12 @@
public Skin generateSkin() {
float[] vertices = geometry.getCoordRefFloat();
- //TODO make these happen in depth first order of the morph ADG
for (int i = 0; i < morphDeltaMaps.length; i++) {
MorphDeltaMap.Range[] ranges = morphDeltaMaps[i].getRanges();
for (int r = 0; r < ranges.length; r++) {
Vector3f[] deltas = ranges[r].getDeltas();
for (int d = 0; d < deltas.length; d++) {
int index = (ranges[r].getLower() - 1 + d) * 3;
- System.out.println(vertices[index] + "," + vertices[index + 1] + "," + vertices[index + 2]);
- System.out.println("Deltas " + deltas[d].x + "," + deltas[d].y + "," + deltas[d].z);
vertices[index] = vertices[index] + deltas[d].x;
vertices[index + 1] = vertices[index + 1] + deltas[d].y;
vertices[index + 2] = vertices[index + 2] + deltas[d].z;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/LineTokenizer.java 2007-10-01 13:57:55 UTC (rev 462)
@@ -51,8 +51,12 @@
}
public static String toString(String[] tokens) {
+ return toString(tokens, 0);
+ }
+
+ public static String toString(String[] tokens, int startingIndex) {
StringBuffer result = new StringBuffer();
- for (int i = 0; i < tokens.length; i++) {
+ for (int i = startingIndex; i < tokens.length; i++) {
result.append(tokens[i] + " ");
}
return result.toString().trim();
Modified: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/viewer/j3d/body/test/MorphTest.java 2007-10-01 13:57:55 UTC (rev 462)
@@ -16,7 +16,9 @@
public void testMorphDeltaMapParse() throws IOException, MorphDeltaMapParseException {
MorphDeltaMap map1 = new MorphDeltaMapParser(UIConstants.getResource(MORPH1_RESOURCE_PATH)).parse();
- assertNotNull(map1.getName());
+ assertEquals("testMorph1", map1.getName());
+ assertEquals("parentMorph1", map1.getParentName());
+
assertTrue(map1.getName().length() > 0);
assertTrue(map1.getRanges().length > 0);
assertTrue(map1.getRanges()[0].getDeltas().length > 0);
@@ -27,6 +29,7 @@
private void assertMapsEqual(MorphDeltaMap map1, MorphDeltaMap map2) {
assertEquals(map1.getName(), map2.getName());
+ assertEquals(map1.getParentName(), map2.getParentName());
assertEquals(map1.getVertexCount(), map2.getVertexCount());
assertEquals(map1.getRanges().length, map2.getRanges().length);
for (int i = 0; i < map1.getRanges().length; i++) {
Modified: maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph
===================================================================
--- maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph 2007-10-01 13:57:49 UTC (rev 461)
+++ maven/trunk/ogoglio-common/src/test/resources/sample-art3d/MorphTest1.ogmorph 2007-10-01 13:57:55 UTC (rev 462)
@@ -1,5 +1,6 @@
# MorphDeltaMap
-testMorph1
+name: testMorph1
+parent: parentMorph1
3 0.000000,0.000000,1.733333 0.000000,0.000000,1.600000 0.000000,0.000000,1.466667 0.000000,0.000000,1.333333 0.000000,0.000000,1.200000 0.000000,0.000000,1.066667 0.000000,0.000000,0.933333 0.000000,0.000000,0.800000 0.000000,0.000000,0.666667 0.000000,0.000000,0.533333 0.000000,0.000000,0.400000 0.000000,0.000000,0.266667
18 0.000000,0.000000,0.000000 0.000000,0.000000,0.133334 0.000000,0.000000,0.266667 0.000000,0.000000,0.400000 0.000000,0.000000,0.533334 0.000000,0.000000,0.666667 0.000000,0.000000,0.800000 0.000000,0.000000,0.933334 0.000000,0.000000,1.066667 0.000000,0.000000,1.200000 0.000000,0.000000,1.333334 0.000000,0.000000,1.466667 0.000000,0.000000,1.600000 0.000000,0.000000,1.733334
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-02 02:28:30
|
Revision: 465
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=465&view=rev
Author: trevorolio
Date: 2007-10-01 19:28:33 -0700 (Mon, 01 Oct 2007)
Log Message:
-----------
THIS CHECKIN REQUIRES A DB DROP
Introducing a new world of user configurable body settings. Ditched the old BodyRecord and created three new record types:
BodyDataRecords: hold information about the wadges of data which make up a body's base (e.g. mesh, morphs, textures...)
BodyConfigurationRecords: a user level representation of a body configuration, with a display name and a set of...
BodySettingRecords: morph interpolation values for a given body configuration (e.g. height, 0.9 or chin width, 0.2)
Halfway through documentifying and RESTifying these records. I can smell the day when this is autogenerated from annotated classes.
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/WebAPIDescriptor.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ArgumentUtils.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/body/Skin.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.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
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDataDocument.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodySettingDocument.java
Removed Paths:
-------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDocument.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-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -40,9 +40,7 @@
import com.ogoglio.message.TCPChannel;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.Log;
-import com.ogoglio.util.UIConstants;
import com.ogoglio.xml.AccountDocument;
-import com.ogoglio.xml.BodyDocument;
import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.ShapeDocument;
@@ -127,7 +125,7 @@
//can't use spaceDoc list of users because it doesn't include the user that just authed (me!)
UserDocument[] userDocs = webClient.getUserDocuments(spaceID);
for (int i = 0; i < userDocs.length; i++) {
- space.addUser(new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), userDocs[i].getBodyID()));
+ space.addUser(new User(space, userDocs[i].getUsername(), userDocs[i].getTransform()));
}
ThingDocument[] thingDocs = spaceDoc.getThingDocuments();
@@ -291,7 +289,7 @@
if (message.getPayload() instanceof PayloadFactory.SpaceEventPayload) {
SpaceEvent event = ((PayloadFactory.SpaceEventPayload) message.getPayload()).getSpaceEvent();
if (SpaceEvent.ADD_USER_EVENT.equals(event.getName())) {
- User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform(), event.getLongProperty(SpaceEvent.BODY_ID).longValue());
+ User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform());
space.addUser(user);
} else if (SpaceEvent.REMOVE_USER_EVENT.equals(event.getName())) {
User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
@@ -693,10 +691,6 @@
}
}
- public BodyDocument getBodyDocument(String username, long bodyID) throws IOException {
- return webClient.getBodyDocument(username, bodyID);
- }
-
public WebAPIClient getWebClient() {
return webClient;
}
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-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -29,7 +29,7 @@
import com.ogoglio.util.StreamUtils;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
-import com.ogoglio.xml.BodyDocument;
+import com.ogoglio.xml.BodyDataDocument;
import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.PossessionDocument;
@@ -59,7 +59,7 @@
}
public AccountDocument createAccount(String username, String accountLevel, String firstName, String lastName, String homepage, String email, String password) throws IOException {
- AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1);
+ AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE);
try {
XMLElement result = wire.sendAuthenticatedXML(descriptor.getAccountURI(), newAccountDoc.toString(), "POST", authenticator.getAuthCookie());
return new AccountDocument(result);
@@ -464,50 +464,20 @@
return wire.sendDelete(descriptor.getSettingURI(spaceID, key), authenticator.getAuthCookie());
}
- public BodyDocument getBodyDocument(String username, long bodyID) throws IOException {
- return new BodyDocument(wire.fetchAuthenticatedXML(descriptor.getBodyURI(username, bodyID), authenticator.getAuthCookie()));
+ public BodyDataDocument createBodyData(String displayName, String fileName) throws IOException {
+ BodyDataDocument doc = new BodyDataDocument(-1, displayName, fileName);
+ XMLElement result = wire.sendAuthenticatedXML(descriptor.getBodiesURI(), doc.toString(), "POST", authenticator.getAuthCookie());
+ return new BodyDataDocument(result);
}
- public BodyDocument[] getBodyDocuments(String username) throws IOException {
- Vector results = new Vector();
-
- XMLElement list = wire.fetchAuthenticatedXML(descriptor.getBodiesURI(username), authenticator.getAuthCookie());
- XMLElement[] children = (XMLElement[]) list.getChildren().toArray(new XMLElement[0]);
- for (int i = 0; i < children.length; i++) {
- results.add(new BodyDocument(children[i]));
- }
-
- return (BodyDocument[]) results.toArray(new BodyDocument[0]);
+ public BodyDataDocument getBodyDataDocument(long bodyDataID) throws IOException {
+ return new BodyDataDocument(wire.fetchAuthenticatedXML(descriptor.getBodyDataDocumentURI(bodyDataID), authenticator.getAuthCookie()));
}
- public BodyDocument createBody(String bodyName) throws IOException {
- BodyDocument bodyDoc = new BodyDocument(-1, authenticator.getUsername(), bodyName, 0, 0, 0, 0, 0, false, 2, 1);
- XMLElement element = wire.postAuthenticatedXML(descriptor.getBodiesURI(authenticator.getUsername()), bodyDoc.toString(), authenticator.getAuthCookie());
- if (element == null) {
- return null;
- }
- return new BodyDocument(element);
+ public void deleteBodyData(long bodyDataID) throws IOException {
+ wire.sendDelete(descriptor.getBodyDataDocumentURI(bodyDataID), authenticator.getAuthCookie());
}
- public BodyDocument updateBody(BodyDocument bodyDoc) throws IOException {
- XMLElement xml = wire.postAuthenticatedXML(descriptor.getBodyURI(bodyDoc.getOwnerUsername(), bodyDoc.getBodyID()), bodyDoc.toString(), authenticator.getAuthCookie());
- return new BodyDocument(xml);
- }
-
- public AccountDocument setDefaultBody(long bodyID) throws IOException {
- AccountDocument newDoc = new AccountDocument(authenticator.getUsername());
- newDoc.setDefaultBodyID(bodyID);
- XMLElement element = wire.postAuthenticatedXML(descriptor.getAccountURI(newDoc.getUsername()), newDoc.toString(), authenticator.getAuthCookie());
- if (element == null) {
- return null;
- }
- return new AccountDocument(element);
- }
-
- public boolean deleteBody(long bodyID) throws IOException {
- return wire.sendDelete(descriptor.getBodyURI(authenticator.getUsername(), bodyID), authenticator.getAuthCookie());
- }
-
public ZipInputStream getBodyData(String bodyName) throws IOException {
InputStream stream = wire.fetchAuthenticatedStream(descriptor.getBodyDataURI(bodyName), authenticator.getAuthCookie());
if(stream == null){
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -115,12 +115,12 @@
return WebAPIUtil.appendToURI(getSpaceURI(spaceID), "user/");
}
- public URI getBodiesURI(String username) {
- return WebAPIUtil.appendToURI(getAccountURI(username), "body/");
+ public URI getBodiesURI() {
+ return WebAPIUtil.appendToURI(getSpacesURI(), "body/");
}
- public URI getBodyURI(String username, long bodyID) {
- return WebAPIUtil.appendToURI(getBodiesURI(username), bodyID + "/");
+ public URI getBodyDataDocumentURI(long bodyDataID) {
+ return WebAPIUtil.appendToURI(getBodiesURI(), bodyDataID + "/");
}
public URI getBodyDataURI(String bodyName) {
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -1,86 +0,0 @@
-package com.ogoglio.client.model;
-
-public class Body {
-
- private long bodyID = -1;
-
- private int hair = -1;
-
- private int eyes = -1;
-
- private int nose = -1;
-
- private int mouth = -1;
-
- private int face = -1;
-
- private boolean male = false;
-
- private float height = 2;
-
- private float girth = 1;
-
- public Body(long bodyID, int hair, int eyes, int nose, int mouth, int face, boolean isMale, float height, float girth) {
- this.bodyID = bodyID;
- this.hair = hair;
- this.eyes = eyes;
- this.nose = nose;
- this.mouth = mouth;
- this.face = face;
- this.male = isMale;
- this.height = height;
- this.girth = girth;
- }
-
- public long getBodyID() {
- return bodyID;
- }
-
- public int getEyes() {
- return eyes;
- }
-
- public int getFace() {
- return face;
- }
-
- public int getHair() {
- return hair;
- }
-
- public int getMouth() {
- return mouth;
- }
-
- public int getNose() {
- return nose;
- }
-
- public void set(int hairIndex, int eyesIndex, int noseIndex, int mouthIndex, int faceIndex) {
- this.hair = hairIndex;
- this.eyes = eyesIndex;
- this.nose = noseIndex;
- this.mouth = mouthIndex;
- this.face = faceIndex;
- }
-
- public boolean isMale() {
- return male;
- }
-
- public float getHeight() {
- return height;
- }
-
- public void setHeight(float height) {
- this.height = height;
- }
-
- public float getGirth() {
- return girth;
- }
-
- public void setMale(boolean male) {
- this.male = male;
- }
-}
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-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -26,8 +26,6 @@
import javax.vecmath.Vector3d;
import com.ogoglio.util.ArgumentUtils;
-import com.ogoglio.util.Log;
-import com.ogoglio.xml.BodyDocument;
public class Space {
@@ -212,8 +210,6 @@
public InputStream getPageContentStream(long thingID, long pageID);
- public BodyDocument getBodyDocument(String username, long bodyID) throws IOException;
-
}
public long getSpaceID() {
@@ -501,12 +497,4 @@
public InputStream getPageContentStream(long thingID, long pageID) throws IOException {
return spaceContext.getPageContentStream(thingID, pageID);
}
-
- public Body getBody(String username, long bodyID) throws IOException {
- if (bodyID < 0) {
- return new Body(-1, 0, 0, 0, 0, 0, false, 2, 0);
- }
- BodyDocument bodyDoc = spaceContext.getBodyDocument(username, bodyID);
- return new Body(bodyDoc.getBodyID(), bodyDoc.getHairIndex(), bodyDoc.getEyesIndex(), bodyDoc.getNoseIndex(), bodyDoc.getMouthIndex(), bodyDoc.getFaceIndex(), bodyDoc.isMale(), bodyDoc.getHeight(), bodyDoc.getGirth());
- }
}
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-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -28,25 +28,17 @@
private Transform3D position = null;
- private Body body = null;
-
private long pathStarted = -1;
private SplinePath path = null;
- public User(Space space, String username, Transform3D position, long bodyID) {
+ public User(Space space, String username, Transform3D position) {
ArgumentUtils.assertNotNull(space);
this.space = space;
ArgumentUtils.assertNotNull(username);
this.username = username;
ArgumentUtils.assertNotNull(position);
this.position = position;
- try {
- body = space.getBody(username, bodyID);
- } catch (IOException e) {
- e.printStackTrace();
- body = new Body(-1, 0, 0, 0, 0, 0, false, 2, 1);
- }
}
public void startMotion(SplinePath path) {
@@ -74,10 +66,6 @@
return position;
}
- public Body getBody() {
- return body;
- }
-
public Space getSpace() {
return space;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/message/PayloadFactory.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -238,10 +238,8 @@
public static final String USERNAME = "username";
- public static final String BODY_ID = "bodyID";
-
- public AuthenticatedPayload(String username, long bodyID) {
- super(create(username, bodyID));
+ public AuthenticatedPayload(String username) {
+ super(create(username));
}
public AuthenticatedPayload(XMLElement data) {
@@ -252,16 +250,11 @@
return getData().getStringAttribute(USERNAME);
}
- public static XMLElement create(String username, long bodyID) {
+ public static XMLElement create(String username) {
XMLElement data = new XMLElement(NAME);
data.setAttribute(USERNAME, username);
- data.setAttribute(BODY_ID, bodyID);
return data;
}
-
- public long getBodyID() {
- return getData().getLongAttribute(BODY_ID);
- }
}
// This is sent to the space simulator when a client logs out
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ArgumentUtils.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ArgumentUtils.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/util/ArgumentUtils.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -37,8 +37,8 @@
}
}
- public static void assertNotNegative(float skinRed) {
- if (skinRed < 0) {
+ public static void assertNotNegative(float value) {
+ if (value < 0) {
throw new IllegalArgumentException("Argument was less than zero");
}
}
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-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -19,14 +19,12 @@
import javax.media.j3d.Billboard;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
-import javax.media.j3d.GeometryArray;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;
-import com.ogoglio.client.model.Body;
import com.ogoglio.client.model.User;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.BodyConstants;
@@ -37,7 +35,6 @@
import com.ogoglio.viewer.j3d.body.SkinLoader;
import com.ogoglio.viewer.j3d.bvh.Bvh;
import com.ogoglio.viewer.j3d.smap.SkinMap;
-import com.ogoglio.viewer.j3d.smap.SkinMapParser;
import com.ogoglio.viewer.render.Camera;
import com.ogoglio.viewer.render.UserRenderable;
import com.sun.j3d.utils.geometry.Text2D;
@@ -95,7 +92,7 @@
private void initBody() {
bodyGroup.removeAllChildren();
- skin = new SkinLoader(bodyData, user.getBody()).generateSkin();
+ skin = new SkinLoader(bodyData).generateSkin();
userHeight = skin.getHeight();
skinMap = bodyData.getSkinMap();
@@ -225,8 +222,7 @@
}
public void repaintSkinTexture() {
- Body body = user.getBody();
- skin.updateTexture(body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale());
+ skin.updateTexture();
}
public synchronized void stopAnimation() {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -53,7 +53,7 @@
private SkinUpdater skinUpdater = null;
- public Skin(int hair, int eyes, int nose, int mouth, int face, boolean isMale, BufferedImage baseImage) {
+ public Skin(BufferedImage baseImage) {
setCapability(Skin.ALLOW_APPEARANCE_WRITE);
setCapability(Skin.ALLOW_PICKABLE_READ);
setCapability(Skin.ALLOW_GEOMETRY_READ);
@@ -68,7 +68,7 @@
texture.getImage(0).setCapability(ImageComponent.ALLOW_IMAGE_READ);
texture.getImage(0).setCapability(ImageComponent.ALLOW_IMAGE_WRITE);
- updateTexture(hair, eyes, nose, mouth, face, isMale);
+ updateTexture();
Appearance appearance = new Appearance();
TextureAttributes textureAtts = new TextureAttributes();
@@ -88,17 +88,7 @@
private class TextureUpdater implements ImageComponent2D.Updater {
- int hair, eyes, nose, mouth, face;
-
- boolean isMale = false;
-
- public TextureUpdater(int hair, int eyes, int nose, int mouth, int face, boolean isMale) {
- this.hair = hair;
- this.eyes = eyes;
- this.nose = nose;
- this.mouth = mouth;
- this.face = face;
- this.isMale = isMale;
+ public TextureUpdater() {
}
public void updateData(ImageComponent2D imageComp, int arg1, int arg2, int arg3, int arg4) {
@@ -107,32 +97,16 @@
}
Graphics g = imageComp.getImage().getGraphics();
g.drawImage(baseImage, 0, 0, null);
-
- /*
- Image[] baseTextures = isMale ? BodyConstants.MALE_BASE_SKIN_TEXTURES : BodyConstants.FEMALE_BASE_SKIN_TEXTURES;
- if (face >= 0 && face < baseTextures.length) {
- g.drawImage(baseTextures[face], 0, 0, null);
- }
- if (eyes >= 0 && eyes < BodyConstants.EYES.length) {
- g.drawImage(BodyConstants.EYES[eyes], 111, 90, 75, 37, null);
- }
- if (nose >= 0 && nose < BodyConstants.NOSES.length) {
- g.drawImage(BodyConstants.NOSES[nose], 135, 105, 25, 50, null);
- }
- if (mouth >= 0 && mouth < BodyConstants.MOUTHES.length) {
- g.drawImage(BodyConstants.MOUTHES[mouth], 121, 151, 50, 25, null);
- }
- */
}
}
- public void updateTexture(int hair, int eyes, int nose, int mouth, int face, boolean isMale) {
+ public void updateTexture() {
if(baseImage == null){
return;
}
ImageComponent2D imageComp = (ImageComponent2D) texture.getImage(0);
- imageComp.updateData(new TextureUpdater(hair, eyes, nose, mouth, face, isMale), 0, 0, baseImage.getWidth(), baseImage.getHeight());
+ imageComp.updateData(new TextureUpdater(), 0, 0, baseImage.getWidth(), baseImage.getHeight());
}
public void setGeometry(Geometry geo) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -19,24 +19,22 @@
import javax.media.j3d.GeometryArray;
import javax.vecmath.Vector3f;
-import com.ogoglio.client.model.Body;
import com.ogoglio.viewer.j3d.J3DBodyData;
public class SkinLoader {
+
+ public static final float AVATAR_SIZE = 2; //this will eventually be changable
private GeometryArray geometry = null;
- private Body body = null;
-
private BufferedImage baseImage;
private MorphDeltaMap[] morphDeltaMaps = null;
- public SkinLoader(J3DBodyData bodyData, Body body) {
+ public SkinLoader(J3DBodyData bodyData) {
this.geometry = bodyData.cloneBodyGeometry();
this.morphDeltaMaps = bodyData.getMorphDeltaMaps();
this.baseImage = bodyData.getBaseTexture();
- this.body = body;
}
public Skin generateSkin() {
@@ -64,7 +62,7 @@
maxY = vertices[i];
}
}
- float heightScale = body.getHeight() / Math.abs(maxY - minY);
+ float heightScale = AVATAR_SIZE / Math.abs(maxY - minY);
if (Math.abs(heightScale) > 0.1) {
for (int i = 0; i < vertices.length - 2; i += 3) {
vertices[i] = vertices[i] * heightScale;
@@ -73,7 +71,7 @@
}
}
- Skin skin = new Skin(body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale(), baseImage);
+ Skin skin = new Skin(baseImage);
skin.setGeometry(geometry);
return skin;
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java 2007-10-02 02:28:24 UTC (rev 464)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -53,11 +53,9 @@
public static final String FROZEN_UNTIL = "frozenuntil";
- private static final String DEFAULT_BODY_ID = "defaultbodyid";
-
XMLElement data = null;
- public AccountDocument(String username, String accountLevel, String firstName, String lastName, String homepage, String password, String email, long creationDate, String cookie, long frozenUntil, long defaultBodyID) {
+ public AccountDocument(String username, String accountLevel, String firstName, String lastName, String homepage, String password, String email, long creationDate, String cookie, long frozenUntil) {
data = new XMLElement(NAME);
if (username == null) {
@@ -86,8 +84,6 @@
data.setAttribute(CREATION_DATE, creationDate);
if (frozenUntil!=AccountDocument.NO_TIME_VALUE)
data.setAttribute(FROZEN_UNTIL, frozenUntil);
- if(defaultBodyID > -1)
- data.setAttribute(DEFAULT_BODY_ID, defaultBodyID);
}
public AccountDocument(XMLElement data) {
@@ -101,7 +97,7 @@
}
public AccountDocument(String username) { //used when updating the document, with absent items indicating no change
- this(username, null, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, 1);
+ this(username, null, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE);
}
public XMLElement toElement() {
@@ -172,18 +168,6 @@
}
}
- public long getDefaultBodyID() {
- return data.getLongAttribute(DEFAULT_BODY_ID, -1);
- }
-
- public void setDefaultBodyID(long bodyID) {
- if(bodyID != -1) {
- data.setAttribute(DEFAULT_BODY_ID, bodyID);
- } else {
- data.removeAttribute(DEFAULT_BODY_ID);
- }
- }
-
public int hashCode() {
return getUsername().hashCode();
}
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java 2007-10-02 02:28:33 UTC (rev 465)
@@ -0,0 +1,88 @@
+/* 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.xml;
+
+import nanoxml.XMLElement;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class BodyConfigurationDocument {
+
+ public static final String NAME = "bodyconfiguration";
+
+ private static final String BODY_CONFIGURATION_ID = "bodyconfigurationid";
+
+ private static final String OWNER_USERNAME = "ownerusername";
+
+ public static final String DISPLAY_NAME = "displayname";
+
+ public static final String BODY_DATA_ID = "bodydataid";
+
+ private XMLElement data = null;
+
+ public BodyConfigurationDocument(long bodyConfigurationID, String ownerUsername, String displayName, long bodyDataID) {
+ data = new XMLElement(NAME);
+ data.setAttribute(BODY_CONFIGURATION_ID, bodyDataID);
+ ArgumentUtils.assertNotEmpty(ownerUsername);
+ data.setAttribute(OWNER_USERNAME, ownerUsername);
+ ArgumentUtils.assertNotNull(displayName);
+ data.setAttribute(DISPLAY_NAME, displayName);
+ ArgumentUtils.assertNotNegative(bodyDataID);
+ data.setAttribute(BODY_DATA_ID, bodyDataID);
+ }
+
+ public BodyConfigurationDocument(XMLElement data) {
+ if (!NAME.equals(data.getName())) {
+ throw new IllegalArgumentException("data is not named " + NAME + ": " + data);
+ }
+ this.data = data;
+ }
+
+ public long getBodyConfigurationID(){
+ return data.getLongAttribute(BODY_CONFIGURATION_ID);
+ }
+
+ public String getDisplayName(){
+ return data.getStringAttribute(DISPLAY_NAME);
+ }
+
+ public String getOwnerUsername(){
+ return data.getStringAttribute(OWNER_USERNAME);
+ }
+
+ public long getBodyDataID(){
+ return data.getLongAttribute(BODY_CONFIGURATION_ID);
+ }
+
+ public void addBodySetting(long bodySettingID, String settingName, long setting) {
+ data.addChild(new BodySettingDocument(bodySettingID, getBodyConfigurationID(), settingName, setting).toElement());
+ }
+
+ public BodySettingDocument[]...
[truncated message content] |
|
From: <tre...@us...> - 2007-10-04 06:30:35
|
Revision: 474
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=474&view=rev
Author: trevorolio
Date: 2007-10-03 23:30:38 -0700 (Wed, 03 Oct 2007)
Log Message:
-----------
Though there's no UI to set them, body rendering now respects body configuration for morphs.
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/WebAPIDescriptor.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyDataProvider.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataCache.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.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/body/SkinLoader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.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
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.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-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -23,6 +23,7 @@
import javax.media.j3d.Transform3D;
import javax.vecmath.Point3d;
+import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Door;
import com.ogoglio.client.model.Page;
@@ -40,7 +41,10 @@
import com.ogoglio.message.TCPChannel;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.Log;
+import com.ogoglio.util.WebConstants;
import com.ogoglio.xml.AccountDocument;
+import com.ogoglio.xml.BodyConfigurationDocument;
+import com.ogoglio.xml.BodyDataDocument;
import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.ShapeDocument;
@@ -125,7 +129,17 @@
//can't use spaceDoc list of users because it doesn't include the user that just authed (me!)
UserDocument[] userDocs = webClient.getUserDocuments(spaceID);
for (int i = 0; i < userDocs.length; i++) {
- space.addUser(new User(space, userDocs[i].getUsername(), userDocs[i].getTransform()));
+ BodyConfigurationDocument bodyConfDoc = null;
+ if (userDocs[i].getUsername().startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
+ System.out.println("Need to handle guest bodies correctly");
+ bodyConfDoc = new BodyConfigurationDocument(0, userDocs[i].getUsername(), "Body", 1);
+ } else {
+ bodyConfDoc = webClient.getBodyConfiguration(userDocs[i].getUsername(), userDocs[i].getBodyConfigurationID());
+ }
+ BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfDoc.getBodyConfigurationID(), bodyConfDoc.getDisplayName(), bodyConfDoc.getBodyDataID());
+ User user = new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), bodyConfig);
+ bodyConfig.setUser(user);
+ space.addUser(user);
}
ThingDocument[] thingDocs = spaceDoc.getThingDocuments();
@@ -289,7 +303,9 @@
if (message.getPayload() instanceof PayloadFactory.SpaceEventPayload) {
SpaceEvent event = ((PayloadFactory.SpaceEventPayload) message.getPayload()).getSpaceEvent();
if (SpaceEvent.ADD_USER_EVENT.equals(event.getName())) {
- User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform());
+ BodyConfigurationDocument bodyConfigDoc = event.getBodyConfigurationDocument();
+ BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfigDoc);
+ User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform(), bodyConfig);
space.addUser(user);
} else if (SpaceEvent.REMOVE_USER_EVENT.equals(event.getName())) {
User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
@@ -701,11 +717,12 @@
private class NetworkBodyDataProvider implements BodyDataProvider {
- public ZipInputStream getBodyData(String bodyName) {
+ public ZipInputStream getBodyData(long bodyDataID) {
try {
- return webClient.getBodyData(bodyName);
+ BodyDataDocument dataDoc = webClient.getBodyDataDocument(bodyDataID);
+ return webClient.getBodyData(dataDoc.getFileName());
} catch (IOException e) {
- Log.warn("Requested an unknown body: " + bodyName);
+ Log.warn("Requested an unknown body: " + bodyDataID);
return null;
}
}
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-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -479,8 +479,8 @@
wire.sendDelete(descriptor.getBodyDataDocumentURI(bodyDataID), authenticator.getAuthCookie());
}
- public ZipInputStream getBodyData(String bodyName) throws IOException {
- InputStream stream = wire.fetchAuthenticatedStream(descriptor.getBodyDataURI(bodyName), authenticator.getAuthCookie());
+ public ZipInputStream getBodyData(String fileName) throws IOException {
+ InputStream stream = wire.fetchAuthenticatedStream(descriptor.getBodyDataURI(fileName), authenticator.getAuthCookie());
if (stream == null) {
return null;
}
@@ -528,4 +528,8 @@
public WebAPIClientWire getWire() {
return wire;
}
+
+ public BodyConfigurationDocument getDefaultBodyConfiguration(String username) throws IOException {
+ return new BodyConfigurationDocument(wire.fetchAuthenticatedXML(descriptor.getDefaultBodyConfiguration(username), authenticator.getAuthCookie()));
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2007-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIDescriptor.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -123,8 +123,8 @@
return WebAPIUtil.appendToURI(getBodiesURI(), bodyDataID + "/");
}
- public URI getBodyDataURI(String bodyName) {
- return WebAPIUtil.appendToURI(serviceURI, "ogoglio-body-" + bodyName + ".jar");
+ public URI getBodyDataURI(String fileName) {
+ return WebAPIUtil.appendToURI(serviceURI, fileName);
}
public URI getBodyConfigurationsURI(String username) {
@@ -135,6 +135,10 @@
return WebAPIUtil.appendToURI(getBodyConfigurationsURI(username), bodyConfigurationID + "/");
}
+ public URI getDefaultBodyConfiguration(String username) {
+ return WebAPIUtil.appendToURI(getBodyConfigurationsURI(username), "default/");
+ }
+
public URI getPagesURI(long spaceID, long thingID) {
return WebAPIUtil.appendToURI(getThingURI(spaceID, thingID), "page/");
}
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -0,0 +1,82 @@
+package com.ogoglio.client.model;
+
+import java.util.HashMap;
+
+import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.xml.BodyConfigurationDocument;
+import com.ogoglio.xml.BodySettingDocument;
+
+public class BodyConfiguration {
+
+ private User user = null;
+
+ private long bodyConfigurationID = -1;
+
+ private String displayName = null;
+
+ private long bodyDataID = -1;
+
+ private HashMap settings = new HashMap();
+
+ public BodyConfiguration(BodyConfigurationDocument configDoc){
+ this(configDoc.getBodyConfigurationID(), configDoc.getDisplayName(), configDoc.getBodyDataID());
+ BodySettingDocument[] settingDocs = configDoc.getBodySettingDocuments();
+ for (int i = 0; i < settingDocs.length; i++) {
+ addSetting(settingDocs[i].getSettingName(), settingDocs[i].getSetting());
+ }
+ }
+
+ public BodyConfiguration(long bodyConfigurationID, String displayName, long bodyDataID){
+ ArgumentUtils.assertNotNegative(bodyConfigurationID);
+ this.bodyConfigurationID = bodyConfigurationID;
+ ArgumentUtils.assertNotEmpty(displayName);
+ this.displayName = displayName;
+ ArgumentUtils.assertNotNegative(bodyDataID);
+ this.bodyDataID = bodyDataID;
+ }
+
+ public void setUser(User user){
+ ArgumentUtils.assertNotNull(user);
+ this.user = user;
+ }
+
+ public void addSetting(String settingName, float setting){
+ ArgumentUtils.assertNotEmpty(settingName);
+ if(setting < 0){
+ setting = 0;
+ }
+ if(setting > 1){
+ setting = 1;
+ }
+ settings.put(settingName, new Float(setting));
+ }
+
+ public void removeSetting(String settingName){
+ settings.remove(settingName);
+ }
+
+ public float getSetting(String settingName){
+ Float setting = (Float)settings.get(settingName);
+ if(setting == null){
+ return 0;
+ }
+ return setting.floatValue();
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public long getBodyConfigurationID() {
+ return bodyConfigurationID;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public long getBodyDataID() {
+ return bodyDataID;
+ }
+
+}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyDataProvider.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyDataProvider.java 2007-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyDataProvider.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -4,6 +4,6 @@
public interface BodyDataProvider {
- public ZipInputStream getBodyData(String bodyName);
+ public ZipInputStream getBodyData(long bodyDataID);
}
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-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -14,8 +14,6 @@
package com.ogoglio.client.model;
-import java.io.IOException;
-
import javax.media.j3d.Transform3D;
import com.ogoglio.util.ArgumentUtils;
@@ -32,13 +30,17 @@
private SplinePath path = null;
- public User(Space space, String username, Transform3D position) {
+ private BodyConfiguration bodyConfiguration = null;
+
+ public User(Space space, String username, Transform3D position, BodyConfiguration bodyConfiguration) {
ArgumentUtils.assertNotNull(space);
this.space = space;
ArgumentUtils.assertNotNull(username);
this.username = username;
ArgumentUtils.assertNotNull(position);
this.position = position;
+ ArgumentUtils.assertNotNull(bodyConfiguration);
+ this.bodyConfiguration = bodyConfiguration;
}
public void startMotion(SplinePath path) {
@@ -58,6 +60,10 @@
space.notifyUserAnimationStarted(this, animationName);
}
+ public BodyConfiguration getBodyConfiguration(){
+ return bodyConfiguration;
+ }
+
public String toString() {
return "User: " + username;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataCache.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataCache.java 2007-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataCache.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -17,7 +17,7 @@
public class J3DDataCache {
- private HashMap bodyDataMap = new HashMap(); //maps body names to J3DBodyData objects
+ private HashMap bodyDataMap = new HashMap(); //maps body IDs to J3DBodyData objects
private HashMap templateDataMap = new HashMap(); //maps template guid to J3DTemplateData objects
@@ -25,12 +25,12 @@
return (J3DTemplateData) templateDataMap.get(createTemplateGUID(templateID, lod));
}
- public void putBodyData(String bodyName, J3DBodyData data){
- bodyDataMap.put(bodyName, data);
+ public void putBodyData(long bodyDataID, J3DBodyData data){
+ bodyDataMap.put(new Long(bodyDataID), data);
}
- public J3DBodyData getBodyData(String bodyName){
- return (J3DBodyData)bodyDataMap.get(bodyName);
+ public J3DBodyData getBodyData(long bodyDataID){
+ return (J3DBodyData)bodyDataMap.get(new Long(bodyDataID));
}
public void putTemplateData(long templateID, int lod, J3DTemplateData entry) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -89,13 +89,13 @@
this.bodyDataProvider = bodyDataProvider;
}
- public J3DBodyData getBodyData(String bodyName) {
- J3DBodyData data = dataCache.getBodyData(bodyName);
+ public J3DBodyData getBodyData(long bodyDataID) {
+ J3DBodyData data = dataCache.getBodyData(bodyDataID);
if (data != null) {
return data;
}
- ZipInputStream bodyDataInput = bodyDataProvider.getBodyData(bodyName);
+ ZipInputStream bodyDataInput = bodyDataProvider.getBodyData(bodyDataID);
if (bodyDataInput == null) {
throw new IllegalStateException("Trevor didn't implement an error body for an unknown body name");
}
@@ -104,8 +104,8 @@
if (bodyData == null) {
throw new IllegalStateException("Trevor didn't implement an error body for an illegible body");
}
- System.out.println("Morph count: " + bodyData.getMorphDeltaMaps().length);
- dataCache.putBodyData(bodyName, bodyData);
+
+ dataCache.putBodyData(bodyDataID, bodyData);
return bodyData;
}
@@ -510,11 +510,9 @@
Log.error("Error parsing obj: " + e);
}
if (!gotObj) {
- System.err.println("didn't get obj for template " + templateID);
try {
ObjParser parser = new ObjParser(UIConstants.getResource("templates/loading.obj"));
objs[0] = parser.parse();
- System.err.println("Set error obj");
} catch (Exception e) {
e.printStackTrace();
}
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-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -38,6 +38,7 @@
import com.ogoglio.client.SpaceClient;
import com.ogoglio.client.UserInputListener;
+import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Door;
import com.ogoglio.client.model.Page;
@@ -615,14 +616,15 @@
}
private UserRenderable createUserRenderable(User user) throws IOException, RenderableParseException {
- J3DBodyData bodyData = dataManager.getBodyData("mike");
+ BodyConfiguration bodyConfig = user.getBodyConfiguration();
+ J3DBodyData bodyData = dataManager.getBodyData(bodyConfig.getBodyDataID());
+ if(rendererStopped){ //this happens sometimes when someone logs in and then a space is cleaned up (usually during testing)
+ return null;
+ }
if(bodyData == null){
throw new IllegalStateException("Cannot load body data");
}
- if(rendererStopped){ //this happens sometimes when someone logs in and then a space is cleaned up (usually during testing)
- return null;
- }
- System.out.println("Trevor needs to allow bodyData other than mike");
+
boolean isLocalUser = !offScreen && username != null && user.getUsername().equals(username);
final J3DUserRenderable renderable = new J3DUserRenderable(user, bodyData);
renderable.setID(USER_ID_PREFIX + user.getUsername());
@@ -750,10 +752,8 @@
public double getLandHeight(double x, double z, double pickHeight) {
pickStart.set(x, pickHeight, z);
if (picker.pickRayClosest(pickStart, DOWN_VEC, intersectionPoint) == null) {
- //System.out.println("no land height: 0!");
return 0;
}
- //System.out.println("intersected with land: "+intersectionPoint.y);
return intersectionPoint.y;
}
}
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-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -92,7 +92,7 @@
private void initBody() {
bodyGroup.removeAllChildren();
- skin = new SkinLoader(bodyData).generateSkin();
+ skin = new SkinLoader(bodyData, user.getBodyConfiguration()).generateSkin();
userHeight = skin.getHeight();
skinMap = bodyData.getSkinMap();
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -19,6 +19,7 @@
import javax.media.j3d.GeometryArray;
import javax.vecmath.Vector3f;
+import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.viewer.j3d.J3DBodyData;
public class SkinLoader {
@@ -29,25 +30,32 @@
private BufferedImage baseImage;
+ private BodyConfiguration bodyConfiguration = null;
+
private MorphDeltaMap[] morphDeltaMaps = null;
- public SkinLoader(J3DBodyData bodyData) {
+ public SkinLoader(J3DBodyData bodyData, BodyConfiguration bodyConfiguration) {
this.geometry = bodyData.cloneBodyGeometry();
this.morphDeltaMaps = bodyData.getMorphDeltaMaps();
this.baseImage = bodyData.getBaseTexture();
+ this.bodyConfiguration = bodyConfiguration;
}
public Skin generateSkin() {
float[] vertices = geometry.getCoordRefFloat();
for (int i = 0; i < morphDeltaMaps.length; i++) {
+ float setting = bodyConfiguration.getSetting(morphDeltaMaps[i].getName());
+ if(setting <= 0.0001){
+ continue;
+ }
MorphDeltaMap.Range[] ranges = morphDeltaMaps[i].getRanges();
for (int r = 0; r < ranges.length; r++) {
Vector3f[] deltas = ranges[r].getDeltas();
for (int d = 0; d < deltas.length; d++) {
int index = (ranges[r].getLower() - 1 + d) * 3;
- vertices[index] = vertices[index] + deltas[d].x;
- vertices[index + 1] = vertices[index + 1] + deltas[d].y;
- vertices[index + 2] = vertices[index + 2] + deltas[d].z;
+ vertices[index] = vertices[index] + (deltas[d].x * setting);
+ vertices[index + 1] = vertices[index + 1] + (deltas[d].y * setting);
+ vertices[index + 2] = vertices[index + 2] + (deltas[d].z * setting);
}
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java 2007-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -33,7 +33,7 @@
public BodyConfigurationDocument(long bodyConfigurationID, String ownerUsername, String displayName, long bodyDataID) {
data = new XMLElement(NAME);
- data.setAttribute(BODY_CONFIGURATION_ID, bodyDataID);
+ data.setAttribute(BODY_CONFIGURATION_ID, bodyConfigurationID);
ArgumentUtils.assertNotEmpty(ownerUsername);
data.setAttribute(OWNER_USERNAME, ownerUsername);
ArgumentUtils.assertNotNull(displayName);
@@ -62,7 +62,7 @@
}
public long getBodyDataID(){
- return data.getLongAttribute(BODY_CONFIGURATION_ID);
+ return data.getLongAttribute(BODY_DATA_ID);
}
public void addBodySetting(String settingName, float setting) {
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-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -25,6 +25,7 @@
import nanoxml.XMLElement;
+import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.SplinePath;
import com.ogoglio.util.ContextMenuItemInfo;
import com.ogoglio.viewer.j3d.J3DSplinePath;
@@ -81,7 +82,7 @@
public static final String USERNAME = "userID";
- public static final String BODY_ID = "bodyID";
+ public static final String BODY_CONFIGURATION_ID = "bodyConfigurationID";
public static final String THING_ID = "thingID";
@@ -227,6 +228,8 @@
private SplinePath splinePath = null;
+ private BodyConfigurationDocument bodyConfigDoc = null;
+
private String html = null;
private Vector contextMenu = new Vector();
@@ -264,6 +267,11 @@
splinePath = new SplinePathDocument(splinePathElement).getSplinePath();
}
+ XMLElement bodyConfigElement = element.getChild(BodyConfigurationDocument.NAME);
+ if (bodyConfigElement != null) {
+ bodyConfigDoc = new BodyConfigurationDocument(bodyConfigElement);
+ }
+
XMLElement htmlElement = element.getChild(HtmlElement.NAME);
if (htmlElement != null) {
HtmlElement ele = new HtmlElement(htmlElement);
@@ -354,7 +362,7 @@
String[] keys = getKeys();
for (int i = 0; i < keys.length; i++) {
Object value = properties.get(keys[i]);
- if(value == null){
+ if (value == null) {
continue;
}
XMLElement property = new XMLElement(PROPERTY);
@@ -384,12 +392,17 @@
element.addChild(new SplinePathDocument((J3DSplinePath) splinePath).toElement());
}
+ if (bodyConfigDoc != null) {
+ element.addChild(bodyConfigDoc.toElement());
+ }
+
if (html != null) {
element.addChild(new HtmlElement(html).toElement());
}
- if (contextMenu!=null) {
- for (int i=0; i<contextMenu.size();++i) {
- ContextMenuItemInfo info=(ContextMenuItemInfo)contextMenu.get(i);
+
+ if (contextMenu != null) {
+ for (int i = 0; i < contextMenu.size(); ++i) {
+ ContextMenuItemInfo info = (ContextMenuItemInfo) contextMenu.get(i);
XMLElement item = new XMLElement();
item.setName(CONTEXT_MENU_DATA_ITEM);
item.setAttribute(CONTEXT_MENU_DATA_ITEM_TEXT, info.getUserVisibleString());
@@ -437,6 +450,10 @@
return splinePath;
}
+ public BodyConfigurationDocument getBodyConfigurationDocument(){
+ return bodyConfigDoc;
+ }
+
public void setSplinePath(SplinePath path) {
this.splinePath = path;
}
@@ -480,4 +497,8 @@
public String toString() {
return toElement().toString();
}
+
+ public void setBodyConfigurationDocument(BodyConfigurationDocument bodyConfigurationDocument) {
+ bodyConfigDoc = bodyConfigurationDocument;
+ }
}
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-10-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/UserDocument.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -26,14 +26,19 @@
public static final String USERNAME = "username";
+ public static final String BODY_CONFIGURATION_ID = "bodyconfigurationid";
+
public UserDocument(User user) {
- this(user.getUsername(), user.getPosition(), user.getSplinePath());
+ this(user.getUsername(), user.getPosition(), user.getSplinePath(), user.getBodyConfiguration().getBodyConfigurationID());
}
- public UserDocument(String username, Transform3D transform, SplinePath splinePath) {
+ public UserDocument(String username, Transform3D transform, SplinePath splinePath, long bodyConfigurationID) {
super(NAME, transform, splinePath);
ArgumentUtils.assertNotNull(username);
getData().setAttribute(USERNAME, username);
+ if (bodyConfigurationID >= 0) {
+ getData().setAttribute(BODY_CONFIGURATION_ID, bodyConfigurationID);
+ }
}
public UserDocument(XMLElement data) {
@@ -47,4 +52,8 @@
public String getUsername() {
return getData().getStringAttribute(USERNAME);
}
+
+ public long getBodyConfigurationID() {
+ return getData().getLongAttribute(BODY_CONFIGURATION_ID);
+ }
}
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-03 16:22:31 UTC (rev 473)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-10-04 06:30:38 UTC (rev 474)
@@ -189,12 +189,14 @@
assertEquals(0, shapeMove1.getSplinePath().getSplineKeyFrames()[1].getKnot(), keyFrames[1].getKnot());
assertEquals(shapeMove1.getShapeName(), "a_shape");
- UserDocument userDoc = new UserDocument(username, new Transform3D(), null);
+ UserDocument userDoc = new UserDocument(username, new Transform3D(), null, 23);
assertEquals(username, userDoc.getUsername());
-
+ assertEquals(23, userDoc.getBodyConfigurationID());
+
userDoc = new UserDocument(XMLElement.parseElementFromString(userDoc.toString()));
assertEquals(username, userDoc.getUsername());
-
+ assertEquals(23, userDoc.getBodyConfigurationID());
+
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-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.
|
|
From: <tre...@us...> - 2007-10-18 18:57:09
|
Revision: 510
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=510&view=rev
Author: trevorolio
Date: 2007-10-18 11:57:11 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
Two thirds of the way to sitting:
Added a "Sit Here" context menu item for things made from templates with seat metadata.
Bound the avatar renderable to the seat thing renderable's transform group (hello, flying sofa).
If an avatar moves or teleports while seated, it stands.
Tried to be somewhat good about progressive loading, showing standing avatars before things and then sitting avatars.
Not yet done:
Call the sit animation.
Add seat metadata UI to the template editor HTML.
Make a flying Le Corbusier sofa with info panel controls.
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/Space.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.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/J3DThingRenderable.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.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-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -104,8 +104,7 @@
//create the event channel and start queuing events
Object selector = AsyncProtoFactory.getDefaultInfo().getProxySpecificSelector();
- messageChannel = new TCPChannel(AsyncProtoFactory.getDefaultClient(serviceURI.getHost(), selector),
- messenger, true, new ChannelListener());
+ messageChannel = new TCPChannel(AsyncProtoFactory.getDefaultClient(serviceURI.getHost(), selector), messenger, true, new ChannelListener());
messenger.authenticate(authCookie);
long startWait = System.currentTimeMillis();
@@ -127,22 +126,6 @@
}
}
- //can't use spaceDoc list of users because it doesn't include the user that just authed (me!)
- UserDocument[] userDocs = webClient.getUserDocuments(spaceID);
- for (int i = 0; i < userDocs.length; i++) {
- BodyConfigurationDocument bodyConfDoc = null;
- if (userDocs[i].getUsername().startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
- System.out.println("Need to handle guest bodies correctly");
- bodyConfDoc = new BodyConfigurationDocument(0, userDocs[i].getUsername(), "Body", 1);
- } else {
- bodyConfDoc = webClient.getBodyConfiguration(userDocs[i].getUsername(), userDocs[i].getBodyConfigurationID());
- }
- BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfDoc.getBodyConfigurationID(), bodyConfDoc.getDisplayName(), bodyConfDoc.getBodyDataID());
- User user = new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), bodyConfig);
- bodyConfig.setUser(user);
- space.addUser(user);
- }
-
ThingDocument[] thingDocs = spaceDoc.getThingDocuments();
for (int i = 0; i < thingDocs.length; i++) {
Template template = space.getTemplate(thingDocs[i].getTemplateID());
@@ -175,6 +158,26 @@
}
+ //can't use spaceDoc list of users because it doesn't include the user that just authed (me!)
+ UserDocument[] userDocs = webClient.getUserDocuments(spaceID);
+ for (int i = 0; i < userDocs.length; i++) {
+ BodyConfigurationDocument bodyConfDoc = null;
+ if (userDocs[i].getUsername().startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
+ System.out.println("Need to handle guest bodies correctly");
+ bodyConfDoc = new BodyConfigurationDocument(0, userDocs[i].getUsername(), "Body", 1);
+ } else {
+ bodyConfDoc = webClient.getBodyConfiguration(userDocs[i].getUsername(), userDocs[i].getBodyConfigurationID());
+ }
+ BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfDoc.getBodyConfigurationID(), bodyConfDoc.getDisplayName(), bodyConfDoc.getBodyDataID());
+ Thing seatThing = null;
+ if (userDocs[i].getSeatThingID() != -1) {
+ seatThing = space.getThing(userDocs[i].getSeatThingID());
+ }
+ User user = new User(space, userDocs[i].getUsername(), userDocs[i].getTransform(), bodyConfig, seatThing);
+ bodyConfig.setUser(user);
+ space.addUser(user);
+ }
+
DoorDocument[] doorDocs = spaceDoc.getDoorDocuments();
for (int i = 0; i < doorDocs.length; i++) {
Template template = space.getTemplate(doorDocs[i].getTemplateID());
@@ -300,13 +303,26 @@
sendSpaceEvent(event);
}
+ public void userRequestedSeat(Thing seatThing) {
+ User user = space.getUser(accountDoc.getUsername());
+ if (user == null || user.getSeat() == seatThing) {
+ return;
+ }
+ user.setSeat(seatThing);
+
+ SpaceEvent event = new SpaceEvent(SpaceEvent.USER_SAT_EVENT);
+ event.setProperty(SpaceEvent.USERNAME, accountDoc.getUsername());
+ event.setProperty(SpaceEvent.THING_ID, new Long(seatThing.getThingID()));
+ sendSpaceEvent(event);
+ }
+
private void handleMessageFromService(Message message) {
if (message.getPayload() instanceof PayloadFactory.SpaceEventPayload) {
SpaceEvent event = ((PayloadFactory.SpaceEventPayload) message.getPayload()).getSpaceEvent();
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);
+ User user = new User(space, event.getStringProperty(SpaceEvent.USERNAME), event.getTransform(), bodyConfig, null);
space.addUser(user);
} else if (SpaceEvent.REMOVE_USER_EVENT.equals(event.getName())) {
User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
@@ -473,6 +489,27 @@
}
user.stopMotion(event.getTransform());
+ } else if (SpaceEvent.USER_SAT_EVENT.equals(event.getName())) {
+ if (accountDoc.getUsername().equals(event.getStringProperty(SpaceEvent.USERNAME))) {
+ return;
+ }
+
+ User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
+ if (user == null) {
+ Log.error("Got a sit event for an unknown user: " + event.getStringProperty(SpaceEvent.USERNAME));
+ return;
+ }
+ Thing thing = space.getThing(event.getLongProperty(SpaceEvent.THING_ID).longValue());
+ if (thing == null) {
+ Log.error("Got a sit event for an unknown thing: " + user.getUsername() + ", " + event.getLongProperty(SpaceEvent.THING_ID));
+ return;
+ }
+ if (!thing.getTemplate().isASeat()) {
+ Log.error("Got a sit event for a thing which is not a seat: " + user.getUsername() + ", " + event.getLongProperty(SpaceEvent.THING_ID));
+ return;
+ }
+ user.setSeat(thing);
+
} else if (SpaceEvent.THING_START_MOTION_EVENT.equals(event.getName())) {
long thingID = event.getLongProperty(SpaceEvent.THING_ID).longValue();
Thing thing = space.getThing(thingID);
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-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Space.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -42,9 +42,9 @@
private String ownerUsername = null;
private boolean displaySea = false;
-
+
private double seaLevel = 0;
-
+
private HashMap templates = new HashMap(); // Long templateIDs to Templates
private HashMap things = new HashMap(); // Long thingIDs to Things
@@ -62,7 +62,7 @@
this.spaceContext = spaceContext;
ArgumentUtils.assertNotNegative(spaceID);
this.spaceID = spaceID;
-
+
ArgumentUtils.assertNotNull(displayName);
this.displayName = displayName;
@@ -76,11 +76,11 @@
public boolean shouldDisplaySea() {
return displaySea;
}
-
+
public double getSeaLevel() {
return seaLevel;
}
-
+
private class ListenerList {
Vector list = new Vector();
@@ -114,20 +114,31 @@
Thing[] things = getThings();
Arrays.sort(things, new DistanceComparator());
-
+
if (things.length > 0) {
listener.thingAdded(things[0]);
}
User[] users = getUsers();
+
+ //We can't show seated users until after the things are loaded, but we should show as many as possible
for (int i = 0; i < users.length; i++) {
- listener.userAdded(users[i]);
+ if (users[i].getSeat() == null) {
+ listener.userAdded(users[i]);
+ }
}
for (int i = 1; i < things.length; i++) {
listener.thingAdded(things[i]);
}
+ //now show seated users
+ for (int i = 0; i < users.length; i++) {
+ if (users[i].getSeat() != null) {
+ listener.userAdded(users[i]);
+ }
+ }
+
Door[] doors = getDoors();
for (int i = 0; i < doors.length; i++) {
listener.doorAdded(doors[i]);
@@ -204,6 +215,10 @@
public void userAnimationStarted(User user, String animationName);
+ public void userSat(User user, Thing seatThing);
+
+ public void userStood(User user, Thing seat);
+
}
public interface Context {
@@ -497,4 +512,18 @@
public InputStream getPageContentStream(long thingID, long pageID) throws IOException {
return spaceContext.getPageContentStream(thingID, pageID);
}
+
+ public void notifyUserSat(User user, Thing seatThing) {
+ Listener[] listeners = listenerList.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ listeners[i].userSat(user, seatThing);
+ }
+ }
+
+ public void notifyUserStood(User user, Thing seat) {
+ Listener[] listeners = listenerList.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ listeners[i].userStood(user, seat);
+ }
+ }
}
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-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -31,8 +31,10 @@
private SplinePath path = null;
private BodyConfiguration bodyConfiguration = null;
-
- public User(Space space, String username, Transform3D position, BodyConfiguration bodyConfiguration) {
+
+ private Thing seatThing = null;
+
+ public User(Space space, String username, Transform3D position, BodyConfiguration bodyConfiguration, Thing seatThing) {
ArgumentUtils.assertNotNull(space);
this.space = space;
ArgumentUtils.assertNotNull(username);
@@ -42,16 +44,18 @@
ArgumentUtils.assertNotNull(bodyConfiguration);
this.bodyConfiguration = bodyConfiguration;
bodyConfiguration.setUser(this);
+ this.seatThing = seatThing;
}
public void startMotion(SplinePath path) {
- //TODO make the model reflect the ongoing movement along the path (by listening to the renderer's motion calcs?)
+ setSeat(null);
this.path = path;
this.pathStarted = System.currentTimeMillis();
space.notifyUserMotionStarted(this, path);
}
public void stopMotion(Transform3D position) {
+ setSeat(null);
this.path = null;
this.pathStarted = -1;
space.notifyUserMotionStopped(this, position);
@@ -61,10 +65,10 @@
space.notifyUserAnimationStarted(this, animationName);
}
- public BodyConfiguration getBodyConfiguration(){
+ public BodyConfiguration getBodyConfiguration() {
return bodyConfiguration;
}
-
+
public String toString() {
return "User: " + username;
}
@@ -80,7 +84,7 @@
public String getUsername() {
return username;
}
-
+
public void setPosition(Transform3D newPosition) {
position.set(newPosition);
}
@@ -88,10 +92,27 @@
public SplinePath getSplinePath() {
SplinePath path = this.path;
long pathStarted = this.pathStarted;
- if(path == null || (!path.isLooping() && pathStarted < System.currentTimeMillis() - path.getDuration())) {
+ if (path == null || (!path.isLooping() && pathStarted < System.currentTimeMillis() - path.getDuration())) {
return null;
}
return path;
}
+ public Thing getSeat() {
+ return seatThing;
+ }
+
+ public void setSeat(Thing seatThing) {
+ if(this.seatThing == seatThing){
+ return;
+ }
+
+ Thing oldSeat = this.seatThing;
+ this.seatThing = seatThing;
+ if (seatThing == null) {
+ space.notifyUserStood(this, oldSeat);
+ } else {
+ space.notifyUserSat(this, seatThing);
+ }
+ }
}
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-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -389,11 +389,23 @@
return;
}
try {
- UserRenderable renderable = createUserRenderable(user);
- if(rendererStopped){
+ J3DUserRenderable renderable = (J3DUserRenderable) createUserRenderable(user);
+ if (rendererStopped) {
return;
}
- addUserRenderable(renderable);
+
+ Thing seat = user.getSeat();
+ if (seat != null) {
+ J3DThingRenderable thingRenderable = (J3DThingRenderable)getThingRenderable(seat.getThingID());
+ if(thingRenderable == null){
+ Log.error("Error: tried to add a user sitting on an unknown thing: " + seat);
+ return;
+ }
+ thingRenderable.addSitter(renderable);
+ return;
+ }
+
+ usersGroup.addChild(renderable);
SplinePath path = user.getSplinePath();
if (path != null) {
userMotionStarted(user, path);
@@ -428,6 +440,38 @@
renderable.stopAnimation();
}
+ public void userSat(User user, Thing seatThing) {
+ if (rendererStopped) {
+ return;
+ }
+ J3DUserRenderable userRenderable = (J3DUserRenderable) getUserRenderable(user.getUsername());
+ if (userRenderable == null) { //haven't loaded the user renderable
+ return;
+ }
+ J3DThingRenderable thingRenderable = (J3DThingRenderable) getThingRenderable(seatThing.getThingID());
+ if (thingRenderable == null) { //haven't loaded the thing renderable
+ return;
+ }
+ usersGroup.removeChild(userRenderable);
+ thingRenderable.addSitter(userRenderable);
+ }
+
+ public void userStood(User user, Thing oldSeat) {
+ if (rendererStopped) {
+ return;
+ }
+ J3DUserRenderable userRenderable = (J3DUserRenderable) getUserRenderable(user.getUsername());
+ if (userRenderable == null) { //haven't loaded the user renderable
+ return;
+ }
+ J3DThingRenderable thingRenderable = (J3DThingRenderable) getThingRenderable(oldSeat.getThingID());
+ if (thingRenderable == null) { //haven't loaded the thing renderable
+ return;
+ }
+ thingRenderable.removeSitter(userRenderable);
+ usersGroup.addChild(userRenderable);
+ }
+
public void userAnimationStarted(User user, String animationName) {
if (rendererStopped) {
return;
@@ -552,24 +596,6 @@
return null;
}
- private void addUserRenderable(UserRenderable group) {
- usersGroup.addChild((J3DUserRenderable) group);
- }
-
- /*
- private UserRenderable[] getUserRenderables() {
- Vector results = new Vector();
- Enumeration children = usersGroup.getAllChildren();
- while (children.hasMoreElements()) {
- Node child = (Node) children.nextElement();
- if (child instanceof J3DUserRenderable) {
- results.add(child);
- }
- }
- return (UserRenderable[]) results.toArray(new UserRenderable[0]);
- }
- */
-
private void removeUserRenderable(UserRenderable renderable) {
if (renderable == null) {
Log.error("User renderable == null");
@@ -591,6 +617,18 @@
}
}
}
+ children = worldGroup.getAllChildren();
+ J3DUserRenderable result = null;
+ while(children.hasMoreElements()){
+ Node node = (Node) children.nextElement();
+ if (node instanceof J3DThingRenderable) {
+ J3DThingRenderable group = (J3DThingRenderable) node;
+ result = group.getSitter(username);
+ if(result != null){
+ return result;
+ }
+ }
+ }
return null;
}
@@ -619,15 +657,15 @@
private UserRenderable createUserRenderable(User user) throws IOException, RenderableParseException {
BodyConfiguration bodyConfig = user.getBodyConfiguration();
J3DBodyData bodyData = dataManager.getBodyData(bodyConfig.getBodyDataID());
- if(rendererStopped){ //this happens sometimes when someone logs in and then a space is cleaned up (usually during testing)
+ if (rendererStopped) { //this happens sometimes when someone logs in and then a space is cleaned up (usually during testing)
return null;
}
- if(bodyData == null){
+ if (bodyData == null) {
throw new IllegalStateException("Cannot load body data");
}
BufferedImage customSkin = dataManager.getBodyTexture(user.getUsername(), bodyConfig.getBodyConfigurationID());
-
+
boolean isLocalUser = !offScreen && username != null && user.getUsername().equals(username);
final J3DUserRenderable renderable = new J3DUserRenderable(user, bodyData, customSkin);
renderable.setID(USER_ID_PREFIX + user.getUsername());
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DThingRenderable.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DThingRenderable.java 2007-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DThingRenderable.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -24,7 +24,9 @@
import javax.media.j3d.Switch;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
+import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
+import javax.vecmath.Vector3d;
import com.ogoglio.client.model.Thing;
import com.ogoglio.viewer.render.ThingRenderable;
@@ -145,4 +147,33 @@
return null;
}
+ public void addSitter(J3DUserRenderable userRenderable) {
+ transformGroup.addChild(userRenderable);
+ Transform3D seatTransform = new Transform3D();
+ seatTransform.setRotation(thing.getTemplate().getSeatRotation());
+ Point3d position = thing.getTemplate().getSeatPosition();
+ seatTransform.setTranslation(new Vector3d(position.x, position.y, position.z));
+ userRenderable.setPosition(seatTransform);
+ }
+
+ public void removeSitter(J3DUserRenderable userRenderable) {
+ transformGroup.removeChild(userRenderable);
+ Transform3D thingTransform = new Transform3D();
+ transformGroup.getTransform(thingTransform);
+ userRenderable.setPosition(thingTransform);
+ }
+
+ public J3DUserRenderable getSitter(String username) {
+ Enumeration children = transformGroup.getAllChildren();
+ while(children.hasMoreElements()){
+ Node node = (Node) children.nextElement();
+ if (node instanceof J3DUserRenderable) {
+ J3DUserRenderable userRenderable = (J3DUserRenderable)node;
+ if(userRenderable.getUser().getUsername().equals(username)){
+ return userRenderable;
+ }
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
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-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -218,10 +218,12 @@
public static final String THING_CONTEXT_SELECTION_MADE_EVENT = "contextMenuItemChosen";
- public static final String SHOW_INFO_PANEL_EVENT = "ShowInfoPanelEvent";
+ public static final String SHOW_INFO_PANEL_EVENT = "ShowInfoPanel";
public static final String INFO_PANEL_NONCE = "infoPanelNonce";
+ public static final String USER_SAT_EVENT = "UserSat";
+
private String name = null;
private HashMap properties = new HashMap();
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-10-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/UserDocument.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -28,17 +28,20 @@
public static final String BODY_CONFIGURATION_ID = "bodyconfigurationid";
+ public static final String SEAT_THING_ID = "seatthingid";
+
public UserDocument(User user) {
- this(user.getUsername(), user.getPosition(), user.getSplinePath(), user.getBodyConfiguration().getBodyConfigurationID());
+ this(user.getUsername(), user.getPosition(), user.getSplinePath(), user.getBodyConfiguration().getBodyConfigurationID(), user.getSeat() == null ? -1 : user.getSeat().getThingID());
}
- public UserDocument(String username, Transform3D transform, SplinePath splinePath, long bodyConfigurationID) {
+ public UserDocument(String username, Transform3D transform, SplinePath splinePath, long bodyConfigurationID, long seatThingID) {
super(NAME, transform, splinePath);
ArgumentUtils.assertNotNull(username);
getData().setAttribute(USERNAME, username);
if (bodyConfigurationID >= 0) {
getData().setAttribute(BODY_CONFIGURATION_ID, bodyConfigurationID);
}
+ getData().setAttribute(SEAT_THING_ID, seatThingID);
}
public UserDocument(XMLElement data) {
@@ -56,4 +59,8 @@
public long getBodyConfigurationID() {
return getData().getLongAttribute(BODY_CONFIGURATION_ID);
}
+
+ public long getSeatThingID(){
+ return getData().getLongAttribute(SEAT_THING_ID);
+ }
}
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-18 18:56:57 UTC (rev 509)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-10-18 18:57:11 UTC (rev 510)
@@ -189,13 +189,15 @@
assertEquals(0, shapeMove1.getSplinePath().getSplineKeyFrames()[1].getKnot(), keyFrames[1].getKnot());
assertEquals(shapeMove1.getShapeName(), "a_shape");
- UserDocument userDoc = new UserDocument(username, new Transform3D(), null, 23);
+ UserDocument userDoc = new UserDocument(username, new Transform3D(), null, 23, 24);
assertEquals(username, userDoc.getUsername());
assertEquals(23, userDoc.getBodyConfigurationID());
+ assertEquals(24, userDoc.getSeatThingID());
userDoc = new UserDocument(XMLElement.parseElementFromString(userDoc.toString()));
assertEquals(username, userDoc.getUsername());
assertEquals(23, userDoc.getBodyConfigurationID());
+ assertEquals(24, userDoc.getSeatThingID());
DoorDocument door1 = new DoorDocument(1, displayName, 2, "susan", uri1, new Transform3D());
assertEquals(1, door1.getDoorID());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-30 00:18:20
|
Revision: 544
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=544&view=rev
Author: trevorolio
Date: 2007-10-29 17:18:21 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
Updated the body editor so that you can choose a new body configuration and choose which body data to use as the base.
Still need to add the ability to add a body configuration.
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/User.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DPageRenderable.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
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/PageRenderable.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.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-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -61,7 +61,7 @@
}
public AccountDocument createAccount(String username, String accountLevel, String firstName, String lastName, String homepage, String email, String password) throws IOException {
- AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE);
+ AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1);
try {
XMLElement result = wire.sendAuthenticatedXML(descriptor.getAccountURI(), newAccountDoc.toString(), "POST", authenticator.getAuthCookie());
return new AccountDocument(result);
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-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/User.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -69,6 +69,12 @@
return bodyConfiguration;
}
+ public void setBodyConfiguration(BodyConfiguration bodyConfiguration){
+ ArgumentUtils.assertNotNull(bodyConfiguration);
+ this.bodyConfiguration = bodyConfiguration;
+ bodyConfiguration.setUser(this);
+ }
+
public String toString() {
return "User: " + username;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DPageRenderable.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DPageRenderable.java 2007-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DPageRenderable.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -31,6 +31,7 @@
import com.ogoglio.util.StreamUtils;
import com.ogoglio.viewer.render.PageRenderable;
import com.ogoglio.viewer.render.Renderable;
+import com.ogoglio.viewer.render.ThingRenderable;
import com.sun.j3d.utils.image.TextureLoader;
import com.sun.j3d.utils.picking.PickTool;
@@ -42,8 +43,11 @@
private BrowserScreen screen = null;
- public J3DPageRenderable(Page page) {
+ private J3DThingRenderable thingRenderable = null;
+
+ public J3DPageRenderable(Page page, J3DThingRenderable thingRenderable) {
this.page = page;
+ this.thingRenderable = thingRenderable;
setCapability(BranchGroup.ALLOW_DETACH);
pageGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
pageGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
@@ -54,6 +58,10 @@
reloadContent();
}
+ public ThingRenderable getThingRenderable(){
+ return thingRenderable;
+ }
+
public void cleanup() {
//removeAllChildren();
//pageGroup.removeAllChildren();
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-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -264,7 +264,7 @@
Log.error("Tried to add a page to an unknown thing: " + page.getThing().getThingID());
return;
}
- J3DPageRenderable pageRenderable = new J3DPageRenderable(page);
+ J3DPageRenderable pageRenderable = new J3DPageRenderable(page, thingRenderable);
thingRenderable.addPageRenderable(pageRenderable);
}
@@ -727,7 +727,7 @@
Page[] pages = thing.getPages();
for (int i = 0; i < pages.length; i++) {
- J3DPageRenderable pageRenderable = new J3DPageRenderable(pages[i]);
+ J3DPageRenderable pageRenderable = new J3DPageRenderable(pages[i], renderable);
renderable.addPageRenderable(pageRenderable);
}
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-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/MotionInputHandler.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -247,6 +247,7 @@
} 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");
@@ -285,6 +286,9 @@
ShapeRenderable shape = (ShapeRenderable) clickTarget.getRenderable();
renderable = (ThingRenderable) shape.getRenderable();
name = shape.getName();
+ } else if(clickTarget.getRenderable() instanceof PageRenderable){
+ PageRenderable pageRenderable = (PageRenderable)clickTarget.getRenderable();
+ renderable = pageRenderable.getThingRenderable();
} else {
return;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/PageRenderable.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/PageRenderable.java 2007-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/render/PageRenderable.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -19,4 +19,5 @@
public Page getPage();
+ public ThingRenderable getThingRenderable();
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java 2007-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -19,7 +19,7 @@
public class AccountDocument {
- public static final long NO_TIME_VALUE=-97; //indicates there is no time value
+ public static final long NO_TIME_VALUE = -97; //indicates there is no time value
public static final String ACCOUNT_LEVEL_BASIC = "basic";
@@ -34,7 +34,7 @@
public static final String NAME = "account";
public static final String USERNAME = "username";
-
+
public static final String ACCOUNT_LEVEL = "accountlevel";
public static final String FIRST_NAME = "firstname";
@@ -53,18 +53,20 @@
public static final String FROZEN_UNTIL = "frozenuntil";
+ public static final String BODY_CONFIGURATION_ID = "bodyconfigurationid";
+
XMLElement data = null;
- public AccountDocument(String username, String accountLevel, String firstName, String lastName, String homepage, String password, String email, long creationDate, String cookie, long frozenUntil) {
+ public AccountDocument(String username, String accountLevel, String firstName, String lastName, String homepage, String password, String email, long creationDate, String cookie, long frozenUntil, long bodyConfigurationID) {
data = new XMLElement(NAME);
if (username == null) {
throw new IllegalArgumentException("Bad username: " + username);
}
data.setAttribute(USERNAME, username);
-
+
if (accountLevel != null) {
- data.setAttribute(ACCOUNT_LEVEL, accountLevel);
+ data.setAttribute(ACCOUNT_LEVEL, accountLevel);
}
if (firstName != null)
@@ -82,22 +84,25 @@
if (creationDate != AccountDocument.NO_TIME_VALUE)
data.setAttribute(CREATION_DATE, creationDate);
- if (frozenUntil!=AccountDocument.NO_TIME_VALUE)
+ if (frozenUntil != AccountDocument.NO_TIME_VALUE)
data.setAttribute(FROZEN_UNTIL, frozenUntil);
+
+ if (bodyConfigurationID != -1)
+ data.setAttribute(BODY_CONFIGURATION_ID, bodyConfigurationID);
}
public AccountDocument(XMLElement data) {
if (data == null) {
throw new IllegalArgumentException("AuthDocument data is null");
}
- if (!NAME.equals(data.getName())) {
+ if (!NAME.equals(data.getName())) {
throw new IllegalArgumentException("AccountDocument data is not named Account: " + data.getName());
}
this.data = data;
}
public AccountDocument(String username) { //used when updating the document, with absent items indicating no change
- this(username, null, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE);
+ this(username, null, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1);
}
public XMLElement toElement() {
@@ -111,71 +116,83 @@
public String getUsername() {
return data.getStringAttribute(USERNAME);
}
-
+
public void setAccountLevel(String level) {
data.setAttribute(ACCOUNT_LEVEL, level);
}
public String getAccountLevel() {
- return data.getStringAttribute(ACCOUNT_LEVEL);
+ return data.getStringAttribute(ACCOUNT_LEVEL);
}
- public String getFirstName(){
+ public String getFirstName() {
return data.getStringAttribute(FIRST_NAME);
}
- public String getLastName(){
+ public String getLastName() {
return data.getStringAttribute(LAST_NAME);
}
-
+
public String getHomepage() {
return data.getStringAttribute(HOMEPAGE);
}
-
+
public String getPassword() {
return data.getStringAttribute(PASSWORD);
}
-
+
public String getEmail() {
return data.getStringAttribute(EMAIL);
}
-
+
public String getCookie() {
return data.getStringAttribute(COOKIE);
}
-
+
public Date getCreationDate() {
long value = data.getLongAttribute(CREATION_DATE, -1);
- if(value == -1) {
+ if (value == -1) {
return null;
}
return new Date(value);
}
-
+
public Date getFrozenUntil() {
long value = data.getLongAttribute(FROZEN_UNTIL, -1);
- if(value == -1) {
+ if (value == -1) {
return null;
}
return new Date(value);
}
public void setFrozenUntil(Date date) {
- if(date == null) {
+ if (date == null) {
data.removeAttribute(FROZEN_UNTIL);
} else {
data.setAttribute(FROZEN_UNTIL, date.getTime());
}
}
+ public long getBodyConfigurationID(){
+ return data.getLongAttribute(BODY_CONFIGURATION_ID);
+ }
+
+ public void setBodyConfigurationID(long id){
+ if(id < 0){
+ data.removeAttribute(BODY_CONFIGURATION_ID);
+ } else {
+ data.setAttribute(BODY_CONFIGURATION_ID, id);
+ }
+ }
+
public int hashCode() {
return getUsername().hashCode();
}
-
+
public boolean equals(Object obj) {
- if(obj == null || !(obj instanceof AccountDocument)) {
+ if (obj == null || !(obj instanceof AccountDocument)) {
return false;
}
- return getUsername().equals(((AccountDocument)obj).getUsername());
+ return getUsername().equals(((AccountDocument) obj).getUsername());
}
}
\ 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-10-27 23:33:47 UTC (rev 543)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-10-30 00:18:21 UTC (rev 544)
@@ -86,7 +86,7 @@
}
public void testAccountDocument() {
- AccountDocument doc1 = new AccountDocument(username1, accountLevel1, firstName1, lastName1, company1, password1, email1, creationDate1, cookie1, frozenUntil1);
+ AccountDocument doc1 = new AccountDocument(username1, accountLevel1, firstName1, lastName1, company1, password1, email1, creationDate1, cookie1, frozenUntil1, 1);
XMLElement element = new XMLElement();
element.parseString(doc1.toString());
AccountDocument doc2 = new AccountDocument(element);
@@ -104,6 +104,7 @@
assertEquals(doc1.getPassword(), doc2.getPassword());
assertEquals(doc1.getUsername(), doc2.getUsername());
assertEquals(doc1.getAccountLevel(), doc2.getAccountLevel());
+ assertEquals(doc1.getBodyConfigurationID(), doc2.getBodyConfigurationID());
}
public void testAuthDocument() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-03 23:35:36
|
Revision: 557
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=557&view=rev
Author: trevorolio
Date: 2007-11-03 16:35:40 -0700 (Sat, 03 Nov 2007)
Log Message:
-----------
Broke the load testing classes into a separate test package, added a way to load many spaces in addition to many users.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.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
Added Paths:
-----------
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java
Removed Paths:
-------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java 2007-11-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -1,211 +0,0 @@
-package com.ogoglio.client;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Random;
-import java.util.Vector;
-
-import javax.media.j3d.Transform3D;
-import javax.vecmath.Vector3d;
-
-import com.ogoglio.client.model.SplinePath;
-import com.ogoglio.client.model.Thing;
-import com.ogoglio.client.model.User;
-import com.ogoglio.util.Log;
-import com.ogoglio.viewer.j3d.J3DSplinePath;
-
-public class MultiuserTests {
-
- private long spaceID = -1;
-
- private URI serviceURI = null;
-
- Vector robots = new Vector();
-
- Random random = new Random();
-
- public MultiuserTests(long spaceID, URI serviceURI) {
- this.spaceID = spaceID;
- this.serviceURI = serviceURI;
- }
-
- public synchronized void addRobot(Transform3D startPosition, boolean wander) throws IOException {
- UserRobot robot = new UserRobot(spaceID, serviceURI);
- robot.teleport(startPosition);
- robots.add(robot);
- if (wander) {
- robot.wander();
- }
- }
-
- private synchronized UserRobot[] getRobots() {
- return (UserRobot[]) robots.toArray(new UserRobot[0]);
- }
-
- public void cleanup() {
- UserRobot[] bots = getRobots();
- for (int i = 0; i < bots.length; i++) {
- bots[i].cleanup();
- }
- }
-
- private class UserRobot implements SpaceClient.Listener {
- SpaceClient spaceClient = null;
-
- WanderThread wanderThread = null;
-
- public UserRobot(long spaceID, URI serviceURI) throws IOException {
- String guestCookie = "guestRobot_Banger_Test_" + System.currentTimeMillis() + "_" + random.nextInt();
- if (guestCookie == null) {
- throw new IOException("Could not get a guest cookie");
- }
- spaceClient = new SpaceClient(spaceID, serviceURI, guestCookie, this);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- wanderThread = new WanderThread(this);
- }
-
- public void wander() {
- wanderThread.start();
- }
-
- public void cleanup() {
- if (spaceClient != null) {
- spaceClient.cleanup();
- }
- }
-
- public void teleport(Transform3D position) {
- spaceClient.viewpointMotionStopped(position);
- }
-
- public void disconnected() {
- Log.error("UserRobot was disconnected");
- }
-
- public void receivedChatMessage(String username, String message) {
- }
-
- public void receivedSpaceTransfer(URI link) {
- }
-
- public void receivedLink(String displayName, String link) {
- }
-
- public void receivedCommandFocusRequest() {
- }
-
- public void receivedBrowserMessage(long sourceThingID, String message) {
- }
-
- public void receivedContextMenuRequest(Thing thing,String shapeName, int x, int y,long nonce) {
- }
-
- public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
- }
-
- public void contextItemChosen(Thing thing, long nonce, String id) {
- }
-
- public void receivedInfoPanel(long sourceThingID, String nonce) {
- }
-
- }
-
- private class WanderThread extends Thread {
- UserRobot robot = null;
-
- public WanderThread(UserRobot robot) {
- this.robot = robot;
- }
-
- public void run() {
- User user = robot.spaceClient.getSpace().getUser(robot.spaceClient.getUsername());
- while(user == null) {
- try {
- sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- user = robot.spaceClient.getSpace().getUser(robot.spaceClient.getUsername());
- }
- Vector3d homePosition = new Vector3d(Math.abs(random.nextInt()) % 10, 0, Math.abs(random.nextInt()) % 10);
- System.out.println("Home position " + homePosition);
- Transform3D userPosition = new Transform3D();
- userPosition.setTranslation(homePosition);
- boolean lastSpun = true;
- while(true) {
- if(random.nextBoolean() || random.nextBoolean()){
- userPosition.setTranslation(homePosition);
- robot.spaceClient.viewpointMotionStopped(userPosition);
- try {
- sleep(1000 + Math.abs((random.nextInt() % 5000)));
- } catch (InterruptedException e) {
- break;
- }
- } else if(lastSpun) {
- userPosition.rotY(random.nextFloat() % (2 * Math.PI));
- userPosition.setTranslation(homePosition);
- SplinePath path = J3DSplinePath.getSplinePath(userPosition, 1, 0, 0, 2);
- robot.spaceClient.viewpointMotionChanged(path);
- try {
- sleep(3000 + Math.abs((random.nextInt() % 6000)));
- } catch (InterruptedException e) {
- break;
- }
- lastSpun = false;
- } else {
- userPosition.setTranslation(homePosition);
- SplinePath path = J3DSplinePath.getSplinePath(userPosition, 0, 1, 0, 2);
- robot.spaceClient.viewpointMotionChanged(path);
- try {
- sleep(1000 + Math.abs((random.nextInt() % 6000)));
- } catch (InterruptedException e) {
- break;
- }
- lastSpun = true;
- }
- }
- }
- }
-
- public static void main(String[] args) {
- if (args.length != 3) {
- Log.error("usage: ... spaceID serviceURI numRobots");
- return;
- }
- MultiuserTests tests = null;
- try {
- //If you are going to run a test like this, these should be pulled from
- //the properties files....
- //String serviceURI = "http://127.0.0.1:8080/og/";
- //String spaceURI = "http://127.0.0.1:8080/og/space/1/";
-
- long spaceID = Long.parseLong(args[0]);
- URI serviceURI = new URI(args[1]);
- tests = new MultiuserTests(spaceID, serviceURI);
-
- int numRobots = Integer.parseInt(args[2]);
- Transform3D startPosition = new Transform3D();
- for (int i = 0; i < numRobots; i++) {
- startPosition.setTranslation(new Vector3d(0, 0, -10));
- tests.addRobot(startPosition, true);
- Log.test("Added robot " + (i + 1) + " of " + numRobots);
- Thread.sleep(1000);
- }
-
- Thread.sleep(500000000);
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(1);
- } finally {
- if (tests != null) {
- tests.cleanup();
- }
- }
- }
-
-}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-11-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -82,10 +82,13 @@
private boolean complainedAboutMemory = false;
- public J3DDataManager(boolean loadAppearances, TemplateDataProvider templateDataProvider, BodyDataProvider bodyDataProvider) {
+ private boolean watchMemory = false;
+
+ public J3DDataManager(boolean loadAppearances, TemplateDataProvider templateDataProvider, BodyDataProvider bodyDataProvider, boolean watchMemory) {
this.loadAppearances = loadAppearances;
this.templateDataProvider = templateDataProvider;
this.bodyDataProvider = bodyDataProvider;
+ this.watchMemory = watchMemory;
}
public BufferedImage getBodyTexture(String username, long bodyConfigurationID) {
@@ -565,6 +568,9 @@
}
private boolean atMaxMemory() {
+ if(!watchMemory){
+ return false;
+ }
boolean atMax = getHeapRemaining() < MINIMUM_REMAINING_HEAP;
if (atMax) {
Runtime.getRuntime().runFinalization();
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-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -121,7 +121,7 @@
this.username = username;
this.userInputListener = userInputListener;
this.offScreen = offScreen;
- this.dataManager = new J3DDataManager(!offScreen, templateDataProvider, bodyDataProvider);
+ this.dataManager = new J3DDataManager(!offScreen, templateDataProvider, bodyDataProvider, !offScreen);
setCapabilities(sceneRoot);
setCapabilities(usersGroup);
@@ -702,7 +702,6 @@
if (displayName.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
displayName = J3DUserRenderable.convertGuestCookieToDisplayName(displayName);
}
- System.out.println("Setting name tag: " + displayName);
renderable.setNameTag(displayName);
}
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-03 23:35:35 UTC (rev 556)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -95,6 +95,7 @@
}
public void initBody(J3DBodyData bodyData, BufferedImage customSkin) {
+ System.out.println("INIT BODY: " + user + " bodyData: " + bodyData + " skin " + customSkin);
bodyGroup.removeAllChildren();
this.bodyData = bodyData;
skin = new SkinLoader(bodyData, user.getBodyConfiguration(), customSkin).generateSkin();
@@ -295,9 +296,6 @@
displayName = displayName.substring(WebConstants.GUEST_COOKIE_PREFIX.length() + 1);
StringBuffer result = new StringBuffer(WebConstants.GUEST_DISPLAY_NAME_PREFIX);
String[] tokens = displayName.split(Pattern.quote("_"));
- for (int i = 0; i < tokens.length; i++) {
- System.out.println("TOKEN " + tokens[i]);
- }
int startIndex = tokens.length > 3 ? 3 : 0;
for (int i = startIndex; i < tokens.length; i++) {
result.append(" " + tokens[i]);
Added: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -0,0 +1,129 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
+
+import com.ogoglio.client.SpaceClient;
+import com.ogoglio.client.model.SplinePath;
+import com.ogoglio.client.model.Thing;
+import com.ogoglio.client.model.User;
+import com.ogoglio.util.Log;
+import com.ogoglio.viewer.j3d.J3DSplinePath;
+
+public class Bot implements SpaceClient.Listener {
+ SpaceClient spaceClient = null;
+
+ Random random = new Random();
+
+ WanderThread wanderThread = null;
+
+ public Bot(long spaceID, URI serviceURI) throws IOException {
+ String guestCookie = "guestRobot_Banger_Test_" + System.currentTimeMillis() + "_" + random.nextInt();
+ if (guestCookie == null) {
+ throw new IOException("Could not get a guest cookie");
+ }
+ spaceClient = new SpaceClient(spaceID, serviceURI, guestCookie, this);
+ }
+
+ public void wander() {
+ wanderThread = new WanderThread();
+ wanderThread.start();
+ }
+
+ public void cleanup() {
+ if (spaceClient != null) {
+ spaceClient.cleanup();
+ }
+ }
+
+ public void teleport(Transform3D position) {
+ spaceClient.viewpointMotionStopped(position);
+ }
+
+ public void disconnected() {
+ Log.error("UserRobot was disconnected");
+ }
+
+ public void receivedChatMessage(String username, String message) {
+ }
+
+ public void receivedSpaceTransfer(URI link) {
+ }
+
+ public void receivedLink(String displayName, String link) {
+ }
+
+ public void receivedCommandFocusRequest() {
+ }
+
+ public void receivedBrowserMessage(long sourceThingID, String message) {
+ }
+
+ public void receivedContextMenuRequest(Thing thing, String shapeName, int x, int y, long nonce) {
+ }
+
+ public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
+ }
+
+ public void contextItemChosen(Thing thing, long nonce, String id) {
+ }
+
+ public void receivedInfoPanel(long sourceThingID, String nonce) {
+ }
+
+ private class WanderThread extends Thread {
+ public void run() {
+ User user = spaceClient.getSpace().getUser(spaceClient.getUsername());
+ while (user == null) {
+ try {
+ sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ user = spaceClient.getSpace().getUser(spaceClient.getUsername());
+ }
+ Vector3d homePosition = new Vector3d(Math.abs(random.nextInt()) % 10, 0, -30 + Math.abs(random.nextInt()) % 10);
+ Transform3D userPosition = new Transform3D();
+ userPosition.setTranslation(homePosition);
+ boolean lastSpun = true;
+ while (true) {
+ if (random.nextBoolean() || random.nextBoolean()) {
+ userPosition.setTranslation(homePosition);
+ spaceClient.viewpointMotionStopped(userPosition);
+ try {
+ sleep(1000 + Math.abs((random.nextInt() % 5000)));
+ } catch (InterruptedException e) {
+ break;
+ }
+ } else if (lastSpun) {
+ userPosition.rotY(random.nextFloat() % (2 * Math.PI));
+ userPosition.setTranslation(homePosition);
+ SplinePath path = J3DSplinePath.getSplinePath(userPosition, 1, 0, 0, 2);
+ spaceClient.viewpointMotionChanged(path);
+ try {
+ sleep(3000 + Math.abs((random.nextInt() % 6000)));
+ } catch (InterruptedException e) {
+ break;
+ }
+ lastSpun = false;
+ } else {
+ userPosition.setTranslation(homePosition);
+ SplinePath path = J3DSplinePath.getSplinePath(userPosition, 0, 1, 0, 2);
+ spaceClient.viewpointMotionChanged(path);
+ try {
+ sleep(1000 + Math.abs((random.nextInt() % 6000)));
+ } catch (InterruptedException e) {
+ break;
+ }
+ lastSpun = true;
+ }
+ }
+ }
+ }
+
+}
Added: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -0,0 +1,67 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Vector;
+
+import com.ogoglio.util.Log;
+
+public class MultispaceTests {
+
+ private URI serviceURI = null;
+
+ private long lowerSpaceID = -1;
+
+ private long upperSpaceID = -1;
+
+ Vector bots = new Vector();
+
+ public MultispaceTests(URI serviceURI, long lowerSpaceID, long upperSpaceID) {
+ this.lowerSpaceID = lowerSpaceID;
+ this.upperSpaceID = upperSpaceID;
+ this.serviceURI = serviceURI;
+ if (lowerSpaceID >= upperSpaceID) {
+ throw new IllegalArgumentException("lower space ID must be less than upper space ID");
+ }
+ }
+
+ public void startTests() throws IOException {
+ for (long i = lowerSpaceID; i <= upperSpaceID; i++) {
+ try {
+ Bot bot = new Bot(i, serviceURI);
+ System.out.println("Adding bot to space " + i);
+ bots.add(bot);
+ } catch (IOException e) {
+ System.out.println("Skipping space " + i);
+ }
+ }
+ }
+
+ public void stopTests() {
+ Bot[] theBots = (Bot[]) bots.toArray(new Bot[0]);
+ for (int i = 0; i < theBots.length; i++) {
+ theBots[i].cleanup();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 3) {
+ Log.error("usage: ... serviceURI lowerSpaceID upperSpaceID");
+ return;
+ }
+
+ URI serviceURI = URI.create(args[0]);
+ long lowerSpaceID = Long.parseLong(args[1]);
+ long upperSpaceID = Long.parseLong(args[2]);
+
+ MultispaceTests tests = new MultispaceTests(serviceURI, lowerSpaceID, upperSpaceID);
+ try {
+ tests.startTests();
+ Thread.sleep(500000000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
Copied: maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java (from rev 549, maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/MultiuserTests.java)
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java (rev 0)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java 2007-11-03 23:35:40 UTC (rev 557)
@@ -0,0 +1,83 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
+
+import com.ogoglio.client.SpaceClient;
+import com.ogoglio.client.SpaceClient.Listener;
+import com.ogoglio.client.model.SplinePath;
+import com.ogoglio.client.model.Thing;
+import com.ogoglio.client.model.User;
+import com.ogoglio.util.Log;
+import com.ogoglio.viewer.j3d.J3DSplinePath;
+
+public class MultiuserTests {
+
+ private long spaceID = -1;
+
+ private URI serviceURI = null;
+
+ Vector robots = new Vector();
+
+ public MultiuserTests(long spaceID, URI serviceURI) {
+ this.spaceID = spaceID;
+ this.serviceURI = serviceURI;
+ }
+
+ public synchronized void addRobot(Transform3D startPosition, boolean wander) throws IOException {
+ Bot robot = new Bot(spaceID, serviceURI);
+ robot.teleport(startPosition);
+ robots.add(robot);
+ if (wander) {
+ robot.wander();
+ }
+ }
+
+ private synchronized Bot[] getRobots() {
+ return (Bot[]) robots.toArray(new Bot[0]);
+ }
+
+ public void cleanup() {
+ Bot[] bots = getRobots();
+ for (int i = 0; i < bots.length; i++) {
+ bots[i].cleanup();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 3) {
+ Log.error("usage: ... spaceID serviceURI numRobots");
+ return;
+ }
+ MultiuserTests tests = null;
+ try {
+ long spaceID = Long.parseLong(args[0]);
+ URI serviceURI = new URI(args[1]);
+ tests = new MultiuserTests(spaceID, serviceURI);
+
+ int numRobots = Integer.parseInt(args[2]);
+ Transform3D startPosition = new Transform3D();
+ for (int i = 0; i < numRobots; i++) {
+ startPosition.setTranslation(new Vector3d(0, 0, -50));
+ tests.addRobot(startPosition, true);
+ Log.test("Added robot " + (i + 1) + " of " + numRobots);
+ Thread.sleep(1000);
+ }
+
+ Thread.sleep(500000000);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(1);
+ } finally {
+ if (tests != null) {
+ tests.cleanup();
+ }
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-08 00:25:34
|
Revision: 563
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=563&view=rev
Author: trevorolio
Date: 2007-11-07 16:25:38 -0800 (Wed, 07 Nov 2007)
Log Message:
-----------
Added account level field to auth docs.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIGuestAuthenticator.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AuthDocument.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/WebAPIGuestAuthenticator.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIGuestAuthenticator.java 2007-11-07 21:06:54 UTC (rev 562)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIGuestAuthenticator.java 2007-11-08 00:25:38 UTC (rev 563)
@@ -12,7 +12,7 @@
public WebAPIGuestAuthenticator(WebAPIDescriptor serviceDescriptor, String authCookie) {
super(serviceDescriptor, authCookie);
- authDoc = new AuthDocument(authCookie, true);
+ authDoc = new AuthDocument(authCookie, true, AccountDocument.ACCOUNT_LEVEL_BASIC);
accountDoc = new AccountDocument(authCookie);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AuthDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AuthDocument.java 2007-11-07 21:06:54 UTC (rev 562)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AuthDocument.java 2007-11-08 00:25:38 UTC (rev 563)
@@ -23,14 +23,16 @@
public static final String AUTHENTICATED = "authenticated";
+ public static final String ACCOUNT_LEVEL = "accountlevel";
+
XMLElement data = null;
public AuthDocument() {
- this.data = create(null, false);
+ this.data = create(null, false, AccountDocument.ACCOUNT_LEVEL_BASIC);
}
- public AuthDocument(String username, boolean authenticated) {
- this.data = create(username, authenticated);
+ public AuthDocument(String username, boolean authenticated, String accountLevel) {
+ this.data = create(username, authenticated, accountLevel);
}
public AuthDocument(XMLElement data) {
@@ -46,12 +48,13 @@
this.data = data;
}
- private XMLElement create(String username, boolean authenticated) {
+ private XMLElement create(String username, boolean authenticated, String accountLevel) {
XMLElement element = new XMLElement(NAME);
if(username != null) {
element.setAttribute(USERNAME, username);
}
element.setAttribute(AUTHENTICATED, authenticated);
+ element.setAttribute(ACCOUNT_LEVEL, accountLevel);
return element;
}
@@ -71,4 +74,8 @@
return data.getStringAttribute(USERNAME);
}
+ public String getAccountLevel(){
+ return data.getStringAttribute(ACCOUNT_LEVEL);
+ }
+
}
\ 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-11-07 21:06:54 UTC (rev 562)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2007-11-08 00:25:38 UTC (rev 563)
@@ -108,7 +108,7 @@
}
public void testAuthDocument() {
- AuthDocument doc1 = new AuthDocument(username1, true);
+ AuthDocument doc1 = new AuthDocument(username1, true, AccountDocument.ACCOUNT_LEVEL_BASIC);
assertEquals(username1, doc1.getUsername());
assertTrue(doc1.isAuthenticated());
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-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-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...> - 2008-01-01 21:34:41
|
Revision: 658
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=658&view=rev
Author: trevorolio
Date: 2008-01-01 13:34:46 -0800 (Tue, 01 Jan 2008)
Log Message:
-----------
WARNING: DB SCHEMA CHANGE
Added an emailValid field to account records, their XML docs, and the Java APIs.
Fixed up the existing email validation framework to update this value.
Added an email validation test to the integration test suite.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.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-12-31 23:16:03 UTC (rev 657)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-01-01 21:34:46 UTC (rev 658)
@@ -62,7 +62,7 @@
}
public AccountDocument createAccount(String username, String accountLevel, String firstName, String lastName, String homepage, String email, String password) throws IOException {
- AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1, null, null);
+ AccountDocument newAccountDoc = new AccountDocument(username, accountLevel, firstName, lastName, homepage, password, email, false, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1, null, null);
try {
XMLElement result = wire.sendAuthenticatedXML(descriptor.getAccountURI(), newAccountDoc.toString(), "POST", authenticator.getAuthCookie());
return new AccountDocument(result);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java 2007-12-31 23:16:03 UTC (rev 657)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AccountDocument.java 2008-01-01 21:34:46 UTC (rev 658)
@@ -59,9 +59,11 @@
public static final String TEXT_URI = "text";
+ private static final String EMAIL_VALID = "emailvalid";
+
XMLElement data = null;
- public AccountDocument(String username, String accountLevel, String firstName, String lastName, String homepage, String password, String email, long creationDate, String cookie, long frozenUntil, long bodyConfigurationID, String voiceURI, String textURI) {
+ public AccountDocument(String username, String accountLevel, String firstName, String lastName, String homepage, String password, String email, boolean emailValid, long creationDate, String cookie, long frozenUntil, long bodyConfigurationID, String voiceURI, String textURI) {
data = new XMLElement(NAME);
if (username == null) {
@@ -83,6 +85,7 @@
data.setAttribute(PASSWORD, password);
if (email != null)
data.setAttribute(EMAIL, email);
+ data.setAttribute(EMAIL_VALID, emailValid);
if (cookie != null)
data.setAttribute(COOKIE, cookie);
@@ -112,7 +115,7 @@
}
public AccountDocument(String username) { //used when updating the document, with absent items indicating no change
- this(username, null, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1, null, null);
+ this(username, null, null, null, null, null, null, false, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1, null, null);
}
public XMLElement toElement() {
@@ -213,4 +216,8 @@
}
return getUsername().equals(((AccountDocument) obj).getUsername());
}
+
+ public boolean isEmailValid() {
+ return data.getBooleanAttribute(EMAIL_VALID);
+ }
}
\ 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-31 23:16:03 UTC (rev 657)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/xml/test/XMLTest.java 2008-01-01 21:34:46 UTC (rev 658)
@@ -87,7 +87,7 @@
}
public void testAccountDocument() {
- AccountDocument doc1 = new AccountDocument(username1, accountLevel1, firstName1, lastName1, company1, password1, email1, creationDate1, cookie1, frozenUntil1, 1, "skype:echo1234", "aim:echo");
+ AccountDocument doc1 = new AccountDocument(username1, accountLevel1, firstName1, lastName1, company1, password1, email1, false, creationDate1, cookie1, frozenUntil1, 1, "skype:echo1234", "aim:echo");
XMLElement element = new XMLElement();
element.parseString(doc1.toString());
AccountDocument doc2 = new AccountDocument(element);
@@ -99,6 +99,7 @@
assertEquals(doc1.getCookie(), doc2.getCookie());
assertEquals(doc1.getCreationDate(), doc2.getCreationDate());
assertEquals(doc1.getEmail(), doc2.getEmail());
+ assertEquals(doc1.isEmailValid(), doc2.isEmailValid());
assertEquals(doc1.getFirstName(), doc2.getFirstName());
assertEquals(doc1.getFrozenUntil(), doc2.getFrozenUntil());
assertEquals(doc1.getLastName(), doc2.getLastName());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-01-11 21:20:35
|
Revision: 676
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=676&view=rev
Author: trevorolio
Date: 2008-01-11 13:20:38 -0800 (Fri, 11 Jan 2008)
Log Message:
-----------
Added private tells among space cohabitants.
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/bvh/Bvh.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/BvhParser.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.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 2008-01-10 19:03:50 UTC (rev 675)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-01-11 21:20:38 UTC (rev 676)
@@ -321,6 +321,14 @@
sendSpaceEvent(event);
}
+ public void userSentPrivateMessage(User user, String messageText) {
+ SpaceEvent event = new SpaceEvent(SpaceEvent.TEXT_TELL_EVENT);
+ event.setProperty(SpaceEvent.USERNAME, accountDoc.getUsername());
+ event.setProperty(SpaceEvent.TTE_RECIPIENT, user.getUsername());
+ event.setProperty(SpaceEvent.TTE_MESSAGE, messageText);
+ sendSpaceEvent(event);
+ }
+
public void userRequestedSeat(Thing seatThing) {
User user = space.getUser(accountDoc.getUsername());
if (user == null || user.getSeat() == seatThing) {
@@ -587,6 +595,14 @@
listener.receivedChatMessage(user.getUsername(), event.getStringProperty(SpaceEvent.TSE_MESSAGE));
+ } else if(SpaceEvent.TEXT_TELL_EVENT.equals(event.getName())){
+ User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
+ if(user == null){
+ Log.error("Got a text tell event for an unknown user: " + event.getStringProperty(SpaceEvent.USERNAME));
+ return;
+ }
+ listener.receivedTellMessage(user.getUsername(), event.getStringProperty(SpaceEvent.TTE_MESSAGE));
+
} else if (SpaceEvent.PLAY_ANIMATION_EVENT.equals(event.getName())) {
User user = space.getUser(event.getStringProperty(SpaceEvent.USERNAME));
if (user == null) {
@@ -744,6 +760,8 @@
public interface Listener {
public void receivedChatMessage(String username, String message);
+ public void receivedTellMessage(String username, String message);
+
public void receivedUserContextMenuRequest(User user, int x, int y);
public void receivedInfoPanel(long sourceThingID, String nonce);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java 2008-01-10 19:03:50 UTC (rev 675)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java 2008-01-11 21:20:38 UTC (rev 676)
@@ -297,4 +297,8 @@
return result;
}
+ public void printInfo(){
+ System.out.println("BVH: " + name + ": " + frames.size() + " frames, " + frameTime + " frame time");
+ printJoint(rootJoint);
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/BvhParser.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/BvhParser.java 2008-01-10 19:03:50 UTC (rev 675)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/BvhParser.java 2008-01-11 21:20:38 UTC (rev 676)
@@ -14,6 +14,8 @@
package com.ogoglio.viewer.j3d.bvh;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -205,4 +207,30 @@
}
return buffer.toString().trim();
}
+
+ public static void main(String[] args){
+ if(args.length < 2){
+ printUsage();
+ return;
+ }
+ try {
+ String name = args[0];
+ FileInputStream input = new FileInputStream(args[1]);
+ BvhParser parser = new BvhParser(name, input);
+ Bvh bvh = parser.parse();
+ bvh.printInfo();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (BvhParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private static void printUsage(){
+ System.out.println("Usage: java ... BvhParser <animationName> <path to bvh>");
+ }
}
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 2008-01-10 19:03:50 UTC (rev 675)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/SpaceEvent.java 2008-01-11 21:20:38 UTC (rev 676)
@@ -120,6 +120,12 @@
public static final String TSE_MESSAGE = "message";
+ public static final String TEXT_TELL_EVENT = "textTell";
+
+ public static final String TTE_MESSAGE = "message";
+
+ public static final String TTE_RECIPIENT = "recipient";
+
public static final String ADD_THING_EVENT = "addThing";
public static final String REMOVE_THING_EVENT = "removeThing";
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 2008-01-10 19:03:50 UTC (rev 675)
+++ maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java 2008-01-11 21:20:38 UTC (rev 676)
@@ -131,4 +131,9 @@
}
+ public void receivedTellMessage(String username, String message) {
+ // TODO Auto-generated method stub
+
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2008-01-31 01:09:13
|
Revision: 701
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=701&view=rev
Author: iansmith
Date: 2008-01-30 17:09:13 -0800 (Wed, 30 Jan 2008)
Log Message:
-----------
I moved the multiuser tests into ogoglio-common. This is not a huge amount of extra bloat and means that it easy for folks (incl me) to write scripts that do load testing. Before this required chicanery with the test jars.
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java
Removed Paths:
-------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java
maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/
Copied: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest (from rev 689, maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest)
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java 2008-01-23 03:18:47 UTC (rev 689)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java 2008-01-31 01:09:13 UTC (rev 701)
@@ -1,139 +0,0 @@
-package com.ogoglio.loadtest;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Random;
-import java.util.Vector;
-
-import javax.media.j3d.Transform3D;
-import javax.vecmath.Vector3d;
-
-import com.ogoglio.client.SpaceClient;
-import com.ogoglio.client.model.SplinePath;
-import com.ogoglio.client.model.Thing;
-import com.ogoglio.client.model.User;
-import com.ogoglio.util.Log;
-import com.ogoglio.viewer.j3d.J3DSplinePath;
-
-public class Bot implements SpaceClient.Listener {
- SpaceClient spaceClient = null;
-
- Random random = new Random();
-
- WanderThread wanderThread = null;
-
- public Bot(long spaceID, URI serviceURI) throws IOException {
- String guestCookie = "guestRobot_Banger_Test_" + System.currentTimeMillis() + "_" + random.nextInt();
- if (guestCookie == null) {
- throw new IOException("Could not get a guest cookie");
- }
- spaceClient = new SpaceClient(spaceID, serviceURI, guestCookie, this);
- }
-
- public void wander() {
- wanderThread = new WanderThread();
- wanderThread.start();
- }
-
- public void cleanup() {
- if (spaceClient != null) {
- spaceClient.cleanup();
- }
- }
-
- public void teleport(Transform3D position) {
- spaceClient.viewpointMotionStopped(position);
- }
-
- public void disconnected() {
- Log.error("UserRobot was disconnected");
- }
-
- public void receivedChatMessage(String username, String message) {
- }
-
- public void receivedSpaceTransfer(URI link) {
- }
-
- public void receivedLink(String displayName, String link) {
- }
-
- public void receivedCommandFocusRequest(String preloadedText) {
- }
-
- public void receivedBrowserMessage(long sourceThingID, String message) {
- }
-
- public void receivedContextMenuRequest(Thing thing, String shapeName, int x, int y, long nonce) {
- }
-
- public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
- }
-
- public void contextItemChosen(Thing thing, long nonce, String id) {
- }
-
- public void receivedInfoPanel(long sourceThingID, String nonce) {
- }
-
- private class WanderThread extends Thread {
- public void run() {
- User user = spaceClient.getSpace().getUser(spaceClient.getUsername());
- while (user == null) {
- try {
- sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- user = spaceClient.getSpace().getUser(spaceClient.getUsername());
- }
- Vector3d homePosition = new Vector3d(Math.abs(random.nextInt()) % 10, 0, -30 + Math.abs(random.nextInt()) % 10);
- Transform3D userPosition = new Transform3D();
- userPosition.setTranslation(homePosition);
- boolean lastSpun = true;
- while (true) {
- if (random.nextBoolean() || random.nextBoolean()) {
- userPosition.setTranslation(homePosition);
- spaceClient.viewpointMotionStopped(userPosition);
- try {
- sleep(1000 + Math.abs((random.nextInt() % 5000)));
- } catch (InterruptedException e) {
- break;
- }
- } else if (lastSpun) {
- userPosition.rotY(random.nextFloat() % (2 * Math.PI));
- userPosition.setTranslation(homePosition);
- SplinePath path = J3DSplinePath.getSplinePath(userPosition, 1, 0, 0, 2);
- spaceClient.viewpointMotionChanged(path);
- try {
- sleep(3000 + Math.abs((random.nextInt() % 6000)));
- } catch (InterruptedException e) {
- break;
- }
- lastSpun = false;
- } else {
- userPosition.setTranslation(homePosition);
- SplinePath path = J3DSplinePath.getSplinePath(userPosition, 0, 1, 0, 2);
- spaceClient.viewpointMotionChanged(path);
- try {
- sleep(1000 + Math.abs((random.nextInt() % 6000)));
- } catch (InterruptedException e) {
- break;
- }
- lastSpun = true;
- }
- }
- }
- }
-
- public void receivedUserContextMenuRequest(User user, int x, int y) {
- // TODO Auto-generated method stub
-
- }
-
- public void receivedTellMessage(String username, String message) {
- // TODO Auto-generated method stub
-
- }
-
-}
Copied: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java (from rev 700, maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/Bot.java)
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/Bot.java 2008-01-31 01:09:13 UTC (rev 701)
@@ -0,0 +1,135 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
+
+import com.ogoglio.client.SpaceClient;
+import com.ogoglio.client.model.SplinePath;
+import com.ogoglio.client.model.Thing;
+import com.ogoglio.client.model.User;
+import com.ogoglio.util.Log;
+import com.ogoglio.viewer.j3d.J3DSplinePath;
+
+public class Bot implements SpaceClient.Listener {
+ SpaceClient spaceClient = null;
+
+ private Random random = new Random();
+ private WanderThread wanderThread = null;
+ private long timeLimitInMillis;
+ private long startTime;
+
+ public Bot(long spaceID, URI serviceURI, long timeLimitInMillis) throws IOException {
+ String guestCookie = "guestRobot_Banger_Test_" + System.currentTimeMillis() + "_" + random.nextInt();
+ if (guestCookie == null) {
+ throw new IOException("Could not get a guest cookie");
+ }
+ spaceClient = new SpaceClient(spaceID, serviceURI, guestCookie, this);
+ this.timeLimitInMillis=timeLimitInMillis;
+ this.startTime=System.currentTimeMillis();
+ }
+
+ public void wander() {
+ wanderThread = new WanderThread();
+ wanderThread.start();
+ }
+
+ public void cleanup() {
+ if (spaceClient != null) {
+ spaceClient.cleanup();
+ }
+ }
+
+ public void teleport(Transform3D position) {
+ spaceClient.viewpointMotionStopped(position);
+ }
+
+ public void disconnected() {
+ Log.error("UserRobot was disconnected");
+ }
+
+ public void receivedChatMessage(String username, String message) {
+ }
+
+ public void receivedSpaceTransfer(URI link) {
+ }
+
+ public void receivedLink(String displayName, String link) {
+ }
+
+ public void receivedCommandFocusRequest(String preloadedText) {
+ }
+
+ public void receivedBrowserMessage(long sourceThingID, String message) {
+ }
+
+ public void receivedContextMenuRequest(Thing thing, String shapeName, int x, int y, long nonce) {
+ }
+
+ public void receivedContextMenuData(long nonce, String errorIfAny, Vector contextMenu) {
+ }
+
+ public void contextItemChosen(Thing thing, long nonce, String id) {
+ }
+
+ public void receivedInfoPanel(long sourceThingID, String nonce) {
+ }
+
+ private class WanderThread extends Thread {
+ public void run() {
+ User user = spaceClient.getSpace().getUser(spaceClient.getUsername());
+ while (user == null) {
+ try {
+ sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ user = spaceClient.getSpace().getUser(spaceClient.getUsername());
+ }
+ try {
+ Vector3d homePosition = new Vector3d(Math.abs(random.nextInt()) % 10, 0, -30 + Math.abs(random.nextInt()) % 10);
+ Transform3D userPosition = new Transform3D();
+ userPosition.setTranslation(homePosition);
+ boolean lastSpun = true;
+ while (System.currentTimeMillis()-startTime < timeLimitInMillis) {
+ if (random.nextBoolean() || random.nextBoolean()) {
+ userPosition.setTranslation(homePosition);
+ spaceClient.viewpointMotionStopped(userPosition);
+ sleep(1000 + Math.abs((random.nextInt() % 5000)));
+ } else if (lastSpun) {
+ userPosition.rotY(random.nextFloat() % (2 * Math.PI));
+ userPosition.setTranslation(homePosition);
+ SplinePath path = J3DSplinePath.getSplinePath(userPosition, 1, 0, 0, 2);
+ spaceClient.viewpointMotionChanged(path);
+ sleep(3000 + Math.abs((random.nextInt() % 6000)));
+ lastSpun = false;
+ } else {
+ userPosition.setTranslation(homePosition);
+ SplinePath path = J3DSplinePath.getSplinePath(userPosition, 0, 1, 0, 2);
+ spaceClient.viewpointMotionChanged(path);
+ sleep(1000 + Math.abs((random.nextInt() % 6000)));
+ lastSpun = true;
+ }
+ }
+ } catch (Throwable t) {
+ Log.warn("Thread "+Thread.currentThread().getId()+" had to abort due to caught error:");
+ Log.warn(t.getClass().getName()+":"+t.getMessage());
+ }
+ }
+ }
+
+ public void receivedUserContextMenuRequest(User user, int x, int y) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void receivedTellMessage(String username, String message) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java 2008-01-23 03:18:47 UTC (rev 689)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java 2008-01-31 01:09:13 UTC (rev 701)
@@ -1,67 +0,0 @@
-package com.ogoglio.loadtest;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Vector;
-
-import com.ogoglio.util.Log;
-
-public class MultispaceTests {
-
- private URI serviceURI = null;
-
- private long lowerSpaceID = -1;
-
- private long upperSpaceID = -1;
-
- Vector bots = new Vector();
-
- public MultispaceTests(URI serviceURI, long lowerSpaceID, long upperSpaceID) {
- this.lowerSpaceID = lowerSpaceID;
- this.upperSpaceID = upperSpaceID;
- this.serviceURI = serviceURI;
- if (lowerSpaceID >= upperSpaceID) {
- throw new IllegalArgumentException("lower space ID must be less than upper space ID");
- }
- }
-
- public void startTests() throws IOException {
- for (long i = lowerSpaceID; i <= upperSpaceID; i++) {
- try {
- Bot bot = new Bot(i, serviceURI);
- System.out.println("Adding bot to space " + i);
- bots.add(bot);
- } catch (IOException e) {
- System.out.println("Skipping space " + i);
- }
- }
- }
-
- public void stopTests() {
- Bot[] theBots = (Bot[]) bots.toArray(new Bot[0]);
- for (int i = 0; i < theBots.length; i++) {
- theBots[i].cleanup();
- }
- }
-
- public static void main(String[] args) {
- if (args.length != 3) {
- Log.error("usage: ... serviceURI lowerSpaceID upperSpaceID");
- return;
- }
-
- URI serviceURI = URI.create(args[0]);
- long lowerSpaceID = Long.parseLong(args[1]);
- long upperSpaceID = Long.parseLong(args[2]);
-
- MultispaceTests tests = new MultispaceTests(serviceURI, lowerSpaceID, upperSpaceID);
- try {
- tests.startTests();
- Thread.sleep(500000000);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
-}
Copied: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java (from rev 700, maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultispaceTests.java)
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultispaceTests.java 2008-01-31 01:09:13 UTC (rev 701)
@@ -0,0 +1,67 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Vector;
+
+import com.ogoglio.util.Log;
+
+public class MultispaceTests {
+
+ private URI serviceURI = null;
+
+ private long lowerSpaceID = -1;
+
+ private long upperSpaceID = -1;
+
+ Vector bots = new Vector();
+
+ public MultispaceTests(URI serviceURI, long lowerSpaceID, long upperSpaceID) {
+ this.lowerSpaceID = lowerSpaceID;
+ this.upperSpaceID = upperSpaceID;
+ this.serviceURI = serviceURI;
+ if (lowerSpaceID >= upperSpaceID) {
+ throw new IllegalArgumentException("lower space ID must be less than upper space ID");
+ }
+ }
+
+ public void startTests() throws IOException {
+ for (long i = lowerSpaceID; i <= upperSpaceID; i++) {
+ try {
+ Bot bot = new Bot(i, serviceURI, 1000 * 10 * 60);
+ System.out.println("Adding bot to space " + i);
+ bots.add(bot);
+ } catch (IOException e) {
+ System.out.println("Skipping space " + i);
+ }
+ }
+ }
+
+ public void stopTests() {
+ Bot[] theBots = (Bot[]) bots.toArray(new Bot[0]);
+ for (int i = 0; i < theBots.length; i++) {
+ theBots[i].cleanup();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 3) {
+ Log.error("usage: ... serviceURI lowerSpaceID upperSpaceID");
+ return;
+ }
+
+ URI serviceURI = URI.create(args[0]);
+ long lowerSpaceID = Long.parseLong(args[1]);
+ long upperSpaceID = Long.parseLong(args[2]);
+
+ MultispaceTests tests = new MultispaceTests(serviceURI, lowerSpaceID, upperSpaceID);
+ try {
+ tests.startTests();
+ Thread.sleep(500000000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
Deleted: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java
===================================================================
--- maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java 2008-01-23 03:18:47 UTC (rev 689)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java 2008-01-31 01:09:13 UTC (rev 701)
@@ -1,83 +0,0 @@
-package com.ogoglio.loadtest;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Random;
-import java.util.Vector;
-
-import javax.media.j3d.Transform3D;
-import javax.vecmath.Vector3d;
-
-import com.ogoglio.client.SpaceClient;
-import com.ogoglio.client.SpaceClient.Listener;
-import com.ogoglio.client.model.SplinePath;
-import com.ogoglio.client.model.Thing;
-import com.ogoglio.client.model.User;
-import com.ogoglio.util.Log;
-import com.ogoglio.viewer.j3d.J3DSplinePath;
-
-public class MultiuserTests {
-
- private long spaceID = -1;
-
- private URI serviceURI = null;
-
- Vector robots = new Vector();
-
- public MultiuserTests(long spaceID, URI serviceURI) {
- this.spaceID = spaceID;
- this.serviceURI = serviceURI;
- }
-
- public synchronized void addRobot(Transform3D startPosition, boolean wander) throws IOException {
- Bot robot = new Bot(spaceID, serviceURI);
- robot.teleport(startPosition);
- robots.add(robot);
- if (wander) {
- robot.wander();
- }
- }
-
- private synchronized Bot[] getRobots() {
- return (Bot[]) robots.toArray(new Bot[0]);
- }
-
- public void cleanup() {
- Bot[] bots = getRobots();
- for (int i = 0; i < bots.length; i++) {
- bots[i].cleanup();
- }
- }
-
- public static void main(String[] args) {
- if (args.length != 3) {
- Log.error("usage: ... spaceID serviceURI numRobots");
- return;
- }
- MultiuserTests tests = null;
- try {
- long spaceID = Long.parseLong(args[0]);
- URI serviceURI = new URI(args[1]);
- tests = new MultiuserTests(spaceID, serviceURI);
-
- int numRobots = Integer.parseInt(args[2]);
- Transform3D startPosition = new Transform3D();
- for (int i = 0; i < numRobots; i++) {
- startPosition.setTranslation(new Vector3d(0, 0, -50));
- tests.addRobot(startPosition, true);
- Log.info("Added robot " + (i + 1) + " of " + numRobots);
- Thread.sleep(1000);
- }
-
- Thread.sleep(500000000);
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(1);
- } finally {
- if (tests != null) {
- tests.cleanup();
- }
- }
- }
-
-}
Copied: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java (from rev 700, maven/trunk/ogoglio-common/src/test/java/com/ogoglio/loadtest/MultiuserTests.java)
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/loadtest/MultiuserTests.java 2008-01-31 01:09:13 UTC (rev 701)
@@ -0,0 +1,85 @@
+package com.ogoglio.loadtest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Date;
+import java.util.Vector;
+
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Vector3d;
+
+import com.ogoglio.util.Log;
+
+public class MultiuserTests {
+
+ private long spaceID = -1;
+
+ private URI serviceURI = null;
+ private long timeLimit;
+
+ Vector robots = new Vector();
+
+ public MultiuserTests(long spaceID, URI serviceURI, long timeLimit) {
+ this.spaceID = spaceID;
+ this.serviceURI = serviceURI;
+ this.timeLimit=timeLimit;
+ }
+
+ public synchronized void addRobot(Transform3D startPosition, boolean wander) throws IOException {
+ Bot robot = new Bot(spaceID, serviceURI, timeLimit);
+ robot.teleport(startPosition);
+ robots.add(robot);
+ if (wander) {
+ robot.wander();
+ }
+ }
+
+ private synchronized Bot[] getRobots() {
+ return (Bot[]) robots.toArray(new Bot[0]);
+ }
+
+ public void cleanup() {
+ Bot[] bots = getRobots();
+ for (int i = 0; i < bots.length; i++) {
+ bots[i].cleanup();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 4) {
+ Log.error("usage: ... spaceID serviceURI numRobots duration");
+ return;
+ }
+ MultiuserTests tests = null;
+ try {
+ long spaceID = Long.parseLong(args[0]);
+ long limit= Long.parseLong(args[3]);
+ URI serviceURI = new URI(args[1]);
+ tests = new MultiuserTests(spaceID, serviceURI, limit);
+
+ int numRobots = Integer.parseInt(args[2]);
+ Transform3D startPosition = new Transform3D();
+ for (int i = 0; i < numRobots; i++) {
+ startPosition.setTranslation(new Vector3d(0, 0, -50));
+ tests.addRobot(startPosition, true);
+ Log.info("Added robot " + (i + 1) + " of " + numRobots);
+ Thread.sleep(1000);
+ }
+ Log.info("Finished launching all robots ("+args[2]+") onto "+args[1]+" space="+args[0]+"@"+(new Date())+" thread id "+Thread.currentThread().getId());
+ try {
+ Thread.sleep(limit);
+ } catch (InterruptedException e) {
+
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return;
+ } finally {
+ Log.info("Cleaning up for thread "+Thread.currentThread().getId()+" @ "+ (new Date()));
+ if (tests != null) {
+ tests.cleanup();
+ }
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-02-06 01:20:14
|
Revision: 710
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=710&view=rev
Author: trevorolio
Date: 2008-02-05 17:20:17 -0800 (Tue, 05 Feb 2008)
Log Message:
-----------
Added the back end and 3D rendering of attachment geometries and appearances, but not yet morphs or skin textures.
Also no example UI for picking attachments in the body editor, yet.
The "time to private parts" for Ogoglio starts now.
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/BodyConfiguration.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.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/body/MorphDeltaMap.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/Obj.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyConfigurationDocument.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
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Attachment.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AttachmentDocument.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 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/SpaceClient.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -26,6 +26,7 @@
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
+import com.ogoglio.client.model.Attachment;
import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Door;
@@ -47,8 +48,10 @@
import com.ogoglio.util.Log;
import com.ogoglio.util.WebConstants;
import com.ogoglio.xml.AccountDocument;
+import com.ogoglio.xml.AttachmentDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
+import com.ogoglio.xml.BodySettingDocument;
import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.ShapeDocument;
@@ -182,7 +185,7 @@
} else {
bodyConfDoc = webClient.getBodyConfiguration(userDocs[i].getUsername(), userDocs[i].getBodyConfigurationID());
}
- BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfDoc);
+ BodyConfiguration bodyConfig = createBodyConfiguration(bodyConfDoc);
Thing seatThing = null;
if (userDocs[i].getSeatThingID() != -1) {
seatThing = space.getThing(userDocs[i].getSeatThingID());
@@ -214,6 +217,31 @@
messenger.stopWaiting();
}
+ public BodyConfiguration createBodyConfiguration(BodyConfigurationDocument configDoc) {
+ BodyConfiguration config = new BodyConfiguration(configDoc.getBodyConfigurationID(), configDoc.getDisplayName(), configDoc.getBodyDataID(), configDoc.getBaseTextureName());
+ BodySettingDocument[] settingDocs = configDoc.getBodySettingDocuments();
+ for (int i = 0; i < settingDocs.length; i++) {
+ config.addSetting(settingDocs[i].getSettingName(), settingDocs[i].getSetting());
+ }
+ AttachmentDocument[] attachmentDocs = configDoc.getAttachmentDocuments();
+ for (int i = 0; i < attachmentDocs.length; i++) {
+ Template template = space.getTemplate(attachmentDocs[i].getTemplateID());
+ if (template == null) {
+ try {
+ TemplateDocument templateDoc = webClient.getTemplateDocument(attachmentDocs[i].getTemplateOwner(), attachmentDocs[i].getTemplateID());
+ template = new Template(templateDoc);
+ space.addTemplate(template);
+ } catch (IOException e) {
+ System.err.println("Could not find template for attachment: " + attachmentDocs[i].getTemplateID());
+ continue;
+ }
+ }
+ Attachment attachment = new Attachment(attachmentDocs[i].getAttachmentID(), template, config);
+ config.addAttachment(attachment);
+ }
+ return config;
+ }
+
public void mouseClickedUser(User user, Point3d intersection) {
Log.warn("SpaceClient ignoring user click");
}
@@ -352,7 +380,8 @@
SpaceEvent event = ((PayloadFactory.SpaceEventPayload) message.getPayload()).getSpaceEvent();
if (SpaceEvent.ADD_USER_EVENT.equals(event.getName())) {
BodyConfigurationDocument bodyConfigDoc = event.getBodyConfigurationDocument();
- BodyConfiguration bodyConfig = new BodyConfiguration(bodyConfigDoc);
+ BodyConfiguration bodyConfig = null;
+ bodyConfig = createBodyConfiguration(bodyConfigDoc);
String role = event.getStringProperty(SpaceEvent.USER_ROLE);
String voiceURI = event.getStringProperty(SpaceEvent.VOICE_URI);
String textURI = event.getStringProperty(SpaceEvent.TEXT_URI);
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 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/WebAPIClient.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -301,7 +301,7 @@
}
public TemplateDocument createTemplate(String templateName) throws IOException {
- TemplateDocument templateDoc = new TemplateDocument(-1, templateName, authenticator.getUsername(), null, null, false, 0, 0, 0, 1, 0, 0, 0);
+ TemplateDocument templateDoc = new TemplateDocument(-1, templateName, authenticator.getUsername(), null, null, false, false, 0, 0, 0, 1, 0, 0, 0);
XMLElement templateXML = wire.postAuthenticatedXML(descriptor.getTemplatesURI(authenticator.getUsername()), templateDoc.toString(), authenticator.getAuthCookie());
return new TemplateDocument(templateXML);
}
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Attachment.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Attachment.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Attachment.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -0,0 +1,35 @@
+package com.ogoglio.client.model;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class Attachment {
+
+ private long attachmentID = -1;
+
+ private Template template = null;
+
+ private BodyConfiguration bodyConfiguration = null;
+
+ public Attachment(long attachmentID, Template template, BodyConfiguration bodyConfiguration){
+ ArgumentUtils.assertNotNegative(attachmentID);
+ this.attachmentID = attachmentID;
+ ArgumentUtils.assertNotNull(template);
+ this.template = template;
+ ArgumentUtils.assertNotNull(bodyConfiguration);
+ this.bodyConfiguration = bodyConfiguration;
+ }
+
+ public long getAttachmentID() {
+ return attachmentID;
+ }
+
+ public Template getTemplate() {
+ return template;
+ }
+
+ public BodyConfiguration getBodyConfiguration() {
+ return bodyConfiguration;
+ }
+
+
+}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/BodyConfiguration.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -1,8 +1,10 @@
package com.ogoglio.client.model;
import java.util.HashMap;
+import java.util.Vector;
import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.xml.AttachmentDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodySettingDocument;
@@ -20,13 +22,7 @@
private HashMap settings = new HashMap();
- public BodyConfiguration(BodyConfigurationDocument configDoc) {
- this(configDoc.getBodyConfigurationID(), configDoc.getDisplayName(), configDoc.getBodyDataID(), configDoc.getBaseTextureName());
- BodySettingDocument[] settingDocs = configDoc.getBodySettingDocuments();
- for (int i = 0; i < settingDocs.length; i++) {
- addSetting(settingDocs[i].getSettingName(), settingDocs[i].getSetting());
- }
- }
+ private Vector attachments = new Vector();
public BodyConfiguration(long bodyConfigurationID, String displayName, long bodyDataID, String baseTextureName) {
ArgumentUtils.assertNotNegative(bodyConfigurationID);
@@ -37,6 +33,25 @@
this.baseTextureName = baseTextureName;
}
+ public Attachment[] getAttachments(){
+ return (Attachment[])attachments.toArray(new Attachment[0]);
+ }
+
+ public void addAttachment(Attachment attachment){
+ attachments.add(attachment);
+ }
+
+ public Attachment removeAttachment(long attachmentID){
+ Attachment[] as = getAttachments();
+ for (int i = 0; i < as.length; i++) {
+ if(as[i].getAttachmentID() == attachmentID){
+ attachments.remove(as[i]);
+ return as[i];
+ }
+ }
+ return null;
+ }
+
public void setUser(User user) {
ArgumentUtils.assertNotNull(user);
this.user = user;
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -0,0 +1,102 @@
+package com.ogoglio.viewer.j3d;
+
+import java.util.Vector;
+
+import javax.media.j3d.Appearance;
+import javax.media.j3d.Geometry;
+import javax.media.j3d.Shape3D;
+import javax.media.j3d.Transform3D;
+import javax.vecmath.Point3f;
+import javax.vecmath.Vector3f;
+
+import com.ogoglio.client.model.Attachment;
+import com.ogoglio.util.Log;
+import com.ogoglio.viewer.j3d.body.Skeleton;
+
+public class J3DAttachment {
+
+ private Attachment attachment = null;
+
+ private Vector skeletonAttachments = new Vector();
+
+ private Skeleton skeleton = null;
+
+ public J3DAttachment(Attachment attachment, J3DDataManager dataManager) {
+ this.attachment = attachment;
+
+ J3DTemplateData[] templateDataList = dataManager.getTemplateData(attachment.getTemplate().getOwnerUsername(), attachment.getTemplate().getTemplateID(), true);
+ J3DTemplateData templateData = null;
+ for (int j = 0; j < templateDataList.length; j++) {
+ if (templateDataList[j] != null) {
+ templateData = templateDataList[j];
+ break;
+ }
+ }
+
+ if (templateData == null) {
+ Log.warn("Could not load template data for attachment " + attachment.getAttachmentID());
+ return;
+ }
+
+ String[] shapeNames = templateData.getShapeNames();
+ for (int j = 0; j < shapeNames.length; j++) {
+ Geometry geometry = templateData.getGeometry(shapeNames[j]);
+ Skeleton.Attachment boneAttachment = new Skeleton.Attachment();
+ Shape3D shape = new Shape3D(geometry);
+ Appearance appearance = templateData.getAppearance(shapeNames[j]);
+ if (appearance != null) {
+ shape.setAppearance(appearance);
+ }
+ boneAttachment.addChild(shape);
+ boneAttachment.setUserData(shapeNames[j]);
+ skeletonAttachments.add(boneAttachment);
+ }
+ }
+
+ public Attachment getAttachment(){
+ return attachment;
+ }
+
+ public Skeleton.Attachment[] getSkeletonAttachments() {
+ return (Skeleton.Attachment[]) skeletonAttachments.toArray(new Skeleton.Attachment[0]);
+ }
+
+ public void detach() {
+ if (skeleton == null) {
+ return;
+ }
+ Skeleton.Attachment[] sAttachments = getSkeletonAttachments();
+ for (int i = 0; i < sAttachments.length; i++) {
+ String shapeName = (String) sAttachments[i].getUserData();
+ Skeleton.Bone bone = skeleton.getRootBone().getBone(shapeName);
+ if(bone != null){
+ bone.removeChild(sAttachments[i]);
+ }
+ }
+ skeleton = null;
+ }
+
+ public void attach(Skeleton skeleton) {
+ if (skeleton == this.skeleton) {
+ return;
+ }
+ detach();
+
+ this.skeleton = skeleton;
+ Skeleton.Attachment[] sAttachments = getSkeletonAttachments();
+ for (int i = 0; i < sAttachments.length; i++) {
+ String shapeName = (String) sAttachments[i].getUserData();
+ Skeleton.Bone bone = skeleton.getRootBone().getBone(shapeName);
+ if (bone == null) {
+ Log.warn("Could not find a bone for attachment shape " + shapeName + ", ignoring.");
+ continue;
+ }
+ Transform3D boneTransform = new Transform3D();
+ Point3f cumulativeOffset = bone.getCumulativeOffset();
+ boneTransform.setTranslation(new Vector3f(-cumulativeOffset.x, -cumulativeOffset.y, -cumulativeOffset.z));
+ sAttachments[i].setTransform(boneTransform);
+
+ bone.addAttachment(sAttachments[i]);
+ }
+ }
+}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -325,7 +325,6 @@
return results;
}
}
-
fetchTemplateData(username, templateID, results);
for (int i = 0; i < results.length; i++) {
if (results[i] == null) {
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 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -17,30 +17,33 @@
import java.awt.GraphicsConfigTemplate;
import java.awt.GraphicsConfiguration;
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;
import javax.media.j3d.AmbientLight;
+import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.DirectionalLight;
+import javax.media.j3d.Geometry;
import javax.media.j3d.GraphicsConfigTemplate3D;
import javax.media.j3d.Node;
+import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
+import javax.vecmath.Point3f;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;
import com.ogoglio.client.SpaceClient;
import com.ogoglio.client.UserInputListener;
+import com.ogoglio.client.model.Attachment;
import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Door;
@@ -54,8 +57,8 @@
import com.ogoglio.client.model.User;
import com.ogoglio.util.BodyConstants;
import com.ogoglio.util.Log;
-import com.ogoglio.util.UIConstants;
import com.ogoglio.util.WebConstants;
+import com.ogoglio.viewer.j3d.body.Skeleton;
import com.ogoglio.viewer.render.Camera;
import com.ogoglio.viewer.render.ClickTarget;
import com.ogoglio.viewer.render.DoorRenderable;
@@ -128,7 +131,7 @@
setCapabilities(sceneRoot);
setCapabilities(usersGroup);
setCapabilities(worldGroup);
- GraphicsConfiguration graphicsConfig = getGraphicsConfiguration(this.offScreen);
+ GraphicsConfiguration graphicsConfig = getGraphicsConfiguration(offScreen);
if (graphicsConfig == null) {
throw new IllegalStateException("Cannot create a 3D graphics configuration.");
}
@@ -216,7 +219,7 @@
sceneRoot.addChild(background);
if (!offScreen && getSpace().shouldDisplaySea()) {
- //TODO ideally this would be infinite in percieved size
+ //TODO ideally this would be infinite in size
float sideLength = 2500;
int divisions = (int) Math.min(20, sideLength / 100);
water = new J3DWater(sideLength, divisions, 2, 0);
@@ -697,10 +700,16 @@
customSkin = dataManager.getBodyTexture(user.getUsername(), bodyConfig.getBodyConfigurationID());
}
- boolean isLocalUser = !offScreen && username != null && user.getUsername().equals(username);
final J3DUserRenderable renderable = new J3DUserRenderable(user, bodyData, customSkin);
renderable.setID(USER_ID_PREFIX + user.getUsername());
+ if (offScreen) {
+ return renderable;
+ }
+
+ //NOTE: BELOW HERE SHOULD BE ONLY ON-SCREEN BLING LIKE CAMERAS, NAME TAGS, AND ATTACHMENTS
+
+ boolean isLocalUser = username != null && user.getUsername().equals(username);
if (isLocalUser) {
float cameraHeight = (float) (renderable.getHeight() - renderable.getHeight() / 5);
camera.setDefaultLocation(0, 0, 0);
@@ -711,7 +720,7 @@
getCanvas().addMouseListener(motionHandler);
getCanvas().addMouseMotionListener(motionHandler);
getCanvas().addMouseWheelListener(motionHandler);
- } else if (!offScreen) {
+ } else {
String displayName = user.getUsername();
if (displayName.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
displayName = J3DUserRenderable.convertGuestCookieToDisplayName(displayName);
@@ -719,6 +728,11 @@
renderable.setNameTag(displayName);
}
+ Attachment[] attachments = bodyConfig.getAttachments();
+ for (int i = 0; i < attachments.length; i++) {
+ J3DAttachment j3dAttachment = new J3DAttachment(attachments[i], dataManager);
+ renderable.attach(j3dAttachment);
+ }
return renderable;
}
@@ -848,7 +862,7 @@
public boolean completedInitialLoad() {
return completedInitialLoad;
}
-
+
public static void getEuler(Quat4d quat, Vector3d euler) {
double heading = 0, bank = 0, attitude = 0;
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 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -16,6 +16,7 @@
import java.awt.Font;
import java.awt.image.BufferedImage;
+import java.util.Vector;
import java.util.regex.Pattern;
import javax.media.j3d.Billboard;
@@ -79,6 +80,8 @@
private boolean playDefaultAnimationWhenComplete = true;
private J3DCameraMotionBehavior cameraBehavior = null;
+
+ private Vector attachments = new Vector();
public J3DUserRenderable(User user, J3DBodyData bodyData, BufferedImage customSkin) {
ArgumentUtils.assertNotNull(user);
@@ -306,4 +309,16 @@
public J3DCameraMotionBehavior getCameraBehavior() {
return cameraBehavior;
}
+
+ public Skeleton getSkeleton() {
+ return skeleton;
+ }
+
+ public void attach(J3DAttachment attachment) {
+ if(attachments.contains(attachment)){
+ return;
+ }
+ attachments.add(attachment);
+ attachment.attach(skeleton);
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMap.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -30,6 +30,9 @@
public MorphDeltaMap(String name, String parentName) {
this.name = name;
+ if(parentName != null && parentName.length() == 0){
+ parentName = null;
+ }
this.parentName = parentName;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/MorphDeltaMapParser.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -63,8 +63,8 @@
}
private void parseParentName(String[] tokens) throws MorphDeltaMapParseException {
- if(tokens.length < 2){
- throw new MorphDeltaMapParseException("Bad parent name definition: " + LineTokenizer.toString(tokens));
+ if(tokens.length == 1){
+ return;
}
parentName = LineTokenizer.toString(tokens, 1);
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -162,6 +162,18 @@
setTransform(workingTransform);
}
+ public Point3f getCumulativeOffset() {
+ Point3f result = new Point3f(offset.x, offset.y, offset.z);
+ Bone parent = getParentBone();
+ while(parent != null){
+ result.x += parent.getOffset().x;
+ result.y += parent.getOffset().y;
+ result.z += parent.getOffset().z;
+ parent = parent.getParentBone();
+ }
+ return result;
+ }
+
}
public void print(Bone bone) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -25,8 +25,10 @@
public class SkinLoader {
- public static final float AVATAR_SIZE = 2; //this will eventually be changable
+ public static final float AVATAR_SIZE = 2; //this will eventually be mutable
+ public static final float ANIMATION_Y_SHIFT = -1.2772343f; //this is the offset to place a human hip at the origin (usually) for standard BVH files
+
private GeometryArray geometry = null;
private BufferedImage baseImage;
@@ -61,37 +63,6 @@
}
public Skin generateSkin(J3DUserRenderable userRenderable) {
- float[] vertices = geometry.getCoordRefFloat();
-
- float maxY = Float.MIN_VALUE;
- float minY = Float.MAX_VALUE;
- for (int i = 1; i < vertices.length; i += 3) {
- if (vertices[i] < minY) {
- minY = vertices[i];
- }
- if (vertices[i] > maxY) {
- maxY = vertices[i];
- }
- }
- float heightScale = AVATAR_SIZE / Math.abs(maxY - minY);
- if (Math.abs(heightScale) > 0.001) {
- for (int i = 0; i < vertices.length - 2; i += 3) {
- vertices[i] = vertices[i] * heightScale;
- vertices[i + 1] = vertices[i + 1] * heightScale;
- vertices[i + 2] = vertices[i + 2] * heightScale;
- }
- }
-
- minY = Float.MAX_VALUE;
- for (int i = 1; i < vertices.length; i += 3) {
- if (vertices[i] < minY) {
- minY = vertices[i];
- }
- }
- float yChange = (float) -1.2772343 - minY;
- for (int i = 0; i < vertices.length - 2; i += 3) {
- vertices[i + 1] = vertices[i + 1] + yChange;
- }
Skin skin = new Skin(baseImage, morphDeltaMaps, bodyConfiguration, userRenderable);
skin.setGeometry(geometry);
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/Obj.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/Obj.java 2008-02-06 01:19:59 UTC (rev 709)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/obj/Obj.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -67,7 +67,13 @@
private ObjMtl mtl = null;
public void writeObj(Writer writer) throws IOException {
- writer.write("# created by Ogoglio Obj library\n");
+ writer.write("# created by Ogoglio Obj library: http://ogoglio.com/\n");
+ writer.write("# num vertices: " + getVertices().length + "\n");
+ writer.write("# num faces: " + faces.size() + "\n");
+ writer.write("# num groups: " + getGroups().length + "\n");
+ writer.write("# num smoothing groups: " + getSmoothingGroups().length + "\n");
+ writer.write("# num material groups: " + getMaterialGroups().length + "\n");
+
if (mtl != null) {
writer.write("mtllib " + mtl.getResourceName() + "\n");
}
@@ -92,7 +98,6 @@
int[][] materialRangeStarts = getRangeStarts(getMaterialGroups());
for (int i = 1; i <= faces.size(); i++) {
-
for (int j = 0; j < groupRangeStarts.length; j++) {
if(groupRangeStarts[j][0] == i) {
writer.write("g " + getGroup(groupRangeStarts[j][1]).getName() + "\n");
@@ -132,6 +137,7 @@
}
writer.write("\n");
}
+ writer.flush();
}
/**
Added: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AttachmentDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AttachmentDocument.java (rev 0)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/AttachmentDocument.java 2008-02-06 01:20:17 UTC (rev 710)
@@ -0,0 +1,62 @@
+package com.ogoglio.xml;
+
+import nanoxml.XMLElement;
+
+import com.ogoglio.util.ArgumentUtils;
+
+public class AttachmentDocument {
+
+ public static final String NAME = "attachment";
+
+ public static final String ATTACHMENT_ID = "attachmentid";
+
+ public static final String TEMPLATE_ID = "templateid";
+
+ public static final String TEMPLATE_OWNER = "templateowner";
+
+ public static final String BODY_CONFIGURATION_ID = "bodyconfigurationid";
+
+ public XMLElement data = null;
+
+ public AttachmentDocument(long attachmentID, String templateOwner, long templateID, long bodyConfigurationID) {
+ data = new XMLElement(NAME);
+ data.setAttribute(ATTACHMENT_ID, attachmentID);
+ ArgumentUtils.assertNotEmpty(templateOwner);
+ data.setAttribute(TEMPLATE_OWNER, templateOwner);
+ ArgumentUtils.assertNotNegative(templateID);
+ data.setAttribute(TEMPLATE_ID, templateID);
+ ArgumentUtils.assertNotNegative(bodyConfigurationID);
+ data.setAttribute(BODY_CONFIGURATION_ID, bodyConfigurationID);
+ }
+
+ public AttachmentDocument(XMLElement data) {
+ if (!NAME.equals(data.getName())) {
+ throw new IllegalArgumentException("data is not named " + NAME + ": " + data);
+ }
+ this.data = data;
+ }
+
+ public long getAttachmentID() {
+ return data.getLongAttribute(ATTACHMENT_ID);
+ }
+
+ public long getTemplateID() {
+ return data.getLongAttribute(TEMPLATE_ID);
+ }
+
+ public String getTemplateOwner() {
+ return data.getStringAttribute(TEMPLATE_OWNER);
+ }
+
+ public long getBodyConfigurationID() {
+ return data.getLongAttribute(BODY_CONFIGURATION_ID);
+ }
+
+ public XMLElement toElement() {
+ return data;
+ }
+
+ public String toString() {
+ return data.toString();
+ }
+}
Modified: maven/trunk/ogoglio-common/src/main/java/com/og...
[truncated message content] |