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.action; 21 22 23 /*** 24 * 25 * @author Carlos da Silva dos Santos e Fábio de Miranda 26 * @version 1.0 27 */ 28 29 import javax.vecmath.*; 30 import javax.media.j3d.*; 31 import camera3d.GeometryBag; 32 import camera3d.J3DBase; 33 import camera3d.test.NodeTester; 34 35 public class AddPlaneGizmoAction extends GeometryBagAction { 36 37 private Vector3d normal = null; 38 private Point3d p1 = null; 39 private Point3d p2 = null; 40 private Point3d p3 = null; 41 private Vector4d plane = null; 42 43 /*** 44 * To help decide wich PlaneGizmo constructor to call 45 */ 46 private int action; 47 48 public AddPlaneGizmoAction(Point3d p1, Point3d p2, Point3d p3) { 49 this.p1 = p1; 50 this.p2 = p2; 51 this.p3 = p3; 52 this.normal = null; 53 plane = null; 54 action = 0; 55 } 56 57 public AddPlaneGizmoAction(Point3d p1, Vector3d normal){ 58 this.p1 = p1; 59 this.p2 = this.p3 = null; 60 this.normal = normal; 61 plane = null; 62 action = 1; 63 } 64 65 public AddPlaneGizmoAction(Vector4d plane){ 66 this.plane = plane; 67 this.p1 = null; 68 this.p2 = this.p3 = null; 69 this.normal = null; 70 action = 2; 71 } 72 73 public void doAction(ActionExecutor executor){ 74 debugflag = true; 75 76 debugln("doaction called in AddPlaneGizmoAction "); 77 J3DBase base = executor.getJ3DBase(); 78 /*** 79 * If a specific geometryBag was not supplied with this action, we have 80 * to use the one that came with J3DBase 81 */ 82 if (geometryBag == null){ 83 geometryBag = base.getDefaultGeometryBag(); 84 } 85 86 87 switch (action) { 88 case 0: 89 geometryBag.addPlane(p1, p2, p3); 90 break; 91 case 1: 92 geometryBag.addPlane(p1, normal); 93 break; 94 case 2: 95 geometryBag.addPlane(plane); 96 break; 97 } 98 } 99 100 /*** 101 * 102 */ 103 static public void main(String[] args) { 104 /*** 105 * 106 */ 107 Point3d p1 = new Point3d(1.0, 1.0, 0.0); 108 Point3d p2 = new Point3d(0.0, 0.0, 1.0); 109 Point3d p3 = new Point3d(0.0, 0.0, -1.0); 110 111 ActionQueue queue = new ActionQueue(); 112 J3DBase base = new J3DBase(); 113 GeometryBag bag = base.getDefaultGeometryBag(); 114 AddPlaneGizmoAction action = new AddPlaneGizmoAction(p1, p2, p3); 115 ActionExecutor exec = new ActionExecutor(queue, new ActionQueue(), base); 116 117 118 119 bag.getBranchGroup().detach(); 120 BranchGroup bg = bag.getBranchGroup(); 121 NodeTester tester = new NodeTester(); 122 tester.add(bg); 123 124 action.doAction(exec); 125 126 //Second plane 127 Vector3d lineVec = new Vector3d(0.0, 1.0, 0.0); 128 Point3d linePoint = new Point3d(0.0,0.0,0.0); 129 /* 130 bag.addPlane(linePoint, lineVec); 131 bag.addLine(linePoint, lineVec); 132 bag.addPoint(p1); 133 bag.addPoint(p2); 134 bag.addPoint(p3); 135 bag.addPlane(p1, p2, p3);*/ 136 Point3d a = new Point3d(0.0, 1.0, 1.0); 137 Point3d b = new Point3d(0.0, 0.0, 0.0); 138 Point3d c = new Point3d(1.0, 0.0, 0.0); 139 //bag.addPlane(a,b,c); 140 //action.doAction(exec); 141 AddPlaneGizmoAction action2 = new AddPlaneGizmoAction(a, b, c); 142 action2.doAction(exec); 143 /* 144 AddPlaneGizmoAction action3 = new AddPlaneGizmoAction(p1, p2, p3); 145 action3.doAction(exec); 146 */ 147 148 bag.addPoint(a); 149 bag.addPoint(b); 150 bag.addPoint(c); 151 152 bag.addPoint(p1); 153 bag.addPoint(p2); 154 bag.addPoint(p3); 155 156 /* 157 bag.addPlane(p1, p2, p3); 158 bag.addPlane(a, b, c); 159 */ 160 161 } 162 }

This page was automatically generated by Maven