Setup kernel for full triangles.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
498539a09e
commit
331097648e
@ -39,7 +39,7 @@ public class Panel extends JPanel implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
triPoints = new float[12*5000];
|
triPoints = new float[21*1];
|
||||||
cm = getCompatibleColorModel();
|
cm = getCompatibleColorModel();
|
||||||
width = getWidth();
|
width = getWidth();
|
||||||
height = getHeight();
|
height = getHeight();
|
||||||
|
@ -23,16 +23,31 @@ public class RenderKernel extends Kernel{
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int id = getGlobalId();
|
int id = getGlobalId();
|
||||||
int x1=(int)tris[id*12+0];
|
float x1=tris[id*21+0];
|
||||||
int y1=(int)tris[id*12+1];
|
float y1=tris[id*21+1];
|
||||||
int x2=(int)tris[id*12+4];
|
float z1=tris[id*21+2];
|
||||||
int y2=(int)tris[id*12+5];
|
float w1=tris[id*21+3];
|
||||||
int x3=(int)tris[id*12+8];
|
float x2=tris[id*21+4];
|
||||||
int y3=(int)tris[id*12+9];
|
float y2=tris[id*21+5];
|
||||||
|
float z2=tris[id*21+6];
|
||||||
|
float w2=tris[id*21+7];
|
||||||
|
float x3=tris[id*21+8];
|
||||||
|
float y3=tris[id*21+9];
|
||||||
|
float z3=tris[id*21+10];
|
||||||
|
float w3=tris[id*21+11];
|
||||||
|
float Tu1=tris[id*21+12];
|
||||||
|
float Tv1=tris[id*21+13];
|
||||||
|
float Tw1=tris[id*21+14];
|
||||||
|
float Uu2=tris[id*21+15];
|
||||||
|
float Uv2=tris[id*21+16];
|
||||||
|
float Uw2=tris[id*21+17];
|
||||||
|
float Vu3=tris[id*21+18];
|
||||||
|
float Vv3=tris[id*21+19];
|
||||||
|
float Vw3=tris[id*21+20];
|
||||||
TexturedTriangle(
|
TexturedTriangle(
|
||||||
x1,y1,0f,0f,1f,
|
(int)x1,(int)y1,0f,0f,1f,
|
||||||
x2,y2,1f,0f,1f,
|
(int)x2,(int)y2,1f,0f,1f,
|
||||||
x3,y3,1f,1f,1f,
|
(int)x3,(int)y3,1f,1f,1f,
|
||||||
getGlobalId()%256,1f);
|
getGlobalId()%256,1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,26 +75,35 @@ public class SigKeeper implements WindowFocusListener,KeyListener,MouseListener,
|
|||||||
panel.init();
|
panel.init();
|
||||||
|
|
||||||
for (int i=0;i<Panel.triPoints.length/12;i++) {
|
for (int i=0;i<Panel.triPoints.length/12;i++) {
|
||||||
tris.add(new Triangle(new Vertex((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100),
|
tris.add(new Triangle(new Vector((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100),
|
||||||
new Vertex((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100),
|
new Vector((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100),
|
||||||
new Vertex((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100)));
|
new Vector((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100)));
|
||||||
}
|
}
|
||||||
/*tris.add(new Triangle(new Vertex(50,300,100),new Vertex(300,300,100),new Vertex(50,100,100)));
|
/*tris.add(new Triangle(new Vertex(50,300,100),new Vertex(300,300,100),new Vertex(50,100,100)));
|
||||||
tris.add(new Triangle(new Vertex(300,300,100),new Vertex(300,100,100),new Vertex(50,100,100)));*/
|
tris.add(new Triangle(new Vertex(300,300,100),new Vertex(300,100,100),new Vertex(50,100,100)));*/
|
||||||
for (int i=0;i<SigKeeper.tris.size();i++) {
|
for (int i=0;i<SigKeeper.tris.size();i++) {
|
||||||
Triangle t = SigKeeper.tris.get(i);
|
Triangle t = SigKeeper.tris.get(i);
|
||||||
Panel.triPoints[i*12+0]=t.A.x;
|
Panel.triPoints[i*21+0]=t.A.x;
|
||||||
Panel.triPoints[i*12+1]=t.A.y;
|
Panel.triPoints[i*21+1]=t.A.y;
|
||||||
Panel.triPoints[i*12+2]=t.A.z;
|
Panel.triPoints[i*21+2]=t.A.z;
|
||||||
Panel.triPoints[i*12+3]=t.A.w;
|
Panel.triPoints[i*21+3]=t.A.w;
|
||||||
Panel.triPoints[i*12+4]=t.B.x;
|
Panel.triPoints[i*21+4]=t.B.x;
|
||||||
Panel.triPoints[i*12+5]=t.B.y;
|
Panel.triPoints[i*21+5]=t.B.y;
|
||||||
Panel.triPoints[i*12+6]=t.B.z;
|
Panel.triPoints[i*21+6]=t.B.z;
|
||||||
Panel.triPoints[i*12+7]=t.B.w;
|
Panel.triPoints[i*21+7]=t.B.w;
|
||||||
Panel.triPoints[i*12+8]=t.C.x;
|
Panel.triPoints[i*21+8]=t.C.x;
|
||||||
Panel.triPoints[i*12+9]=t.C.y;
|
Panel.triPoints[i*21+9]=t.C.y;
|
||||||
Panel.triPoints[i*12+10]=t.C.z;
|
Panel.triPoints[i*21+10]=t.C.z;
|
||||||
Panel.triPoints[i*12+11]=t.C.w;
|
Panel.triPoints[i*21+11]=t.C.w;
|
||||||
|
Panel.triPoints[i*21+12]=t.T.u;
|
||||||
|
Panel.triPoints[i*21+13]=t.T.v;
|
||||||
|
Panel.triPoints[i*21+14]=t.T.w;
|
||||||
|
Panel.triPoints[i*21+15]=t.U.u;
|
||||||
|
Panel.triPoints[i*21+16]=t.U.v;
|
||||||
|
Panel.triPoints[i*21+17]=t.U.w;
|
||||||
|
Panel.triPoints[i*21+18]=t.V.u;
|
||||||
|
Panel.triPoints[i*21+19]=t.V.v;
|
||||||
|
Panel.triPoints[i*21+20]=t.V.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Thread() {
|
new Thread() {
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
package sig;
|
package sig;
|
||||||
|
|
||||||
public class Triangle {
|
public class Triangle {
|
||||||
Vertex A;
|
Vector A;
|
||||||
Vertex B;
|
Vector B;
|
||||||
Vertex C;
|
Vector C;
|
||||||
public Triangle(Vertex a, Vertex b, Vertex c) {
|
Vector2 T;
|
||||||
|
Vector2 U;
|
||||||
|
Vector2 V;
|
||||||
|
public Triangle(Vector a, Vector b, Vector c) {
|
||||||
|
this(a,b,c,new Vector2(),new Vector2(),new Vector2());
|
||||||
|
}
|
||||||
|
public Triangle(Vector a, Vector b, Vector c, Vector2 t, Vector2 u, Vector2 v) {
|
||||||
A = a;
|
A = a;
|
||||||
B = b;
|
B = b;
|
||||||
C = c;
|
C = c;
|
||||||
|
T = t;
|
||||||
|
U = u;
|
||||||
|
V = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package sig;
|
package sig;
|
||||||
|
|
||||||
public class Vertex {
|
public class Vector {
|
||||||
float x,y,z,w;
|
float x,y,z,w;
|
||||||
|
|
||||||
public Vertex() {
|
public Vector() {
|
||||||
this(0,0,0,1);
|
this(0,0,0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vertex(float x, float y, float z) {
|
public Vector(float x, float y, float z) {
|
||||||
this(x,y,z,1);
|
this(x,y,z,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vertex(float x, float y, float z,float w) {
|
public Vector(float x, float y, float z,float w) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
19
src/sig/Vector2.java
Normal file
19
src/sig/Vector2.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package sig;
|
||||||
|
|
||||||
|
public class Vector2 {
|
||||||
|
float u,v,w;
|
||||||
|
|
||||||
|
public Vector2() {
|
||||||
|
this(0,0,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2(float u, float v) {
|
||||||
|
this(u,v,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2(float y, float v, float w) {
|
||||||
|
this.u=u;
|
||||||
|
this.v=v;
|
||||||
|
this.w=w;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user