r2109 - tools/ObjToMap/objtomap
savagex at icculus.org
savagex at icculus.org
Sun Jan 14 12:06:21 EST 2007
Author: savagex
Date: 2007-01-14 12:06:21 -0500 (Sun, 14 Jan 2007)
New Revision: 2109
Modified:
tools/ObjToMap/objtomap/ObjToMap.java
Log:
wow, now even *better*
Modified: tools/ObjToMap/objtomap/ObjToMap.java
===================================================================
--- tools/ObjToMap/objtomap/ObjToMap.java 2007-01-14 13:41:44 UTC (rev 2108)
+++ tools/ObjToMap/objtomap/ObjToMap.java 2007-01-14 17:06:21 UTC (rev 2109)
@@ -151,6 +151,16 @@
private class Vector3D {
public double x, y, z;
+ public Vector3D() {
+ this(0.0, 0.0, 0.0);
+ }
+
+ public Vector3D(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
public Vector3D crossproduct(Vector3D p1) {
Vector3D result = new Vector3D();
@@ -161,6 +171,10 @@
return result;
}
+ public double dotproduct(Vector3D p1) {
+ return this.x * p1.x + this.y * p1.y + this.z * p1.z;
+ }
+
public Vector3D substract(Vector3D p1) {
Vector3D result = new Vector3D();
@@ -204,6 +218,17 @@
Vector3D normal = vector1.crossproduct(vector2);
normal.normalize();
+
+ Vector3D normal_xy = new Vector3D(0.0, 0.0, 1.0);
+ double angle_xy = Math.acos(normal.dotproduct(normal_xy)) / (2 * Math.PI) * 360.0;
+
+ //
+ if(angle_xy < 60.0) {
+ normal.x = 0.0;
+ normal.y = 0.0;
+ normal.z = 1.0;
+ }
+
normal.scale(4.0);
Vector3D p1_, p2_, p3_;
@@ -233,9 +258,9 @@
return result;
}
-
+
private String getMapPlaneString(Vector3D p1, Vector3D p2, Vector3D p3, String material) {
- return "( " + p1.x + " " + p1.y + " " + p1.z + " ) ( " + p2.x + " " + p2.y + " " + p2.z + " ) ( " + p3.x + " " + p3.y + " " + p3.z + " ) " + material + " 0 0 0 0.5 0.5 0 0 0\n";
+ return "( " + (float)p1.x + " " + (float)p1.y + " " + (float)p1.z + " ) ( " + (float)p2.x + " " + (float)p2.y + " " + (float)p2.z + " ) ( " + (float)p3.x + " " + (float)p3.y + " " + (float)p3.z + " ) " + material + " 0 0 0 0.5 0.5 0 0 0\n";
}
}
More information about the nexuiz-commits
mailing list