private static final double scale = 50d;
- private static Graph getCosinusGraph(final Point3D location)
+ private static Graph getCosineGraph(final Point3D location)
throws IOException {
final List<Point2D> data = new ArrayList<>();
for (double x = 0; x < 20; x += 0.25) {
data.add(p);
}
- return new Graph(scale, data, "Cosinus", location);
+ return new Graph(scale, data, "Cosine", location);
}
private static Graph getFormula1Graph(final Point3D location)
return new Graph(scale, data, "y = sin(x/2) + sin(x/1.26)", location);
}
- private static Graph getSinusGraph(final Point3D location)
+ private static Graph getSineGraph(final Point3D location)
throws IOException {
final List<Point2D> data = new ArrayList<>();
for (double x = 0; x < 20; x += 0.25) {
data.add(p);
}
- return new Graph(scale, data, "Sinus", location);
+ return new Graph(scale, data, "Sine", location);
}
private static Graph getTangentGraph(final Point3D location)
final ViewFrame viewFrame = new ViewFrame();
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
- .getContext().getRootShapeCollection();
+ .getRootShapeCollection();
Point3D location = new Point3D(-600, -300, 0);
- geometryCollection.addShape(getSinusGraph(location));
+ geometryCollection.addShape(getSineGraph(location));
location = new Point3D(600, -300, 0);
geometryCollection.addShape(getFormula1Graph(location));
location = new Point3D(-600, 0, 0);
- geometryCollection.addShape(getCosinusGraph(location));
+ geometryCollection.addShape(getCosineGraph(location));
location = new Point3D(600, 0, 0);
geometryCollection.addShape(getFormula2Graph(location));
location = new Point3D(600, 300, 0);
geometryCollection.addShape(getFormula3Graph(location));
- viewFrame.getViewPanel().getContext().getAvatar()
+ viewFrame.getViewPanel().getAvatar()
.setLocation(new Point3D(0, 0, -500));
}
package eu.svjatoslav.sixth.e3d.examples;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
import eu.svjatoslav.sixth.e3d.math.Transform;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationTracker;
import eu.svjatoslav.sixth.e3d.renderer.octree.OctreeVolume;
private final Vector<LightSource> lights = new Vector<>();
private OctreeVolume octreeVolume;
private ShapeCollection shapeCollection;
- private ViewContext context;
+ private ViewPanel viewPanel;
public static void main(final String[] args) {
new OctreeDemo().init();
private void init() {
final ViewFrame viewFrame = new ViewFrame();
- context = viewFrame.getViewPanel().getContext();
+ viewPanel = viewFrame.getViewPanel();
- context.getAvatar().setLocation(new Point3D(0, -30, -300));
+ viewPanel.getAvatar().setLocation(new Point3D(0, -30, -300));
octreeVolume = new OctreeVolume();
- shapeCollection = context.getRootShapeCollection();
+ shapeCollection = viewPanel.getRootShapeCollection();
shapeCollection.addShape(new Grid3D(
new Point3D(-10000, -10000, -10000), new Point3D(10000, 10000,
Color.WHITE, Color.PURPLE);
shapeCollection.addShape(message);
- context.getKeyboardFocusTracker().setFocusOwner(this);
- context.getViewPanel().repaintDuringNextViewUpdate();
+ viewPanel.getKeyboardFocusTracker().setFocusOwner(this);
+ viewPanel.repaintDuringNextViewUpdate();
}
@Override
- public void keyPressed(final KeyEvent event, final ViewContext viewContext) {
+ public void keyPressed(final KeyEvent event, final ViewPanel viewPanel) {
if ('r' == event.getKeyChar()) {
raytrace();
return;
}
- super.keyPressed(event, viewContext);
+ super.keyPressed(event, viewPanel);
}
private void putPixel(final int x, final int y, final int z,
private void raytrace() {
// create and add camera object to scene
- final Camera camera = new Camera(context.getAvatar(), magnification);
+ final Camera camera = new Camera(viewPanel.getAvatar(), magnification);
shapeCollection.addShape(camera);
// initialize and start Raytracer in a separate thread
final RayTracer rayTracer = new RayTracer(camera.getTexture(),
- octreeVolume, lights, camera, context.getViewPanel());
+ octreeVolume, lights, camera, viewPanel);
final Thread thread = new Thread(rayTracer);
thread.start();
}
final ViewFrame viewFrame = new ViewFrame();
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
- .getContext().getRootShapeCollection();
+ .getRootShapeCollection();
Transform transform = new Transform(new Point3D(0, -1000, 1000), 0, 0);
package eu.svjatoslav.sixth.e3d.examples;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
import eu.svjatoslav.sixth.e3d.math.Transform;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
import eu.svjatoslav.sixth.e3d.gui.ViewRenderListener;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
}
@Override
- public boolean beforeRender(final ViewContext viewContext,
+ public boolean beforeRender(final ViewPanel viewPanel,
final int millisecondsSinceLastFrame) {
- final Collection<AbstractShape> shapes = viewContext
+ final Collection<AbstractShape> shapes = viewPanel
.getRootShapeCollection().getShapes();
final double translateAmount = millisecondsSinceLastFrame / 50d;
return true;
}
- private void run() throws IOException {
+ private void run() {
final ViewFrame viewFrame = new ViewFrame();
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
- .getContext().getRootShapeCollection();
+ .getRootShapeCollection();
Random random = new Random();
final ViewFrame viewFrame = new ViewFrame();
final ShapeCollection shapeCollection = viewFrame.getViewPanel()
- .getContext().getRootShapeCollection();
+ .getRootShapeCollection();
// add grid
final LineAppearance appearance = new LineAppearance(5, new Color(100,
package eu.svjatoslav.sixth.e3d.examples;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
public static void main(final String[] args) {
final ViewFrame viewFrame = new ViewFrame();
- final ViewContext context = viewFrame.getViewPanel().getContext();
+ final ViewPanel viewPanel = viewFrame.getViewPanel();
- final ShapeCollection geometryCollection = context
+ final ShapeCollection geometryCollection = viewPanel
.getRootShapeCollection();
final LineAppearance appearance = new LineAppearance(4, new Color(255,
makeWobblySurface(geometryCollection, 200);
makeWobblySurface(geometryCollection, -200);
- context.getAvatar().setLocation(new Point3D(0, 0, -340));
+ viewPanel.getAvatar().setLocation(new Point3D(0, 0, -340));
}
}
import eu.svjatoslav.sixth.e3d.geometry.Point2D;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
import eu.svjatoslav.sixth.e3d.math.Transform;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
public static void main(final String[] args) {
final ViewFrame viewFrame = new ViewFrame();
- final ViewContext viewContext = viewFrame.getViewPanel().getContext();
+ final ViewPanel viewPanel = viewFrame.getViewPanel();
final ShapeCollection shapeCollection = viewFrame.getViewPanel()
- .getContext().getRootShapeCollection();
+ .getRootShapeCollection();
shapeCollection.addShape(createGrid());
for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
final TextEditComponent textEditor = new TextEditComponent(
- new Transform(new Point3D(x, 0, z)), viewContext,
+ new Transform(new Point3D(x, 0, z)), viewPanel,
new Point2D(200, 120));
shapeCollection.addShape(textEditor);
}
- viewContext.getAvatar().setLocation(new Point3D(500, -300, -800));
- viewContext.getAvatar().setAngleXZ(0.6);
- viewContext.getAvatar().setAngleYZ(-0.5);
+ viewPanel.getAvatar().setLocation(new Point3D(500, -300, -800));
+ viewPanel.getAvatar().setAngleXZ(0.6);
+ viewPanel.getAvatar().setAngleYZ(-0.5);
}
}
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
-import eu.svjatoslav.sixth.e3d.math.Transform;
import eu.svjatoslav.sixth.e3d.gui.Avatar;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationTracker;
+import eu.svjatoslav.sixth.e3d.math.Transform;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
* Handle keyboard input.
*/
@Override
- public void keyPressed(final KeyEvent event, final ViewContext viewContext) {
+ public void keyPressed(final KeyEvent event, final ViewPanel viewPanel) {
switch (event.getKeyChar()) {
case ' ': // space key
MATRIX.evolve(false);
MATRIX.clear();
break;
default:
- super.keyPressed(event, viewContext);
+ super.keyPressed(event, viewPanel);
}
}
final ViewFrame viewFrame = new ViewFrame();
final ShapeCollection shapeCollection = viewFrame.getViewPanel()
- .getContext().getRootShapeCollection();
+ .getRootShapeCollection();
// add matrix
shapeCollection.addShape(MATRIX);
- // add wireframe grid (optional)
+ // add wire-frame grid (optional)
shapeCollection.addShape(createGrid());
- final ViewContext context = viewFrame.getViewPanel().getContext();
+ final ViewPanel viewPanel = viewFrame.getViewPanel();
- setAvatarOrientation(context.getAvatar());
+ setAvatarOrientation(viewPanel.getAvatar());
// enable receiving of keyboard events
- context.getKeyboardFocusTracker().setFocusOwner(this);
+ viewPanel.getKeyboardFocusTracker().setFocusOwner(this);
// Done! World is built. So ensure screen is updated too.
- context.getViewPanel().repaintDuringNextViewUpdate();
+ viewPanel.repaintDuringNextViewUpdate();
}
/**
- * Create pink wireframe grid below (for decorative purposes).
+ * Create pink wire-frame grid below (for decorative purposes).
*/
private Grid2D createGrid() {
return new Grid2D(