/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.geometry;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.geometry;
/**
* Calculate length of vector.
+ *
* @return length of vector.
*/
public double getVectorLength() {
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.geometry;
/**
* Add coordinates of current point to other point. Value of current point will not be changed.
+ *
* @return current point.
*/
- public Point3D addTo(final Point3D ... otherPoints) {
+ public Point3D addTo(final Point3D... otherPoints) {
for (final Point3D otherPoint : otherPoints) otherPoint.add(this);
return this;
}
* <p>
* See also: <a href="https://marctenbosch.com/quaternions/">Let's remove Quaternions from every 3D Engine</a>
*
- * @param center center point.
+ * @param center center point.
* @param angleXZ angle around XZ axis.
* @param angleYZ angle around YZ axis.
*/
public Point3D rotate(final Point3D center, final double angleXZ,
- final double angleYZ) {
+ final double angleYZ) {
final double s1 = sin(angleXZ);
final double c1 = cos(angleXZ);
/**
* Set current point coordinates to given values.
+ *
* @param x X coordinate.
* @param y Y coordinate.
* @param z Z coordinate.
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.geometry;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.geometry;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
import eu.svjatoslav.sixth.e3d.geometry.Box;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
-import eu.svjatoslav.sixth.e3d.gui.humaninput.MouseInteractionController;
-import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardInputHandler;
import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardHelper;
+import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardInputHandler;
+import eu.svjatoslav.sixth.e3d.gui.humaninput.MouseInteractionController;
import eu.svjatoslav.sixth.e3d.math.Transform;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
* UI component that mouse is currently hovering over.
*/
private MouseInteractionController objectPreviouslyUnderMouseCursor;
-
- public void prepareForNewFrameRendering(){
- mouseEvent = null;
- currentObjectUnderMouseCursor = null;
- }
-
/**
* Mouse click event that needs to be processed.
* This event is processed only once per frame.
* This field is set to null after the event is processed.
*/
private MouseEvent mouseEvent;
-
- public void setMouseEvent(MouseEvent mouseEvent) {
- this.mouseEvent = mouseEvent;
- }
-
- public MouseEvent getMouseEvent() {
- return mouseEvent;
- }
-
/**
* UI component that mouse is currently hovering over.
*/
private MouseInteractionController currentObjectUnderMouseCursor;
- /**
- * Called when given object was detected under mouse cursor, while processing {@link #mouseEvent}.
- * Because objects are rendered back to front. The last method caller will set the top-most object, if
- * there are multiple objects under mouse cursor.
- */
- public void setCurrentObjectUnderMouseCursor(MouseInteractionController currentObjectUnderMouseCursor) {
- this.currentObjectUnderMouseCursor = currentObjectUnderMouseCursor;
- }
-
public RenderingContext(final int width, final int height) {
this.width = width;
this.height = height;
graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
+ public void prepareForNewFrameRendering() {
+ mouseEvent = null;
+ currentObjectUnderMouseCursor = null;
+ }
+
+ public MouseEvent getMouseEvent() {
+ return mouseEvent;
+ }
+
+ public void setMouseEvent(MouseEvent mouseEvent) {
+ this.mouseEvent = mouseEvent;
+ }
+
+ /**
+ * Called when given object was detected under mouse cursor, while processing {@link #mouseEvent}.
+ * Because objects are rendered back to front. The last method caller will set the top-most object, if
+ * there are multiple objects under mouse cursor.
+ */
+ public void setCurrentObjectUnderMouseCursor(MouseInteractionController currentObjectUnderMouseCursor) {
+ this.currentObjectUnderMouseCursor = currentObjectUnderMouseCursor;
+ }
+
/**
* @return <code>true</code> if view update is needed as a consequence of this mouse event.
*/
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
/**
* Checks if this pointer is between the specified pointers.
*
- * @param start
- * The start pointer.
- * @param end
- * The end pointer.
+ * @param start The start pointer.
+ * @param end The end pointer.
* @return True if this pointer is between the specified pointers.
*/
public boolean isBetween(final TextPointer start, final TextPointer end) {
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
*/
public class ViewPanel extends JPanel implements ComponentListener {
private static final long serialVersionUID = 1683277888885045387L;
- public Color backgroundColor = Color.BLACK;
private final HIDInputTracker HIDInputTracker = new HIDInputTracker(this);
private final KeyboardFocusStack keyboardFocusStack;
private final Avatar avatar = new Avatar();
private final ShapeCollection rootShapeCollection = new ShapeCollection();
private final Set<ViewRenderListener> viewRenderListeners = ConcurrentHashMap.newKeySet();
+ public Color backgroundColor = Color.BLACK;
/**
* Last time this view was updated.
*/
int panelWidth = getWidth();
int panelHeight = getHeight();
- if (panelWidth <= 0 || panelHeight <=0){
+ if (panelWidth <= 0 || panelHeight <= 0) {
renderingContext = null;
return;
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui;
private final Map<Integer, Long> pressedKeysToPressedTimeMap = new HashMap<>();
private final List<MouseEvent> detectedMouseEvents = new ArrayList<>();
private final List<KeyEvent> detectedKeyEvents = new ArrayList<>();
- private int wheelMovedDirection = 0;
private final Point2D mouseDraggedDirection = new Point2D();
- private Point2D oldMouseCoordinatesWhenDragging;
private final ViewPanel viewPanel;
+ private int wheelMovedDirection = 0;
+ private Point2D oldMouseCoordinatesWhenDragging;
private Point2D currentMouseLocation;
private boolean mouseMoved;
private boolean mouseWithinWindow = false;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.humaninput;
public class KeyboardFocusStack {
private final ViewPanel viewPanel;
- private WorldNavigationUserInputTracker defaultInputHandler = new WorldNavigationUserInputTracker();
- private Stack<KeyboardInputHandler> inputHandlers = new Stack<>();
+ private final WorldNavigationUserInputTracker defaultInputHandler = new WorldNavigationUserInputTracker();
+ private final Stack<KeyboardInputHandler> inputHandlers = new Stack<>();
private KeyboardInputHandler currentUserInputHandler;
public KeyboardFocusStack(final ViewPanel viewPanel) {
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.humaninput;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.humaninput;
/**
* This is the process:
- *
+ * <p>
* 1. Component receives focus, perhaps because user clicked on it with the mouse.
* 2. Now component will receive user key press and release events from the keyboard.
* 3. Component loses focus. Perhaps user chose another component to interact with.
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.humaninput;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.humaninput;
/**
* Called when mouse is clicked on component.
+ *
* @return <code>true</code> if view update is needed as a consequence of this mouse click.
*/
boolean mouseClicked(int button);
/**
* Called when mouse gets over given component.
+ *
* @return <code>true</code> if view update is needed as a consequence of this mouse enter.
*/
boolean mouseEntered();
/**
* Called when mouse leaves screen area occupied by component.
+ *
* @return <code>true</code> if view update is needed as a consequence of this mouse exit.
*/
boolean mouseExited();
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.humaninput;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
/**
* Returns the specified line.
*
- * @param row
- * The line number.
+ * @param row The line number.
* @return The line.
*/
public TextLine getLine(final int row) {
/**
* Returns the length of the specified line.
*
- * @param row
- * The line number.
+ * @param row The line number.
* @return The length of the line.
*/
public int getLineLength(final int row) {
/**
* Removes the specified character from the page.
*
- * @param row
- * The line number.
- * @param col
- * The character number.
+ * @param row The line number.
+ * @param col The character number.
*/
public void removeCharacter(final int row, final int col) {
if (rows.size() <= row)
/**
* Removes the specified line from the page.
*
- * @param row
- * The line number.
+ * @param row The line number.
*/
public void removeLine(final int row) {
if (rows.size() <= row)
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
if (keyCode == KeyboardHelper.PGUP) {
cursorLocation.row -= textCanvas.getSize().row;
repaintPage = true;
- return;
}
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.io;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.math;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.math;
/**
* Creates a new transform with the specified translation.
*
- * @param translation
- * the translation
+ * @param translation the translation
*/
public Transform(final Point3D translation) {
this.translation = translation;
/**
* Creates a new transform with the specified translation and orientation.
*
- * @param translation
- * the translation
- * @param angleXZ
- * the angle around the XZ axis
- * @param angleYZ
- * the angle around the YZ axis
+ * @param translation the translation
+ * @param angleXZ the angle around the XZ axis
+ * @param angleYZ the angle around the YZ axis
*/
public Transform(final Point3D translation, final double angleXZ,
final double angleYZ) {
/**
* Creates a new transform with the specified translation and orientation.
*
- * @param translation
- * the translation
- * @param orientation
- * the orientation
+ * @param translation the translation
+ * @param orientation the orientation
*/
public Transform(final Point3D translation, final Orientation orientation) {
this.translation = translation;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.math;
* Transforms vertex coordinate to calculate its location relative to the viewer.
* It also calculates its location on the screen.
*
- * @param transforms Transforms pipeline.
+ * @param transforms Transforms pipeline.
* @param renderContext Rendering context.
*/
public void calculateLocationRelativeToViewer(final TransformsStack transforms,
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.Ray;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
-import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
/**
* <pre>
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*
-*
+ *
* Realtime voxel renderer (in software).
* Uses octree for data compression.
*/
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
// compute camera view coordinates as if camera is at (0,0,0) and look at (0,0,1)
final float viewAngle = (float) .6;
cameraCenter = new Point3D();
- topLeft = new Point3D(0,0, SIZE).rotate(-viewAngle, -viewAngle);
- topRight = new Point3D(0,0, SIZE).rotate(viewAngle, -viewAngle);
- bottomLeft = new Point3D(0,0,SIZE).rotate(-viewAngle, viewAngle);
- bottomRight = new Point3D(0,0,SIZE).rotate(viewAngle, viewAngle);
+ topLeft = new Point3D(0, 0, SIZE).rotate(-viewAngle, -viewAngle);
+ topRight = new Point3D(0, 0, SIZE).rotate(viewAngle, -viewAngle);
+ bottomLeft = new Point3D(0, 0, SIZE).rotate(-viewAngle, viewAngle);
+ bottomRight = new Point3D(0, 0, SIZE).rotate(viewAngle, viewAngle);
topLeft.rotate(-avatar.getAngleXZ(), -avatar.getAngleYZ());
topRight.rotate(-avatar.getAngleXZ(), -avatar.getAngleYZ());
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
*/
public class LightSource {
- /**
- * Light source location.
- */
- Point3D location;
-
/**
* Light source color.
*/
public Color color;
-
/**
* Light source brightness.
*/
public float brightness;
+ /**
+ * Light source location.
+ */
+ Point3D location;
public LightSource(final Point3D location, final Color color,
final float Brightness) {
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
cameraView.cameraCenter.y,
cameraView.cameraCenter.z),
new Point3D(
- cx3 - cameraView.cameraCenter.x, cy3
- - cameraView.cameraCenter.y, cz3
- - cameraView.cameraCenter.z)
+ cx3 - cameraView.cameraCenter.x, cy3
+ - cameraView.cameraCenter.y, cz3
+ - cameraView.cameraCenter.z)
);
final int c = traceRay(r);
final Ray r1 = new Ray(
new Point3D(
- ray.hitCellX,
- ray.hitCellY - (float) 1.5,
- ray.hitCellZ),
+ ray.hitCellX,
+ ray.hitCellY - (float) 1.5,
+ ray.hitCellZ),
new Point3D((float) l.location.x - (float) ray.hitCellX, l.location.y
- - (ray.hitCellY - (float) 1.5), (float) l.location.z
- - (float) ray.hitCellZ)
+ - (ray.hitCellY - (float) 1.5), (float) l.location.z
+ - (float) ray.hitCellZ)
);
final int rt1 = octreeVolume.traceCell(0, 0, 0,
final Ray r2 = new Ray(
new Point3D(
- ray.hitCellX - (float) 1.5,
- ray.hitCellY, ray.hitCellZ),
+ ray.hitCellX - (float) 1.5,
+ ray.hitCellY, ray.hitCellZ),
new Point3D(
- l.location.x - (ray.hitCellX - (float) 1.5), (float) l.location.y
- - (float) ray.hitCellY, (float) l.location.z
- - (float) ray.hitCellZ)
+ l.location.x - (ray.hitCellX - (float) 1.5), (float) l.location.y
+ - (float) ray.hitCellY, (float) l.location.z
+ - (float) ray.hitCellZ)
);
final int rt2 = octreeVolume.traceCell(0, 0, 0,
}
final Ray r3 = new Ray(
- new Point3D (
- ray.hitCellX, ray.hitCellY,
- ray.hitCellZ - (float) 1.5),
new Point3D(
- (float) l.location.x - (float) ray.hitCellX, (float) l.location.y
- - (float) ray.hitCellY, l.location.z
- - (ray.hitCellZ - (float) 1.5))
+ ray.hitCellX, ray.hitCellY,
+ ray.hitCellZ - (float) 1.5),
+ new Point3D(
+ (float) l.location.x - (float) ray.hitCellX, (float) l.location.y
+ - (float) ray.hitCellY, l.location.z
+ - (ray.hitCellZ - (float) 1.5))
);
final int rt3 = octreeVolume.traceCell(0, 0, 0,
final Ray r4 = new Ray(
new Point3D(
- ray.hitCellX,
- ray.hitCellY+ (float) 1.5,
- ray.hitCellZ),
+ ray.hitCellX,
+ ray.hitCellY + (float) 1.5,
+ ray.hitCellZ),
new Point3D(
- (float) l.location.x - (float) ray.hitCellX, l.location.y
- - (ray.hitCellY + (float) 1.5), (float) l.location.z
- - (float) ray.hitCellZ)
+ (float) l.location.x - (float) ray.hitCellX, l.location.y
+ - (ray.hitCellY + (float) 1.5), (float) l.location.z
+ - (float) ray.hitCellZ)
);
final int rt4 = octreeVolume.traceCell(0, 0, 0,
final Ray r5 = new Ray(
new Point3D(
- ray.hitCellX + (float) 1.5,
- ray.hitCellY, ray.hitCellZ),
+ ray.hitCellX + (float) 1.5,
+ ray.hitCellY, ray.hitCellZ),
new Point3D(
- l.location.x - (ray.hitCellX + (float) 1.5), (float) l.location.y
- - (float) ray.hitCellY, (float) l.location.z
- - (float) ray.hitCellZ)
- );
+ l.location.x - (ray.hitCellX + (float) 1.5), (float) l.location.y
+ - (float) ray.hitCellY, (float) l.location.z
+ - (float) ray.hitCellZ)
+ );
final int rt5 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r5);
final Ray r6 = new Ray(
new Point3D(
- ray.hitCellX, ray.hitCellY,
- ray.hitCellZ + (float) 1.5),
+ ray.hitCellX, ray.hitCellY,
+ ray.hitCellZ + (float) 1.5),
new Point3D(
- (float) l.location.x - (float) ray.hitCellX, (float) l.location.y
- - (float) ray.hitCellY, l.location.z
- - (ray.hitCellZ + (float) 1.5)));
+ (float) l.location.x - (float) ray.hitCellX, (float) l.location.y
+ - (float) ray.hitCellY, l.location.z
+ - (ray.hitCellZ + (float) 1.5)));
final int rt6 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r6);
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*
-*
+ *
* Raytracer through voxel data that is stored in octree.
*/
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*
* Various 3D renderers utilizing different rendering approaches.
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster;
public class RenderAggregator {
- private ArrayList<AbstractCoordinateShape> shapes = new ArrayList<>();
- private ShapesZIndexComparator comparator = new ShapesZIndexComparator();
+ private final ArrayList<AbstractCoordinateShape> shapes = new ArrayList<>();
+ private final ShapesZIndexComparator comparator = new ShapesZIndexComparator();
public void paint(final RenderingContext renderBuffer) {
shapes.sort(comparator);
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*
-*
+ *
* <pre>
* Realtime renderer (in software) using traditional approaches:
* Wireframe
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes;
/**
* Scale of the texture object.
- *
+ * <p>
* Object rendered visible size on the screen depends on underlying texture size and scale.
- *
+ * <p>
* 0 means that object will be infinitely small.
* 1 in recommended value to maintain sharpness of the texture as seen by the viewer.
*/
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic;
for (int y = 0; y < TEXTURE_RESOLUTION_PIXELS; y++) {
int address = texture.primaryBitmap.getAddress(x, y);
- final int distanceFromCenter = (int) sqrt(pow (halfResolution - x, 2) + pow (halfResolution - y, 2));
+ final int distanceFromCenter = (int) sqrt(pow(halfResolution - x, 2) + pow(halfResolution - y, 2));
int alpha = 255 - ((270 * distanceFromCenter) / halfResolution);
if (alpha < 0)
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line;
if (y1 < y2) {
if (y >= y1)
- if (y <= y2)
- return true;
+ return y <= y2;
} else if (y >= y2)
- if (y <= y1)
- return true;
+ return y <= y1;
return false;
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon;
if (p1.y <= p2.y) {
if (y >= p1.y)
- if (y <= p2.y)
- return true;
+ return y <= p2.y;
} else if (y >= p2.y)
- if (y <= p1.y)
- return true;
+ return y <= p1.y;
return false;
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon;
if (p1.y < p2.y) {
if (y >= p1.y)
- if (y <= p2.y)
- return true;
+ return y <= p2.y;
} else if (y >= p2.y)
- if (y <= p1.y)
- return true;
+ return y <= p1.y;
return false;
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base;
public List<SubShape> getGroup(final String groupIdentifier) {
return originalSubShapes.stream().filter(
- subShape -> subShape.matchesGroup(groupIdentifier))
+ subShape -> subShape.matchesGroup(groupIdentifier))
.collect(Collectors.toList());
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.solid;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.solid;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
public static final int FONT_CHAR_HEIGHT_TEXTURE_PIXELS = 32;
- public static final Font FONT = CanvasCharacter.getFont((int)(FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.066));
+ public static final Font FONT = CanvasCharacter.getFont((int) (FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.066));
private static final String GROUP_TEXTURE = "texture";
private static final String GROUP_CHARACTERS = "characters";
private final TextPointer size;
graphics.setColor(foreground.toAwtColor());
graphics.drawChars(
new char[]{character,}, 0, 1,
- (column * FONT_CHAR_WIDTH_TEXTURE_PIXELS) - 0,
- (row * FONT_CHAR_HEIGHT_TEXTURE_PIXELS) + (int)(FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.23f));
+ (column * FONT_CHAR_WIDTH_TEXTURE_PIXELS),
+ (row * FONT_CHAR_HEIGHT_TEXTURE_PIXELS) + (int) (FONT_CHAR_HEIGHT_TEXTURE_PIXELS / 1.23f));
getTexture().resetResampledBitmapCache();
}
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
public class Grid2D extends AbstractCompositeShape {
/**
- * @param transform Grid location
- * @param rectangle Grid dimensions
+ * @param transform Grid location
+ * @param rectangle Grid dimensions
* @param xDivisionCount Division count along X axis
* @param yDivisionCount Division count along Y axis
- * @param appearance Grid lines appearance
+ * @param appearance Grid lines appearance
*/
public Grid2D(final Transform transform, final Rectangle rectangle,
final int xDivisionCount, final int yDivisionCount,
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.slicer;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.slicer;
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.slicer;
final PolygonCoordinate c2, final PolygonCoordinate c3,
final TexturedPolygon originalPolygon) {
- final BorderLine lines[] = new BorderLine[]{
+ final BorderLine[] lines = new BorderLine[]{
new BorderLine(c1, c2, 1), new BorderLine(c2, c3, 2),
new BorderLine(c3, c1, 3)};
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.texture;
/**
* Returns the bitmap that should be used for rendering at the given zoom
+ *
* @param scaleFactor The upscale factor
* @return The bitmap
*/
/**
* Returns the bitmap that should be used for rendering at the given zoom
+ *
* @param zoomLevel The zoom level
* @return The bitmap
*/
/**
* Upscales the given bitmap by a factor of 2
+ *
* @param originalBitmap The bitmap to upscale
* @return The upscaled bitmap
*/
/**
* Accumulates the color values of the given pixel
+ *
* @param bitmap The bitmap
- * @param x The x coordinate of the pixel
- * @param y The y coordinate of the pixel
+ * @param x The x coordinate of the pixel
+ * @param y The y coordinate of the pixel
*/
public void accumulate(final TextureBitmap bitmap, final int x,
final int y) {
/**
* Stores the accumulated color values in the given bitmap
+ *
* @param bitmap The bitmap
- * @param x The x coordinate of the pixel
- * @param y The y coordinate of the pixel
+ * @param x The x coordinate of the pixel
+ * @param y The y coordinate of the pixel
*/
public void storeResult(final TextureBitmap bitmap, final int x,
final int y) {
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.texture;
* Transfer (render) one pixel from current {@link TextureBitmap} to target raster bitmap.
*
* @param sourceBitmapPixelAddress Pixel address within current {@link TextureBitmap} as indicated by its offset.
- * @param targetBitmap Bitmap of the target image where pixel should be rendered to.
+ * @param targetBitmap Bitmap of the target image where pixel should be rendered to.
* @param targetBitmapPixelAddress Pixel location within target image where pixel should be rendered to.
*/
public void drawPixel(int sourceBitmapPixelAddress,