forked from emptyflash/FluidSimulation
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNew Text Document.txt
74 lines (73 loc) · 2.58 KB
/
New Text Document.txt
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
/*
if(numActiveParticles > 3)
{
float minX = Float.MAX_VALUE;
float minY = Float.MAX_VALUE;
int leastXIndex = 0, leastYIndex = 0;
float maxX = Float.MIN_VALUE;
float maxY = Float.MIN_VALUE;
int greatestXIndex = 0, greatestYIndex = 0;
for(int i = 0; i < activeParticles.size(); i++)
{
Particle particle = liquid[activeParticles.get(i)];
if(particle.position.x < minX)
{
minX = particle.position.x;
leastXIndex = activeParticles.get(i);
continue;
}
if(particle.position.x > maxX)
{
maxX = particle.position.x;
greatestXIndex = activeParticles.get(i);
continue;
}
}
for(int i = 0; i < activeParticles.size(); i++)
{
Particle particle = liquid[activeParticles.get(i)];
if(particle.position.y < minY)
{
minY = particle.position.y;
leastYIndex = activeParticles.get(i);
continue;
}
if(particle.position.y > maxY)
{
maxY = particle.position.y;
greatestYIndex = activeParticles.get(i);
continue;
}
}
if((int)((maxX-minX)*OPENGL_SCALE) > 0 && (int)((maxY-minY)*OPENGL_SCALE) > 0)
{
waterImage = new BufferedImage((int)((maxX-minX)*OPENGL_SCALE), (int)((maxY-minY)*OPENGL_SCALE), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = (Graphics2D)waterImage.getGraphics();
Composite translucent = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
graphics.setComposite(translucent);
for (int i = 0; i < numActiveParticles; i++)
{
Particle particle = liquid[activeParticles.get(i)];
graphics.setColor(Color.blue);
graphics.fillRect(0, 0, waterImage.getWidth(), waterImage.getHeight());
//graphics.fillRect((int)((particle.position.x-minX)*OPENGL_SCALE), (int)((particle.position.y-minY)*OPENGL_SCALE), 1, 1);
}
waterTexture = null;
try {
waterTexture = BufferedImageUtil.getTexture("waterImage", waterImage);
} catch (IOException e) {
e.printStackTrace();
}
GL11.glPushMatrix();
waterTexture.bind();
GL11.glTranslatef(minX, minY, 0.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2d(0.0,0.0); GL11.glVertex2d(0.0,0.0);
GL11.glTexCoord2d(1.0,0.0); GL11.glVertex2d(waterImage.getWidth()*BOX2D_SCALE,0.0);
GL11.glTexCoord2d(1.0,1.0); GL11.glVertex2d(waterImage.getWidth()*BOX2D_SCALE, waterImage.getHeight()*BOX2D_SCALE);
GL11.glTexCoord2d(0.0,1.0); GL11.glVertex2d(0.0, waterImage.getHeight()*BOX2D_SCALE);
GL11.glEnd();
GL11.glPopMatrix();
}
}
*/