|
From: <tre...@us...> - 2007-10-04 21:24:17
|
Revision: 478
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=478&view=rev
Author: trevorolio
Date: 2007-10-04 14:24:13 -0700 (Thu, 04 Oct 2007)
Log Message:
-----------
At last, in the body editor applet you can change the morph settings and see them reflected in real time. Hit save, and the next time you visit a space the morph settings will be respected.
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-10-04 21:24:10 UTC (rev 477)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-04 21:24:13 UTC (rev 478)
@@ -15,6 +15,7 @@
import java.applet.Applet;
import java.awt.BorderLayout;
+import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
@@ -22,7 +23,10 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
+import java.awt.Label;
import java.awt.Panel;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -38,6 +42,7 @@
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
+import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
@@ -54,11 +59,14 @@
import com.ogoglio.client.model.User;
import com.ogoglio.client.model.Space.Context;
import com.ogoglio.util.UIConstants;
+import com.ogoglio.viewer.j3d.J3DBodyData;
import com.ogoglio.viewer.j3d.J3DCamera;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DDataManager;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
+import com.ogoglio.viewer.j3d.body.MorphDeltaMap;
+import com.ogoglio.viewer.j3d.bvh.Bvh;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
@@ -124,6 +132,8 @@
J3DUserRenderable renderable = null;
+ private J3DBodyData bodyData = null;
+
public BodyPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
@@ -141,8 +151,11 @@
public boolean addUserRenderable() {
try {
- renderable = new J3DUserRenderable(user, dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID()));
+ bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
+ renderable = new J3DUserRenderable(user, bodyData);
userGroup.addChild(renderable);
+ westPanel.morphList.initList();
+ eastPanel.animationList.initAnimationList();
return true;
} catch (Exception e) {
e.printStackTrace();
@@ -177,6 +190,9 @@
userGroup.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
userGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
userGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ Transform3D userTransform = new Transform3D();
+ userTransform.rotY(1);
+ userGroup.setTransform(userTransform);
canvas.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
canvas.getView().setSceneAntialiasingEnable(true);
@@ -189,54 +205,183 @@
}
}
- private class WestPanel extends Panel {
- Dimension dimension = new Dimension(150, 300);
+ private class MorphListPanel extends Panel implements ActionListener {
+ Dimension dimension = new Dimension(150, 400);
- public WestPanel() {
+ Button saveButton = new Button("Save");
+
+ public MorphListPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
setBackground(Color.WHITE);
+ }
+ void initList() {
+ removeAll();
+ validate();
+ MorphDeltaMap[] deltaMaps = bodyPanel.bodyData.getMorphDeltaMaps();
+ if (deltaMaps.length == 0) {
+ add(new Label("No Available Morphs"));
+ validate();
+ return;
+ }
+ for (int i = deltaMaps.length - 1; i >= 0; i--) {
+ add(new MorphPanel(deltaMaps[i]));
+ validate();
+ }
+
+ saveButton.setBackground(Color.WHITE);
+ saveButton.addActionListener(this);
+ add(saveButton);
+ validate();
}
+
+ public void actionPerformed(ActionEvent event) {
+ if (event.getSource() == saveButton) {
+ try {
+ webClient.updateBodyConfiguration(new BodyConfigurationDocument(user.getBodyConfiguration()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
- private class TexturePanel extends Panel {
- Dimension dimension = new Dimension(80, 35);
+ private class MorphPanel extends Panel implements ActionListener {
- public TexturePanel() {
+ float buttonStep = 0.1f;
+
+ Dimension dimension = new Dimension(150, 65);
+
+ MorphDeltaMap morphDeltaMap = null;
+
+ Label nameLabel = null;
+
+ Label valueLabel = null;
+
+ Button moreButton = new Button("+");
+
+ Button lessButton = new Button("-");
+
+ public MorphPanel(MorphDeltaMap morphDeltaMap) {
setPreferredSize(dimension);
setMinimumSize(dimension);
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ setBackground(Color.WHITE);
- setBackground(Color.GRAY);
+ this.morphDeltaMap = morphDeltaMap;
+ nameLabel = new Label(morphDeltaMap.getName() + ":");
+ nameLabel.setBackground(Color.WHITE);
+ add(nameLabel);
+
+ Panel buttonPanel = new Panel();
+ buttonPanel.setBackground(Color.WHITE);
+
+ moreButton.setBackground(Color.WHITE);
+ moreButton.addActionListener(this);
+ buttonPanel.add(moreButton);
+
+ valueLabel = new Label(formatValue(getMorphSetting()));
+ valueLabel.setBackground(Color.WHITE);
+ buttonPanel.add(valueLabel);
+
+ lessButton.setBackground(Color.WHITE);
+ lessButton.addActionListener(this);
+ buttonPanel.add(lessButton);
+
+ add(buttonPanel);
}
+
+ float getMorphSetting() {
+ return user.getBodyConfiguration().getSetting(morphDeltaMap.getName());
+ }
+
+ public void actionPerformed(ActionEvent event) {
+ float setting = -1;
+ if (event.getSource() == moreButton) {
+ setting = getMorphSetting();
+ if (setting >= 1) {
+ return;
+ }
+ setting += buttonStep;
+ } else if (event.getSource() == lessButton) {
+ setting = getMorphSetting();
+ if (setting <= 0) {
+ return;
+ }
+ setting -= buttonStep;
+ }
+ if (setting != -1) {
+ user.getBodyConfiguration().addSetting(morphDeltaMap.getName(), setting);
+ valueLabel.setText(formatValue(getMorphSetting()));
+ bodyPanel.renderable.updateMorphs();
+ }
+ }
+
+ String formatValue(float value) {
+ Object[] args = { new Float(value) };
+ return String.format("%1.1f", args);
+ }
+
}
+ private class WestPanel extends Panel {
+ Dimension dimension = new Dimension(150, 400);
- private class WidthPanel extends Panel {
- Dimension dimension = new Dimension(150, 25);
+ MorphListPanel morphList = new MorphListPanel();
- public WidthPanel() {
+ public WestPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
+ setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
+ setBackground(Color.WHITE);
+ add(morphList);
+ }
+ }
- setBackground(Color.GRAY);
+ private class AnimationList extends Panel implements ActionListener {
+ Dimension dimension = new Dimension(150, 400);
+
+ public AnimationList() {
+ setPreferredSize(dimension);
+ setMinimumSize(dimension);
+ setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
+ setBackground(Color.WHITE);
}
+
+ void initAnimationList() {
+ removeAll();
+ validate();
+ Bvh[] animations = bodyPanel.bodyData.getAnimations();
+ for (int i = 0; i < animations.length; i++) {
+ Button button = new Button(animations[i].getName());
+ button.addActionListener(this);
+ add(button);
+ validate();
+ }
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if(e.getSource() instanceof Button){
+ Button button = (Button)e.getSource();
+ bodyPanel.renderable.playAnimation(button.getLabel(), false);
+ }
+ }
}
private class EastPanel extends Panel {
- Dimension dimension = new Dimension(150, 300);
+ Dimension dimension = new Dimension(150, 400);
- TexturePanel texturePanel = new TexturePanel();
+ AnimationList animationList = new AnimationList();
- WidthPanel widthPanel = new WidthPanel();
-
public EastPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
setBackground(Color.WHITE);
+ add(animationList);
}
}
@@ -312,7 +457,7 @@
return null;
}
}
-
+
private class BodyProvider implements BodyDataProvider {
public ZipInputStream getBodyData(long bodyDataID) {
try {
@@ -328,7 +473,7 @@
}
}
-
+
//TODO make the error panel less ugly
private class ErrorPanel extends Panel {
public ErrorPanel(String errorMessage) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|