|
From: <tre...@us...> - 2008-02-06 01:19:52
|
Revision: 709
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=709&view=rev
Author: trevorolio
Date: 2008-02-05 17:19:59 -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-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
Modified: maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
===================================================================
--- maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2008-02-06 01:19:48 UTC (rev 708)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2008-02-06 01:19:59 UTC (rev 709)
@@ -51,13 +51,16 @@
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.client.WebAPIClientWire;
import com.ogoglio.client.WebAPIDescriptor;
+import com.ogoglio.client.model.Attachment;
import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Space;
+import com.ogoglio.client.model.Template;
import com.ogoglio.client.model.TemplateDataProvider;
import com.ogoglio.client.model.User;
import com.ogoglio.client.model.Space.Context;
import com.ogoglio.util.UIConstants;
+import com.ogoglio.viewer.j3d.J3DAttachment;
import com.ogoglio.viewer.j3d.J3DBodyData;
import com.ogoglio.viewer.j3d.J3DCamera;
import com.ogoglio.viewer.j3d.J3DCanvas;
@@ -68,8 +71,11 @@
import com.ogoglio.viewer.j3d.body.MorphDeltaMap;
import com.ogoglio.viewer.j3d.bvh.Bvh;
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.TemplateDocument;
/*
* NOTE: String arrays don't function in LiveConnect in IE, so we use the getXXXCount and getXXX(index) pattern
@@ -205,8 +211,8 @@
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return;
}
- new Thread(){
- public void run(){
+ new Thread() {
+ public void run() {
try {
// Obtain the size of the displayed canvas
@@ -243,7 +249,7 @@
} catch (Throwable e) {
e.printStackTrace();
}
-
+
}
}.start();
}
@@ -322,7 +328,7 @@
System.err.println("Could not fetch body config");
return;
}
- user.setBodyConfiguration(new BodyConfiguration(doc));
+ user.setBodyConfiguration(createBodyConfiguration(doc));
bodyPanel.bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
bodyPanel.renderable.initBody(bodyPanel.bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
accountDoc.setBodyConfigurationID(bodyConfigurationID);
@@ -334,9 +340,29 @@
}
}
+ private 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++) {
+ try {
+ TemplateDocument templateDoc = webClient.getTemplateDocument(attachmentDocs[i].getTemplateOwner(), attachmentDocs[i].getTemplateID());
+ Template template = new Template(templateDoc);
+ Attachment attachment = new Attachment(attachmentDocs[i].getAttachmentID(), template, config);
+ config.addAttachment(attachment);
+ } catch (IOException e) {
+ System.err.println("Could not find template " + attachmentDocs[i].getTemplateID() + " for attachment: " + e);
+ }
+ }
+ return config;
+ }
+
private class SpacelessUser extends User {
public SpacelessUser(String username, BodyConfigurationDocument bodyConfigDoc) {
- super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0, UIConstants.LIGHT_BLUE), username, new Transform3D(), new BodyConfiguration(bodyConfigDoc), null, null, null, null);
+ super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0, UIConstants.LIGHT_BLUE), username, new Transform3D(), createBodyConfiguration(bodyConfigDoc), null, null, null, null);
}
}
@@ -400,6 +426,13 @@
renderable = new J3DUserRenderable(user, bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
renderable.setCamera(camera);
renderable.getCameraBehavior().setAllowXRotation(false);
+
+ Attachment[] attachments = user.getBodyConfiguration().getAttachments();
+ for (int i = 0; i < attachments.length; i++) {
+ J3DAttachment j3dAttachment = new J3DAttachment(attachments[i], dataManager);
+ renderable.attach(j3dAttachment);
+ }
+
userGroup.addChild(renderable);
return true;
} catch (Exception e) {
@@ -409,7 +442,7 @@
}
public void fetchNewBodyConfiguration() throws IOException {
- user.setBodyConfiguration(new BodyConfiguration(webClient.getDefaultBodyConfiguration(accountDoc.getUsername())));
+ user.setBodyConfiguration(createBodyConfiguration(webClient.getDefaultBodyConfiguration(accountDoc.getUsername())));
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
renderable.initBody(bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
}
@@ -522,11 +555,21 @@
private class TemplateProvider implements TemplateDataProvider {
public InputStream getTemplateGeometry(String username, long templateID, int lod) {
- return null;
+ try {
+ return webClient.getTemplateGeometryStream(username, templateID, lod);
+ } catch (IOException e) {
+ System.err.println("Could not fetch template geometry: " + username + ", " + templateID + ", " + lod);
+ return null;
+ }
}
public InputStream getTemplateResource(String username, long templateID, String resourceName) {
- return null;
+ try {
+ return webClient.getTemplateResourceStream(username, templateID, resourceName);
+ } catch (IOException e) {
+ System.err.println("Could not fetch template resource: " + username + ", " + templateID + ", " + resourceName);
+ return null;
+ }
}
public String getTemplateScript(String username, long templateID) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|