ColladaImporter { public ColladaStorage load(InputStream inputStream) { DataCache dataCache = new DataCache(); Element collada = readCollada(inputStream, dataCache); ColladaDOMUtil colladaDomUtil = new ColladaDOMUtil(dataCache); ColladaMeshParser colladaMeshParser = new ColladaMeshParser(dataCache, colladaDomUtil); ColladaNodeParser colladaNodeParser = new ColladaNodeParser(dataCache, colladaDomUtil, colladaMeshParser); AssetData asset = new AssetDataParser(collada.getChild("asset")).parse(); Node scene = colladaNodeParser.getVisualScene(collada); return new ColladaStorage(asset, scene); }  ColladaStorage load(InputStream inputStream);  }
@Test public void testLoadAssetData() { ColladaStorage colladaStorage = colladaImporter.load(getInputData("fearless-render-collada/src/test/resources/boll.dae")); assertNotNull("Collada storage was null", colladaStorage); AssetData assetdata = colladaStorage.getAssetdata(); assertNotNull("Asset Data was null", assetdata); assertEquals("spoo", assetdata.getAuthor()); assertEquals("this is a test structure", assetdata.getComments()); assertEquals("FBX COLLADA exporter", assetdata.getAuthoringTool()); assertEquals("1.0", assetdata.getRevision()); assertEquals("Test Ball", assetdata.getTitle()); assertEquals("this is a test", assetdata.getSubject()); assertEquals("test", assetdata.getKeywords()); assertEquals(1.000f, assetdata.getUnitMeter(), 0.002); assertEquals(Vector3.UNIT_Y, assetdata.getUpAxis()); }
@Test public void testLoadVertexData() { ColladaStorage colladaStorage = colladaImporter.load(getInputData("fearless-render-collada/src/test/resources/notransform.dae")); assertNotNull("Collada storage was null", colladaStorage); Node scene = colladaStorage.getScene(); MeshData meshData = scene.getChildren().get(0).getChildren().get(0).getMeshes().get(0); assertEqualsData(expectedVertex, meshData.getVertexBuffer()); assertEqualsData(expectedNormal, meshData.getNormalBuffer()); assertEqualsData(expectedTexCoord, meshData.getTextureCoordsMap().get(0)); assertEqualsData(expectedIndices, meshData.getIndices()); }
@Test public void testBenderTransformations() { Matrix4 mainTransform = new Matrix4(3.603417, 0.0, 0.0, -0.998503, 0.0, 0.0, 3.603417, 342.593842, 0.0, -3.456769, 0.0, -8.590803, 0.0, 0.0, 0.0, 1.0); Matrix4 mainPivotTransform = new Matrix4(1.0, 0.0, 0.0, -9.458588, 0.0, 1.0, 0.0, 0.523689, 0.0, 0.0, 1.0, 3.60814, 0.0, 0.0, 0.0, 1.0); Matrix4 mainMeshTransform = null; ColladaStorage colladaStorage = colladaImporter.load(getInputData("fearless-render-collada/src/test/resources/bender.dae")); assertNotNull("Collada storage was null", colladaStorage); Node scene = colladaStorage.getScene(); Node main = scene.getChildren().get(0); Node mainPivot = main.getChildren().get(0); Node mainMesh = mainPivot.getChildren().get(0); assertEqualsMatrix(mainTransform, main.getTransform()); assertEqualsMatrix(mainPivotTransform, mainPivot.getTransform()); assertEqualsMatrix(mainMeshTransform, mainMesh.getTransform()); }
@Test public void testCombineMeshWithJustOneMeshAndNoTransforms() { ColladaImporter colladaImporter = new ColladaImporter(); ColladaStorage colladaStorage = colladaImporter.load(getInputData("fearless-render-collada/src/test/resources/notransform.dae")); assertNotNull("Collada storage was null", colladaStorage); MeshData meshData = colladaStorage.getScene().getChildren().get(0).getChildren().get(0).getMeshes().get(0); MeshData combinedMeshData = colladaStorage.getCombinedMeshData(); assertEqualsBuffer(meshData.getVertexBuffer(), combinedMeshData.getVertexBuffer()); assertEqualsBuffer(meshData.getNormalBuffer(), combinedMeshData.getNormalBuffer()); assertEqualsBuffer(meshData.getIndices(), combinedMeshData.getIndices()); assertEqualsBuffer(meshData.getTextureCoordsMap().get(0), combinedMeshData.getTextureCoordsMap().get(0)); assertEquals(meshData.getIndices().getClass(), combinedMeshData.getIndices().getClass()); assertEquals(meshData.getVertexIndexMode(), combinedMeshData.getVertexIndexMode()); }