-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccumulationBuffer.java
More file actions
116 lines (81 loc) · 2.79 KB
/
AccumulationBuffer.java
File metadata and controls
116 lines (81 loc) · 2.79 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
package tasks;
import jToolkit4FixedPipeline.primitives.Box;
import jToolkit4FixedPipeline.primitives.Surface;
import jToolkit4FixedPipeline.vector.Vector3f;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.GL_RETURN;
import static org.lwjgl.opengl.GL11.glAccum;
/**
* Created with IntelliJ IDEA.
* User: Astemir Eleev
* Date: 9/1/13
* Time: 3:06 PM
* To change this template use File | Settings | File Templates.
*/
public class AccumulationBuffer {
private float angle;
private Box box;
private Surface surface;
private Vector3f[] stars;
public AccumulationBuffer () {
box = new Box(10, .0f, new Vector3f(), new Vector3f(), new Vector3f().makeIdentity(), new Vector3f(1, 0, 0));
surface = new Surface();
surface.drawChessBoard(2, 20, 16, .0f, new Vector3f(), new Vector3f(), new Vector3f().makeIdentity(), new Vector3f());
}
/**
* Simulation of motion blur effect by accumulation buffer
*/
public void motionBlurEffect () {
glCallList(2);
float dx = .1f, dy = 10.0f, dz = .1f;
int max = 8;
glClear(GL_ACCUM_BUFFER_BIT);
glAccum(GL_LOAD, 1.f);
for (int i = 0 ; i < max; i++) {
box.setTranslate(new Vector3f(dx * (i * i), dy, dz));
box.draw();
if(i == 0)
glAccum(GL_LOAD, 1.0f);
else
glAccum(GL_ACCUM, 1.f / max);
}
glAccum(GL_RETURN, 1.f);
}
public void generateStars (final int starsCount) {
stars = new Vector3f[starsCount];
for (Vector3f star : stars) {
float rx = (float)(-1000 + Math.random() * 1000);
float ry = (float)(-1000 + Math.random() * 1000);
float rz = (float)(-1000 + Math.random() * 1000);
star = new Vector3f(rx, ry, rz);
}
}
public void bluredSpace () {
}
@Deprecated
public void fullScreenAntialising (final boolean isEnabled) {
if (isEnabled) {
glClear(GL_ACCUM_BUFFER_BIT);
float factor = .005f;
for (int i = 1; i < 8; i++, factor += .005f) {
glPushMatrix(); {
glTranslated(.0f + factor, .0f + factor, .0f + factor);
glCallList(2);
}
glPopMatrix();
// glPushMatrix(); {
// box.setTranslate(new Vector3f(box.getTranslate().getX() + factor , box.getTranslate().getY() * factor, box.getTranslate().getZ() * factor));
// box.draw();
// }
glPopMatrix();
glAccum(GL_ACCUM, 1.f/8);
}
glAccum(GL_RETURN, 1.0f);
} else {
glCallList(2);
}
}
@Deprecated
public void depthOfField () {
}
}