/** * Used with serialization. Not to be called manually. * * @param in * ObjectInput * @throws IOException * @throws ClassNotFoundException */ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { setA((Vector3) in.readObject()); setB((Vector3) in.readObject()); setC((Vector3) in.readObject()); setIndex(in.readInt()); }
/** * Used with serialization. Not to be called manually. * * @param in * ObjectInput * @throws IOException * @throws ClassNotFoundException */ @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { setA((Vector3) in.readObject()); setB((Vector3) in.readObject()); setC((Vector3) in.readObject()); setIndex(in.readInt()); }
/** * Sets a point to a new value. * * @param index * the index of the point to set (0-2, corresponding to A-C) * @param point * the new value * @throws IllegalArgumentException * if index is not in [0, 2] */ public void set(final int index, final ReadOnlyVector3 point) { switch (index) { case 0: setA(point); return; case 1: setB(point); return; case 2: setC(point); return; } throw new IllegalArgumentException("index must be 0, 1 or 2 (corresponding to A, B or C.)"); }
/** * Sets a point to a new value. * * @param index * the index of the point to set (0-2, corresponding to A-C) * @param point * the new value * @throws IllegalArgumentException * if index is not in [0, 2] */ public void set(final int index, final ReadOnlyVector3 point) { switch (index) { case 0: setA(point); return; case 1: setB(point); return; case 2: setC(point); return; } throw new IllegalArgumentException("index must be 0, 1 or 2 (corresponding to A, B or C.)"); }
@Test public void testNormal() { final Triangle tri1 = new Triangle(Vector3.ZERO, Vector3.UNIT_Y, Vector3.UNIT_X, 0); assertEquals(new Vector3(0, 0, -1), tri1.getNormal()); // dirty assertEquals(new Vector3(0, 0, -1), tri1.getNormal()); // clean tri1.setB(Vector3.UNIT_Z); assertEquals(new Vector3(0, 1, 0), tri1.getNormal()); // dirty, but with existing normal } }
} else { t.setA(vertices[0]); t.setB(vertices[1]); t.setC(vertices[2]);
} else { t.setA(vertices[0]); t.setB(vertices[1]); t.setC(vertices[2]);
tri1.setB(Vector3.UNIT_X); tri1.setC(Vector3.UNIT_Z); tri1.setIndex(1);