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 import camera3d.J3DBase; 23 import camera3d.VcLaserArray; 24 import camera3d.VcAmbientLight; 25 import camera3d.VcDirectLight; 26 import camera3d.VcPointLight; 27 import camera3d.VcSpotLight; 28 import camera3d.VcLight; 29 30 /*** 31 * Adds a light to the scene graph. 32 * 33 * @author Fábio Roberto de Miranda 34 * @version 1.0 35 */ 36 public class AddLightAction extends VcLightAction { 37 38 public static final int POINT_LIGHT = 0; 39 public static final int SPOT_LIGHT = 1; 40 public static final int DIRECTIONAL_LIGHT = 2; 41 public static final int AMBIENT_LIGHT = 3; 42 public static final int LASER_ARRAY = 4; 43 44 // We need to know references to the lights created by this object so that 45 // if an undo operation is needed, we'll know which elements to erase 46 private VcPointLight pointLight; 47 private VcSpotLight spotLight; 48 private VcAmbientLight ambientLight; 49 private VcDirectLight directionalLight; 50 private VcLaserArray laserArray; 51 52 private String name; 53 private int type; 54 55 56 public AddLightAction(int type, String name) { 57 this.type = type; 58 this.name = name; 59 } 60 61 public AddLightAction(String type, String name) { 62 this.type = 0; 63 if (type.equals("POINT")){ 64 this.type = 0; 65 } 66 if (type.equals("SPOT")){ 67 this.type = 1; 68 } 69 if (type.equals("DIRECTIONAL")){ 70 this.type = 2; 71 } 72 if (type.equals("AMBIENT")){ 73 this.type = 3; 74 } 75 if (type.equals("LASER_ARRAY")){ 76 this.type = 4; 77 } 78 this.name = name; 79 } 80 81 public void doAction(ActionExecutor executor) { 82 /***@todo: implement this camera3d.VcAction abstract method*/ 83 J3DBase base = executor.getJ3DBase(); 84 switch (type){ 85 case POINT_LIGHT: 86 pointLight = new VcPointLight(); 87 pointLight.setLabel(name); 88 base.addLight(pointLight); 89 break; 90 case SPOT_LIGHT: 91 spotLight = new VcSpotLight(); 92 spotLight.setLabel(name); 93 base.addLight(spotLight); 94 break; 95 case DIRECTIONAL_LIGHT: 96 directionalLight = new VcDirectLight(); 97 directionalLight.setLabel(name); 98 base.addLight(directionalLight); 99 break; 100 case AMBIENT_LIGHT: 101 ambientLight = new VcAmbientLight(); 102 ambientLight.setLabel(name); 103 base.addLight(ambientLight); 104 break; 105 case LASER_ARRAY: 106 laserArray = new VcLaserArray(4,4,0.5,0.5); 107 laserArray.setLabel(name); 108 base.addLaserArray(laserArray); 109 break; 110 default: 111 pointLight = new VcPointLight(); 112 pointLight.setLabel(name); 113 base.addLight(pointLight); 114 break; 115 } 116 117 } 118 119 int getType(String s){ 120 if (s.equals("POINT")){ 121 return 0; 122 } 123 if (s.equals("SPOT")){ 124 return 1; 125 } 126 if (s.equals("DIRECTIONAL")){ 127 return 2; 128 } 129 if (s.equals("AMBIENT")){ 130 return 3; 131 } 132 if (s.equals("LASER_ARRAY")){ 133 return 4; 134 } 135 return 0; 136 } 137 138 139 }

This page was automatically generated by Maven