Repository navigation
Expand file tree
/
Copy pathOfflinePNW.java
More file actions
122 lines (95 loc) · 3.61 KB
/
Copy pathOfflinePNW.java
File metadata and controls
122 lines (95 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
Course: CS 45500
Name: Preston Porter
Email: porter31@pnw.edu
Assignment: 4
*/
import renderer.scene.*;
import renderer.models.*;
import renderer.pipeline.*;
import renderer.framebuffer.*;
import java.awt.Color;
/**
*/
public class OfflinePNW
{
public static void main(String[] args)
{
// Create the Scene object that we shall render.
final Scene scene = new Scene();
// Create a set of x and y axes.
Model axes = new Axes2D(-2, +2, -2, +4, 8, 12);
ModelShading.setColor(axes, Color.red);
Position axes_p = new Position( axes );
scene.addPosition( axes_p );
// Push the axes away from where the camera is.
axes_p.matrix = Matrix.translate(0, 0, -3);
// Add the letters to the Scene.
scene.addPosition(new Position( new P() ),
new Position( new N() ),
new Position( new W() ));
// Give the letters random colors.
for (Position p : scene.positionList)
{
ModelShading.setRandomColor(p.model);
}
// Create a FrameBuffer to render our scene into.
int width = 900;
int height = 900;
double pos1 =0;
double pos2 =0;
double pos3 =0;
int count1=0;
int count2=0;
int count3=0;
FrameBuffer fb = new FrameBuffer(width, height);
//scene.positionList.get(3).matrix.mult( Matrix.translate(4, 2, 0) );
// Create the animation frames.
for (int i = 0; i < 360; i++)
{
// Push the letters away from the camera.
scene.positionList.get(1).matrix = Matrix.translate(0, 0, -3); // P
scene.positionList.get(2).matrix = Matrix.translate(0, 0, -3); // N
scene.positionList.get(3).matrix = Matrix.translate(1, 0, -3); // W
//scene.positionList.get(3).matrix = Matrix.translate(2, 0, 0); // W
// do P
// Rotate the P
scene.positionList.get(1).matrix.mult( Matrix.rotateZ(-6*i) ); // notice the difference here
// Translate the P
scene.positionList.get(1).matrix.mult( Matrix.translate(-2, 0, 0) );
// do N
if(i<20){
pos1 = 0.1*i;
scene.positionList.get(2).matrix.mult( Matrix.translate(0, 0.1*i, 0) );}
if((i>19)&&(i<116)){
if(i<65){count1++;}
if(i>64){count1--;}
pos2 = -0.1*count1 + pos1;
scene.positionList.get(2).matrix.mult( Matrix.translate(0, -0.1*count1 + pos1, 0) );
}
if((i>115)&&(i<211)){
pos3 = -0.1*count2 +pos2;
scene.positionList.get(2).matrix.mult( Matrix.translate(0,-0.1*count2 + pos2,0));
if(i<165){count2++;}
if(i>164){count2--;}
}
if(i>210){
scene.positionList.get(2).matrix.mult( Matrix.translate(0,-0.1*count3 + pos3,0));
if(i<261){count3++;}
if((i>260)&&(i<316)){count3--;}
if(i>316){count3++;}
}
scene.positionList.get(2).matrix.mult( Matrix.rotateY(9*i) );
scene.positionList.get(2).matrix.mult( Matrix.translate(-0.5, -0.5, 0) );
// do W
//
scene.positionList.get(3).matrix.mult( Matrix.translate(1, 1, 0) );
scene.positionList.get(3).matrix.mult( Matrix.rotateZ(6*i) );
scene.positionList.get(3).matrix.mult( Matrix.translate(-1, -1, 0) );
// Render again.
fb.clearFB(Color.black);
Pipeline.render(scene, fb.vp);
fb.dumpFB2File(String.format("PPM_PNW_Frame%03d.ppm", i));
}
}
}