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 * Title: Câmera Virtual - LIVES
23 * Description: Câmera Virtual para Controle via LabVIEW
24 * Copyright: Copyright (c) 2001
25 * Company: Centro de Educação em Informática - SENAC - SP
26 */
27 import javax.vecmath.*;
28 import javax.media.j3d.*;
29
30 /***
31 * Represents a spot light.
32 * @author Fábio Roberto de Miranda
33 * @version 1.0
34 */
35 public class VcSpotLight extends VcPointLight {
36
37 private static int instanceCounter = 0;
38 SpotLight spotLight;
39
40 //TransformGroup avatarTG;
41
42 public VcSpotLight() {
43 spotLight = new SpotLight();
44 spotLight.setCapability(SpotLight.ALLOW_ATTENUATION_READ);
45 spotLight.setCapability(SpotLight.ALLOW_ATTENUATION_WRITE);
46 spotLight.setCapability(SpotLight.ALLOW_CONCENTRATION_READ);
47 spotLight.setCapability(SpotLight.ALLOW_CONCENTRATION_WRITE);
48 spotLight.setCapability(SpotLight.ALLOW_SPREAD_ANGLE_READ);
49 spotLight.setCapability(SpotLight.ALLOW_SPREAD_ANGLE_WRITE);
50
51 this.pointLight = spotLight;
52 // removes pointLight avatar which had been added during call to super()
53 this.pivotTG.removeChild(avatar);
54 // gets correct avatar
55 avatar = AvatarManager.getAvatarManager().getSpotLightAvatarShape();
56
57 this.pivotTG.addChild(avatar);
58 this.pivotTG.addChild(spotLight);
59 this.color = new Color3f();
60 this.setLabel("SpotLight"+this.instanceCounter++);
61 }
62
63 /***
64 * Returns the number of objects instatiated so far.
65 */
66 public static int getInstanceCounter(){
67 return instanceCounter;
68 }
69
70 public void setConcentration(double concentration){
71 this.spotLight.setConcentration((float)concentration);
72 }
73
74 public double getConcentration(){
75 return (double)this.spotLight.getConcentration();
76 }
77
78 public void setSpreadAngle(double angle){
79 this.spotLight.setSpreadAngle((float)angle);
80 }
81
82 public double getSpreadAngle(){
83 return this.spotLight.getSpreadAngle();
84 }
85
86 public Point3f getAttenuation(){
87 Point3f tempP3f = new Point3f();
88 spotLight.getAttenuation(tempP3f);
89 return tempP3f;
90 }
91
92 public double getConstantAttenuation(){
93 spotLight.getAttenuation(tempP3f);
94 return (double)tempP3f.x;
95 }
96
97 public double getLinearAttenuation(){
98 spotLight.getAttenuation(tempP3f);
99 return (double)tempP3f.y;
100 }
101
102 public double getQuadraticAttenuation(){
103 spotLight.getAttenuation(tempP3f);
104 return (double)tempP3f.z;
105 }
106
107 public Light getJ3DLight(){
108 return this.spotLight;
109 }
110
111 public void setEnable(boolean b){
112 this.spotLight.setEnable(b);
113 }
114
115 public void setColor(float r, float g, float b){
116 this.color.set(r,g,b);
117 this.spotLight.setColor(color);
118 }
119
120 public void setJ3DLight(Light light){
121 if (light instanceof SpotLight){
122 SpotLight s = (SpotLight)light;
123
124 }
125 }
126
127 }
This page was automatically generated by Maven