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.media.j3d.*;
23 import javax.vecmath.*;
24
25 /***
26 * Represents a directional light.
27 * @author Fábio Roberto de Miranda
28 * @version 1.0
29 */
30 public class VcDirectLight extends VcLight {
31 private static int instanceCounter = 0;
32 private Shape3D avatar;
33 private DirectionalLight directionalLight;
34
35 public VcDirectLight() {
36 avatar = AvatarManager.getAvatarManager().getDirectLightAvatarShape();
37 directionalLight = new DirectionalLight();
38 this.pivotTG.addChild(directionalLight);
39 this.pivotTG.addChild(avatar);
40 this.color = new Color3f();
41 this.setLabel("DirectLight"+this.instanceCounter++);
42 }
43
44 public Light getJ3DLight(){
45 return this.directionalLight;
46 }
47
48 public void setEnable(boolean enabled){
49 this.directionalLight.setEnable(enabled);
50 }
51
52 public void setColor(float red, float green, float blue){
53 this.color.set(red, green, blue);
54 this.directionalLight.setColor(color);
55 }
56
57 /***
58 * Returns the number of objects instatiated so far.
59 */
60 public static int getInstanceCounter(){
61 return instanceCounter;
62 }
63
64
65 public void setJ3DLight(javax.media.j3d.Light light){
66 if (light instanceof DirectionalLight){
67 DirectionalLight d = (DirectionalLight)light;
68 pivotTG.removeChild(directionalLight);
69 directionalLight = d;
70 pivotTG.addChild(directionalLight);
71 }
72 }
73
74 }
This page was automatically generated by Maven