|
From: <tre...@us...> - 2008-02-12 04:59:12
|
Revision: 738
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=738&view=rev
Author: trevorolio
Date: 2008-02-11 20:59:18 -0800 (Mon, 11 Feb 2008)
Log Message:
-----------
Changes for the new avatar art.
Modified Paths:
--------------
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/body/Skeleton.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/viewer/j3d/J3DAttachment.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java 2008-02-12 04:59:08 UTC (rev 737)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DAttachment.java 2008-02-12 04:59:18 UTC (rev 738)
@@ -16,6 +16,7 @@
import com.ogoglio.client.model.Attachment;
import com.ogoglio.util.Log;
import com.ogoglio.viewer.j3d.body.Skeleton;
+import com.ogoglio.viewer.j3d.body.SkinLoader;
public class J3DAttachment {
@@ -53,7 +54,7 @@
if (appearance != null) {
shape.setAppearance(appearance);
}
- boneAttachment.addChild(shape);
+ boneAttachment.getTransformGroup().addChild(shape);
boneAttachment.setUserData(shapeNames[j]);
skeletonAttachments.add(boneAttachment);
}
@@ -117,8 +118,8 @@
}
Transform3D boneTransform = new Transform3D();
Point3f cumulativeOffset = bone.getCumulativeOffset();
- boneTransform.setTranslation(new Vector3f(-cumulativeOffset.x, -cumulativeOffset.y, -cumulativeOffset.z));
- sAttachments[i].setTransform(boneTransform);
+ boneTransform.setTranslation(new Vector3f(-cumulativeOffset.x, SkinLoader.ANIMATION_Y_SHIFT - cumulativeOffset.y, -cumulativeOffset.z));
+ sAttachments[i].getTransformGroup().setTransform(boneTransform);
bone.addAttachment(sAttachments[i]);
}
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-12 04:59:08 UTC (rev 737)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DDataManager.java 2008-02-12 04:59:18 UTC (rev 738)
@@ -70,6 +70,7 @@
DEFAULT_MATERIAL.setLightingEnable(true);
DEFAULT_APPEARANCE.setMaterial(DEFAULT_MATERIAL);
+ DEFAULT_APPEARANCE.setUserData("Default Ogoglio Appearance");
}
private TemplateDataProvider templateDataProvider = null;
@@ -83,7 +84,7 @@
private boolean complainedAboutMemory = false;
private boolean watchMemory = false;
-
+
public J3DDataManager(boolean loadAppearances, TemplateDataProvider templateDataProvider, BodyDataProvider bodyDataProvider, boolean watchMemory) {
this.loadAppearances = loadAppearances;
this.templateDataProvider = templateDataProvider;
@@ -92,7 +93,7 @@
}
public BufferedImage getBodyTexture(String username, long bodyConfigurationID) {
- if(!loadAppearances || username == null || username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)){
+ if (!loadAppearances || username == null || username.startsWith(WebConstants.GUEST_COOKIE_PREFIX)) {
return null;
}
@@ -368,12 +369,13 @@
return null;
}
+ Vector normalVectors = new Vector();
Vector textureVertices = new Vector();
Vector vertices = new Vector();
Vector stripCounts = new Vector();
for (int i = 0; i < ranges.length; i++) { //for each range
for (int j = ranges[i].getLower(); j <= ranges[i].getUpper(); j++) { //for each face in range
- stripCounts.add(new Integer(addFaceVertices(group.getObj(), j, vertices, textureVertices)));
+ stripCounts.add(new Integer(addFaceVertices(group.getObj(), j, vertices, textureVertices, normalVectors)));
}
}
@@ -416,7 +418,22 @@
gi.setTextureCoordinateIndices(0, texCoordIndices);
gi.setTextureCoordinates(0, texCoords);
- new NormalGenerator(-1.0f).generateNormals(gi);
+ boolean gotNormal = false;
+ for (int i = 0; i < normalVectors.size(); i++) {
+ if (((Vector3f) normalVectors.get(i)).length() != 0) {
+ gotNormal = true;
+ }
+ }
+ if (gotNormal) {
+ int[] indices = new int[normalVectors.size()];
+ for (int i = 0; i < indices.length; i++) {
+ indices[i] = i;
+ }
+ gi.setNormalIndices(indices);
+ gi.setNormals((Vector3f[])normalVectors.toArray(new Vector3f[0]));
+ } else {
+ new NormalGenerator(-1.0f).generateNormals(gi);
+ }
GeometryArray geometryArray = gi.getGeometryArray(false, false, false);
geometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
geometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ);
@@ -426,7 +443,7 @@
return geometryArray;
}
- private int addFaceVertices(Obj obj, int faceIndex, Vector vertices, Vector textureCoordinates) {
+ private int addFaceVertices(Obj obj, int faceIndex, Vector vertices, Vector textureCoordinates, Vector normalCoordinates) {
int[][] faceIndices = obj.getFaceIndices(faceIndex);
for (int i = 0; i < faceIndices.length; i++) {
vertices.add(obj.getVertex(faceIndices[i][0]));
@@ -435,6 +452,11 @@
} else {
textureCoordinates.add(new Point3f());
}
+ if (faceIndices[i].length > 2 && faceIndices[i][2] != -1) {
+ normalCoordinates.add(obj.getNormal(faceIndices[i][2]));
+ } else {
+ normalCoordinates.add(new Vector3f());
+ }
}
return faceIndices.length;
}
@@ -508,6 +530,7 @@
TextureAttributes textureAttributes = new TextureAttributes();
textureAttributes.setTextureMode(TextureAttributes.MODULATE);
appearance.setTextureAttributes(textureAttributes);
+ appearance.setUserData(material.getDiffuseMapName());
// this is a hack so that only textures named transparent_* get these attributes set
// otherwise we get all kinds of bad ordering problems
@@ -542,7 +565,7 @@
Log.error("Got obj with no groups for template " + templateID);
objs[i] = null;
}
- if (!gotObj && objs[i] != null) {
+ if (objs[i] != null) {
gotObj = true;
}
}
@@ -550,6 +573,7 @@
Log.error("Error parsing obj: " + e);
}
if (!gotObj) {
+ System.out.println("Got no obj for template: " + templateID + ", " + username);
try {
ObjParser parser = new ObjParser(UIConstants.getResource("templates/loading.obj"));
objs[0] = parser.parse();
@@ -573,7 +597,7 @@
}
private boolean atMaxMemory() {
- if(!watchMemory){
+ if (!watchMemory) {
return false;
}
boolean atMax = getHeapRemaining() < MINIMUM_REMAINING_HEAP;
@@ -593,6 +617,9 @@
try {
ObjParser parser = new ObjParser(username, templateID, lodIndex, templateDataProvider);
return parser.parse();
+ } catch (ObjParseException e) {
+ Log.warn("Obj parse exception: " + e);
+ return null;
} catch (Exception e) {
return null;
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java 2008-02-12 04:59:08 UTC (rev 737)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skeleton.java 2008-02-12 04:59:18 UTC (rev 738)
@@ -49,7 +49,16 @@
return rootBone;
}
- public static class Attachment extends TransformGroup {
+ public static class Attachment extends BranchGroup {
+ TransformGroup transformGroup = new TransformGroup();
+
+ public Attachment() {
+ addChild(transformGroup);
+ }
+
+ public TransformGroup getTransformGroup(){
+ return transformGroup;
+ }
}
public void addDebugAttachments() {
@@ -165,7 +174,7 @@
public Point3f getCumulativeOffset() {
Point3f result = new Point3f(offset.x, offset.y, offset.z);
Bone parent = getParentBone();
- while(parent != null){
+ while (parent != null) {
result.x += parent.getOffset().x;
result.y += parent.getOffset().y;
result.z += parent.getOffset().z;
@@ -181,7 +190,7 @@
}
private void print(Bone bone, int indent) {
- StringBuffer buffer=new StringBuffer();
+ StringBuffer buffer = new StringBuffer();
for (int i = 0; i < indent; i++) {
buffer.append("\t");
}
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-12 04:59:08 UTC (rev 737)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/Skin.java 2008-02-12 04:59:18 UTC (rev 738)
@@ -16,6 +16,7 @@
import java.awt.Graphics;
import java.awt.image.BufferedImage;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Vector;
@@ -62,9 +63,11 @@
private BodyConfiguration bodyConfiguration = null;
private J3DUserRenderable userRenderable = null;
-
+
private Vector decals = new Vector(); // list of BufferedImage
-
+
+ float[] baseCoordinates = null;
+
public Skin(BufferedImage baseImage, MorphDeltaMap[] morphDeltaMaps, BodyConfiguration bodyConfiguration, J3DUserRenderable userRenderable) {
setCapability(Skin.ALLOW_APPEARANCE_WRITE);
setCapability(Skin.ALLOW_PICKABLE_READ);
@@ -101,8 +104,8 @@
appearance.setMaterial(material);
setAppearance(appearance);
}
-
- public J3DUserRenderable getUserRenderable(){
+
+ public J3DUserRenderable getUserRenderable() {
return userRenderable;
}
@@ -166,6 +169,12 @@
}
public void updateData(Geometry ignored) {
+ if (baseCoordinates != null) {
+ for (int i = 0; i < baseCoordinates.length; i++) {
+ vertices[i] = baseCoordinates[i];
+ }
+ }
+
for (int i = 0; i < morphDeltaMaps.length; i++) {
float setting = bodyConfiguration.getSetting(morphDeltaMaps[i].getName());
if (lastMorphValues.get(morphDeltaMaps[i].getName()) != null) {
@@ -184,6 +193,10 @@
}
}
}
+ baseCoordinates = new float[vertices.length];
+ for (int i = 0; i < baseCoordinates.length; i++) {
+ baseCoordinates[i] = vertices[i];
+ }
}
}
@@ -316,8 +329,8 @@
y = (j * 3) + 1;
z = (j * 3) + 2;
- workingPoint.set(coords[x], coords[y], coords[z]);
- lastTransforms[g].transform(workingPoint); //get back to original position
+ workingPoint.set(baseCoordinates[x], baseCoordinates[y], baseCoordinates[z]);
+ //lastTransforms[g].transform(workingPoint); //get back to original position
currentTransforms[g].transform(workingPoint);
coords[x] = workingPoint.x;
coords[y] = workingPoint.y;
@@ -337,17 +350,17 @@
return (float) (upper.y - lower.y);
}
- public BufferedImage[] getDecals(){
- return (BufferedImage[])decals.toArray(new BufferedImage[0]);
+ 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)){
+ 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.
|