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
23 import javax.media.j3d.*;
24 import javax.vecmath.*;
25
26 /***
27 * Represents a point light.
28 *
29 * @author Fábio Roberto de Miranda
30 * @version 1.0
31 */
32 public class VcPointLight extends VcLight {
33
34 private static int instanceCounter = 0;
35 PointLight pointLight;
36 Point3f tempP3f = new Point3f();
37 Color3f tempColor3f = new Color3f();
38 Shape3D avatar;
39
40 public VcPointLight() {
41 avatar = AvatarManager.getAvatarManager().getPointLightAvatarShape();
42 pivotTG.addChild(avatar);
43 pointLight = new PointLight();
44 pivotTG.addChild(pointLight);
45 this.color = new Color3f();
46 this.setLabel("PointLight"+this.instanceCounter++);
47 }
48
49 /***
50 * Returns the number of objects instatiated so far.
51 */
52 public static int getInstanceCounter(){
53 return instanceCounter;
54 }
55
56 public Point3f getAttenuation(){
57 Point3f tempP3f = new Point3f();
58 pointLight.getAttenuation(tempP3f);
59 return tempP3f;
60 }
61
62 public void setAttenuation(Point3f p3f){
63 pointLight.setAttenuation(p3f);
64 }
65
66 public void setAttenuation(double constant, double linear, double quadratic){
67 tempP3f.x = (float) constant;
68 tempP3f.y = (float) linear;
69 tempP3f.z = (float) quadratic;
70 pointLight.setAttenuation(tempP3f);
71 }
72
73 public double getConstantAttenuation(){
74 pointLight.getAttenuation(tempP3f);
75 return (double)tempP3f.x;
76 }
77
78 public double getLinearAttenuation(){
79 pointLight.getAttenuation(tempP3f);
80 return (double)tempP3f.y;
81 }
82
83 public double getQuadraticAttenuation(){
84 pointLight.getAttenuation(tempP3f);
85 return (double)tempP3f.z;
86 }
87
88 public Light getJ3DLight(){
89 return this.pointLight;
90 }
91
92 public void setEnable(boolean b){
93 this.pointLight.setEnable(b);
94 }
95
96 public void setColor(float r, float g, float b){
97 this.color.set(r,g,b);
98 this.pointLight.setColor(color);
99 }
100
101 public void setJ3DLight(javax.media.j3d.Light light){
102 if (light instanceof PointLight){
103 pivotTG.removeChild(pointLight);
104 PointLight p = (PointLight) light;
105 pointLight = p;
106 pivotTG.addChild(p);
107 }
108 }
109 }
This page was automatically generated by Maven