I've been playing about with PolygonManager and GenericVertexController and have a couple of questions.
I've set up a very simple class the extends GenericVertexController:
public class TestVertexController extends GenericVertexController {
TestVertexController() {
}
public void apply() {
SimpleVector[] srcMesh=this.getSourceMesh();
int size=this.getMeshSize();
for (int i=0; i<size; i++) {
System.out.println("A" + i + ": (" + srcMesh[i].x + ", " + srcMesh[i].y + ", " + srcMesh[i].z +")");
}
}
}
I have also put code into the mouse click event to print out vertex info from the PolygonManager:
SimpleVector td = Interact2D.reproject2D3D(theCamera,frameBuffer,mousePosition.x,mousePosition.y);
int[] res = Interact2D.pickPolygon(theWorld.getVisibilityList(), td, Interact2D.EXCLUDE_NOT_SELECTABLE);
Object3D obj = theWorld.getObject(Interact2D.getObjectID(res));
PolygonManager polyManager = obj.getPolygonManager();
SimpleVector v0 = polyManager.getTransformedVertex(res[1], 0);
SimpleVector v1 = polyManager.getTransformedVertex(res[1], 1);
SimpleVector v2 = polyManager.getTransformedVertex(res[1], 2);
System.out.println("V0: (" + v0.x + ", " + v0.y + ", " + v0.z + ")");
System.out.println("V1: (" + v1.x + ", " + v1.y + ", " + v1.z + ")");
System.out.println("V2: (" + v2.x + ", " + v2.y + ", " + v2.z + ")");
When I run the applet, and click on one polygon I get the following:
A0: (2.0, 2.0000002, 2.0000002)
A1: (2.0, 2.0000002, -1.9999996)
A2: (-2.0, 2.0000002, -1.9999996)
A3: (-2.0, 2.0000002, 2.0000002)
A4: (-2.0, -1.9999996, -1.9999998)
A5: (-2.0, -1.9999999, 2.0000002)
A6: (2.0, -1.9999996, -1.9999998)
A7: (1.999998, -2.0000017, 2.0000002)
V0: (2.0000002, 2.0000002, -1.9999999)
V1: (-1.9999998, -1.9999996, -2.0)
V2: (-1.9999998, 2.0000002, -1.9999999)
The problem is that the numbers don't exactly match - is this a rounding problem, or simply a System.out.println problem?
If I did V0.equals(A1) (assuming they were SimpleVector variables) would it return true?
(I know I could write code to compare and find out, but I haven't worked out how to do that yet and it's 4.30pm on Friday evening...)
Many Thanks,
Janine