mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 18:55:18 +00:00
ZPan
This commit is contained in:
parent
8586ec67b6
commit
7406da66a7
@ -5,16 +5,23 @@ import java.awt.Dimension;
|
|||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.awt.event.MouseWheelListener;
|
import java.awt.event.MouseWheelListener;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JViewport;
|
||||||
|
|
||||||
import com.volmit.iris.noise.CNG;
|
import com.volmit.iris.noise.CNG;
|
||||||
import com.volmit.iris.object.NoiseStyle;
|
import com.volmit.iris.object.NoiseStyle;
|
||||||
@ -31,6 +38,9 @@ public class NoiseView extends JPanel implements MouseWheelListener {
|
|||||||
static JComboBox<NoiseStyle> combo;
|
static JComboBox<NoiseStyle> combo;
|
||||||
RollingSequence r = new RollingSequence(60);
|
RollingSequence r = new RollingSequence(60);
|
||||||
boolean colorMode = true;
|
boolean colorMode = true;
|
||||||
|
double scale = 1;
|
||||||
|
static boolean hd = false;
|
||||||
|
double ascale = 10;
|
||||||
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
||||||
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY,
|
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY,
|
||||||
"Iris Renderer");
|
"Iris Renderer");
|
||||||
@ -38,26 +48,74 @@ public class NoiseView extends JPanel implements MouseWheelListener {
|
|||||||
int[][] co;
|
int[][] co;
|
||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
|
double oxp = 0;
|
||||||
|
double ozp = 0;
|
||||||
|
double ox = 0;
|
||||||
|
double oz = 0;
|
||||||
|
boolean down = false;
|
||||||
|
|
||||||
|
double lx = Double.MAX_VALUE;
|
||||||
|
double lz = Double.MAX_VALUE;
|
||||||
|
|
||||||
public NoiseView() {
|
public NoiseView() {
|
||||||
for (int i = 0; i < 60; i++) {
|
|
||||||
r.put(10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
addMouseWheelListener((MouseWheelListener) this);
|
addMouseWheelListener((MouseWheelListener) this);
|
||||||
|
addMouseMotionListener(new MouseMotionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
Point cp = e.getPoint();
|
||||||
|
|
||||||
|
lx = (cp.getX());
|
||||||
|
lz = (cp.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
Point cp = e.getPoint();
|
||||||
|
ox += (lx - cp.getX()) * scale;
|
||||||
|
oz += (lz - cp.getY()) * scale;
|
||||||
|
lx = cp.getX();
|
||||||
|
lz = cp.getY();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
int notches = e.getWheelRotation();
|
int notches = e.getWheelRotation();
|
||||||
cng.scale(cng.getScale() + ((0.05*cng.getScale())* notches));
|
scale = scale + ((0.044 * scale) * notches);
|
||||||
cng.scale(cng.getScale() < 0.00001 ? 0.00001 : cng.getScale());
|
scale = scale < 0.00001 ? 0.00001 : scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
||||||
|
if (scale < ascale) {
|
||||||
|
ascale -= Math.abs(scale - ascale) * 0.16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scale > ascale) {
|
||||||
|
ascale += Math.abs(ascale - scale) * 0.16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ox < oxp) {
|
||||||
|
oxp -= Math.abs(ox - oxp) * 0.16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ox > oxp) {
|
||||||
|
oxp += Math.abs(oxp - ox) * 0.16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oz < ozp) {
|
||||||
|
ozp -= Math.abs(oz - ozp) * 0.16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oz > ozp) {
|
||||||
|
ozp += Math.abs(ozp - oz) * 0.16;
|
||||||
|
}
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
int accuracy = M.clip(r.getAverage() / 13D, 1D, 128D).intValue();
|
int accuracy = hd ? 1 : M.clip((r.getAverage() / 13D) + 1, 1D, 128D).intValue();
|
||||||
|
|
||||||
if (g instanceof Graphics2D) {
|
if (g instanceof Graphics2D) {
|
||||||
Graphics2D gg = (Graphics2D) g;
|
Graphics2D gg = (Graphics2D) g;
|
||||||
@ -76,7 +134,8 @@ public class NoiseView extends JPanel implements MouseWheelListener {
|
|||||||
int xx = x;
|
int xx = x;
|
||||||
gx.queue("a", () -> {
|
gx.queue("a", () -> {
|
||||||
for (int z = 0; z < getParent().getHeight(); z += accuracy) {
|
for (int z = 0; z < getParent().getHeight(); z += accuracy) {
|
||||||
double n = cng.noise(xx, Math.sin((double) M.ms() / 10000D) * 800D, z);
|
double n = cng.noise((xx * ascale) + oxp, Math.sin((double) M.ms() / 20000D) * 800D,
|
||||||
|
(z * ascale) + ozp);
|
||||||
|
|
||||||
if (n > 1 || n < 0) {
|
if (n > 1 || n < 0) {
|
||||||
System.out.println("EXCEEDED " + n);
|
System.out.println("EXCEEDED " + n);
|
||||||
@ -119,11 +178,12 @@ public class NoiseView extends JPanel implements MouseWheelListener {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
NoiseStyle s = (NoiseStyle)(((JComboBox<NoiseStyle>)e.getSource()).getSelectedItem());
|
NoiseStyle s = (NoiseStyle) (((JComboBox<NoiseStyle>) e.getSource()).getSelectedItem());
|
||||||
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
combo.setSize(500, 100);
|
|
||||||
|
combo.setSize(500, 30);
|
||||||
JLayeredPane pane = new JLayeredPane();
|
JLayeredPane pane = new JLayeredPane();
|
||||||
nv.setSize(new Dimension(1440, 820));
|
nv.setSize(new Dimension(1440, 820));
|
||||||
pane.add(nv, 1, 0);
|
pane.add(nv, 1, 0);
|
||||||
@ -141,4 +201,24 @@ public class NoiseView extends JPanel implements MouseWheelListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class HandScrollListener extends MouseAdapter {
|
||||||
|
private static final Point pp = new Point();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
JViewport vport = (JViewport) e.getSource();
|
||||||
|
JComponent label = (JComponent) vport.getView();
|
||||||
|
Point cp = e.getPoint();
|
||||||
|
Point vp = vport.getViewPosition();
|
||||||
|
vp.translate(pp.x - cp.x, pp.y - cp.y);
|
||||||
|
label.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
|
||||||
|
|
||||||
|
pp.setLocation(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
pp.setLocation(e.getPoint());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user