projects
/
sixth-3d.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
99cc272
)
Improved code readability
author
Svjatoslav Agejenko
<svjatoslav@svjatoslav.eu>
Sat, 20 May 2023 23:32:17 +0000
(
02:32
+0300)
committer
Svjatoslav Agejenko
<svjatoslav@svjatoslav.eu>
Sat, 20 May 2023 23:32:17 +0000
(
02:32
+0300)
src/main/java/eu/svjatoslav/sixth/e3d/gui/TextPointer.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/sixth/e3d/math/package-info.java
[new file with mode: 0644]
patch
|
blob
src/main/java/eu/svjatoslav/sixth/e3d/renderer/package-info.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/RenderMode.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/package-info.java
[new file with mode: 0644]
patch
|
blob
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/gui/TextPointer.java
b/src/main/java/eu/svjatoslav/sixth/e3d/gui/TextPointer.java
index
701ec50
..
67291f5
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/gui/TextPointer.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/gui/TextPointer.java
@@
-5,11
+5,21
@@
package eu.svjatoslav.sixth.e3d.gui;
/**
package eu.svjatoslav.sixth.e3d.gui;
/**
- * A pointer to a character in a text.
+ * A pointer to a character in a text using row and column.
+ * <p>
+ * It can be used to represent a cursor position in a text.
+ * Also, it can be used to represent beginning and end of a selection.
*/
public class TextPointer implements Comparable<TextPointer> {
*/
public class TextPointer implements Comparable<TextPointer> {
+ /**
+ * The row of the character. Starts from 0.
+ */
public int row;
public int row;
+
+ /**
+ * The column of the character. Starts from 0.
+ */
public int column;
public TextPointer() {
public int column;
public TextPointer() {
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java
b/src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java
index
9cc6dcd
..
f4b2851
100644
(file)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/math/Orientation.java
@@
-6,12
+6,22
@@
package eu.svjatoslav.sixth.e3d.math;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import static java.lang.Math.cos;
+import static java.lang.Math.sin;
+
/**
/**
- * Used to represent transformation in a 3D space.
+ * Used to represent orientation in a 3D space.
+ *
+ * Orientations are represented as two angles of rotation around the XZ and YZ axes.
+ * The angles are stored as sines and cosines to avoid unnecessary trigonometric calculations.
+ *
+ * Orientations are used for rotating object coordinates in a 3D space.
*/
public class Orientation implements Cloneable {
*/
public class Orientation implements Cloneable {
-
+ /**
+ * The sine and cosine of the angles.
+ */
private double s1, c1, s2, c2;
/**
private double s1, c1, s2, c2;
/**
@@
-28,6
+38,11
@@
public class Orientation implements Cloneable {
computeMultipliers();
}
computeMultipliers();
}
+ /**
+ * Creates a new orientation with the specified angles.
+ * @param angleXZ The angle of rotation around the XZ axis.
+ * @param angleYZ The angle of rotation around the YZ axis.
+ */
public Orientation(final double angleXZ, final double angleYZ) {
this.angleXZ = angleXZ;
this.angleYZ = angleYZ;
public Orientation(final double angleXZ, final double angleYZ) {
this.angleXZ = angleXZ;
this.angleYZ = angleYZ;
@@
-43,21
+58,30
@@
public class Orientation implements Cloneable {
* Computes the sine and cosine of the angles.
*/
private void computeMultipliers() {
* Computes the sine and cosine of the angles.
*/
private void computeMultipliers() {
- s1 =
Math.
sin(angleXZ);
- c1 =
Math.
cos(angleXZ);
+ s1 = sin(angleXZ);
+ c1 = cos(angleXZ);
- s2 =
Math.
sin(angleYZ);
- c2 =
Math.
cos(angleYZ);
+ s2 = sin(angleYZ);
+ c2 = cos(angleYZ);
}
}
+ /**
+ * Rotates the specified point around the XZ and YZ axes relative to the origin.
+ * @param point3d The point to rotate.
+ */
public void rotate(final Point3D point3d) {
public void rotate(final Point3D point3d) {
+ // Rotate around the XZ axis.
final double z1 = (point3d.z * c1) - (point3d.x * s1);
point3d.x = (point3d.z * s1) + (point3d.x * c1);
final double z1 = (point3d.z * c1) - (point3d.x * s1);
point3d.x = (point3d.z * s1) + (point3d.x * c1);
+ // Rotate around the YZ axis.
point3d.z = (z1 * c2) - (point3d.y * s2);
point3d.y = (z1 * s2) + (point3d.y * c2);
}
point3d.z = (z1 * c2) - (point3d.y * s2);
point3d.y = (z1 * s2) + (point3d.y * c2);
}
+ /**
+ * Rotates current orientation around the XZ and YZ axes.
+ */
public void rotate(final double angleXZ, final double angleYZ) {
this.angleXZ += angleXZ;
this.angleYZ += angleYZ;
public void rotate(final double angleXZ, final double angleYZ) {
this.angleXZ += angleXZ;
this.angleYZ += angleYZ;
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java
b/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java
index
85a2dda
..
90015b7
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java
@@
-8,11
+8,18
@@
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
/**
* Used to represent transformation in a 3D space.
/**
* Used to represent transformation in a 3D space.
- * Transformations are represented as a translation and an
orientation
.
+ * Transformations are represented as a translation and an
{@link Orientation}
.
*/
public class Transform implements Cloneable {
*/
public class Transform implements Cloneable {
+ /**
+ * The translation is applied after the orientation.
+ */
private final Point3D translation;
private final Point3D translation;
+
+ /**
+ * The orientation is applied before the translation.
+ */
private final Orientation orientation;
public Transform() {
private final Orientation orientation;
public Transform() {
@@
-68,6
+75,11
@@
public class Transform implements Cloneable {
return translation;
}
return translation;
}
+ /**
+ * Applies this transform to the specified point in a 3D space.
+ *
+ * @param point to apply this transform to
+ */
public void transform(final Point3D point) {
orientation.rotate(point);
point.add(translation);
public void transform(final Point3D point) {
orientation.rotate(point);
point.add(translation);
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/math/package-info.java
b/src/main/java/eu/svjatoslav/sixth/e3d/math/package-info.java
new file mode 100644
(file)
index 0000000..
98dfff8
--- /dev/null
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/math/package-info.java
@@ -0,0
+1,9
@@
+/**
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ * <p>
+ * Math that is needed for the project.
+ */
+
+package eu.svjatoslav.sixth.e3d.math;
+
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/package-info.java
b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/package-info.java
index
4de6f25
..
249622e
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/package-info.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/package-info.java
@@
-1,6
+1,7
@@
-/*
+/*
*
* Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
* Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
+ * <p>
*
* Various 3D renderers utilizing different rendering approaches.
*
*
* Various 3D renderers utilizing different rendering approaches.
*
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/RenderMode.java
b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/RenderMode.java
index
ebc0f86
..
0379ab5
100644
(file)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/RenderMode.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/RenderMode.java
@@
-5,6
+5,13
@@
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
public enum RenderMode {
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
public enum RenderMode {
- TEXTURE, // Text is rendered on textured polygon
- CHARACTERS // Text is rendered as high quality, anti-aliazed tiles
+ /**
+ * Text is rendered as a textured polygon.
+ */
+ TEXTURE,
+
+ /**
+ * Text is rendered as high quality, anti-aliazed tiles.
+ */
+ CHARACTERS
}
}
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java
b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java
index
854d756
..
f77f71e
100644
(file)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java
@@
-22,12
+22,24
@@
import static eu.svjatoslav.sixth.e3d.renderer.raster.Color.WHITE;
public class TextCanvas extends TexturedRectangle {
public class TextCanvas extends TexturedRectangle {
- // character size in world coordinates
+ /**
+ * Font character width in world coordinates.
+ */
public static final int FONT_CHAR_WIDTH = 8;
public static final int FONT_CHAR_WIDTH = 8;
+
+ /**
+ * Font character height in world coordinates.
+ */
public static final int FONT_CHAR_HEIGHT = 16;
public static final int FONT_CHAR_HEIGHT = 16;
- // character size on texture
+ /**
+ * Font character width in texture pixels.
+ */
public static final int FONT_CHAR_WIDTH_TEXTURE_PIXELS = 16;
public static final int FONT_CHAR_WIDTH_TEXTURE_PIXELS = 16;
+
+ /**
+ * Font character height in texture pixels.
+ */
public static final int FONT_CHAR_HEIGHT_TEXTURE_PIXELS = 32;
public static final int FONT_CHAR_HEIGHT_TEXTURE_PIXELS = 32;
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/package-info.java
b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/package-info.java
new file mode 100644
(file)
index 0000000..
3d5e87e
--- /dev/null
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/package-info.java
@@ -0,0
+1,9
@@
+/**
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ * <p>
+ *
+ * Text canvas is a canvas that can be used to render text.
+ */
+
+package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
\ No newline at end of file