|
From: <tre...@us...> - 2007-09-17 22:37:43
|
Revision: 403
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=403&view=rev
Author: trevorolio
Date: 2007-09-17 15:37:42 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Rewhacked Mike avatar to take a commonly available BVH style, so now he can walk, wave, and point.
Haven't tested it with the other two Croquet models yet, but it might Just Work. (famous last words)
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-09-17 16:05:11 UTC (rev 402)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-09-17 22:37:42 UTC (rev 403)
@@ -63,6 +63,8 @@
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
+import com.ogoglio.viewer.j3d.bvh.Bvh;
+import com.ogoglio.viewer.j3d.bvh.BvhParser;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyDocument;
@@ -197,8 +199,11 @@
public boolean addUserRenderable() {
try {
- renderable = new J3DUserRenderable(user, true);
+ renderable = new J3DUserRenderable(user, true, new BvhParser(user, 1).parse());
userGroup.addChild(renderable);
+ BvhParser bvhParser = new BvhParser(user, 1);
+ Bvh bvh = bvhParser.parse();
+ renderable.playAnimation(bvh, false);
return true;
} catch (Exception e) {
e.printStackTrace();
@@ -238,7 +243,7 @@
canvas.getView().setSceneAntialiasingEnable(true);
camera.setRotation(-0.5, Math.PI, 0);
- camera.setLocation(new Vector3f(0f, 1.7f, -0.9f));
+ camera.setLocation(new Vector3f(0f, 0.8f, -1.9f));
sceneRoot.addChild(camera.getNode());
universe.makeLive();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-17 23:35:23
|
Revision: 410
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=410&view=rev
Author: trevorolio
Date: 2007-09-17 16:35:27 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Refactored the way user animations are referenced so as to reduce duplicate code and allow for easy addition.
Now avatars can /wave /clap /point and /laugh in addition to the usual standing and walking animations.
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-09-17 22:39:50 UTC (rev 409)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-09-17 23:35:27 UTC (rev 410)
@@ -58,13 +58,12 @@
import com.ogoglio.client.model.User;
import com.ogoglio.client.model.Space.Context;
import com.ogoglio.util.BodyConstants;
-import com.ogoglio.viewer.render.UIConstants;
import com.ogoglio.viewer.j3d.J3DCamera;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
-import com.ogoglio.viewer.j3d.bvh.Bvh;
import com.ogoglio.viewer.j3d.bvh.BvhParser;
+import com.ogoglio.viewer.render.UIConstants;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyDocument;
@@ -124,14 +123,7 @@
}
public InputStream getUserAnimationStream(String username, long animationID) throws IOException {
- if (animationID == 1) {
- return UIConstants.getResource("avatar/avatar.bvh");
- } else if (animationID == 2) {
- return UIConstants.getResource("avatar/avatar-walk.bvh");
- } else if (animationID == 3) {
- return UIConstants.getResource("avatar/avatar-wave.bvh");
- }
- return null;
+ return UIConstants.getUserAnimation((int) animationID);
}
public InputStream getUserSkinMapStream(String username) throws IOException {
@@ -199,11 +191,8 @@
public boolean addUserRenderable() {
try {
- renderable = new J3DUserRenderable(user, true, new BvhParser(user, 1).parse());
+ renderable = new J3DUserRenderable(user, true, new BvhParser(user, 0).parse());
userGroup.addChild(renderable);
- BvhParser bvhParser = new BvhParser(user, 1);
- Bvh bvh = bvhParser.parse();
- renderable.playAnimation(bvh, false);
return true;
} catch (Exception e) {
e.printStackTrace();
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:02:48
|
Revision: 415
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=415&view=rev
Author: trevorolio
Date: 2007-09-18 09:02:42 -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-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-09-18 15:05:26 UTC (rev 414)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-09-18 16:02:42 UTC (rev 415)
@@ -26,6 +26,8 @@
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Panel;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
@@ -43,8 +45,11 @@
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
+import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
+import javax.swing.JButton;
import javax.swing.JLabel;
+import javax.swing.JRadioButton;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
@@ -58,12 +63,14 @@
import com.ogoglio.client.model.User;
import com.ogoglio.client.model.Space.Context;
import com.ogoglio.util.BodyConstants;
+import com.ogoglio.util.UIConstants;
import com.ogoglio.viewer.j3d.J3DCamera;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
+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.render.UIConstants;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyDocument;
@@ -105,9 +112,12 @@
private WebAPIClient webClient;
+ private boolean completedInitialLoad = false;
+
public BodyEditorApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
+ setSize(new Dimension(500, 500));
}
private class SpacelessUser extends User {
@@ -119,15 +129,23 @@
private class SpacelessContext implements Context {
public InputStream getUserGeometryStream(String username, String name) throws IOException {
- return UIConstants.getResource("avatar/avatar.obj");
+ 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");
+ if (user.getBody().isMale()) {
+ return UIConstants.getResource(BodyConstants.MALE_SMAP_PATH);
+ } else {
+ return UIConstants.getResource(BodyConstants.FEMALE_SMAP_PATH);
+ }
}
public InputStream getPageContentStream(long thingID, long pageID) {
@@ -232,7 +250,7 @@
canvas.getView().setSceneAntialiasingEnable(true);
camera.setRotation(-0.5, Math.PI, 0);
- camera.setLocation(new Vector3f(0f, 0.8f, -1.9f));
+ camera.setLocation(new Vector3f(0f, 1.8f, -1.2f));
sceneRoot.addChild(camera.getNode());
universe.makeLive();
@@ -252,10 +270,10 @@
ScrollingRowPanel faceRow = new ScrollingRowPanel(true, faceRowModel);
+ HeightPanel heightPanel = new HeightPanel();
+
GenderPanel genderPanel = new GenderPanel();
- HeightPanel heightPanel = new HeightPanel();
-
public WestPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
@@ -267,20 +285,62 @@
add(noseRow);
add(mouseRow);
add(faceRow);
- //add(genderPanel);
+ add(genderPanel);
//add(heightPanel);
}
}
- private class GenderPanel extends Panel {
- Dimension dimension = new Dimension(80, 35);
+ private BodyDocument bodyToDoc(Body body) {
+ return new BodyDocument(body.getBodyID(), user.getUsername(), "Body", body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale(), body.getHeight(), body.getGirth());
+ }
+ private void changeGender() {
+ Body body = user.getBody();
+ body.setMale(westPanel.genderPanel.maleButton.isSelected());
+ BodyDocument bodyDoc = bodyToDoc(body);
+ bodyPanel.renderable.setMale(body.isMale());
+ try {
+ webClient.updateBody(bodyDoc);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private class GenderPanel extends Panel implements ActionListener {
+ Dimension dimension = new Dimension(80, 55);
+
+ JRadioButton maleButton = new JRadioButton("male");
+
+ JRadioButton femaleButton = new JRadioButton("female");
+
public GenderPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
- setBackground(Color.GRAY);
+ ButtonGroup group = new ButtonGroup();
+
+ group.add(maleButton);
+ maleButton.setBackground(Color.WHITE);
+ maleButton.setSelected(user.getBody().isMale());
+ add(maleButton);
+ maleButton.addActionListener(this);
+
+ group.add(femaleButton);
+ femaleButton.setBackground(Color.WHITE);
+ femaleButton.setSelected(!user.getBody().isMale());
+ add(femaleButton);
+ femaleButton.addActionListener(this);
+
+ setBackground(Color.WHITE);
}
+
+ public void actionPerformed(ActionEvent event) {
+ if (user.getBody().isMale() == maleButton.isSelected()) {
+ return;
+ }
+ changeGender();
+ }
}
private class TexturePanel extends Panel {
@@ -316,6 +376,51 @@
}
}
+ private class AnimationPanel extends Panel implements ActionListener {
+ Dimension dimension = new Dimension(150, 170);
+
+ JButton[] animationButtons = null;
+
+ AnimationPanel(){
+ setPreferredSize(dimension);
+ setMinimumSize(dimension);
+ setBackground(Color.WHITE);
+ animationButtons = new JButton[BodyConstants.USER_ANIMATION_COMMANDS.length];
+ for (int i = 0; i < BodyConstants.USER_ANIMATION_COMMANDS.length; i++) {
+ animationButtons[i] = new JButton(BodyConstants.USER_ANIMATION_COMMANDS[i]);
+ animationButtons[i].setBackground(Color.WHITE);
+ animationButtons[i].addActionListener(this);
+ add(animationButtons[i]);
+ }
+
+ }
+
+ public void actionPerformed(ActionEvent event) {
+ for (int i = 0; i < animationButtons.length; i++) {
+ if(event.getSource() == animationButtons[i]){
+ playAnimation(animationButtons[i].getText());
+ break;
+ }
+ }
+ }
+ }
+
+ private void playAnimation(String command){
+ for (int i = 0; i < BodyConstants.USER_ANIMATION_COMMANDS.length; i++) {
+ if(BodyConstants.USER_ANIMATION_COMMANDS[i].equals(command)){
+ try {
+ Bvh bvh = new BvhParser(user, i).parse();
+ bodyPanel.renderable.playAnimation(bvh, false);
+ } catch (BvhParseException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ break;
+ }
+ }
+ }
+
private class EastPanel extends Panel {
Dimension dimension = new Dimension(150, 300);
@@ -333,6 +438,8 @@
WidthPanel widthPanel = new WidthPanel();
+ AnimationPanel animationPanel = new AnimationPanel();
+
public EastPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
@@ -344,7 +451,8 @@
add(noseRow);
add(mouthRow);
add(faceRow);
-
+
+ add(animationPanel);
//add(texturePanel);
//add(widthPanel);
}
@@ -569,8 +677,11 @@
eyesRowModel = new RowModel(bodyDoc.getEyesIndex(), BodyConstants.EYES);
noseRowModel = new RowModel(bodyDoc.getNoseIndex(), BodyConstants.NOSES);
mouthRowModel = new RowModel(bodyDoc.getMouthIndex(), BodyConstants.MOUTHES);
- faceRowModel = new RowModel(bodyDoc.getFaceIndex(), BodyConstants.BASE_SKIN_TEXTURES);
-
+ if (user.getBody().isMale()) {
+ faceRowModel = new RowModel(bodyDoc.getFaceIndex(), BodyConstants.MALE_BASE_SKIN_TEXTURES);
+ } else {
+ faceRowModel = new RowModel(bodyDoc.getFaceIndex(), BodyConstants.FEMALE_BASE_SKIN_TEXTURES);
+ }
add(bodyPanel, BorderLayout.CENTER);
westPanel = new WestPanel();
add(westPanel, BorderLayout.WEST);
@@ -592,6 +703,7 @@
new Thread() {
public void run() {
bodyPanel.addUserRenderable();
+ completedInitialLoad = true;
}
}.start();
}
@@ -625,5 +737,9 @@
configTemplate.setDoubleBuffer(GraphicsConfigTemplate.REQUIRED);
return device.getBestConfiguration(configTemplate);
}
+
+ public boolean completedInitialLoad() {
+ return completedInitialLoad ;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-19 20:33:27
|
Revision: 429
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=429&view=rev
Author: trevorolio
Date: 2007-09-19 13:33:25 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
Give the height slider a white background.
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-09-19 20:32:53 UTC (rev 428)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-09-19 20:33:25 UTC (rev 429)
@@ -387,6 +387,7 @@
slider.setMajorTickSpacing(20);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
+ slider.setBackground(Color.WHITE);
add(slider, BorderLayout.CENTER);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-27 18:06:50
|
Revision: 449
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=449&view=rev
Author: trevorolio
Date: 2007-09-27 11:06:53 -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-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-09-27 18:06:51 UTC (rev 448)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-09-27 18:06:53 UTC (rev 449)
@@ -16,25 +16,18 @@
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
-import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
-import java.awt.Graphics;
import java.awt.GraphicsConfigTemplate;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import java.awt.Image;
import java.awt.Panel;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Vector;
+import java.util.zip.ZipInputStream;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Background;
@@ -45,12 +38,8 @@
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
-import javax.swing.ButtonGroup;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -63,41 +52,22 @@
import com.ogoglio.client.WebAPIClientWire;
import com.ogoglio.client.WebAPIDescriptor;
import com.ogoglio.client.model.Body;
+import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Space;
+import com.ogoglio.client.model.TemplateDataProvider;
import com.ogoglio.client.model.User;
import com.ogoglio.client.model.Space.Context;
-import com.ogoglio.util.BodyConstants;
import com.ogoglio.util.UIConstants;
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.bvh.Bvh;
-import com.ogoglio.viewer.j3d.bvh.BvhParseException;
-import com.ogoglio.viewer.j3d.bvh.BvhParser;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyDocument;
public class BodyEditorApplet extends Applet {
- public static final ImageIcon LEFT_ARROW = UIConstants.loadIconFromResource("images/LeftArrow.gif");
-
- public static final ImageIcon LEFT_ARROW_DISABLED = UIConstants.loadIconFromResource("images/LeftArrowDisabled.gif");
-
- public static final ImageIcon RIGHT_ARROW = UIConstants.loadIconFromResource("images/RightArrow.gif");
-
- public static final ImageIcon RIGHT_ARROW_DISABLED = UIConstants.loadIconFromResource("images/RightArrowDisabled.gif");
-
- private RowModel hairRowModel = null;
-
- private RowModel eyesRowModel = null;
-
- private RowModel noseRowModel = null;
-
- private RowModel mouthRowModel = null;
-
- private RowModel faceRowModel = null;
-
private URI serviceURI = null;
private String authCookie = null;
@@ -114,10 +84,12 @@
private SpacelessUser user = null;
- private WebAPIClient webClient;
+ private WebAPIClient webClient = null;
private boolean completedInitialLoad = false;
+ private J3DDataManager dataManager = null;
+
public BodyEditorApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
@@ -132,49 +104,14 @@
private class SpacelessContext implements Context {
- public InputStream getUserGeometryStream(String username, String name) throws IOException {
- if (user.getBody().isMale()) {
- return UIConstants.getResource(BodyConstants.MALE_AVATAR_PATH);
- } else {
- return UIConstants.getResource(BodyConstants.FEMALE_AVATAR_PATH);
- }
+ public BodyDocument getBodyDocument(String username, long bodyID) throws IOException {
+ return new BodyDocument(bodyID, username, "Body", 1, 1, 1, 1, 1, false, 2, 1);
}
- public InputStream getUserAnimationStream(String username, long animationID) throws IOException {
- return BodyConstants.getUserAnimation((int) animationID);
- }
-
- public InputStream getUserSkinMapStream(String username) throws IOException {
- if (user.getBody().isMale()) {
- return UIConstants.getResource(BodyConstants.MALE_SMAP_PATH);
- } else {
- return UIConstants.getResource(BodyConstants.FEMALE_SMAP_PATH);
- }
- }
-
public InputStream getPageContentStream(long thingID, long pageID) {
return null;
}
- public InputStream getTemplateGeometryStream(String ownerUsername, long templateID, int lodIndex) {
- return null;
- }
-
- public InputStream getTemplateResourceStream(String ownerUsername, long templateID, String name) throws IOException {
- return null;
- }
-
- public InputStream getThingAnimationStream(long thingID, long animationID) throws IOException {
- return null;
- }
-
- public String getThingScript(long thingID) throws IOException {
- return null;
- }
-
- public BodyDocument getBodyDocument(String username, long bodyID) throws IOException {
- return bodyDoc;
- }
}
private class BodyPanel extends Panel {
@@ -213,7 +150,8 @@
public boolean addUserRenderable() {
try {
- renderable = new J3DUserRenderable(user, true, new BvhParser(user, 0).parse());
+ System.err.println("Trevor needs to fix the body editor");
+ renderable = new J3DUserRenderable(user, dataManager.getBodyData("mike"));
userGroup.addChild(renderable);
return true;
} catch (Exception e) {
@@ -264,18 +202,6 @@
private class WestPanel extends Panel {
Dimension dimension = new Dimension(150, 300);
- ScrollingRowPanel hairRow = new ScrollingRowPanel(true, hairRowModel);
-
- ScrollingRowPanel eyesRow = new ScrollingRowPanel(true, eyesRowModel);
-
- ScrollingRowPanel noseRow = new ScrollingRowPanel(true, noseRowModel);
-
- ScrollingRowPanel mouseRow = new ScrollingRowPanel(true, mouthRowModel);
-
- ScrollingRowPanel faceRow = new ScrollingRowPanel(true, faceRowModel);
-
- GenderPanel genderPanel = new GenderPanel();
-
HeightPanel heightPanel = new HeightPanel();
public WestPanel() {
@@ -284,12 +210,6 @@
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
setBackground(Color.WHITE);
- //add(hairRow);
- //add(eyesRow);
- //add(noseRow);
- //add(mouseRow);
- //add(faceRow);
- add(genderPanel);
add(heightPanel);
}
@@ -299,58 +219,6 @@
return new BodyDocument(body.getBodyID(), user.getUsername(), "Body", body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale(), body.getHeight(), body.getGirth());
}
- private void changeGender() {
- Body body = user.getBody();
- body.setMale(westPanel.genderPanel.maleButton.isSelected());
- BodyDocument bodyDoc = bodyToDoc(body);
- bodyPanel.renderable.setMale(body.isMale());
- try {
- webClient.updateBody(bodyDoc);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private class GenderPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(80, 100);
-
- ImageIcon maleIcon = UIConstants.loadIconFromResource("images/MaleIcon32x32.gif");
-
- ImageIcon femaleIcon = UIConstants.loadIconFromResource("images/FemaleIcon32x32.gif");
-
- JRadioButton maleButton = new JRadioButton("male", maleIcon);
-
- JRadioButton femaleButton = new JRadioButton("female", femaleIcon);
-
- public GenderPanel() {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
-
- ButtonGroup group = new ButtonGroup();
-
- group.add(maleButton);
- maleButton.setBackground(Color.WHITE);
- maleButton.setSelected(user.getBody().isMale());
- add(maleButton);
- maleButton.addActionListener(this);
-
- group.add(femaleButton);
- femaleButton.setBackground(Color.WHITE);
- femaleButton.setSelected(!user.getBody().isMale());
- add(femaleButton);
- femaleButton.addActionListener(this);
-
- setBackground(Color.WHITE);
- }
-
- public void actionPerformed(ActionEvent event) {
- if (user.getBody().isMale() == maleButton.isSelected()) {
- return;
- }
- changeGender();
- }
- }
-
private class TexturePanel extends Panel {
Dimension dimension = new Dimension(80, 35);
@@ -364,6 +232,7 @@
private class HeightPanel extends Panel implements ChangeListener {
Dimension dimension = new Dimension(150, 150);
+
JSlider slider = new JSlider(JSlider.VERTICAL, 150, 210, 200);
public HeightPanel() {
@@ -373,15 +242,14 @@
setLayout(new BorderLayout());
setBackground(Color.WHITE);
-
JLabel heightLabel = new JLabel("height:");
heightLabel.setBackground(Color.WHITE);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.setBackground(Color.WHITE);
panel.add(heightLabel);
add(panel, BorderLayout.NORTH);
-
- int value = (int)(user.getBody().getHeight() * 100);
+
+ int value = (int) (user.getBody().getHeight() * 100);
slider.setValue(value);
slider.addChangeListener(this);
slider.setMajorTickSpacing(20);
@@ -420,279 +288,21 @@
}
}
- private class AnimationPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(150, 170);
-
- JButton[] animationButtons = null;
-
- AnimationPanel() {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setBackground(Color.WHITE);
- animationButtons = new JButton[BodyConstants.USER_ANIMATION_COMMANDS.length];
- for (int i = 0; i < BodyConstants.USER_ANIMATION_COMMANDS.length; i++) {
- animationButtons[i] = new JButton(BodyConstants.USER_ANIMATION_COMMANDS[i]);
- animationButtons[i].setBackground(Color.WHITE);
- animationButtons[i].addActionListener(this);
- add(animationButtons[i]);
- }
-
- }
-
- public void actionPerformed(ActionEvent event) {
- for (int i = 0; i < animationButtons.length; i++) {
- if (event.getSource() == animationButtons[i]) {
- playAnimation(animationButtons[i].getText());
- break;
- }
- }
- }
- }
-
- private void playAnimation(String command) {
- for (int i = 0; i < BodyConstants.USER_ANIMATION_COMMANDS.length; i++) {
- if (BodyConstants.USER_ANIMATION_COMMANDS[i].equals(command)) {
- try {
- Bvh bvh = new BvhParser(user, i).parse();
- bodyPanel.renderable.playAnimation(bvh, false);
- } catch (BvhParseException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- break;
- }
- }
- }
-
private class EastPanel extends Panel {
Dimension dimension = new Dimension(150, 300);
- ScrollingRowPanel hairRow = new ScrollingRowPanel(false, hairRowModel);
-
- ScrollingRowPanel eyesRow = new ScrollingRowPanel(false, eyesRowModel);
-
- ScrollingRowPanel noseRow = new ScrollingRowPanel(false, noseRowModel);
-
- ScrollingRowPanel mouthRow = new ScrollingRowPanel(false, mouthRowModel);
-
- ScrollingRowPanel faceRow = new ScrollingRowPanel(false, faceRowModel);
-
TexturePanel texturePanel = new TexturePanel();
WidthPanel widthPanel = new WidthPanel();
- AnimationPanel animationPanel = new AnimationPanel();
-
public EastPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
setBackground(Color.WHITE);
-
- //add(hairRow);
- //add(eyesRow);
- //add(noseRow);
- //add(mouthRow);
- //add(faceRow);
-
- add(animationPanel);
- //add(texturePanel);
- //add(widthPanel);
}
}
- private class ArrowButton extends Panel implements MouseListener {
- Image image = null;
-
- ArrowButtonListener listener = null;
-
- ArrowButton(Image image, ArrowButtonListener listener) {
- this.image = image;
- this.listener = listener;
- this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- setPreferredSize(new Dimension(image.getWidth(this), image.getHeight(this)));
- addMouseListener(this);
- }
-
- public void paint(Graphics graphics) {
- graphics.drawImage(image, 0, 0, this);
- }
-
- public void mouseClicked(MouseEvent event) {
- if (listener != null) {
- listener.clicked(this);
- }
- }
-
- public void mouseEntered(MouseEvent arg0) {
- }
-
- public void mouseExited(MouseEvent arg0) {
- }
-
- public void mousePressed(MouseEvent arg0) {
- }
-
- public void mouseReleased(MouseEvent arg0) {
- }
-
- }
-
- private interface ArrowButtonListener {
- public void clicked(ArrowButton button);
- }
-
- private class RowModel {
- int currentIndex = 0;
-
- Image[] icons = null;
-
- Vector listeners = new Vector();
-
- RowModel(int index, Image[] icons) {
- this.currentIndex = index;
- this.icons = icons;
- }
-
- void increment() {
- if (currentIndex >= icons.length - 1) {
- return;
- }
- currentIndex++;
- for (int i = 0; i < listeners.size(); i++) {
- ((RowModelListener) listeners.elementAt(i)).indexChanged(this);
- }
- }
-
- void decrement() {
- if (currentIndex <= 0) {
- return;
- }
- currentIndex--;
- for (int i = 0; i < listeners.size(); i++) {
- ((RowModelListener) listeners.elementAt(i)).indexChanged(this);
- }
- }
- }
-
- private interface RowModelListener {
- public void indexChanged(RowModel model);
- }
-
- private class ScrollingRowPanel extends Panel implements ArrowButtonListener, RowModelListener {
- boolean left = false;
-
- int iconDisplayWidth = 32;
-
- int iconDisplayHeight = 32;
-
- int iconPadding = 12;
-
- Dimension dimension = new Dimension(150, 38);
-
- ArrowButton arrowButton = null;
-
- RowModel model = null;
-
- int numIcons = 0;
-
- int iconYPos = 1;
-
- public ScrollingRowPanel(boolean left, RowModel model) {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setBackground(Color.WHITE);
- this.left = left;
- this.model = model;
-
- setLayout(new FlowLayout(left ? FlowLayout.LEFT : FlowLayout.RIGHT, 0, 1));
-
- arrowButton = new ArrowButton(left ? LEFT_ARROW.getImage() : RIGHT_ARROW.getImage(), this);
- add(arrowButton);
- float widthToHeightRatio = model.icons[0].getWidth(null) / (float) model.icons[0].getHeight(null);
- if (model.icons[0].getWidth(null) > model.icons[0].getHeight(null)) {
- iconDisplayHeight = (int) (iconDisplayWidth / widthToHeightRatio);
- } else {
- iconDisplayWidth = (int) (iconDisplayHeight * widthToHeightRatio);
- }
-
- numIcons = (int) ((dimension.width - arrowButton.getPreferredSize().getWidth()) / (iconDisplayWidth + (2 * iconPadding)));
- iconYPos = (dimension.height / 2) - (iconDisplayHeight / 2);
- model.listeners.add(this);
- }
-
- public void paint(Graphics graphics) {
- graphics.setColor(Color.WHITE);
- graphics.fillRect(0, 0, getWidth(), getHeight());
- if (left) {
- paintLeft(graphics);
- } else {
- paintRight(graphics);
- }
- }
-
- void paintLeft(Graphics graphics) {
- graphics.setColor(Color.GRAY);
- graphics.drawRect(0, 0, getWidth() + 1, getHeight() - 1);
- if (getWidth() <= 1) {
- return;
- }
- int numDrawn = 0;
- for (int i = model.currentIndex - 1; i >= 0 && i < model.icons.length && numDrawn <= numIcons; i--) {
- graphics.drawImage(model.icons[i], getWidth() - iconDisplayWidth - (numDrawn * iconDisplayWidth) - (numDrawn * iconPadding), iconYPos, iconDisplayWidth, iconDisplayHeight, this);
- numDrawn++;
- }
- }
-
- void paintRight(Graphics graphics) {
- graphics.setColor(Color.GRAY);
- graphics.drawRect(-1, 0, getWidth(), getHeight() - 1);
- if (getWidth() <= 1) {
- return;
- }
- int numDrawn = 0;
- for (int i = model.currentIndex + 1; i < model.icons.length && numDrawn <= numIcons; i++) {
- graphics.drawImage(model.icons[i], ((i - model.currentIndex - 1) * iconDisplayWidth) + (numDrawn * iconPadding), iconYPos, iconDisplayWidth, iconDisplayHeight, this);
- numDrawn++;
- }
-
- }
-
- public void clicked(ArrowButton button) {
- if (left) {
- model.increment();
- } else {
- model.decrement();
- }
- }
-
- public void indexChanged(RowModel model) {
- repaint();
- if (model == hairRowModel) {
- bodyDoc.setHairIndex(hairRowModel.currentIndex);
- } else if (model == eyesRowModel) {
- bodyDoc.setEyesIndex(eyesRowModel.currentIndex);
- } else if (model == noseRowModel) {
- bodyDoc.setNoseIndex(noseRowModel.currentIndex);
- } else if (model == mouthRowModel) {
- bodyDoc.setMouthIndex(mouthRowModel.currentIndex);
- } else if (model == faceRowModel) {
- bodyDoc.setFaceIndex(faceRowModel.currentIndex);
- } else {
- throw new IllegalStateException("Unknown model: " + model);
- }
- Body body = user.getBody();
- body.set(bodyDoc.getHairIndex(), bodyDoc.getEyesIndex(), bodyDoc.getNoseIndex(), bodyDoc.getMouthIndex(), bodyDoc.getFaceIndex());
- bodyPanel.renderable.repaintSkinTexture();
- try {
- webClient.updateBody(bodyDoc);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
public void start() {
authCookie = getParameter("loginCookie");
if (authCookie == null) {
@@ -715,17 +325,10 @@
accountDoc = authenticator.getAccountDocument(true);
bodyDoc = webClient.getBodyDocument(accountDoc.getUsername(), accountDoc.getDefaultBodyID());
+ dataManager = new J3DDataManager(true, new TemplateProvider(), new BodyProvider());
+
user = new SpacelessUser(accountDoc.getUsername());
- hairRowModel = new RowModel(bodyDoc.getEyesIndex(), BodyConstants.EYES);
- eyesRowModel = new RowModel(bodyDoc.getEyesIndex(), BodyConstants.EYES);
- noseRowModel = new RowModel(bodyDoc.getNoseIndex(), BodyConstants.NOSES);
- mouthRowModel = new RowModel(bodyDoc.getMouthIndex(), BodyConstants.MOUTHES);
- if (user.getBody().isMale()) {
- faceRowModel = new RowModel(bodyDoc.getFaceIndex(), BodyConstants.MALE_BASE_SKIN_TEXTURES);
- } else {
- faceRowModel = new RowModel(bodyDoc.getFaceIndex(), BodyConstants.FEMALE_BASE_SKIN_TEXTURES);
- }
add(bodyPanel, BorderLayout.CENTER);
westPanel = new WestPanel();
add(westPanel, BorderLayout.WEST);
@@ -760,6 +363,34 @@
//renderer.stopRenderer();
}
+ private class TemplateProvider implements TemplateDataProvider {
+ public InputStream getTemplateGeometry(String username, long templateID, int lod) {
+ return null;
+ }
+
+ public InputStream getTemplateResource(String username, long templateID, String resourceName) {
+ return null;
+ }
+
+ public String getTemplateScript(String username, long templateID) {
+ return null;
+ }
+ }
+
+ private class BodyProvider implements BodyDataProvider {
+ public ZipInputStream getBodyData(String bodyName) {
+ try {
+ return webClient.getBodyData(bodyName);
+ } catch (IOException e) {
+ removeAll();
+ validate();
+ add(new ErrorPanel("Unfortunately, I could not load a body."));
+ validate();
+ return null;
+ }
+ }
+ }
+
//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.
|
|
From: <tre...@us...> - 2007-10-02 02:28:40
|
Revision: 468
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=468&view=rev
Author: trevorolio
Date: 2007-10-01 19:28:44 -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-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-02 02:28:41 UTC (rev 467)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-02 02:28:44 UTC (rev 468)
@@ -51,7 +51,6 @@
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.client.WebAPIClientWire;
import com.ogoglio.client.WebAPIDescriptor;
-import com.ogoglio.client.model.Body;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Space;
import com.ogoglio.client.model.TemplateDataProvider;
@@ -63,8 +62,8 @@
import com.ogoglio.viewer.j3d.J3DDataManager;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
+import com.ogoglio.viewer.j3d.body.SkinLoader;
import com.ogoglio.xml.AccountDocument;
-import com.ogoglio.xml.BodyDocument;
public class BodyEditorApplet extends Applet {
@@ -74,8 +73,6 @@
private AccountDocument accountDoc = null;
- private BodyDocument bodyDoc = null;
-
private WestPanel westPanel = null;
private BodyPanel bodyPanel = new BodyPanel();
@@ -98,16 +95,12 @@
private class SpacelessUser extends User {
public SpacelessUser(String username) {
- super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0), username, new Transform3D(), 1);
+ super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0), username, new Transform3D());
}
}
private class SpacelessContext implements Context {
- public BodyDocument getBodyDocument(String username, long bodyID) throws IOException {
- return new BodyDocument(bodyID, username, "Body", 1, 1, 1, 1, 1, false, 2, 1);
- }
-
public InputStream getPageContentStream(long thingID, long pageID) {
return null;
}
@@ -202,23 +195,16 @@
private class WestPanel extends Panel {
Dimension dimension = new Dimension(150, 300);
- HeightPanel heightPanel = new HeightPanel();
-
public WestPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
setBackground(Color.WHITE);
- add(heightPanel);
}
}
- private BodyDocument bodyToDoc(Body body) {
- return new BodyDocument(body.getBodyID(), user.getUsername(), "Body", body.getHair(), body.getEyes(), body.getNose(), body.getMouth(), body.getFace(), body.isMale(), body.getHeight(), body.getGirth());
- }
-
private class TexturePanel extends Panel {
Dimension dimension = new Dimension(80, 35);
@@ -230,53 +216,7 @@
}
}
- private class HeightPanel extends Panel implements ChangeListener {
- Dimension dimension = new Dimension(150, 150);
- JSlider slider = new JSlider(JSlider.VERTICAL, 150, 210, 200);
-
- public HeightPanel() {
-
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setLayout(new BorderLayout());
- setBackground(Color.WHITE);
-
- JLabel heightLabel = new JLabel("height:");
- heightLabel.setBackground(Color.WHITE);
- JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- panel.setBackground(Color.WHITE);
- panel.add(heightLabel);
- add(panel, BorderLayout.NORTH);
-
- int value = (int) (user.getBody().getHeight() * 100);
- slider.setValue(value);
- slider.addChangeListener(this);
- slider.setMajorTickSpacing(20);
- slider.setPaintTicks(true);
- slider.setPaintLabels(true);
- slider.setBackground(Color.WHITE);
- add(slider, BorderLayout.CENTER);
- }
-
- public void stateChanged(ChangeEvent event) {
- if (slider.getModel().getValueIsAdjusting()) {
- return;
- }
- float newHeight = slider.getValue() / 100f;
- if (user.getBody().getHeight() != newHeight) {
- user.getBody().setHeight(newHeight);
- bodyPanel.renderable.setHeight(newHeight);
- try {
- bodyDoc.setHeight(newHeight);
- webClient.updateBody(bodyDoc);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
private class WidthPanel extends Panel {
Dimension dimension = new Dimension(150, 25);
@@ -323,7 +263,6 @@
WebAPIAuthenticator authenticator = new WebAPIAuthenticator(wire, descriptor, authCookie);
webClient = new WebAPIClient(descriptor, authenticator, wire);
accountDoc = authenticator.getAccountDocument(true);
- bodyDoc = webClient.getBodyDocument(accountDoc.getUsername(), accountDoc.getDefaultBodyID());
dataManager = new J3DDataManager(true, new TemplateProvider(), new BodyProvider());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-04 06:30:45
|
Revision: 476
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=476&view=rev
Author: trevorolio
Date: 2007-10-03 23:30:49 -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-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 06:30:45 UTC (rev 475)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-04 06:30:49 UTC (rev 476)
@@ -39,10 +39,6 @@
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JSlider;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
@@ -51,6 +47,7 @@
import com.ogoglio.client.WebAPIClient;
import com.ogoglio.client.WebAPIClientWire;
import com.ogoglio.client.WebAPIDescriptor;
+import com.ogoglio.client.model.BodyConfiguration;
import com.ogoglio.client.model.BodyDataProvider;
import com.ogoglio.client.model.Space;
import com.ogoglio.client.model.TemplateDataProvider;
@@ -62,8 +59,9 @@
import com.ogoglio.viewer.j3d.J3DDataManager;
import com.ogoglio.viewer.j3d.J3DUniverse;
import com.ogoglio.viewer.j3d.J3DUserRenderable;
-import com.ogoglio.viewer.j3d.body.SkinLoader;
import com.ogoglio.xml.AccountDocument;
+import com.ogoglio.xml.BodyConfigurationDocument;
+import com.ogoglio.xml.BodyDataDocument;
public class BodyEditorApplet extends Applet {
@@ -94,8 +92,8 @@
}
private class SpacelessUser extends User {
- public SpacelessUser(String username) {
- super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0), username, new Transform3D());
+ public SpacelessUser(String username, BodyConfigurationDocument bodyConfigDoc) {
+ super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0), username, new Transform3D(), new BodyConfiguration(bodyConfigDoc));
}
}
@@ -143,8 +141,7 @@
public boolean addUserRenderable() {
try {
- System.err.println("Trevor needs to fix the body editor");
- renderable = new J3DUserRenderable(user, dataManager.getBodyData("mike"));
+ renderable = new J3DUserRenderable(user, dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID()));
userGroup.addChild(renderable);
return true;
} catch (Exception e) {
@@ -266,7 +263,7 @@
dataManager = new J3DDataManager(true, new TemplateProvider(), new BodyProvider());
- user = new SpacelessUser(accountDoc.getUsername());
+ user = new SpacelessUser(accountDoc.getUsername(), webClient.getDefaultBodyConfiguration(accountDoc.getUsername()));
add(bodyPanel, BorderLayout.CENTER);
westPanel = new WestPanel();
@@ -317,9 +314,10 @@
}
private class BodyProvider implements BodyDataProvider {
- public ZipInputStream getBodyData(String bodyName) {
+ public ZipInputStream getBodyData(long bodyDataID) {
try {
- return webClient.getBodyData(bodyName);
+ BodyDataDocument bodyDataDoc = webClient.getBodyDataDocument(bodyDataID);
+ return webClient.getBodyData(bodyDataDoc.getFileName());
} catch (IOException e) {
removeAll();
validate();
@@ -328,6 +326,7 @@
return null;
}
}
+
}
//TODO make the error panel less ugly
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <tre...@us...> - 2007-10-05 02:59:42
|
Revision: 481
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=481&view=rev
Author: trevorolio
Date: 2007-10-04 19:59:47 -0700 (Thu, 04 Oct 2007)
Log Message:
-----------
Added a chooser for the body editor. You'll need to add this to your maven settings.xml:
<ogoglio.bodyDataDisplayNames>Mike,Andrea</ogoglio.bodyDataDisplayNames>
<ogoglio.bodyDataFileNames>ogoglio-body-mike.jar,ogoglio-body-andrea.jar</ogoglio.bodyDataFileNames>
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-05 02:59:44 UTC (rev 480)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-05 02:59:47 UTC (rev 481)
@@ -31,6 +31,7 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Vector;
import java.util.zip.ZipInputStream;
import javax.media.j3d.AmbientLight;
@@ -43,6 +44,7 @@
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.swing.BoxLayout;
+import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
@@ -92,7 +94,9 @@
private boolean completedInitialLoad = false;
private J3DDataManager dataManager = null;
-
+
+ private BodyDataDocument[] bodyDataDocuments = null;
+
public BodyEditorApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
@@ -206,7 +210,7 @@
}
private class MorphListPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(150, 400);
+ Dimension dimension = new Dimension(150, 300);
Button saveButton = new Button("Save");
@@ -222,7 +226,7 @@
validate();
MorphDeltaMap[] deltaMaps = bodyPanel.bodyData.getMorphDeltaMaps();
if (deltaMaps.length == 0) {
- add(new Label("No Available Morphs"));
+ add(saveButton);
validate();
return;
}
@@ -327,9 +331,59 @@
}
+ private class BodyPickerPanel extends Panel implements ActionListener {
+ Dimension dimension = new Dimension(150, 75);
+
+ JComboBox bodyComboBox = null;
+
+ public BodyPickerPanel() {
+ setPreferredSize(dimension);
+ setMinimumSize(dimension);
+ setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
+ setBackground(Color.WHITE);
+
+ Vector names = new Vector();
+ int selectedIndex = -1;
+ for (int i = 0; i < bodyDataDocuments.length; i++) {
+ names.add(bodyDataDocuments[i].getDisplayName());
+ if(user.getBodyConfiguration().getBodyDataID() == bodyDataDocuments[i].getBodyDataID()){
+ selectedIndex = i;
+ }
+ }
+ bodyComboBox = new JComboBox(names.toArray());
+ bodyComboBox.setSelectedIndex(selectedIndex);
+ bodyComboBox.setBackground(Color.WHITE);
+ bodyComboBox.addActionListener(this);
+ add(bodyComboBox);
+ }
+
+ public void actionPerformed(ActionEvent event) {
+ if(event.getSource() == bodyComboBox){
+ String bodyName = (String)bodyComboBox.getSelectedItem();
+ if(bodyName == null){
+ return;
+ }
+ for (int i = 0; i < bodyDataDocuments.length; i++) {
+ if(bodyName.equals(bodyDataDocuments[i].getDisplayName())){
+ if(bodyDataDocuments[i].getBodyDataID() == user.getBodyConfiguration().getBodyDataID()){
+ return;
+ }
+ user.getBodyConfiguration().setBodyDataID(bodyDataDocuments[i].getBodyDataID());
+ bodyPanel.bodyData = dataManager.getBodyData(bodyDataDocuments[i].getBodyDataID());
+ bodyPanel.renderable.initBody(bodyPanel.bodyData);
+ westPanel.morphList.initList();
+ eastPanel.animationList.initAnimationList();
+ }
+ }
+ }
+ }
+ }
+
private class WestPanel extends Panel {
Dimension dimension = new Dimension(150, 400);
+ BodyPickerPanel bodyPickerPanel = new BodyPickerPanel();
+
MorphListPanel morphList = new MorphListPanel();
public WestPanel() {
@@ -337,6 +391,7 @@
setMinimumSize(dimension);
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
setBackground(Color.WHITE);
+ add(bodyPickerPanel);
add(morphList);
}
}
@@ -364,8 +419,8 @@
}
public void actionPerformed(ActionEvent e) {
- if(e.getSource() instanceof Button){
- Button button = (Button)e.getSource();
+ if (e.getSource() instanceof Button) {
+ Button button = (Button) e.getSource();
bodyPanel.renderable.playAnimation(button.getLabel(), false);
}
}
@@ -410,6 +465,8 @@
user = new SpacelessUser(accountDoc.getUsername(), webClient.getDefaultBodyConfiguration(accountDoc.getUsername()));
+ bodyDataDocuments = webClient.getBodyDataDocuments();
+
add(bodyPanel, BorderLayout.CENTER);
westPanel = new WestPanel();
add(westPanel, BorderLayout.WEST);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-06 03:11:40
|
Revision: 482
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=482&view=rev
Author: trevorolio
Date: 2007-10-05 20:11:42 -0700 (Fri, 05 Oct 2007)
Log Message:
-----------
Added a spin behavior to the body editor so we can see all glorious sides of Mike and Alien Andrea.
Tweaked a sim debug message which was bothering me.
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-05 02:59:47 UTC (rev 481)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-06 03:11:42 UTC (rev 482)
@@ -72,6 +72,7 @@
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
+import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
public class BodyEditorApplet extends Applet {
@@ -197,6 +198,11 @@
Transform3D userTransform = new Transform3D();
userTransform.rotY(1);
userGroup.setTransform(userTransform);
+ MouseRotate behavior = new MouseRotate();
+ behavior.setFactor(0.05, 0);
+ behavior.setTransformGroup(userGroup);
+ userGroup.addChild(behavior);
+ behavior.setSchedulingBounds(bounds);
canvas.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
canvas.getView().setSceneAntialiasingEnable(true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-07 18:45:14
|
Revision: 485
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=485&view=rev
Author: trevorolio
Date: 2007-10-07 11:45:16 -0700 (Sun, 07 Oct 2007)
Log Message:
-----------
Added a bunch of face morphs to the Mike avatar.
Added a handy createMorph.sh script to make this process less painful.
Tweaked the body editor to show more morph controls.
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-07 00:23:19 UTC (rev 484)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-07 18:45:16 UTC (rev 485)
@@ -216,14 +216,14 @@
}
private class MorphListPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(150, 300);
+ Dimension dimension = new Dimension(150, 565);
Button saveButton = new Button("Save");
public MorphListPanel() {
setPreferredSize(dimension);
setMinimumSize(dimension);
- setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
+ setLayout(new FlowLayout(FlowLayout.CENTER, 0, 1));
setBackground(Color.WHITE);
}
@@ -263,7 +263,7 @@
float buttonStep = 0.1f;
- Dimension dimension = new Dimension(150, 65);
+ Dimension dimension = new Dimension(150, 50);
MorphDeltaMap morphDeltaMap = null;
@@ -338,7 +338,7 @@
}
private class BodyPickerPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(150, 75);
+ Dimension dimension = new Dimension(150, 35);
JComboBox bodyComboBox = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-15 13:04:49
|
Revision: 492
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=492&view=rev
Author: trevorolio
Date: 2007-10-15 06:04:46 -0700 (Mon, 15 Oct 2007)
Log Message:
-----------
Added a body texture web resource, backed by the media service. This is used in conjunction with body configurations to provide users with skin customization.
Still to come in texture land:
the body editor UI needs some design love to incorporate the texture upload form
body loading takes too long and shows no progress information
a base skin texture with decal textures baked on top
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-15 13:04:39 UTC (rev 491)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-15 13:04:46 UTC (rev 492)
@@ -157,7 +157,7 @@
public boolean addUserRenderable() {
try {
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
- renderable = new J3DUserRenderable(user, bodyData);
+ renderable = new J3DUserRenderable(user, bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
userGroup.addChild(renderable);
westPanel.morphList.initList();
eastPanel.animationList.initAnimationList();
@@ -376,7 +376,7 @@
}
user.getBodyConfiguration().setBodyDataID(bodyDataDocuments[i].getBodyDataID());
bodyPanel.bodyData = dataManager.getBodyData(bodyDataDocuments[i].getBodyDataID());
- bodyPanel.renderable.initBody(bodyPanel.bodyData);
+ bodyPanel.renderable.initBody(bodyPanel.bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
westPanel.morphList.initList();
eastPanel.animationList.initAnimationList();
}
@@ -535,6 +535,10 @@
}
}
+ public InputStream getBodyTexture(String username, long bodyConfigurationID) {
+ return webClient.getBodyTexture(username, bodyConfigurationID);
+ }
+
}
//TODO make the error panel less ugly
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-15 16:15:36
|
Revision: 498
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=498&view=rev
Author: trevorolio
Date: 2007-10-15 09:15:40 -0700 (Mon, 15 Oct 2007)
Log Message:
-----------
Added a way for javascript to refresh the skin of a body editor applet after uploading a new texture.
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-15 16:15:38 UTC (rev 497)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-15 16:15:40 UTC (rev 498)
@@ -103,6 +103,15 @@
setLayout(new BorderLayout());
setSize(new Dimension(800, 600));
}
+
+ public void updateTextures(){
+ if(bodyPanel == null || bodyPanel.renderable == null){
+ return;
+ }
+ dataManager.removeBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID());
+ bodyPanel.renderable.setSkinTexture(dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
+ bodyPanel.renderable.repaintSkinTexture();
+ }
private class SpacelessUser extends User {
public SpacelessUser(String username, BodyConfigurationDocument bodyConfigDoc) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-15 19:10:20
|
Revision: 501
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=501&view=rev
Author: trevorolio
Date: 2007-10-15 12:10:20 -0700 (Mon, 15 Oct 2007)
Log Message:
-----------
Switched the body editor applet to just show the 3D, with editing functions exposed to the page via LiveConnect.
Made body.html use the new functions to display morph controls, animation triggers, and a save button.
Hopefully we will avoid future use of applets for any 2D controls.
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-15 19:10:14 UTC (rev 500)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-15 19:10:20 UTC (rev 501)
@@ -15,23 +15,17 @@
import java.applet.Applet;
import java.awt.BorderLayout;
-import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.FlowLayout;
import java.awt.GraphicsConfigTemplate;
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;
import java.net.URISyntaxException;
-import java.util.Vector;
import java.util.zip.ZipInputStream;
import javax.media.j3d.AmbientLight;
@@ -43,8 +37,6 @@
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
-import javax.swing.BoxLayout;
-import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
@@ -82,12 +74,8 @@
private AccountDocument accountDoc = null;
- private WestPanel westPanel = null;
-
private BodyPanel bodyPanel = new BodyPanel();
- private EastPanel eastPanel = null;
-
private SpacelessUser user = null;
private WebAPIClient webClient = null;
@@ -95,17 +83,17 @@
private boolean completedInitialLoad = false;
private J3DDataManager dataManager = null;
-
+
private BodyDataDocument[] bodyDataDocuments = null;
-
+
public BodyEditorApplet() {
setBackground(Color.WHITE);
setLayout(new BorderLayout());
- setSize(new Dimension(800, 600));
+ setSize(new Dimension(300, 400));
}
-
- public void updateTextures(){
- if(bodyPanel == null || bodyPanel.renderable == null){
+
+ public void updateTextures() {
+ if (bodyPanel == null || bodyPanel.renderable == null) {
return;
}
dataManager.removeBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID());
@@ -113,12 +101,80 @@
bodyPanel.renderable.repaintSkinTexture();
}
+ public String[] getMorphNames() {
+ if (bodyPanel.bodyData == null) {
+ return new String[0];
+ }
+ MorphDeltaMap[] deltaMaps = bodyPanel.bodyData.getMorphDeltaMaps();
+ String[] results = new String[deltaMaps.length];
+ for (int i = 0; i < results.length; i++) {
+ results[i] = deltaMaps[i].getName();
+ }
+ return results;
+ }
+
+ public float getMorphSetting(String morphName) {
+ if (user == null) {
+ return 0;
+ }
+ return user.getBodyConfiguration().getSetting(morphName);
+ }
+
+ public void setMorphSetting(String morphName, float setting) {
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return;
+ }
+ user.getBodyConfiguration().addSetting(morphName, setting);
+ bodyPanel.renderable.updateMorphs();
+ }
+
+ public String[] getAnimationNames() {
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return new String[0];
+ }
+ Bvh[] animations = bodyPanel.bodyData.getAnimations();
+ String[] results = new String[animations.length];
+ for (int i = 0; i < results.length; i++) {
+ results[i] = animations[i].getName();
+ }
+ return results;
+ }
+
+ public void playAnimation(String animationName) {
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return;
+ }
+ bodyPanel.renderable.playAnimation(animationName, false);
+ }
+
+ public String getBodyConfigurationDocument() {
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return null;
+ }
+ return new BodyConfigurationDocument(user.getBodyConfiguration()).toElement().toString();
+ }
+
+ public void saveBodyConfiguration(){
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return;
+ }
+ try {
+ webClient.updateBodyConfiguration(new BodyConfigurationDocument(user.getBodyConfiguration()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
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));
}
}
+ public boolean completedInitialLoad() {
+ return completedInitialLoad;
+ }
+
private class SpacelessContext implements Context {
public InputStream getPageContentStream(long thingID, long pageID) {
@@ -168,8 +224,6 @@
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
renderable = new J3DUserRenderable(user, bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
userGroup.addChild(renderable);
- westPanel.morphList.initList();
- eastPanel.animationList.initAnimationList();
return true;
} catch (Exception e) {
e.printStackTrace();
@@ -224,237 +278,6 @@
}
}
- private class MorphListPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(150, 565);
-
- Button saveButton = new Button("Save");
-
- public MorphListPanel() {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setLayout(new FlowLayout(FlowLayout.CENTER, 0, 1));
- setBackground(Color.WHITE);
- }
-
- void initList() {
- removeAll();
- validate();
- MorphDeltaMap[] deltaMaps = bodyPanel.bodyData.getMorphDeltaMaps();
- if (deltaMaps.length == 0) {
- add(saveButton);
- 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 MorphPanel extends Panel implements ActionListener {
-
- float buttonStep = 0.1f;
-
- Dimension dimension = new Dimension(150, 50);
-
- 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);
-
- 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 BodyPickerPanel extends Panel implements ActionListener {
- Dimension dimension = new Dimension(150, 35);
-
- JComboBox bodyComboBox = null;
-
- public BodyPickerPanel() {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
- setBackground(Color.WHITE);
-
- Vector names = new Vector();
- int selectedIndex = -1;
- for (int i = 0; i < bodyDataDocuments.length; i++) {
- names.add(bodyDataDocuments[i].getDisplayName());
- if(user.getBodyConfiguration().getBodyDataID() == bodyDataDocuments[i].getBodyDataID()){
- selectedIndex = i;
- }
- }
- bodyComboBox = new JComboBox(names.toArray());
- bodyComboBox.setSelectedIndex(selectedIndex);
- bodyComboBox.setBackground(Color.WHITE);
- bodyComboBox.addActionListener(this);
- add(bodyComboBox);
- }
-
- public void actionPerformed(ActionEvent event) {
- if(event.getSource() == bodyComboBox){
- String bodyName = (String)bodyComboBox.getSelectedItem();
- if(bodyName == null){
- return;
- }
- for (int i = 0; i < bodyDataDocuments.length; i++) {
- if(bodyName.equals(bodyDataDocuments[i].getDisplayName())){
- if(bodyDataDocuments[i].getBodyDataID() == user.getBodyConfiguration().getBodyDataID()){
- return;
- }
- user.getBodyConfiguration().setBodyDataID(bodyDataDocuments[i].getBodyDataID());
- bodyPanel.bodyData = dataManager.getBodyData(bodyDataDocuments[i].getBodyDataID());
- bodyPanel.renderable.initBody(bodyPanel.bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
- westPanel.morphList.initList();
- eastPanel.animationList.initAnimationList();
- }
- }
- }
- }
- }
-
- private class WestPanel extends Panel {
- Dimension dimension = new Dimension(150, 400);
-
- BodyPickerPanel bodyPickerPanel = new BodyPickerPanel();
-
- MorphListPanel morphList = new MorphListPanel();
-
- public WestPanel() {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
- setBackground(Color.WHITE);
- add(bodyPickerPanel);
- add(morphList);
- }
- }
-
- 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, 400);
-
- AnimationList animationList = new AnimationList();
-
- public EastPanel() {
- setPreferredSize(dimension);
- setMinimumSize(dimension);
- setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
- setBackground(Color.WHITE);
- add(animationList);
- }
- }
-
public void start() {
authCookie = getParameter("loginCookie");
if (authCookie == null) {
@@ -481,13 +304,8 @@
user = new SpacelessUser(accountDoc.getUsername(), webClient.getDefaultBodyConfiguration(accountDoc.getUsername()));
bodyDataDocuments = webClient.getBodyDataDocuments();
-
- add(bodyPanel, BorderLayout.CENTER);
- westPanel = new WestPanel();
- add(westPanel, BorderLayout.WEST);
- eastPanel = new EastPanel();
- add(eastPanel, BorderLayout.EAST);
+ add(bodyPanel, BorderLayout.CENTER);
} catch (URISyntaxException e) {
e.printStackTrace();
removeAll();
@@ -571,9 +389,4 @@
configTemplate.setDoubleBuffer(GraphicsConfigTemplate.REQUIRED);
return device.getBestConfiguration(configTemplate);
}
-
- public boolean completedInitialLoad() {
- return completedInitialLoad;
- }
-
}
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:12
|
Revision: 511
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=511&view=rev
Author: trevorolio
Date: 2007-10-18 11:57:16 -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-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-18 18:57:11 UTC (rev 510)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-18 18:57:16 UTC (rev 511)
@@ -167,7 +167,7 @@
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));
+ super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0), username, new Transform3D(), new BodyConfiguration(bodyConfigDoc), null);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-19 00:58:50
|
Revision: 515
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=515&view=rev
Author: trevorolio
Date: 2007-10-18 17:58:54 -0700 (Thu, 18 Oct 2007)
Log Message:
-----------
Now plays the sit animation when sitting.
Other folks see the sitting avatar, both upon the event and on initial load.
Need to add UI to template html.
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-19 00:58:48 UTC (rev 514)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-19 00:58:54 UTC (rev 515)
@@ -144,7 +144,7 @@
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return;
}
- bodyPanel.renderable.playAnimation(animationName, false);
+ bodyPanel.renderable.playAnimation(animationName, false, true);
}
public String getBodyConfigurationDocument() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-20 12:21:37
|
Revision: 523
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=523&view=rev
Author: trevorolio
Date: 2007-10-20 05:21:41 -0700 (Sat, 20 Oct 2007)
Log Message:
-----------
Added a better mouse control for camera movement.
Currently used only in the body editor, but eventually will work for viewers.
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-20 12:21:34 UTC (rev 522)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-20 12:21:41 UTC (rev 523)
@@ -55,6 +55,7 @@
import com.ogoglio.util.UIConstants;
import com.ogoglio.viewer.j3d.J3DBodyData;
import com.ogoglio.viewer.j3d.J3DCamera;
+import com.ogoglio.viewer.j3d.J3DCameraMotionBehavior;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DDataManager;
import com.ogoglio.viewer.j3d.J3DUniverse;
@@ -258,21 +259,18 @@
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);
- MouseRotate behavior = new MouseRotate();
- behavior.setFactor(0.05, 0);
- behavior.setTransformGroup(userGroup);
- userGroup.addChild(behavior);
- behavior.setSchedulingBounds(bounds);
+ J3DCameraMotionBehavior zoomBehavior = new J3DCameraMotionBehavior(camera.getTransformGroup(), 1.1);
+ zoomBehavior.setTransformGroup(camera.getTransformGroup());
+ camera.getTransformGroup().addChild(zoomBehavior);
+ zoomBehavior.setSchedulingBounds(bounds);
+
canvas.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
canvas.getView().setSceneAntialiasingEnable(true);
- camera.setRotation(-0.2, Math.PI, 0);
- camera.setLocation(new Vector3f(0f, 1.7f, -2.5f));
- sceneRoot.addChild(camera.getNode());
+ camera.setRotation(-0, Math.PI, 0);
+ camera.setLocation(new Vector3f(0f, 1.5f, -1.1f));
+ userGroup.addChild(camera.getNode());
universe.makeLive();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-21 16:11:39
|
Revision: 527
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=527&view=rev
Author: trevorolio
Date: 2007-10-21 09:11:42 -0700 (Sun, 21 Oct 2007)
Log Message:
-----------
INCLUDES A NEW DB SCHEMA. Dump your old db and make clean.
For those who don't want to break out photoshop to get a new look, added the capability to select from a set of textures included in the body data jar.
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-21 16:11:36 UTC (rev 526)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-21 16:11:42 UTC (rev 527)
@@ -22,6 +22,7 @@
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Panel;
+import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -65,7 +66,6 @@
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
-import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
public class BodyEditorApplet extends Applet {
@@ -98,7 +98,25 @@
return;
}
dataManager.removeBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID());
- bodyPanel.renderable.setSkinTexture(dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
+ BufferedImage bodyTexture = dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID());
+ if (bodyTexture != null) {
+ bodyPanel.renderable.setSkinTexture(bodyTexture);
+ bodyPanel.renderable.repaintSkinTexture();
+ return;
+ }
+ if (user.getBodyConfiguration().getBaseTextureName() == null) {
+ bodyPanel.renderable.setSkinTexture(bodyPanel.bodyData.getDefaultBaseTexture().getImage());
+ bodyPanel.renderable.repaintSkinTexture();
+ return;
+ }
+ J3DBodyData.BaseTexture baseTexture = bodyPanel.bodyData.getBaseTexture(user.getBodyConfiguration().getBaseTextureName());
+ if (baseTexture != null) {
+ bodyPanel.renderable.setSkinTexture(baseTexture.getImage());
+ bodyPanel.renderable.repaintSkinTexture();
+ return;
+ }
+
+ bodyPanel.renderable.setSkinTexture(bodyPanel.bodyData.getDefaultBaseTexture().getImage());
bodyPanel.renderable.repaintSkinTexture();
}
@@ -155,7 +173,28 @@
return new BodyConfigurationDocument(user.getBodyConfiguration()).toElement().toString();
}
- public void saveBodyConfiguration(){
+ public String[] getBaseTextureNames() {
+ if (user == null || bodyPanel == null || bodyPanel.bodyData == null) {
+ return null;
+ }
+ J3DBodyData.BaseTexture[] baseTextures = bodyPanel.bodyData.getBaseTextures();
+ String[] results = new String[baseTextures.length];
+ for (int i = 0; i < results.length; i++) {
+ results[i] = baseTextures[i].getName();
+ }
+ return results;
+ }
+
+ public void setBaseTexture(String baseTextureName) {
+ if (user == null || bodyPanel == null || bodyPanel.bodyData == null) {
+ return;
+ }
+ user.getBodyConfiguration().setBaseTextureName(baseTextureName);
+ saveBodyConfiguration();
+ updateTextures();
+ }
+
+ public void saveBodyConfiguration() {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return;
}
@@ -165,7 +204,7 @@
e.printStackTrace();
}
}
-
+
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);
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:27
|
Revision: 547
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=547&view=rev
Author: trevorolio
Date: 2007-10-29 17:18:31 -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-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-30 00:18:29 UTC (rev 546)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-10-30 00:18:31 UTC (rev 547)
@@ -193,6 +193,16 @@
saveBodyConfiguration();
updateTextures();
}
+
+ public void setBodyData(long bodyDataID){
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return;
+ }
+ user.getBodyConfiguration().setBodyDataID(bodyDataID);
+ bodyPanel.bodyData = dataManager.getBodyData(bodyDataID);
+ bodyPanel.renderable.initBody(bodyPanel.bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
+ saveBodyConfiguration();
+ }
public void saveBodyConfiguration() {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
@@ -204,7 +214,32 @@
e.printStackTrace();
}
}
-
+
+ public void setDefaultBodyConfiguration(long bodyConfigurationID){
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return;
+ }
+ if(user.getBodyConfiguration().getBodyDataID() == bodyConfigurationID){
+ return;
+ }
+ try {
+ BodyConfigurationDocument doc = webClient.getBodyConfiguration(user.getUsername(), bodyConfigurationID);
+ if(doc == null){
+ System.err.println("Could not fetch body config");
+ return;
+ }
+ user.setBodyConfiguration(new BodyConfiguration(doc));
+ bodyPanel.bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
+ bodyPanel.renderable.initBody(bodyPanel.bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
+ accountDoc.setBodyConfigurationID(bodyConfigurationID);
+ webClient.updateAccount(accountDoc);
+
+ } 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);
@@ -258,8 +293,8 @@
add(canvas, BorderLayout.CENTER);
setupUniverse();
}
-
- public boolean addUserRenderable() {
+
+ public boolean initUserRenderable() {
try {
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
renderable = new J3DUserRenderable(user, bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
@@ -271,6 +306,12 @@
}
}
+ 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);
@@ -357,7 +398,7 @@
validate();
new Thread() {
public void run() {
- bodyPanel.addUserRenderable();
+ bodyPanel.initUserRenderable();
completedInitialLoad = true;
}
}.start();
@@ -393,6 +434,7 @@
} catch (IOException e) {
removeAll();
validate();
+ e.printStackTrace();
add(new ErrorPanel("Unfortunately, I could not load a body."));
validate();
return null;
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:28
|
Revision: 555
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=555&view=rev
Author: trevorolio
Date: 2007-11-03 16:35:32 -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-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-01 18:27:22 UTC (rev 554)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-11-03 23:35:32 UTC (rev 555)
@@ -377,7 +377,7 @@
webClient = new WebAPIClient(descriptor, authenticator, wire);
accountDoc = authenticator.getAccountDocument(true);
- dataManager = new J3DDataManager(true, new TemplateProvider(), new BodyProvider());
+ dataManager = new J3DDataManager(true, new TemplateProvider(), new BodyProvider(), true);
user = new SpacelessUser(accountDoc.getUsername(), webClient.getDefaultBodyConfiguration(accountDoc.getUsername()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <tre...@us...> - 2007-11-24 12:43:17
|
Revision: 601
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=601&view=rev
Author: trevorolio
Date: 2007-11-24 04:43:06 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Now the camera motion imitates many games:
Left-mouse-drag pans and tilts the camera, rotating around the head.
Escape key resets camera position.
Scroll-wheel zooms in and out.
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-24 12:43:01 UTC (rev 600)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-11-24 12:43:06 UTC (rev 601)
@@ -18,6 +18,8 @@
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Panel;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
@@ -51,7 +53,6 @@
import com.ogoglio.util.UIConstants;
import com.ogoglio.viewer.j3d.J3DBodyData;
import com.ogoglio.viewer.j3d.J3DCamera;
-import com.ogoglio.viewer.j3d.J3DCameraMotionBehavior;
import com.ogoglio.viewer.j3d.J3DCanvas;
import com.ogoglio.viewer.j3d.J3DDataManager;
import com.ogoglio.viewer.j3d.J3DRenderer;
@@ -67,7 +68,7 @@
* NOTE: String arrays don't function in LiveConnect in IE, so we use the getXXXCount and getXXX(index) pattern
*/
-public class BodyEditorApplet extends Applet {
+public class BodyEditorApplet extends Applet{
private URI serviceURI = null;
@@ -127,9 +128,9 @@
return bodyPanel.bodyData.getMorphDeltaMaps().length;
}
- public String getMorphName(int index){
+ public String getMorphName(int index) {
String[] names = getMorphNames();
- if(index < 0 || index > names.length - 1){
+ if (index < 0 || index > names.length - 1) {
return null;
}
return names[index];
@@ -162,18 +163,18 @@
bodyPanel.renderable.updateMorphs();
}
- public int getAnimationCount(){
+ public int getAnimationCount() {
return getAnimationNames().length;
}
- public String getAnimationName(int index){
+ public String getAnimationName(int index) {
String[] names = getAnimationNames();
- if(index < 0 || index > names.length - 1){
+ 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];
@@ -200,18 +201,18 @@
return new BodyConfigurationDocument(user.getBodyConfiguration()).toElement().toString();
}
- public int getBaseTextureCount(){
+ public int getBaseTextureCount() {
return getBaseTextureNames().length;
}
-
- public String getBaseTextureName(int index){
+
+ public String getBaseTextureName(int index) {
String[] names = getBaseTextureNames();
- if(index < 0 || index > names.length - 1){
+ 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;
@@ -297,7 +298,7 @@
}
- private class BodyPanel extends Panel {
+ private class BodyPanel extends Panel implements MouseWheelListener {
Dimension dimension = new Dimension(300, 400);
private J3DUniverse universe = null;
@@ -326,6 +327,7 @@
universe = new J3DUniverse();
canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), false);
+ canvas.addMouseWheelListener(this);
camera = new J3DCamera();
camera.setCanvas(canvas);
@@ -337,6 +339,8 @@
try {
bodyData = dataManager.getBodyData(user.getBodyConfiguration().getBodyDataID());
renderable = new J3DUserRenderable(user, bodyData, dataManager.getBodyTexture(user.getUsername(), user.getBodyConfiguration().getBodyConfigurationID()));
+ renderable.setCamera(camera);
+ renderable.getCameraBehavior().setAllowXRotation(false);
userGroup.addChild(renderable);
return true;
} catch (Exception e) {
@@ -379,20 +383,26 @@
userGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
userGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- J3DCameraMotionBehavior zoomBehavior = new J3DCameraMotionBehavior(camera.getTransformGroup(), 1.1);
- zoomBehavior.setTransformGroup(camera.getTransformGroup());
- camera.getTransformGroup().addChild(zoomBehavior);
- zoomBehavior.setSchedulingBounds(bounds);
-
canvas.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
canvas.getView().setSceneAntialiasingEnable(true);
- camera.setRotation(-0, Math.PI, 0);
- camera.setLocation(new Vector3f(0f, 1.5f, -1.1f));
- userGroup.addChild(camera.getNode());
-
+ camera.setDefaultLocation(0, 0, 0);
+ camera.setRelativePosition(0, 1.5f, 1f);
+ Transform3D rotTransform = new Transform3D();
+ rotTransform.rotY(Math.PI);
+ camera.getTransformGroup().setTransform(rotTransform);
universe.makeLive();
}
+
+ public void mouseWheelMoved(MouseWheelEvent event) {
+ int zoomDelta = event.getWheelRotation();
+ if (zoomDelta == 0) {
+ return;
+ }
+ int cameraZoom = zoomDelta > 0 ? 1 : -1;
+ camera.changeRelativePosition(0, 0, cameraZoom);
+ }
+
}
public void start() {
@@ -498,4 +508,5 @@
add(errorLabel);
}
}
+
}
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:47
|
Revision: 622
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=622&view=rev
Author: trevorolio
Date: 2007-12-10 14:50:26 -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-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-12-10 22:50:15 UTC (rev 621)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-12-10 22:50:26 UTC (rev 622)
@@ -282,7 +282,7 @@
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, null);
+ super(new Space(new SpacelessContext(), 1, "Space", "nobody", false, 0, UIConstants.LIGHT_BLUE), username, new Transform3D(), new BodyConfiguration(bodyConfigDoc), null, null);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-12-30 23:15:00
|
Revision: 651
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=651&view=rev
Author: trevorolio
Date: 2007-12-30 15:15:03 -0800 (Sun, 30 Dec 2007)
Log Message:
-----------
Added the ability to update the account photo using the body editor
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-12-29 20:07:54 UTC (rev 650)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2007-12-30 23:15:03 UTC (rev 651)
@@ -17,27 +17,38 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.GraphicsConfiguration;
import java.awt.Panel;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.zip.ZipInputStream;
+import javax.imageio.ImageIO;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
+import javax.media.j3d.Canvas3D;
import javax.media.j3d.DirectionalLight;
+import javax.media.j3d.GraphicsContext3D;
+import javax.media.j3d.ImageComponent;
+import javax.media.j3d.ImageComponent2D;
+import javax.media.j3d.Raster;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.swing.JLabel;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
+import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;
import com.ogoglio.client.WebAPIAuthenticator;
@@ -63,12 +74,15 @@
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
+import com.sun.image.codec.jpeg.JPEGCodec;
+import com.sun.image.codec.jpeg.JPEGEncodeParam;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
/*
* NOTE: String arrays don't function in LiveConnect in IE, so we use the getXXXCount and getXXX(index) pattern
*/
-public class BodyEditorApplet extends Applet{
+public class BodyEditorApplet extends Applet {
private URI serviceURI = null;
@@ -194,6 +208,14 @@
bodyPanel.renderable.playAnimation(animationName, false, true);
}
+ public void saveAccountPhoto() {
+ if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
+ return;
+ }
+ bodyPanel.canvas.writeJPEG = true;
+ bodyPanel.canvas.repaint();
+ }
+
public String getBodyConfigurationDocument() {
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return null;
@@ -301,23 +323,23 @@
private class BodyPanel extends Panel implements MouseWheelListener {
Dimension dimension = new Dimension(300, 400);
- private J3DUniverse universe = null;
+ J3DUniverse universe = null;
- private J3DCamera camera = null;
+ J3DCamera camera = null;
- private J3DCanvas canvas = null;
+ CapturingCanvas3D canvas = null;
- private BranchGroup sceneRoot = new BranchGroup();
+ BranchGroup sceneRoot = new BranchGroup();
- private BranchGroup worldBranch = new BranchGroup();
+ BranchGroup worldBranch = new BranchGroup();
- private TransformGroup userGroup = new TransformGroup();
+ TransformGroup userGroup = new TransformGroup();
- private BoundingSphere bounds = new BoundingSphere(new Point3d(), 1000);
+ BoundingSphere bounds = new BoundingSphere(new Point3d(), 1000);
J3DUserRenderable renderable = null;
- private J3DBodyData bodyData = null;
+ J3DBodyData bodyData = null;
public BodyPanel() {
setPreferredSize(dimension);
@@ -326,7 +348,7 @@
setLayout(new BorderLayout());
universe = new J3DUniverse();
- canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), false);
+ canvas = new CapturingCanvas3D(J3DRenderer.getGraphicsConfiguration(), false);
canvas.addMouseWheelListener(this);
camera = new J3DCamera();
camera.setCanvas(canvas);
@@ -461,6 +483,35 @@
//renderer.stopRenderer();
}
+ private class CapturingCanvas3D extends J3DCanvas {
+ boolean writeJPEG = false;
+
+ public CapturingCanvas3D(GraphicsConfiguration graphicsConfiguration, boolean offscreen) {
+ super(graphicsConfiguration, offscreen);
+ }
+
+ public void postSwap() {
+ if (!writeJPEG) {
+ super.postSwap();
+ return;
+ }
+ try {
+ GraphicsContext3D ctx = getGraphicsContext3D();
+ Raster ras = new Raster(new Point3f(-1.0f, -1.0f, -1.0f), Raster.RASTER_COLOR, 0, 0, getWidth(), getHeight(), new ImageComponent2D(ImageComponent.FORMAT_RGB, new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB)), null);
+ ctx.readRaster(ras);
+ BufferedImage img = ras.getImage().getImage();
+
+ ByteArrayOutputStream jpegBuffer = new ByteArrayOutputStream();
+ ImageIO.write(img, "jpeg", jpegBuffer);
+ webClient.setAccountPhoto(webClient.getAuthenticator().getUsername(), new ByteArrayInputStream(jpegBuffer.toByteArray()), "image/jpeg");
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ writeJPEG = false;
+ }
+ }
+ }
+
private class TemplateProvider implements TemplateDataProvider {
public InputStream getTemplateGeometry(String username, long templateID, int lod) {
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-01-13 00:29:30
|
Revision: 682
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=682&view=rev
Author: trevorolio
Date: 2008-01-12 16:29:30 -0800 (Sat, 12 Jan 2008)
Log Message:
-----------
Tried a new way of capturing profile images, which will hopefully work on XP and Linux in addition to OS X.
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-01-13 00:28:53 UTC (rev 681)
+++ maven/trunk/ogoglio-body-editor-applet/src/main/java/com/ogoglio/bodyeditor/BodyEditorApplet.java 2008-01-13 00:29:30 UTC (rev 682)
@@ -17,14 +17,13 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.GraphicsConfiguration;
import java.awt.Panel;
+import java.awt.Rectangle;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -36,19 +35,16 @@
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
-import javax.media.j3d.Canvas3D;
import javax.media.j3d.DirectionalLight;
-import javax.media.j3d.GraphicsContext3D;
import javax.media.j3d.ImageComponent;
import javax.media.j3d.ImageComponent2D;
-import javax.media.j3d.Raster;
+import javax.media.j3d.Screen3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.swing.JLabel;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
-import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;
import com.ogoglio.client.WebAPIAuthenticator;
@@ -74,9 +70,6 @@
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.BodyConfigurationDocument;
import com.ogoglio.xml.BodyDataDocument;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGEncodeParam;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
/*
* NOTE: String arrays don't function in LiveConnect in IE, so we use the getXXXCount and getXXX(index) pattern
@@ -212,8 +205,47 @@
if (user == null || bodyPanel == null || bodyPanel.renderable == null) {
return;
}
- bodyPanel.canvas.writeJPEG = true;
- bodyPanel.canvas.repaint();
+ new Thread(){
+ public void run(){
+ try {
+
+ // Obtain the size of the displayed canvas
+ Rectangle rect = bodyPanel.canvas.getBounds();
+
+ // Create a buffer for the Off Screen Canvas large enough to contain the displayed image
+ BufferedImage img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB);
+ ImageComponent2D buf = new ImageComponent2D(ImageComponent.FORMAT_RGB, img);
+
+ // provide the buffer to the off-screen canvas
+ bodyPanel.offscreenCanvas.setOffScreenBuffer(buf);
+
+ // get the Screen3d associated with this canvas, and set the physical dimensions
+ Screen3D screen = bodyPanel.offscreenCanvas.getScreen3D();
+ Screen3D screenDisplay = bodyPanel.canvas.getScreen3D();
+
+ screen.setSize(screenDisplay.getSize());
+ screen.setPhysicalScreenWidth(screenDisplay.getPhysicalScreenWidth());
+ screen.setPhysicalScreenHeight(screenDisplay.getPhysicalScreenHeight());
+
+ // Request that the Off-Screen canvas is rendered
+ bodyPanel.offscreenCanvas.renderOffScreenBuffer();
+
+ // wait for the rendering to complete
+ bodyPanel.offscreenCanvas.waitForOffScreenRendering();
+
+ // obtain the image from the Off-Screen canvas
+ ImageComponent2D image = bodyPanel.offscreenCanvas.getOffScreenBuffer();
+ BufferedImage img2 = image.getImage();
+
+ ByteArrayOutputStream jpegBuffer = new ByteArrayOutputStream();
+ ImageIO.write(img2, "jpeg", jpegBuffer);
+ webClient.setAccountPhoto(webClient.getAuthenticator().getUsername(), new ByteArrayInputStream(jpegBuffer.toByteArray()), "image/jpeg");
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+ }
+ }.start();
}
public String getBodyConfigurationDocument() {
@@ -327,8 +359,10 @@
J3DCamera camera = null;
- CapturingCanvas3D canvas = null;
+ J3DCanvas canvas = null;
+ J3DCanvas offscreenCanvas = null;
+
BranchGroup sceneRoot = new BranchGroup();
BranchGroup worldBranch = new BranchGroup();
@@ -348,12 +382,15 @@
setLayout(new BorderLayout());
universe = new J3DUniverse();
- canvas = new CapturingCanvas3D(J3DRenderer.getGraphicsConfiguration(), false);
+ canvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), false);
canvas.addMouseWheelListener(this);
camera = new J3DCamera();
camera.setCanvas(canvas);
+ add(canvas, BorderLayout.CENTER);
- add(canvas, BorderLayout.CENTER);
+ offscreenCanvas = new J3DCanvas(J3DRenderer.getGraphicsConfiguration(), true);
+ camera.getView().addCanvas3D(offscreenCanvas);
+
setupUniverse();
}
@@ -483,35 +520,6 @@
//renderer.stopRenderer();
}
- private class CapturingCanvas3D extends J3DCanvas {
- boolean writeJPEG = false;
-
- public CapturingCanvas3D(GraphicsConfiguration graphicsConfiguration, boolean offscreen) {
- super(graphicsConfiguration, offscreen);
- }
-
- public void postSwap() {
- if (!writeJPEG) {
- super.postSwap();
- return;
- }
- try {
- GraphicsContext3D ctx = getGraphicsContext3D();
- Raster ras = new Raster(new Point3f(-1.0f, -1.0f, -1.0f), Raster.RASTER_COLOR, 0, 0, getWidth(), getHeight(), new ImageComponent2D(ImageComponent.FORMAT_RGB, new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB)), null);
- ctx.readRaster(ras);
- BufferedImage img = ras.getImage().getImage();
-
- ByteArrayOutputStream jpegBuffer = new ByteArrayOutputStream();
- ImageIO.write(img, "jpeg", jpegBuffer);
- webClient.setAccountPhoto(webClient.getAuthenticator().getUsername(), new ByteArrayInputStream(jpegBuffer.toByteArray()), "image/jpeg");
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- writeJPEG = false;
- }
- }
- }
-
private class TemplateProvider implements TemplateDataProvider {
public InputStream getTemplateGeometry(String username, long templateID, int lod) {
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|