@@ -33,13 +33,6 @@ public static void main(String[]args) throws IOException {
3333 textureData [(textureReader .getHeight ()-i -1 )*textureReader .getWidth ()+j ]=(textureReader .getRGB (j ,i ));
3434 }
3535 }
36-
37-
38- //instantiate zBuffer
39- for (int i =0 ; i <zBuffer .length ; i ++)
40- {
41- zBuffer [i ] = -Float .MAX_VALUE ;
42- }
4336 //init window
4437 ImageDisplay img = new ImageDisplay (pix_width ,pix_height ,"test display" );
4538 img .setSize (pix_width ,pix_height );
@@ -64,14 +57,20 @@ public static void main(String[]args) throws IOException {
6457
6558
6659 //TODO make breaking of while loop dependent on user input
60+ myRenderer .diffuse .lightColor = new Color (0.65f , 0.85f ,1.0f );
61+ // myRenderer.diffuse.direction = new Vec3f(0.45f, -0.3f, -0.15f);
62+ myRenderer .ambient .lightColor = new Color (0.0F ,0.05F ,0.05F );
6763 int i = 0 ;
6864 Color [] colorBufferWindow = new Color [myRenderer .colorBuffer .length ];
6965 while (true )
7066 {
7167 long start = System .nanoTime ();
68+ //reset buffer at the beginning of the frame
69+ myRenderer .fill (new Color (50 ,50 ,50 ));
7270 //as proof of concept, render something cool
73- int radius = 50 ;
74- Pixel center = new Pixel (i %(pix_width -1 ),i %(pix_height ));
71+ int radius = 50 +(int )((sin ((double ) System .currentTimeMillis () /1000 )+1 )/2 *50 );
72+ Pixel center = new Pixel (i %(pix_width -1 )+(int )(((sin ((double ) System .currentTimeMillis () /1000 )+1 )/2 )*100 ),
73+ i %(pix_height )+(int )(((sin ((double ) System .currentTimeMillis () /1000 )+1 )/2 )*100 ));
7574 for (int j =center .y ()-radius ;j <center .y ()+radius ;j ++)
7675 {
7776 for (int k = center .x ()-radius ;k <center .x ()+radius ;k ++)
@@ -81,12 +80,14 @@ public static void main(String[]args) throws IOException {
8180 {
8281 Pixel point = new Pixel (abs (candidate .x ()%(pix_width -1 )), abs (candidate .y ()%(pix_height -1 )));
8382
84- myRenderer .setPixel (point , new Color ((int )(random ()*255 ), (int )(random ()*255 ), (int )(random ()*255 ), 255 ));
83+ myRenderer .setPixel (point , new Color ((int )((sin ((double ) System .currentTimeMillis () /1200 )+1 )/2 *255 ),
84+ (int )((sin ((double ) System .currentTimeMillis () /900 )+1 )/2 *255 ), (int )((sin ((double ) System .currentTimeMillis () /800 )+1 )/2 *255 ), 255 ));
8585 }
8686 }
8787 }
88- //
89- // myRenderer.renderModel(africanHead);
88+ //TODO bug fixing : model render gets removed after one frame
89+ // myRenderer.renderModel(africanHead);
90+
9091 //copy renderer output to screen buffer
9192 for (int j =0 ;j <myRenderer .colorBuffer .length ;j ++)
9293 {
@@ -106,7 +107,6 @@ public static Pixel mapToScreen (float x, float y, float min, float max)
106107 }
107108 public static final int pix_height = 1000 ;
108109 public static final int pix_width = 1000 ;
109- public static float [] zBuffer = new float [pix_height *pix_width ];
110110}
111111// we keep this code in case of need
112112 /* testing
0 commit comments