feat: some changes from before vac

This commit is contained in:
Laureηt 2022-05-09 22:50:43 +02:00
parent b530773a86
commit 5636643595
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
3 changed files with 36 additions and 2 deletions

View file

@ -27,6 +27,7 @@ public class DepthBuffer {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
buffer[i * width + j] = Double.POSITIVE_INFINITY;
// buffer[i * width + j] = 0;
}
}
@ -44,6 +45,11 @@ public class DepthBuffer {
return true;
}
// if (fragment.getDepth() > this.buffer[fragment.getY() * width +
// fragment.getX()]) {
// return true;
// }
return false;
} else {
return false;

View file

@ -65,7 +65,7 @@ public class GraphicsWrapper {
drawComp.setPreferredSize(new Dimension(width * pixelSize, height * pixelSize));
drawComp.setVisible(true);
myFrame = new JFrame("Simple Inverse Rasterization Renderer (TSI)");
myFrame = new JFrame("TP_RENDU1");
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.add("Center", drawComp);
myFrame.pack();

View file

@ -20,7 +20,7 @@ public class Renderer {
static Lighting lighting;
static boolean lightingEnabled;
static boolean Thong;
static boolean repaint;
static boolean repaint = false;
static void init(String sceneFilename) throws Exception {
scene = new Scene(sceneFilename);
@ -157,6 +157,14 @@ public class Renderer {
}
}
public static void wait(double sec) {
try {
Thread.sleep((int) (sec * 1000));
} catch (Exception e) {
/* nothing */
}
}
public static void waitKey() {
Scanner s = new Scanner(System.in);
s.nextLine();
@ -222,6 +230,26 @@ public class Renderer {
// wait(3);
waitKey();
/* solid rendering, with lighting and rotation */
int nbRots = 100;
double radius = 7;
double angle;
setLightingEnabled(true);
for (int i = 0; i < nbRots; i++) {
angle = 2 * Math.PI / nbRots * i + Math.PI / 4;
System.out.println("solid rendering, with lighting, rotation=" + angle);
scene.cameraPosition.set(0, radius * Math.cos(angle));
scene.cameraPosition.set(2, radius * Math.sin(angle));
xform.setLookAt(scene.getCameraPosition(), scene.getCameraLookAt(), scene.getCameraUp());
shader.reset();
screen.clearBuffer();
renderSolid();
screen.swapBuffers();
wait(0.016);
// waitKey();
}
waitKey();
/* solid rendering, with lighting Thong */
System.out.println("solid rendering, with lighting Thong");
screen.clearBuffer();