View Javadoc
1 /***************************************************************************** 2 * Virtual Mockup for Machine Vision 3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr., 4 * Carlos S. Santos. 5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP 6 * 7 * Permission is granted to redistribute and/or modify this 8 * software under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This software is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html) 16 * for more details. 17 * 18 *****************************************************************************/ 19 20 package camera3d; 21 22 23 24 import javax.media.j3d.*; 25 import javax.vecmath.*; 26 27 /*** 28 * This class concentrates methods for calculating the correct value of some 29 * quantities subject to variation according to the dimensions of loaded object, such as 30 * the size of avatars, the increment of translation sliders, and so on. 31 * @author Fábio Roberto de Miranda 32 * @version 1.0 33 */ 34 public class DimensionsManager { 35 36 private static DimensionsManager dimensionsManager = null; 37 38 private double translationsIncrement; 39 40 /* 41 * The distance at which 42 */ 43 44 // The distance at which the front clipping plane 45 // for views must be 46 private double frontClippingPlane; 47 private double backClippingPlane; 48 private double baseCameraSize; 49 private double baseLightSize; 50 private double contentBBoxDiagonal; 51 52 private DimensionsManager() { 53 } 54 55 public static DimensionsManager getDimensionsManager(){ 56 if (dimensionsManager == null){ 57 dimensionsManager = new DimensionsManager(); 58 } 59 return dimensionsManager; 60 } 61 62 public double getTranslationIncrement(){ 63 return this.translationsIncrement; 64 } 65 66 public void setTranslationIncrement(){ 67 this.translationsIncrement = translationsIncrement; 68 } 69 70 /*** 71 * Sets the increment step for the translation controls, based on the length of 72 * the diagonal of the bounding box of an object. 73 */ 74 public void computeTranslationControlsIncrement(VcObject vcObject){ 75 BoundingBox tempBB = new BoundingBox(); 76 Point3d tempP3d = new Point3d(); 77 Vector3d tempVec3d = new Vector3d(); 78 vcObject.getBoundingBoxInVWorld(tempBB); 79 tempBB.getUpper(tempP3d); 80 tempVec3d.set(tempP3d); 81 tempBB.getLower(tempP3d); 82 tempVec3d.x-=tempP3d.x; 83 tempVec3d.y-=tempP3d.y; 84 tempVec3d.z-=tempP3d.z; 85 double length = tempVec3d.length(); 86 contentBBoxDiagonal = length; 87 double incrementFactor = 10; 88 incrementFactor = length/incrementFactor; 89 this.translationsIncrement = incrementFactor; 90 } 91 92 }

This page was automatically generated by Maven