style: r/badcode jpp
This commit is contained in:
parent
bb1aea52b2
commit
163c93666b
|
@ -44,11 +44,12 @@ public class GraphicsWrapper {
|
|||
|
||||
private ImageComponent drawComp = null;
|
||||
|
||||
private BufferedImage backBuffer = null;
|
||||
// private BufferedImage backBuffer = null;
|
||||
private BufferedImage frontBuffer = null;
|
||||
|
||||
private void init() {
|
||||
backBuffer = new BufferedImage(width * pixelSize, height * pixelSize, BufferedImage.TYPE_INT_ARGB);
|
||||
// backBuffer = new BufferedImage(width * pixelSize, height * pixelSize,
|
||||
// BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
frontBuffer = new BufferedImage(width * pixelSize, height * pixelSize, BufferedImage.TYPE_3BYTE_BGR);
|
||||
|
||||
|
@ -204,6 +205,10 @@ public class GraphicsWrapper {
|
|||
myFrame.repaint();
|
||||
}
|
||||
|
||||
public void repaint() {
|
||||
myFrame.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy window.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import algebra.*;
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
import algebra.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Simple shader that just copy the interpolated color to the screen,
|
||||
* taking the depth of the fragment into acount.
|
||||
*
|
||||
* @author: cdehais
|
||||
*/
|
||||
public class PainterShader extends Shader {
|
||||
|
@ -27,4 +25,3 @@ public class PainterShader extends Shader {
|
|||
depth.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
import algebra.*;
|
||||
import java.lang.Math.*;
|
||||
|
||||
/**
|
||||
* The PerspectiveCorrectRasterizer class extends Rasterizer to perform Persepctive Correct interpolation
|
||||
* The PerspectiveCorrectRasterizer class extends Rasterizer to perform
|
||||
* Persepctive Correct interpolation
|
||||
* of attributes.
|
||||
*
|
||||
* @author cdehais
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
import algebra.*;
|
||||
import java.lang.Math.*;
|
||||
|
||||
/**
|
||||
* The Rasterizer class is responsible for the discretization of geometric
|
||||
|
@ -85,7 +84,6 @@ public class Rasterizer {
|
|||
// }
|
||||
|
||||
// tracé d'un segment avec l'algo de Bresenham
|
||||
int numAttributes = v1.getNumAttributes();
|
||||
Fragment fragment = new Fragment(0, 0); // , numAttributes);
|
||||
|
||||
boolean sym = (Math.abs(y2 - y1) > Math.abs(x2 - x1));
|
||||
|
@ -129,9 +127,8 @@ public class Rasterizer {
|
|||
for (int i = 1; i <= delta_x; i++) {
|
||||
x = x + 1;
|
||||
y_courant = y_courant + m;
|
||||
if ((ystep == 1) && (y_courant < y + 0.5) || ((ystep == -1) && (y_courant > y
|
||||
- 0.5))) {
|
||||
y = y;
|
||||
if ((ystep == 1) && (y_courant < y + 0.5) || ((ystep == -1) && (y_courant > y - 0.5))) {
|
||||
y = y; // dafuk ?
|
||||
} else {
|
||||
y = y + ystep;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class Renderer {
|
|||
Fragment v1 = fragment[faces[i + j]];
|
||||
Fragment v2 = fragment[faces[i + ((j + 1) % 3)]];
|
||||
rasterizer.rasterizeEdge(v1, v2);
|
||||
screen.swapBuffers(); // on repaint juste
|
||||
screen.repaint(); // on refresh l'écran
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,9 +111,8 @@ public class Renderer {
|
|||
Fragment v1 = fragments[faces[i]];
|
||||
Fragment v2 = fragments[faces[i + 1]];
|
||||
Fragment v3 = fragments[faces[i + 2]];
|
||||
|
||||
rasterizer.rasterizeFace(v1, v2, v3);
|
||||
screen.swapBuffers(); // on repaint juste
|
||||
screen.repaint(); // on refresh l'écran
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
import algebra.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Simple shader that just copy the interpolated color to the screen.
|
||||
*
|
||||
* @author: cdehais
|
||||
*/
|
||||
public class SimpleShader extends Shader {
|
||||
|
@ -18,4 +16,3 @@ public class SimpleShader extends Shader {
|
|||
screen.setPixel(fragment.getX(), fragment.getY(), fragment.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@ public class TestAlgebra {
|
|||
Vector v1 = new Vector(1);
|
||||
v1.setName("up");
|
||||
try {
|
||||
Vector v0 = new Vector (0);
|
||||
new Vector(0);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Wrong size exception caught OK");
|
||||
}
|
||||
try {
|
||||
Vector v0 = new Vector ("named", 0);
|
||||
new Vector("named", 0);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Wrong size exception caught OK");
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ public class TestAlgebra {
|
|||
r.normalize();
|
||||
System.out.println("norm(" + r.getName() + ") (after ::normalize()) = " + r.norm());
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
System.out.println("--\n-- Matrix tests\n--");
|
||||
|
||||
|
@ -71,7 +70,7 @@ public class TestAlgebra {
|
|||
M1.set(1, 2, 5.0);
|
||||
|
||||
try {
|
||||
Matrix M2 = new Matrix ("M2", 0, 2);
|
||||
new Matrix("M2", 0, 2);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Wrong size exception caught OK");
|
||||
}
|
||||
|
@ -82,7 +81,6 @@ public class TestAlgebra {
|
|||
System.out.println("Caught exception: " + e);
|
||||
}
|
||||
|
||||
|
||||
Matrix M2 = Matrix.createIdentity(5);
|
||||
System.out.println(M2);
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.lang.Math.*;
|
||||
|
||||
public class TestGraphicWrapper {
|
||||
|
||||
|
@ -51,7 +49,6 @@ public class TestGraphicWrapper {
|
|||
for (int x = 0; x < width; x++) {
|
||||
int c = countNeighbours(x, y);
|
||||
Color pix = screen.getFrontPixel(x, y);
|
||||
Color bpix = screen.getPixel (x, y);
|
||||
if (pix.getRed() == 0) {
|
||||
// System.out.println (x + " " + y + " : dead (" + c + " nbrs) "
|
||||
// + ((bpix.getRed () == 0) ? "dead" : "alive")
|
||||
|
@ -98,13 +95,13 @@ public class TestGraphicWrapper {
|
|||
// screen.clearBuffer ();
|
||||
// screen.swapBuffers ();
|
||||
/*
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (Math.random() < 0.3) {
|
||||
screen.setPixel (x, y, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
* for (int y = 0; y < height; y++) {
|
||||
* for (int x = 0; x < width; x++) {
|
||||
* if (Math.random() < 0.3) {
|
||||
* screen.setPixel (x, y, 255, 255, 255);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
screen.setPixel(20, 10, 255, 255, 255);
|
||||
screen.setPixel(21, 11, 255, 255, 255);
|
||||
|
@ -138,4 +135,3 @@ public class TestGraphicWrapper {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
import algebra.*;
|
||||
|
||||
/**
|
||||
* Test class for the Rasterizer class
|
||||
*
|
||||
* @author: cdehais
|
||||
*/
|
||||
public class TestRasterizer {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
|
||||
import algebra.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Simple shader that just copy the interpolated color to the screen,
|
||||
* taking the depth of the fragment into acount.
|
||||
*
|
||||
* @author: cdehais
|
||||
*/
|
||||
public class TextureShader extends Shader {
|
||||
|
@ -38,12 +35,8 @@ public class TextureShader extends Shader {
|
|||
/* The Fragment may not have texture coordinates */
|
||||
try {
|
||||
|
||||
|
||||
|
||||
/* à compléter */
|
||||
|
||||
|
||||
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
screen.setPixel(fragment.getX(), fragment.getY(), fragment.getColor());
|
||||
}
|
||||
|
@ -55,4 +48,3 @@ public class TextureShader extends Shader {
|
|||
depth.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
package algebra;
|
||||
|
||||
import java.lang.Math;
|
||||
|
||||
public class Matrix {
|
||||
|
||||
protected Matrix() {
|
||||
|
|
|
@ -93,7 +93,6 @@ public class Vector3 extends Vector {
|
|||
}
|
||||
|
||||
public double dot(Vector3 v) {
|
||||
double r = 0.0;
|
||||
return (values[0] * v.values[0] + values[1] * v.values[1] + values[2] * v.values[2]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue