protected float[] calcBoundingBox() { float[] box = null; for (Animated3D skin : modello) { float[] skinBB = skin.getMesh().getBoundingBox(); if (box == null) { box = skinBB; } else { // x box[0] = Math.min(box[0], skinBB[0]); box[1] = Math.max(box[1], skinBB[1]); // y box[2] = Math.min(box[2], skinBB[2]); box[3] = Math.max(box[3], skinBB[3]); // z box[4] = Math.min(box[4], skinBB[4]); box[5] = Math.max(box[5], skinBB[5]); } } return box; }
float[] bb = calcBoundingBox();box_h = (bb[3] - bb[2]); // model heightCamera camera = world.getCamera();if(width < height){ camera.setPosition(0,-box_h/2,0);camera.moveCamera(Camera.CAMERA_MOVEOUT, 70); //la sposto indietrocamera.lookAt(new SimpleVector(0, -box_h/2, 0));}else{float fovy=camera.getYFOV();double cameraDistance = ( box_h / 2 ) / Math.tan( fovy / 2 );camera.setPosition(0,-box_h/2,(float)cameraDistance-100);camera.lookAt(new SimpleVector(0, -box_h/2, 0)); }