|
From: <tre...@us...> - 2007-09-28 19:39:58
|
Revision: 456
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=456&view=rev
Author: trevorolio
Date: 2007-09-28 12:39:59 -0700 (Fri, 28 Sep 2007)
Log Message:
-----------
Introducing morphs! Well, some foundations for morphs, anyway.
Added a data data format to save vertex deltas between two obj files, which we will eventually use to interpolate a mesh.
So, someone can tweak a body mesh (e.g. make the nose bigger) and generate a morph file which describes the change.
I still have to make the J3DBodyData read the morphs, arrange them in an ADG, read user prefs for how far to interpolate the morphs, and then apply them to the mesh. And it all needs to be tested and represented in the body editor UI. *whew*
Modified Paths:
--------------
maven/trunk/ogoglio-bodies/.classpath
maven/trunk/ogoglio-bodies/pom.xml
Added Paths:
-----------
maven/trunk/ogoglio-bodies/.settings/
maven/trunk/ogoglio-bodies/.settings/org.eclipse.jdt.core.prefs
maven/trunk/ogoglio-bodies/ogoglio-body-tools/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/pom.xml
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/util/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/util/body/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/util/body/BodyMorphTool.java
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/resources/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/test/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/test/java/
maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/test/resources/
Property Changed:
----------------
maven/trunk/ogoglio-bodies/
Property changes on: maven/trunk/ogoglio-bodies
___________________________________________________________________
Name: svn:ignore
+ target
Modified: maven/trunk/ogoglio-bodies/.classpath
===================================================================
--- maven/trunk/ogoglio-bodies/.classpath 2007-09-27 21:19:18 UTC (rev 455)
+++ maven/trunk/ogoglio-bodies/.classpath 2007-09-28 19:39:59 UTC (rev 456)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="ogoglio-body-tools/src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Added: maven/trunk/ogoglio-bodies/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- maven/trunk/ogoglio-bodies/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ maven/trunk/ogoglio-bodies/.settings/org.eclipse.jdt.core.prefs 2007-09-28 19:39:59 UTC (rev 456)
@@ -0,0 +1,12 @@
+#Fri Sep 28 09:58:33 PDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
Property changes on: maven/trunk/ogoglio-bodies/ogoglio-body-tools
___________________________________________________________________
Name: svn:ignore
+ target
Added: maven/trunk/ogoglio-bodies/ogoglio-body-tools/pom.xml
===================================================================
--- maven/trunk/ogoglio-bodies/ogoglio-body-tools/pom.xml (rev 0)
+++ maven/trunk/ogoglio-bodies/ogoglio-body-tools/pom.xml 2007-09-28 19:39:59 UTC (rev 456)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>com.ogoglio</groupId>
+ <artifactId>ogoglio</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <relativePath>../ogoglio-bodies</relativePath>
+ </parent>
+
+ <artifactId>ogoglio-body-tools</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip><!-- ugh, no unit tests -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.ogoglio</groupId>
+ <artifactId>ogoglio-common</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/util/body/BodyMorphTool.java
===================================================================
--- maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/util/body/BodyMorphTool.java (rev 0)
+++ maven/trunk/ogoglio-bodies/ogoglio-body-tools/src/main/java/com/ogoglio/util/body/BodyMorphTool.java 2007-09-28 19:39:59 UTC (rev 456)
@@ -0,0 +1,94 @@
+package com.ogoglio.util.body;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Vector;
+
+import javax.vecmath.Point3f;
+import javax.vecmath.Vector3f;
+
+import com.ogoglio.viewer.j3d.body.MorphDeltaMap;
+import com.ogoglio.viewer.j3d.obj.Obj;
+import com.ogoglio.viewer.j3d.obj.ObjParseException;
+import com.ogoglio.viewer.j3d.obj.ObjParser;
+
+public class BodyMorphTool {
+
+ public static void main(String[] args) {
+ if (args.length < 3) {
+ printHelp();
+ return;
+ }
+ String name = args[0];
+ File baseMeshFile = new File(args[1]);
+ File morphMeshFile = new File(args[2]);
+ if (!baseMeshFile.exists() || !morphMeshFile.exists()) {
+ printHelp();
+ return;
+ }
+ try {
+
+ Obj baseObj = new ObjParser(new FileInputStream(baseMeshFile)).parse();
+ Obj morphObj = new ObjParser(new FileInputStream(morphMeshFile)).parse();
+
+ MorphDeltaMap deltaMap = generateDeltaMap(name, baseObj, morphObj);
+
+ System.out.println(deltaMap);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ObjParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static Vector3f createDelta(Point3f point1, Point3f point2) {
+ return new Vector3f(point2.x - point1.x, point2.y - point1.y, point2.x - point1.y);
+ }
+
+ private static final MorphDeltaMap generateDeltaMap(String name, Obj baseObj, Obj morphObj) {
+ Point3f[] basePoints = baseObj.getVertices();
+ Point3f[] morphPoints = morphObj.getVertices();
+
+ MorphDeltaMap map = new MorphDeltaMap(name);
+
+ int lower = -1;
+ int upper = -1;
+ Vector deltas = new Vector();
+ for (int i = 0; i < basePoints.length; i++) {
+ if (!equalish(basePoints[i], morphPoints[i])) {
+ if (lower == -1) {
+ lower = i + 1;
+ upper = -1;
+ deltas.add(createDelta(basePoints[i], morphPoints[i]));
+ } else if ((upper == -1 && lower == i) || upper == i) {
+ upper = i + 1;
+ deltas.add(createDelta(basePoints[i], morphPoints[i]));
+ } else {
+ map.addRange(new MorphDeltaMap.Range(lower, (Vector3f[]) deltas.toArray(new Vector3f[0])));
+ lower = i + 1;
+ deltas.clear();
+ deltas.add(createDelta(basePoints[i], morphPoints[i]));
+ upper = -1;
+ }
+ }
+ }
+
+ if (lower != -1) {
+ map.addRange(new MorphDeltaMap.Range(lower, (Vector3f[]) deltas.toArray(new Vector3f[0])));
+ }
+ return map;
+ }
+
+ private static boolean equalish(Point3f point1, Point3f point2) {
+ return equalish(point1.x, point2.x) && equalish(point1.y, point2.y) && equalish(point1.z, point2.z);
+ }
+
+ private static boolean equalish(float one, float two) {
+ return Math.abs(one - two) < 0.001;
+ }
+
+ public static final void printHelp() {
+ System.out.println("Usage: ... name baseMeshFile morphMeshFile");
+ }
+}
Modified: maven/trunk/ogoglio-bodies/pom.xml
===================================================================
--- maven/trunk/ogoglio-bodies/pom.xml 2007-09-27 21:19:18 UTC (rev 455)
+++ maven/trunk/ogoglio-bodies/pom.xml 2007-09-28 19:39:59 UTC (rev 456)
@@ -16,6 +16,7 @@
<relativePath>../ogoglio</relativePath>
</parent>
<modules>
+ <module>ogoglio-body-tools</module>
<module>ogoglio-body-sim</module>
<module>ogoglio-body-mike</module>
<module>ogoglio-body-andrea</module>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|