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 import javax.vecmath.*; 23 import javax.media.j3d.*; 24 import camera3d.test.NodeTester; 25 import camera3d.action.ActionExecutor; 26 import camera3d.action.ActionQueue; 27 import camera3d.manipulation.*; 28 import java.awt.event.*; 29 30 /*** 31 * A simple application to demonstrate the debugging utilities. 32 * 33 * @author Carlos da Silva dos Santos 34 */ 35 36 public class DebugUtilTest { 37 38 private Vector4d plane; 39 private GeometryBag bag; 40 private TranslationManipulator manip; 41 private NodeTester tester; 42 private Canvas3D canvas3d; 43 private Transform3D imagePlateToVworld = new Transform3D(); 44 private Point3d clickPoint3D = new Point3d(); 45 46 private Point3d eyePos = new Point3d(); 47 private Vector3d lineVector = new Vector3d(); 48 private Point3d result = new Point3d(); 49 50 51 public DebugUtilTest() { 52 tester = new NodeTester(); 53 tester.setBackgroundColor(new Color3f(1.0f,1.0f,1.0f)); 54 bag = new GeometryBag(); 55 tester.add(bag.getBranchGroup()); 56 canvas3d = tester.getCanvas3D(); 57 canvas3d.addMouseListener(new InternalListener()); 58 59 manip = new TranslationManipulator(); 60 manip.setCanvas3D(tester.getCanvas3D()); 61 62 plane = new Vector4d(); 63 MathUtility.buildPlaneFromPointAndNormal(plane,new Point3d(0.0,1.0,0.0),new Vector3d(0,.3,.6)); 64 65 ActionQueue queue = new ActionQueue(); 66 //GUIControl guiControl = new GUIControl(queue); 67 68 bag.addPlane(plane, new Color3b((byte)128,(byte)128,(byte)128)); 69 } 70 71 public static void main(String[] args) { 72 DebugUtilTest test = new DebugUtilTest(); 73 } 74 75 /*** 76 * Calculates the eye position in Vworld coordinates. 77 */ 78 private void recomputeEyeVectors(){ 79 canvas3d.getCenterEyeInImagePlate(eyePos); 80 //debugln("TranslationManipulator: eye Pos (IP): ("+eyePos.x+","+eyePos.y+","+eyePos.z+")"); 81 imagePlateToVworld.transform(eyePos); 82 //debugln("TranslationManipulator: eye Pos (VW): ("+eyePos.x+","+eyePos.y+","+eyePos.z+")"); 83 } 84 85 private void recomputeMatrices(){ 86 canvas3d.getImagePlateToVworld(imagePlateToVworld); 87 } 88 89 private class InternalListener extends java.awt.event.MouseAdapter{ 90 public void mouseClicked(MouseEvent e){ 91 int x = e.getX(); 92 int y = e.getY(); 93 recomputeMatrices(); 94 recomputeEyeVectors(); 95 canvas3d.getPixelLocationInImagePlate(x, y, clickPoint3D); 96 imagePlateToVworld.transform(clickPoint3D); 97 lineVector.sub(clickPoint3D,eyePos); 98 MathUtility.computeIntersection(result, eyePos, lineVector, plane); 99 bag.addLine(eyePos,result); 100 bag.addPoint(result); 101 } 102 } 103 }

This page was automatically generated by Maven