|
From: <tre...@us...> - 2007-09-18 22:45:37
|
Revision: 424
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=424&view=rev
Author: trevorolio
Date: 2007-09-18 15:45:32 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
Now you can select your height from the body editor applet.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.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/SkinLoader.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDocument.java
Added Paths:
-----------
maven/trunk/ogoglio-common/src/main/resources/sourceArt/Icons/
maven/trunk/ogoglio-common/src/main/resources/sourceArt/Icons/GenderIcons.psd
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java 2007-09-18 22:45:25 UTC (rev 423)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/client/model/Body.java 2007-09-18 22:45:32 UTC (rev 424)
@@ -19,7 +19,7 @@
private float height = 2;
private float girth = 1;
-
+
public Body(long bodyID, int hair, int eyes, int nose, int mouth, int face, boolean isMale, float height, float girth) {
this.bodyID = bodyID;
this.hair = hair;
@@ -28,8 +28,8 @@
this.mouth = mouth;
this.face = face;
this.male = isMale;
- this.height = height;
- this.girth = girth;
+ this.height = height;
+ this.girth = girth;
}
public long getBodyID() {
@@ -68,11 +68,15 @@
return male;
}
- public float getHeight(){
+ public float getHeight() {
return height;
}
-
- public float getGirth(){
+
+ public void setHeight(float height) {
+ this.height = height;
+ }
+
+ public float getGirth() {
return girth;
}
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 2007-09-18 22:45:25 UTC (rev 423)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DUserRenderable.java 2007-09-18 22:45:32 UTC (rev 424)
@@ -109,6 +109,7 @@
scaleBVH(defaultAnimation);
skeleton = new SkeletonLoader(defaultAnimation).generateSkeleton();
+ //skeleton.addDebugAttachments();
if (isVisible) {
skin.setSkeleton(skeleton, skinMap);
}
@@ -137,7 +138,7 @@
float bvhHeight = bvh.getHeight();
if (bvhHeight != userHeight) {
skeletonScale = userHeight / bvhHeight / MAGIC_SKELETON_SCALE; //TODO figure out why we need this magic scale number
- bvh.scale(skeletonScale);
+ bvh.scale(skeletonScale, skeletonScale, skeletonScale);
}
}
@@ -277,4 +278,19 @@
e.printStackTrace();
}
}
+
+ public void setHeight(float newHeight) {
+ try {
+ initBody();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ObjParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SkinMapParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-09-18 22:45:25 UTC (rev 423)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/body/SkinLoader.java 2007-09-18 22:45:32 UTC (rev 424)
@@ -52,12 +52,30 @@
Point3f[] vertices = obj.getVertices();
float[] vertexArray = new float[vertices.length * 3];
+ float minY = Float.MAX_VALUE;
+ float maxY = Float.MIN_VALUE;
for (int i = 0; i < vertices.length; i++) {
vertexArray[i * 3] = vertices[i].x;
vertexArray[(i * 3) + 1] = vertices[i].y;
vertexArray[(i * 3) + 2] = vertices[i].z;
+
+ if(vertices[i].y < minY){
+ minY = vertices[i].y;
+ }
+ if(vertices[i].y > maxY){
+ maxY = vertices[i].y;
+ }
}
+ float heightScale = body.getHeight() / Math.abs(maxY - minY);
+ if(Math.abs(heightScale) > 0.1){
+ for (int i = 0; i < vertices.length; i++) {
+ vertexArray[i * 3] = vertexArray[i * 3] * heightScale;
+ vertexArray[(i * 3) + 1] = vertexArray[(i * 3) + 1] * heightScale;
+ vertexArray[(i * 3) + 2] = vertexArray[(i * 3) + 2] * heightScale;
+ }
+ }
+
Point3f[] texCoords = obj.getTextureVertices();
float[] textureCoordinateArray = new float[texCoords.length * 2];
for (int i = 0; i < texCoords.length; i++) {
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java 2007-09-18 22:45:25 UTC (rev 423)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/bvh/Bvh.java 2007-09-18 22:45:32 UTC (rev 424)
@@ -107,14 +107,14 @@
//TODO stop ignoring scale
}
- public void scaleFrameData(float amountToScale, Frame frame) {
+ public void scaleFrameData(float xScale, float yScale, float zScale, Frame frame) {
if (startIndex == -1) {
return;
}
if (channelIndices[0] != -1 && channelIndices[1] != -1 && channelIndices[2] != -1) {
- frame.data[startIndex + channelIndices[0]] = frame.data[startIndex + channelIndices[0]] * amountToScale;
- frame.data[startIndex + channelIndices[1]] = frame.data[startIndex + channelIndices[1]] * amountToScale;
- frame.data[startIndex + channelIndices[2]] = frame.data[startIndex + channelIndices[2]] * amountToScale;
+ frame.data[startIndex + channelIndices[0]] = frame.data[startIndex + channelIndices[0]] * xScale;
+ frame.data[startIndex + channelIndices[1]] = frame.data[startIndex + channelIndices[1]] * yScale;
+ frame.data[startIndex + channelIndices[2]] = frame.data[startIndex + channelIndices[2]] * zScale;
}
}
@@ -234,15 +234,15 @@
return maxY - minY;
}
- public void scale(float amountToScale) {
+ public void scale(float xScale, float yScale, float zScale) {
Vector joints = new Vector();
getJoints(getRootJoint(), joints);
for (int i = 0; i < joints.size(); i++) {
Joint joint = (Joint) joints.get(i);
Vector3f offset = joint.getOffset();
- joint.setOffset(offset.x * amountToScale, offset.y * amountToScale, offset.z * amountToScale);
+ joint.setOffset(offset.x * xScale, offset.y * yScale, offset.z * zScale);
for (int j = 0; j < getFrameCount(); j++) {
- joint.scaleFrameData(amountToScale, getFrame(j));
+ joint.scaleFrameData(xScale, yScale, zScale, getFrame(j));
}
}
}
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDocument.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDocument.java 2007-09-18 22:45:25 UTC (rev 423)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/xml/BodyDocument.java 2007-09-18 22:45:32 UTC (rev 424)
@@ -144,18 +144,26 @@
data.setAttribute(FACE_INDEX, index);
}
- public boolean isMale(){
+ public boolean isMale() {
return data.getBooleanAttribute(IS_MALE);
}
-
- public float getHeight(){
+
+ public float getHeight() {
return data.getFloatAttribute(HEIGHT);
}
-
- public float getGirth(){
+
+ public void setHeight(float newHeight) {
+ data.setAttribute(HEIGHT, newHeight);
+ }
+
+ public float getGirth() {
return data.getFloatAttribute(GIRTH);
}
-
+
+ public void setGirth(float girth) {
+ data.setAttribute(GIRTH, girth);
+ }
+
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof BodyDocument)) {
return false;
@@ -166,4 +174,5 @@
public int hashCode() {
return ("BodyDocument-" + getBodyID()).hashCode();
}
+
}
\ No newline at end of file
Added: maven/trunk/ogoglio-common/src/main/resources/sourceArt/Icons/GenderIcons.psd
===================================================================
(Binary files differ)
Property changes on: maven/trunk/ogoglio-common/src/main/resources/sourceArt/Icons/GenderIcons.psd
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|