Skip to content

Commit 1244723

Browse files
authored
Merge pull request jMonkeyEngine#2473 from capdevon/capdevon-Light-toString
Consistent toString() for Lights
2 parents e99a63b + d855401 commit 1244723

File tree

5 files changed

+62
-26
lines changed

5 files changed

+62
-26
lines changed

jme3-core/src/main/java/com/jme3/light/AmbientLight.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2012, 2015 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -83,4 +83,13 @@ public Type getType() {
8383
return Type.Ambient;
8484
}
8585

86+
@Override
87+
public String toString() {
88+
return getClass().getSimpleName()
89+
+ "[name=" + name
90+
+ ", color=" + color
91+
+ ", enabled=" + enabled
92+
+ "]";
93+
}
94+
8695
}

jme3-core/src/main/java/com/jme3/light/DirectionalLight.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2012, 2015-2016 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -132,11 +132,6 @@ public Type getType() {
132132
return Type.Directional;
133133
}
134134

135-
@Override
136-
public String toString() {
137-
return getClass().getSimpleName() + "[name=" + name + ", direction=" + direction + ", color=" + color + ", enabled=" + enabled + "]";
138-
}
139-
140135
@Override
141136
public void write(JmeExporter ex) throws IOException {
142137
super.write(ex);
@@ -157,4 +152,14 @@ public DirectionalLight clone() {
157152
l.direction = direction.clone();
158153
return l;
159154
}
155+
156+
@Override
157+
public String toString() {
158+
return getClass().getSimpleName()
159+
+ "[name=" + name
160+
+ ", direction=" + direction
161+
+ ", color=" + color
162+
+ ", enabled=" + enabled
163+
+ "]";
164+
}
160165
}

jme3-core/src/main/java/com/jme3/light/LightProbe.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@
4848
/**
4949
* A LightProbe is not exactly a light. It holds environment map information used for Image Based Lighting.
5050
* This is used for indirect lighting in the Physically Based Rendering pipeline.
51-
*
51+
* <p>
5252
* A light probe has a position in world space. This is the position from where the Environment Map are rendered.
5353
* There are two environment data structure held by the LightProbe :
5454
* - The irradiance spherical harmonics factors (used for indirect diffuse lighting in the PBR pipeline).
@@ -57,9 +57,9 @@
5757
* To compute them see
5858
* {@link com.jme3.environment.LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial)}
5959
* and {@link EnvironmentCamera}.
60-
*
60+
* <p>
6161
* The light probe has an area of effect centered on its position. It can have a Spherical area or an Oriented Box area
62-
*
62+
* <p>
6363
* A LightProbe will only be taken into account when it's marked as ready and enabled.
6464
* A light probe is ready when it has valid environment map data set.
6565
* Note that you should never call setReady yourself.
@@ -71,7 +71,8 @@
7171
public class LightProbe extends Light implements Savable {
7272

7373
private static final Logger logger = Logger.getLogger(LightProbe.class.getName());
74-
public static final Matrix4f FALLBACK_MATRIX = new Matrix4f(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1);
74+
public static final Matrix4f FALLBACK_MATRIX = new Matrix4f(
75+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1);
7576

7677
private Vector3f[] shCoefficients;
7778
private TextureCubeMap prefilteredEnvMap;
@@ -149,16 +150,12 @@ public void setPrefilteredMap(TextureCubeMap prefilteredEnvMap) {
149150
* @return the pre-existing matrix
150151
*/
151152
public Matrix4f getUniformMatrix(){
152-
153153
Matrix4f mat = area.getUniformMatrix();
154-
155154
// setting the (sp) entry of the matrix
156155
mat.m33 = nbMipMaps + 1f / area.getRadius();
157-
158156
return mat;
159157
}
160158

161-
162159
@Override
163160
public void write(JmeExporter ex) throws IOException {
164161
super.write(ex);
@@ -180,7 +177,7 @@ public void read(JmeImporter im) throws IOException {
180177
position = (Vector3f) ic.readSavable("position", null);
181178
area = (ProbeArea)ic.readSavable("area", null);
182179
if(area == null) {
183-
// retro compat
180+
// retro compatibility
184181
BoundingSphere bounds = (BoundingSphere) ic.readSavable("bounds", new BoundingSphere(1.0f, Vector3f.ZERO));
185182
area = new SphereProbeArea(bounds.getCenter(), bounds.getRadius());
186183
}
@@ -200,7 +197,6 @@ public void read(JmeImporter im) throws IOException {
200197
}
201198
}
202199

203-
204200
/**
205201
* returns the bounding volume of this LightProbe
206202
* @return a bounding volume.
@@ -318,8 +314,12 @@ public Type getType() {
318314

319315
@Override
320316
public String toString() {
321-
return "Light Probe : " + name + " at " + position + " / " + area;
317+
return getClass().getSimpleName()
318+
+ "[name=" + name
319+
+ ", position=" + position
320+
+ ", area=" + area
321+
+ ", enabled=" + enabled
322+
+ "]";
322323
}
323324

324-
325325
}

jme3-core/src/main/java/com/jme3/light/PointLight.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2012, 2015-2016, 2018 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -247,4 +247,15 @@ public PointLight clone() {
247247
p.position = position.clone();
248248
return p;
249249
}
250+
251+
@Override
252+
public String toString() {
253+
return getClass().getSimpleName()
254+
+ "[name=" + name
255+
+ ", position=" + position
256+
+ ", radius=" + radius
257+
+ ", color=" + color
258+
+ ", enabled=" + enabled
259+
+ "]";
260+
}
250261
}

jme3-core/src/main/java/com/jme3/light/SpotLight.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -118,8 +118,7 @@ public SpotLight(Vector3f position, Vector3f direction, ColorRGBA color) {
118118
setPosition(position);
119119
setDirection(direction);
120120
}
121-
122-
121+
123122
/**
124123
* Creates a SpotLight at the given position, with the given direction,
125124
* the given range and the given color.
@@ -160,7 +159,6 @@ public SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA c
160159
setDirection(direction);
161160
setSpotRange(range);
162161
}
163-
164162

165163
private void computeAngleParameters() {
166164
float innerCos = FastMath.cos(spotInnerAngle);
@@ -458,5 +456,18 @@ public SpotLight clone() {
458456
s.position = position.clone();
459457
return s;
460458
}
461-
}
462459

460+
@Override
461+
public String toString() {
462+
return getClass().getSimpleName()
463+
+ "[name=" + name
464+
+ ", direction=" + direction
465+
+ ", position=" + position
466+
+ ", range=" + spotRange
467+
+ ", innerAngle=" + spotInnerAngle
468+
+ ", outerAngle=" + spotOuterAngle
469+
+ ", color=" + color
470+
+ ", enabled=" + enabled
471+
+ "]";
472+
}
473+
}

0 commit comments

Comments
 (0)