/** * Recursively compute the bounding box of the {@link MeshPrimitiveModel} * objects of all {@link MeshModel} objects in the given {@link SceneModel} * (including the respective global node transforms). * If the given result is <code>null</code>, then a new bounding box * will be created and returned. * * @param sceneModel The {@link SceneModel} * @param transform The root transform, as a column major 4x4 matrix * @param boundingBox The optional bounding box that will store the result * @return The result */ private BoundingBox computeSceneBoundingBox( SceneModel sceneModel, float transform[], BoundingBox boundingBox) { BoundingBox localResult = boundingBox; if (localResult == null) { localResult = new BoundingBox(); } List<NodeModel> nodeModels = sceneModel.getNodeModels(); for (NodeModel nodeModel : nodeModels) { computeNodeBoundingBox(nodeModel, transform, localResult); } return localResult; }
for (NodeModel child : children) computeNodeBoundingBox(child, transform, result);