Commit 06b3bd40 authored by Human Gamer's avatar Human Gamer

Fixed Incorrect Vector Dot Function Which in turn fixed texture alignment

Added warnMat.png for Textures that aren't found.
Custom textures to avoid using MB textures
parent bf82da44
......@@ -1086,7 +1086,7 @@ public class Interior
{
Point3F point = this.points[this.windings[k]].getPoint();
System.out.println("Point: " + point.toString());
//System.out.println("Point: " + point.toString());
minHull.setMin(point);
maxHull.setMax(point);
......
......@@ -25,6 +25,8 @@ public class MeshBuilder
{
this.positions.add(vertex);
this.textureCoordinates.add(uv);
if (texture.endsWith(".001"))
texture = texture.substring(0, texture.lastIndexOf(".001"));
this.textures.add(texture);
}
......
......@@ -41,7 +41,7 @@ public class OBJModel
while((line = meshReader.readLine()) != null)
{
String[] tokens = line.split(" ");
System.out.println(Util.getArrayString(tokens));
//System.out.println(Util.getArrayString(tokens));
if (tokens.length == 0 || tokens[0].equals("#"))
continue;
......
......@@ -25,6 +25,7 @@ public class InteriorRender extends SceneObject
private EnumSelectionMode surfaceHighlight;
private ColorF highlightColor;
private ColorF highlightColorAlt;
private ColorF highlightColorAlt2;
public InteriorRender(InteriorResource interior)
{
......@@ -32,6 +33,7 @@ public class InteriorRender extends SceneObject
this.highlightColor = new ColorF(0.0f, 0.0f, 1.0f, 0.75f);
this.highlightColorAlt = new ColorF(0.0f, 1.0f, 0.0f, 0.75f);
this.highlightColorAlt2 = new ColorF(1.0f, 0.0f, 0.0f, 0.75f);
this.surfaceHighlight = EnumSelectionMode.NONE;
this.highlightIndex = -1;
......@@ -85,6 +87,8 @@ public class InteriorRender extends SceneObject
return;
GLTexture texture = new GLTexture("textures/" + textureName);
if (!texture.isValid())
texture = new GLTexture("textures/" + "warnMat");
this.textures.put(textureName, texture);
}
......@@ -325,6 +329,11 @@ public class InteriorRender extends SceneObject
if (this.highlightIndex >= 0 && this.highlightIndex < surfaces.length)
{
Surface surface = surfaces[this.highlightIndex];
Point3F normal = interior.getPlanes()[surface.getPlaneIndex()];
Point3F cPoint = new Point3F();
int windingStart = surface.getWindingStart();
int windingCount = surface.getWindingCount();
for (int i = windingStart; i < windingStart + windingCount; i++)
......@@ -332,19 +341,16 @@ public class InteriorRender extends SceneObject
Point3F point = points[interior.getWindings()[i]].getPoint();
Cube cube = new Cube(point, new Point3F(0.25f), this.highlightColorAlt);
cube.render();
/*float px = point.getX();
float py = point.getY();
float pz = point.getZ();
glBegin(GL_POINTS);
{
glColor3f(0.0f, 0.0f, 1.0f);
//glVertex3f(px - 0.5f, py - 0.5f, pz - 0.5f);
glVertex3f(px, py, pz);
}
glEnd();*/
cPoint = cPoint.add(point);
}
Point3F n1 = cPoint.div(windingCount).add(normal.mul(0.25f));
Point3F n2 = n1.add(normal);
Cube nc1 = new Cube(n1, new Point3F(0.25f), this.highlightColorAlt2);
nc1.render();
Cube nc2 = new Cube(n2, new Point3F(0.25f), this.highlightColor);
nc2.render();
}
} else if (this.surfaceHighlight == EnumSelectionMode.POINTS)
{
......
......@@ -107,7 +107,7 @@ public class Point3F
public float dot(Point3F r)
{
return this.x * r.x + this.y * r.y + this.z + r.z;
return this.x * r.x + this.y * r.y + this.z * r.z;
}
public Point3F add(Point3F r)
......
......@@ -21,6 +21,9 @@ public class TexGenPlanes
float[][] vecs = Util.getTextureAxis(normal);
//System.out.println("(0): " + Util.getArrayString(vecs[0]));
//System.out.println("(1): " + Util.getArrayString(vecs[1]));
int sv;
int tv;
......@@ -72,10 +75,30 @@ public class TexGenPlanes
this.planeY = new PlaneF(vx, vy, vz, vd);
}
public TexGenPlanes(Point2F uv)
public TexGenPlanes(Point3F normal, Point3F point, Point2F uv)
{
this();
//this(normal, uv, 0, new Point2F(0.25f, 0.25f));
//this.scaleDown(32);
// TODO: Use UV
//float u = uv.getX();
//float v = uv.getY();
//Point3F x = normal.mul(u).normalize();
//Point3F y = normal.mul(v).normalize();
//this.planeX = new PlaneF(x.getX(), x.getY(), x.getZ(), u);
//this.planeY = new PlaneF(y.getX(), y.getY(), y.getZ(), v);
//System.out.println("U: " + u + ", V:" + v);
//System.out.println("U: " + planeX.getDistanceToPoint(point) + ", V:" + planeY.getDistanceToPoint(point));
//u = planeX.getDistanceToPoint(p1)
//v = planeY.getDistanceToPoint(p1)
//(this.x * point.x + this.y * point.y + this.z * point.z) + this.d
}
public TexGenPlanes()
......
......@@ -19,6 +19,8 @@ public class ImageData
public static final ImageData loadImage(String path)
{
if (path.endsWith("_mbm"))
path = path.substring(0, path.lastIndexOf("_mbm"));
BufferedImage img = null;
try {
......
......@@ -273,7 +273,7 @@ public final class Util
if (arr == null)
return "<NULL>";
StringBuilder sb = new StringBuilder();
sb.append("byte[" + arr.length + "]{");
sb.append("Object[" + arr.length + "]{");
for (int i = 0; i < arr.length; i++)
{
sb.append(arr[i]);
......@@ -348,7 +348,7 @@ public final class Util
for (int i = 0; i < 6; i++)
{
dot = normal.dot(new Point3F(baseAxis[i*3][0], Util.baseAxis[i*3][1], baseAxis[i*3][2]));
dot = normal.dot(new Point3F(Util.baseAxis[i*3][0], Util.baseAxis[i*3][1], Util.baseAxis[i*3][2]));
if (dot > best)
{
best = dot;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment