|
From: <tre...@us...> - 2008-02-06 17:30:30
|
Revision: 715
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=715&view=rev
Author: trevorolio
Date: 2008-02-06 09:30:33 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
Switched over to naked Joe model in preparation for attachments. Added the ability for attachments to include body images which are baked onto the base skin image.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java 2008-02-06 01:26:13 UTC (rev 714)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Template.java 2008-02-06 17:30:33 UTC (rev 715)
@@ -13,6 +13,8 @@
limitations under the License. */
package com.ogoglio.client.model;
+import java.util.Vector;
+
import javax.vecmath.Point3d;
import javax.vecmath.Quat4d;
@@ -35,6 +37,8 @@
private Quat4d seatRotation = new Quat4d();
+ Vector resourceNames = new Vector();
+
public Template(long templateID, String ownerUsername, String displayName, boolean isASeat, Point3d seatPosition, Quat4d seatRotation) {
ArgumentUtils.assertNotNegative(templateID);
this.templateID = templateID;
@@ -49,8 +53,16 @@
public Template(TemplateDocument templateDoc) {
this(templateDoc.getTemplateID(), templateDoc.getOwnerUsername(), templateDoc.getDisplayName(), templateDoc.isSeat(), templateDoc.getSeatPosition(), templateDoc.getSeatRotation());
+ String[] fileNames = templateDoc.getAllSupportFileNames();
+ for (int i = 0; i < fileNames.length; i++) {
+ resourceNames.add(fileNames[i]);
+ }
}
+ public String[] getResourceNames(){
+ return (String[])resourceNames.toArray(new String[0]);
+ }
+
public long getTemplateID() {
return templateID;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java 2008-02-06 01:26:13 UTC (rev 714)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java 2008-02-06 17:30:33 UTC (rev 715)
@@ -1,7 +1,11 @@
package com.ogoglio.viewer.j3d;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Vector;
+import javax.imageio.ImageIO;
import javax.media.j3d.Appearance;
import javax.media.j3d.Geometry;
import javax.media.j3d.Shape3D;
@@ -21,6 +25,8 @@
private Skeleton skeleton = null;
+ private BufferedImage bodyImage = null;
+
public J3DAttachment(Attachment attachment, J3DDataManager dataManager) {
this.attachment = attachment;
@@ -51,6 +57,24 @@
boneAttachment.setUserData(shapeNames[j]);
skeletonAttachments.add(boneAttachment);
}
+ String[] resourceNames = attachment.getTemplate().getResourceNames();
+ String bodyImageName = null;
+ for (int i = 0; i < resourceNames.length; i++) {
+ if(resourceNames[i].equals("body.jpg") || resourceNames[i].equals("body.gif")){
+ bodyImageName = resourceNames[i];
+ break;
+ }
+ }
+ if(bodyImageName != null){
+ InputStream bodyImageStream = dataManager.getTemplateResource(attachment.getTemplate().getOwnerUsername(), attachment.getTemplate().getTemplateID(), bodyImageName);
+ if(bodyImageStream != null){
+ try {
+ bodyImage = ImageIO.read(bodyImageStream);
+ } catch (IOException e) {
+ Log.debug("Could not read body image: " + attachment.getTemplate().getTemplateID() + ", " + bodyImageName);
+ }
+ }
+ }
}
public Attachment getAttachment(){
@@ -99,4 +123,8 @@
bone.addAttachment(sAttachments[i]);
}
}
+
+ public BufferedImage getBodyImage() {
+ return bodyImage;
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-06 01:26:13 UTC (rev 714)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-06 17:30:33 UTC (rev 715)
@@ -563,6 +563,10 @@
return objs;
}
+ public InputStream getTemplateResource(String ownerUsername, long templateID, String resourceName) {
+ return templateDataProvider.getTemplateResource(ownerUsername, templateID, resourceName);
+ }
+
private long getHeapRemaining() {
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
return memoryBean.getHeapMemoryUsage().getMax() - memoryBean.getHeapMemoryUsage().getUsed();
@@ -597,4 +601,5 @@
public void cleanup() {
dataCache.cleanup();
}
+
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2008-02-06 01:26:13 UTC (rev 714)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2008-02-06 17:30:33 UTC (rev 715)
@@ -320,5 +320,10 @@
}
attachments.add(attachment);
attachment.attach(skeleton);
+
+ BufferedImage bodyImage = attachment.getBodyImage();
+ if(bodyImage != null){
+ skin.addDecal(bodyImage);
+ }
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2008-02-06 01:26:13 UTC (rev 714)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2008-02-06 17:30:33 UTC (rev 715)
@@ -63,6 +63,8 @@
private J3DUserRenderable userRenderable = null;
+ private Vector decals = new Vector(); // list of BufferedImage
+
public Skin(BufferedImage baseImage, MorphDeltaMap[] morphDeltaMaps, BodyConfiguration bodyConfiguration, J3DUserRenderable userRenderable) {
setCapability(Skin.ALLOW_APPEARANCE_WRITE);
setCapability(Skin.ALLOW_PICKABLE_READ);
@@ -116,7 +118,10 @@
Graphics g = imageComp.getImage().getGraphics();
g.drawImage(baseImage, 0, 0, null);
- //TODO this is where we'd draw on the decals
+ BufferedImage[] decalBIs = getDecals();
+ for (int i = 0; i < decalBIs.length; i++) {
+ g.drawImage(decalBIs[i], 0, 0, null);
+ }
}
}
@@ -332,4 +337,18 @@
return (float) (upper.y - lower.y);
}
+ public BufferedImage[] getDecals(){
+ return (BufferedImage[])decals.toArray(new BufferedImage[0]);
+ }
+
+ public void addDecal(BufferedImage decal) {
+ decals.add(decal);
+ updateTexture();
+ }
+
+ public void removeDecal(BufferedImage decal){
+ if(decals.remove(decal)){
+ updateTexture();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|