/* * Moonlight|3D Copyright (C) 2005 The Moonlight|3D team * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on Feb 27, 2005 */ package ml.test; import java.util.ArrayList; import junit.framework.TestCase; import ml.math.Ray; import ml.math.Vector3D; import ml.plugins.modelling.mesh.Mesh; /** * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates * * @author gregor */ public class MeshTest extends TestCase { public static void main(String[] args) { junit.awtui.TestRunner.run(MeshTest.class); } public void testTranslate() { //TODO Implement translate(). } public void testScale() { //TODO Implement scale(). } /* * Class under test for void applyMatrix(Matrix3) */ public void testApplyMatrixMatrix3() { //TODO Implement applyMatrix(). } /* * Class under test for void applyMatrix(Matrix4) */ public void testApplyMatrixMatrix4() { //TODO Implement applyMatrix(). } public void testGetBoundingBox() { //TODO Implement getBoundingBox(). } public void testGetIntersectionPoint() { Vector3D position; int vertexID, vertexID2, vertexID3; ArrayList edgeList=new ArrayList(); Ray ray; Vector3D result; Mesh m=new Mesh(); ray=new Ray(); ray.start.X1=ray.start.X2=ray.start.X3=0.0; ray.direction.X1=1.0; ray.direction.X2=0.25; ray.direction.X3=0.1; position=new Vector3D(); position.X1=1.0; position.X2=0.0; position.X3=0.0; vertexID=m.addVertex(position); edgeList.add(vertexID); position.X1=1.0; position.X2=1.0; position.X3=0.0; vertexID2=m.addVertex(position); edgeList.add(vertexID2); position.X1=1.0; position.X2=0.0; position.X3=1.0; vertexID3=m.addVertex(position); edgeList.add(vertexID3); try { m.addEdge(vertexID,vertexID2); m.addEdge(vertexID,vertexID3); m.addEdge(vertexID2,vertexID3); m.addFace(edgeList); result=m.getIntersectionPoint(ray); position=ray.direction.clone(); assertTrue(result.equals(position)); ray.direction.X3=0.751; result=m.getIntersectionPoint(ray); assertTrue(result==null); } catch(Exception e) { assertFalse(true); // just fail test here } } public void testGetNumVertices() { //TODO Implement getNumVertices(). } public void testGetVertex() { //TODO Implement getVertex(). } public void testSetVertexPosition() { //TODO Implement setVertexPosition(). } public void testAddVertex() { Vector3D position; int vertexID; Mesh m=new Mesh(); position=new Vector3D(); position.X1=1.0; position.X2=1.0; position.X3=1.0; try { vertexID=m.addVertex(position); } catch(Exception e) { assertFalse(true); // just fail test here } } public void testRemoveVertex() { Vector3D position; int vertexID; Mesh m=new Mesh(); position=new Vector3D(); position.X1=1.0; position.X2=1.0; position.X3=1.0; vertexID=m.addVertex(position); try { m.removeVertex(vertexID); } catch(Exception e) { assertFalse(true); // just fail test here } assertTrue(m.getNumVertices()==0); } public void testAddEdge() { Vector3D position; int vertexID, vertexID2; Mesh m=new Mesh(); position=new Vector3D(); position.X1=1.0; position.X2=1.0; position.X3=1.0; vertexID=m.addVertex(position); vertexID2=m.addVertex(position); try { m.addEdge(vertexID,vertexID2); } catch(Exception e) { assertFalse(true); // just fail test here } } public void testFindEdge() { Vector3D position; int vertexID, vertexID2; int edgeID; Mesh m=new Mesh(); position=new Vector3D(); position.X1=1.0; position.X2=1.0; position.X3=1.0; vertexID=m.addVertex(position); vertexID2=m.addVertex(position); try { edgeID=m.addEdge(vertexID,vertexID2); assertTrue(edgeID==m.findEdge(vertexID,vertexID2)); } catch(Exception e) { assertFalse(true); // just fail test here } } public void testRemoveEdge() { //TODO Implement removeEdge(). } public void testGetEdge() { //TODO Implement getEdge(). } public void testAddFace() { Vector3D position; int vertexID, vertexID2, vertexID3; ArrayList edgeList=new ArrayList(); Mesh m=new Mesh(); position=new Vector3D(); position.X1=1.0; position.X2=1.0; position.X3=1.0; vertexID=m.addVertex(position); edgeList.add(vertexID); vertexID2=m.addVertex(position); edgeList.add(vertexID2); vertexID3=m.addVertex(position); edgeList.add(vertexID3); try { m.addEdge(vertexID,vertexID2); m.addEdge(vertexID,vertexID3); m.addEdge(vertexID2,vertexID3); m.addFace(edgeList); } catch(Exception e) { assertFalse(true); // just fail test here } } public void testGetFace() { Vector3D position; int vertexID, vertexID2, vertexID3; ArrayList edgeList=new ArrayList(); int faceID; Mesh m=new Mesh(); position=new Vector3D(); position.X1=1.0; position.X2=1.0; position.X3=1.0; vertexID=m.addVertex(position); edgeList.add(vertexID); vertexID2=m.addVertex(position); edgeList.add(vertexID2); vertexID3=m.addVertex(position); edgeList.add(vertexID3); try { m.addEdge(vertexID,vertexID2); m.addEdge(vertexID,vertexID3); m.addEdge(vertexID2,vertexID3); faceID=m.addFace(edgeList); assertTrue(m.getFace(faceID)!=null); } catch(Exception e) { assertFalse(true); // just fail test here } } public void testRemoveFace() { //TODO Implement removeFace(). } public void testFirstVertex() { //TODO Implement firstVertex(). } public void testGetFirstManifoldEdge() { //TODO Implement getFirstManifoldEdge(). } public void testGetFirstEdge() { //TODO Implement getFirstEdge(). } public void testFirstFace() { //TODO Implement firstFace(). } }