|
From: <tre...@us...> - 2007-11-17 16:36:02
|
Revision: 584
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=584&view=rev
Author: trevorolio
Date: 2007-11-17 08:36:05 -0800 (Sat, 17 Nov 2007)
Log Message:
-----------
Tweaked the Java3D setup to fall back to aliased, single buffered if the graphics board doesn't support it, which makes us run on lesser machines and also on the Parallels emulator on OS X Intel machines, making life much easier for Macish developers who want to maintain support WinIE.
Used this fact to fix IE+Java quirks (e.g. no String[] passing over liveconnect) so that the majority of browser installations can once again use Ogoglio.
Modified Paths:
--------------
maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
Modified: maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java
===================================================================
--- maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-11-17 16:36:00 UTC (rev 583)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-11-17 16:36:05 UTC (rev 584)
@@ -17,10 +17,6 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.GraphicsConfigTemplate;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
import java.awt.Panel;
import java.awt.image.BufferedImage;
import java.io.IOException;
@@ -34,7 +30,6 @@
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.DirectionalLight;
-import javax.media.j3d.GraphicsConfigTemplate3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
@@ -59,6 +54,7 @@
import com.ogoglio.viewer.j3d.J3DCameraMotionBehavior;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DDataManager;
+import com.ogoglio.viewer.j3d.J3DRenderer;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
import com.ogoglio.viewer.j3d.body.MorphDeltaMap;
@@ -67,6 +63,10 @@
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
+/*
+ * NOTE: String arrays don't function in LiveConnect in IE, so we use the getXXXCount and getXXX(index) pattern
+ */
+
public class BodyEditorApplet extends Applet {
private URI serviceURI = null;
@@ -120,6 +120,21 @@
bodyPanel.renderable.repaintSkinTexture();
}
+ public int getMorphCount() {
+ if (bodyPanel.bodyData == null) {
+ return 0;
+ }
+ return bodyPanel.bodyData.getMorphDeltaMaps().length;
+ }
+
+ public String getMorphName(int index){
+ String[] names = getMorphNames();
+ if(index < 0 || index > names.length - 1){
+ return null;
+ }
+ return names[index];
+ }
+
public String[] getMorphNames() {
if (bodyPanel.bodyData == null) {
return new String[0];
@@ -147,6 +162,18 @@
bodyPanel.renderable.updateMorphs();
}
+ public int getAnimationCount(){
+ return getAnimationNames().length;
+ }
+
+ public String getAnimationName(int index){
+ String[] names = getAnimationNames();
+ if(index < 0 || index > names.length - 1){
+ return null;
+ }
+ return names[index];
+ }
+
public String[] getAnimationNames() {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return new String[0];
@@ -173,6 +200,18 @@
return new BodyConfigurationDocument(user.getBodyConfiguration()).toElement().toString();
}
+ public int getBaseTextureCount(){
+ return getBaseTextureNames().length;
+ }
+
+ public String getBaseTextureName(int index){
+ String[] names = getBaseTextureNames();
+ if(index < 0 || index > names.length - 1){
+ return null;
+ }
+ return names[index];
+ }
+
public String[] getBaseTextureNames() {
if (user == null || bodyPanel == null || bodyPanel.bodyData == null) {
return null;
@@ -193,8 +232,8 @@
saveBodyConfiguration();
updateTextures();
}
-
- public void setBodyData(long bodyDataID){
+
+ public void setBodyData(long bodyDataID) {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return;
}
@@ -214,17 +253,17 @@
e.printStackTrace();
}
}
-
- public void setDefaultBodyConfiguration(long bodyConfigurationID){
+
+ public void setDefaultBodyConfiguration(long bodyConfigurationID) {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return;
}
- if(user.getBodyConfiguration().getBodyDataID() == bodyConfigurationID){
+ if (user.getBodyConfiguration().getBodyDataID() == bodyConfigurationID) {
return;
}
try {
BodyConfigurationDocument doc = webClient.getBodyConfiguration(user.getUsername(), bodyConfigurationID);
- if(doc == null){
+ if (doc == null) {
System.err.println("Could not fetch body config");
return;
}
@@ -233,13 +272,13 @@
bodyPanel.renderable.initBody(bodyPanel.bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
accountDoc.setBodyConfigurationID(bodyConfigurationID);
webClient.updateAccount(accountDoc);
-
- } catch(IOException e){
+
+ } catch (IOException e) {
System.err.println("Could not fetch body config: " + e);
return;
}
}
-
+
private class SpacelessUser extends User {
public SpacelessUser(String username, BodyConfigurationDocument bodyConfigDoc) {
super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0), username, new Transform3D(), new BodyConfiguration(bodyConfigDoc), null);
@@ -286,14 +325,14 @@
setLayout(new BorderLayout());
universe = new J3DUniverse();
- canvas = new J3DCanvas(get3DConfiguration(), false);
+ canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), false);
camera = new J3DCamera();
camera.setCanvas(canvas);
add(canvas, BorderLayout.CENTER);
setupUniverse();
}
-
+
public boolean initUserRenderable() {
try {
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
@@ -306,12 +345,12 @@
}
}
- public void fetchNewBodyConfiguration() throws IOException{
+ public void fetchNewBodyConfiguration() throws IOException {
user.setBodyConfiguration(new BodyConfiguration(webClient.getDefaultBodyConfiguration(accountDoc.getUsername())));
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
renderable.initBody(bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
}
-
+
private void addDirectionalLight(Color3f color, Vector3f direction) {
DirectionalLight lightD1 = new DirectionalLight(color, direction);
lightD1.setInfluencingBounds(bounds);
@@ -459,13 +498,4 @@
add(errorLabel);
}
}
-
- private GraphicsConfiguration get3DConfiguration() {
- GraphicsConfigTemplate3D configTemplate = new GraphicsConfigTemplate3D();
- GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice device = graphicsEnv.getDefaultScreenDevice();
- configTemplate.setSceneAntialiasing(GraphicsConfigTemplate.REQUIRED);
- configTemplate.setDoubleBuffer(GraphicsConfigTemplate.REQUIRED);
- return device.getBestConfiguration(configTemplate);
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|