- minor cleanups
- fixed polygon slicing.
1 parent 7448cf8 commit 26eb2b47458f513e2bde4c8bc4bab2518408fe53
@cory cory authored on 30 Nov 2022
Showing 11 changed files
View
out/production/EPQ 3D renderer/Face.class
Not supported
View
out/production/EPQ 3D renderer/Matrix.class
Not supported
View
out/production/EPQ 3D renderer/Object3d.class
Not supported
View
out/production/EPQ 3D renderer/Screen.class
Not supported
View
out/production/EPQ 3D renderer/Triangle.class
Not supported
View
28
src/Face.java
newPoints.add(new PointComp(
(0.1+gradX*point.getRotatedPoint().x-point.getRotatedPoint().z)/gradX,
(0.1+gradY*point.getRotatedPoint().y-point.getRotatedPoint().z)/gradY,
0.1));
if(Double.isFinite(gradX)){
if(!Double.isFinite(gradX)){
newPoints.get(newPoints.size() - 1).point.x = point.getRotatedPoint().x;}
if(Double.isFinite(gradY)){
if(!Double.isFinite(gradY)){
newPoints.get(newPoints.size() - 1).point.y = point.getRotatedPoint().y;}
}
// finally - if the current point is valid, then add it to the list
if(thisValid){
point.getRotatedPoint().x,
point.getRotatedPoint().y,
point.getRotatedPoint().z));
}
lastPoint = point;
lastValid = thisValid;
}
// finished fixing points, now we need to create a new face consisting of those points.
fixedFace.points = newPoints.toArray(new PointComp[0]);
fixedFace.separateTris();
// invalidate all the points so they are actually calculated
for (PointComp point:
newPoints) {
point.invalidate();
// there must be at least 3 points in the face for it to be drawn successfully
if(newPoints.size() >= 3) {
// finished fixing points, now we need to create a new face consisting of those points.
fixedFace.points = newPoints.toArray(new PointComp[0]);
fixedFace.separateTris();
// invalidate all the points so they are actually calculated
for (PointComp point :
newPoints) {
point.invalidate();
}
fixedFace.draw(img, zBuf, debugImg, fixedFace.perspectiveMappingMatrix, FPDis, scrX, scrY);
}
fixedFace.draw(img, zBuf, debugImg, fixedFace.perspectiveMappingMatrix, FPDis, scrX, scrY);
}
return numberOfPixels;
}
public void separateTris(){
View
6
src/Line2d.java
public class Line2d {
public Point2D point1;
public Point2D point2;
 
public boolean isDrawn = true;
public boolean isDrawn;
 
// initializer variables
boolean is_initialised = false;
private Point2D realPoint1; private Point2D realPoint2;
}
 
/**
* Performs the initial calculations required to draw the line
* Is automatically called whenever nextpix() or draw() are called when initialise() has not run.
* Is automatically called whenever nextPix() or draw() are called when initialise() has not run.
*/
public void initialise(){
// initialise brensenham algorithm
if (point2.x > point1.x) {
}
iteratorVal += 1;
return returnVal;
}
public double getZval(int x){
public double getZVal(int x){
return realPoint1.z + (gradient * (x - realPoint1.x));
}
}
 
View
src/Matrix.java
View
src/Object3d.java
View
src/Screen.java
View
src/Triangle.java