|
From: <tre...@us...> - 2007-09-27 18:06:48
|
Revision: 448
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=448&view=rev
Author: trevorolio
Date: 2007-09-27 11:06:51 -0700 (Thu, 27 Sep 2007)
Log Message:
-----------
Halfway through a grand avatar rewhack.
In this half I switch over to using downloadable wadges of avatar data instead of in-jar resources for avatar data.
Removed the GeomtryProvider interface, which is now replaced by TemplateDataProvider and BodyDataProvider interfaces which are used to fill the J3DDataManager with cached versions of all network accessed resources. This allows us to control memory usage, but also (eventually) reduces our memory footprint as we only make copies of data which is avatar specific.
Modified Paths:
--------------
maven/trunk/ogoglio-server/pom.xml
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
maven/trunk/ogoglio-server/src/main/resources/siteTemplates/thingPopup.html
Removed Paths:
-------------
maven/trunk/ogoglio-server/src/main/resources/populate/template-23/OfficeBuilding.blend1
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/pom.xml 2007-09-27 18:06:51 UTC (rev 448)
@@ -89,13 +89,35 @@
<!-- PLUGINS -->
<!-- -->
<plugins>
-
- <!-- DEPENDENCY PLUGIN: We need to pull in applets -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
+
<execution>
+ <id>copy-body</id>
+ <phase>test</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/${pom.artifactId}-${version}/WEB-INF/classes
+ </outputDirectory>
+ <stripVersion>true</stripVersion>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.ogoglio.body</groupId>
+ <artifactId>
+ ogoglio-body-sim
+ </artifactId>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+
+ <!-- We need to pull in applets -->
+ <execution>
<id>copy-applets</id>
<phase>test</phase>
<goals>
@@ -114,6 +136,18 @@
</artifactId>
</artifactItem>
<artifactItem>
+ <groupId>com.ogoglio.body</groupId>
+ <artifactId>
+ ogoglio-body-mike
+ </artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.ogoglio.body</groupId>
+ <artifactId>
+ ogoglio-body-andrea
+ </artifactId>
+ </artifactItem>
+ <artifactItem>
<groupId>com.ogoglio</groupId>
<artifactId>
ogoglio-body-editor-applet
@@ -199,7 +233,7 @@
<server>localMachine</server>
<path>/og</path>
</configuration>
-
+
<executions>
<execution>
<phase>install</phase>
@@ -209,7 +243,7 @@
</goals>
</execution>
</executions>
-
+
</plugin>
</plugins>
</build>
@@ -272,9 +306,6 @@
<artifactId>ogoglio-appdev</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
- <!-- -->
- <!-- BOGUS DEPENDENCIES-->
- <!-- -->
<dependency>
<groupId>com.ogoglio</groupId>
<artifactId>ogoglio-viewer-applet</artifactId>
@@ -293,7 +324,24 @@
<version>0.0.1-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
-
+ <dependency>
+ <groupId>com.ogoglio.body</groupId>
+ <artifactId>ogoglio-body-mike</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ogoglio.body</groupId>
+ <artifactId>ogoglio-body-andrea</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ogoglio.body</groupId>
+ <artifactId>ogoglio-body-sim</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/SpaceSimulator.java 2007-09-27 18:06:51 UTC (rev 448)
@@ -21,26 +21,27 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
+import java.util.zip.ZipInputStream;
import javax.media.j3d.Transform3D;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import com.ogoglio.client.UserInputListener;
+import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Door;
-import com.ogoglio.client.model.GeometryProvider;
import com.ogoglio.client.model.Page;
import com.ogoglio.client.model.Shape;
import com.ogoglio.client.model.Space;
import com.ogoglio.client.model.SplinePath;
import com.ogoglio.client.model.Template;
+import com.ogoglio.client.model.TemplateDataProvider;
import com.ogoglio.client.model.Thing;
import com.ogoglio.client.model.User;
import com.ogoglio.sim.script.ScriptHTTPResponse;
import com.ogoglio.sim.script.SpaceScriptEngine;
import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.BlockingQueue;
-import com.ogoglio.util.BodyConstants;
import com.ogoglio.util.Log;
import com.ogoglio.util.UIConstants;
import com.ogoglio.util.BlockingQueue.QueueClosedException;
@@ -81,6 +82,8 @@
// a flag that mark this simulator to be deleted after it will be shutdown
private boolean deleted = false;
+ private InSimTemplateDataProvider templateDataProvider = new InSimTemplateDataProvider();
+
public SpaceSimulator(SpaceDocument spaceDocument, Listener listener) {
ArgumentUtils.assertNotNull(listener);
this.listener = listener;
@@ -91,7 +94,7 @@
space = new Space(new SimulatorSpaceContext(), spaceDocument.getSpaceID(), spaceDocument.getDisplayName(), spaceDocument.getOwnerUsername(), spaceDocument.getDisplaySea(), spaceDocument.getSeaLevel());
//TODO evaluate whether we should stop using Java3D on the sim side to calculate collision and motion (gut feeling: hell yes!)
- renderer = new J3DRenderer(space, null, new InSimInputListener(), new InSimErrorGeometryProvider(), true);
+ renderer = new J3DRenderer(space, null, new InSimInputListener(), templateDataProvider, new InSimBodyDataProvider(), true);
renderer.startRenderer();
renderer.setSimCamera(); //Sigh, you have to add a view before it will schedule the behavior
@@ -144,42 +147,6 @@
private class SimulatorSpaceContext implements Space.Context {
- public InputStream getTemplateGeometryStream(String ownerUsername, long templateID, int lodIndex) {
- Template template = space.getTemplate(templateID);
- if (template == null) {
- return null;
- }
- return listener.getTemplateGeometryStream(templateID, lodIndex);
- }
-
- public InputStream getTemplateResourceStream(String ownerUsername, long templateID, String name) throws IOException {
- Template template = space.getTemplate(templateID);
- if (template == null) {
- return null;
- }
- return listener.getTemplateResourceStream(templateID, name);
- }
-
- public InputStream getThingAnimationStream(long thingID, long animationID) throws IOException {
- return null;
- }
-
- public InputStream getUserAnimationStream(String username, long animationID) throws IOException {
- return BodyConstants.getUserAnimation((int) animationID);
- }
-
- public InputStream getUserSkinMapStream(String username) throws IOException {
- 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 String getThingScript(long thingID) throws IOException {
Thing thing = space.getThing(thingID);
if (thing == null) {
@@ -188,18 +155,6 @@
return listener.getTemplateScript(thing.getTemplate().getTemplateID());
}
- public InputStream getUserGeometryStream(String username, String name) throws IOException {
- 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 getPageContentStream(long thingID, long pageID) {
return null; //we don't need to render pages, do we?
}
@@ -247,6 +202,9 @@
while (!cleaned) {
try {
SpaceEvent event = (SpaceEvent) queue.dequeue();
+ if(cleaned){
+ return;
+ }
if (SpaceEvent.ADD_USER_EVENT.equals(event.getName())) {
listener.generatedSpaceEvent(event, SpaceSimulator.this);
log("added user " + event.getStringProperty(SpaceEvent.USERNAME));
@@ -383,22 +341,13 @@
// this is a hack to play pre-baked animations
// TODO create a user animation record and a method to dl and play them
- if(chatMessage.startsWith("/") && chatMessage.length() > 1){
+ if (chatMessage.startsWith("/") && chatMessage.length() > 1) {
String command = chatMessage.substring(1);
- boolean sentAnimation = false;
- for (int i = 0; i < BodyConstants.USER_ANIMATION_COMMANDS.length; i++) {
- if(BodyConstants.USER_ANIMATION_COMMANDS[i].equals(command)){
- SpaceEvent playAnimationEvent = new SpaceEvent(SpaceEvent.PLAY_ANIMATION_EVENT);
- playAnimationEvent.setProperty(SpaceEvent.USERNAME, user.getUsername());
- playAnimationEvent.setProperty(SpaceEvent.ANIMATION_ID, new Long(i));
- listener.generatedSpaceEvent(playAnimationEvent, SpaceSimulator.this);
- sentAnimation = true;
- break;
- }
- }
- if(sentAnimation){
- continue;
- }
+ SpaceEvent playAnimationEvent = new SpaceEvent(SpaceEvent.PLAY_ANIMATION_EVENT);
+ playAnimationEvent.setProperty(SpaceEvent.USERNAME, user.getUsername());
+ playAnimationEvent.setProperty(SpaceEvent.ANIMATION_NAME, command);
+ listener.generatedSpaceEvent(playAnimationEvent, SpaceSimulator.this);
+ continue;
}
chatMessage = markdownChatMessage(chatMessage);
@@ -409,10 +358,7 @@
listener.generatedSpaceEvent(markedUpEvent, SpaceSimulator.this);
- } else if (((SpaceEvent.THING_CLICKED_EVENT.equals(event.getName()))) ||
- ((SpaceEvent.THING_CONTEXT_CLICKED_EVENT.equals(event.getName()))) ||
- ((SpaceEvent.THING_CONTEXT_SELECTION_MADE_EVENT.equals(event.getName())))
- ){
+ } else if (((SpaceEvent.THING_CLICKED_EVENT.equals(event.getName()))) || ((SpaceEvent.THING_CONTEXT_CLICKED_EVENT.equals(event.getName()))) || ((SpaceEvent.THING_CONTEXT_SELECTION_MADE_EVENT.equals(event.getName())))) {
String username = event.getStringProperty(SpaceEvent.USERNAME);
User user = space.getUser(username);
if (user == null) {
@@ -438,7 +384,7 @@
log("Internal server error: " + e);
e.printStackTrace();
} catch (Throwable e) {
- Log.error("Error handling space event",e);
+ Log.error("Error handling space event", e);
}
}
}
@@ -1033,30 +979,37 @@
}
}
- private class InSimErrorGeometryProvider implements GeometryProvider {
-
- public InputStream getAnimationStream(long animationID) throws IOException {
- return null;
+ private class InSimBodyDataProvider implements BodyDataProvider {
+ public ZipInputStream getBodyData(String bodyName) {
+ return new ZipInputStream(getClass().getClassLoader().getResourceAsStream("ogoglio-body-sim.jar"));
}
+ }
- public InputStream getGeometryStream(int lodIndex) throws IOException {
- if (lodIndex != 0) {
+ private class InSimTemplateDataProvider implements TemplateDataProvider {
+
+ public InputStream getTemplateGeometry(String username, long templateID, int lod) {
+ Template template = space.getTemplate(templateID);
+ if (template == null) {
return null;
}
- return UIConstants.getResource("templates/loading.obj");
+ return listener.getTemplateGeometryStream(templateID, lod);
}
- public InputStream getSkinMapStream() throws IOException {
- return null;
+ public InputStream getTemplateResource(String username, long templateID, String resourceName) {
+ Template template = space.getTemplate(templateID);
+ if (template == null) {
+ return null;
+ }
+ return listener.getTemplateResourceStream(templateID, resourceName);
}
- public InputStream getSubGeometryStream(String name) throws IOException {
- if ("loading.mtl".equals(name)) {
- return UIConstants.getResource("templates/loading.mtl");
+ public String getTemplateScript(String username, long templateID){
+ Template template = space.getTemplate(templateID);
+ if (template == null) {
+ return null;
}
- return null;
+ return listener.getTemplateScript(templateID);
}
-
}
private class InSimInputListener implements UserInputListener {
@@ -1084,4 +1037,8 @@
public void mouseContextClickedThing(Thing thing, String name, int x, int y) {
}
}
+
+ public TemplateDataProvider getTemplateDataProvider() {
+ return templateDataProvider;
+ }
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/script/SpaceScriptEngine.java 2007-09-27 18:06:51 UTC (rev 448)
@@ -118,7 +118,7 @@
}
public void constructThingScript(Thing thing) throws IOException {
- String script = thing.getScript();
+ String script = spaceSimulator.getTemplateDataProvider().getTemplateScript(thing.getTemplate().getOwnerUsername(), thing.getTemplate().getTemplateID());
if (script == null) {
spaceSimulator.log("Constructed scriptless thing " + thing.getThingID());
return;
@@ -464,6 +464,6 @@
public void shapeMotionStopped(Shape shape, Transform3D position) {
}
- public void userAnimationStarted(User user, long animationID) {
+ public void userAnimationStarted(User user, String animationName) {
}
}
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-09-27 18:06:51 UTC (rev 448)
@@ -74,7 +74,7 @@
public void init(ServletConfig config) throws ServletException {
super.init(config);
- System.out.println("IN INIT:"+config.getServletName()+","+config.getServletContext().getServletContextName());
+ System.out.println("REALLY IN INIT:"+config.getServletName()+","+config.getServletContext().getServletContextName());
try {
Context envCtx = (Context) initCtx.lookup("java:comp/env");
simURI = new URI((String) envCtx.lookup("ogoglio/baseSimURL"));
@@ -127,7 +127,6 @@
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
- System.out.println("FART: SERVICE:"+request.getPathInfo());
super.service(request, response);
}
@@ -290,10 +289,8 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
long spaceID = Long.parseLong(pathElements[2]);
- System.out.println("FART: do get:"+spaceID);
try {
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(spaceID, getSessionFactory());
- System.out.println("FART: do get:"+spaceID+" w/"+spaceRecord.getSimID());
if (spaceRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
@@ -355,7 +352,6 @@
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
- System.out.println("FART: do post:"+spaceID+","+spaceRecord.getSimID());
AccountRecord authedAccount = AuthServlet.getAuthedAccountRecord(request, getSessionFactory());
if (authedAccount != null && !authedAccount.getUsername().equals(spaceRecord.getOwnerUsername())) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/site/SpaceServlet.java 2007-09-27 18:06:51 UTC (rev 448)
@@ -481,10 +481,8 @@
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
}
- System.out.println("FART: PROXY authed:"+authedAccount.getUsername());
SimRecord simRecord = SpacePersistTasks.findOrAssignSim(spaceRecord, getSessionFactory());
- System.out.println("FART PROXY: "+simRecord.getSimID()+","+simRecord.getSimURI());
if (simRecord == null) {
Log.error("Could not assign a sim to space " + spaceRecord.getSpaceID());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -496,7 +494,6 @@
proxyURI += pathElements[i] + "/";
}
- System.out.println("FART: PROXY URI ABOUT TO GO:"+proxyURI);
proxy(new URI(proxyURI), method, request, response);
} catch (PersistException e) {
Deleted: maven/trunk/ogoglio-server/src/main/resources/populate/template-23/OfficeBuilding.blend1
===================================================================
(Binary files differ)
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/ogoglio.js 2007-09-27 18:06:51 UTC (rev 448)
@@ -295,6 +295,14 @@
}
}
+Quaternion.prototype.add = function(q1){
+ this.x += q1.x;
+ this.y += q1.y;
+ this.z += q1.z;
+ this.w += q1.w;
+ this.normalize();
+}
+
Quaternion.prototype.mul = function(q1){
var nw = this.w * q1.w - this.x * q1.x - this.y * q1.y - this.z * q1.z;
var nx = this.w * q1.x + q1.w * this.x + this.y * q1.z - this.z * q1.y;
Modified: maven/trunk/ogoglio-server/src/main/resources/siteTemplates/thingPopup.html
===================================================================
--- maven/trunk/ogoglio-server/src/main/resources/siteTemplates/thingPopup.html 2007-09-27 18:06:47 UTC (rev 447)
+++ maven/trunk/ogoglio-server/src/main/resources/siteTemplates/thingPopup.html 2007-09-27 18:06:51 UTC (rev 448)
@@ -98,17 +98,23 @@
function moveToX(x){
if(thingXML == null) return;
thingXML.setAttribute('x', x);
+ thingXML.setAttribute('y', yPosInput.value);
+ thingXML.setAttribute('z', zPosInput.value);
updateThing(spaceID, thingXML, handleThingDocument);
}
function moveToY(y){
if(thingXML == null) return;
+ thingXML.setAttribute('x', xPosInput.value);
thingXML.setAttribute('y', y);
+ thingXML.setAttribute('z', zPosInput.value);
updateThing(spaceID, thingXML, handleThingDocument);
}
function moveToZ(z){
if(thingXML == null) return;
+ thingXML.setAttribute('x', xPosInput.value);
+ thingXML.setAttribute('y', yPosInput.value);
thingXML.setAttribute('z', z);
updateThing(spaceID, thingXML, handleThingDocument);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|