Skip to content

Commit 89d0866

Browse files
committed
cleanups, releasing v60
1 parent fd2bed1 commit 89d0866

File tree

10 files changed

+47
-26
lines changed

10 files changed

+47
-26
lines changed

examples/Fluid_StreamLines_CustomRender/Fluid_StreamLines_Custom.java renamed to examples/Fluid_StreamLines_CustomRender/Fluid_StreamLines_CustomRender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import processing.opengl.PGraphics2D;
2929

3030

31-
public class Fluid_StreamLines_Custom extends PApplet {
31+
public class Fluid_StreamLines_CustomRender extends PApplet {
3232

3333
private class MyFluidData implements DwFluid2D.FluidData{
3434

@@ -433,6 +433,6 @@ public void createGUI(){
433433

434434

435435
public static void main(String args[]) {
436-
PApplet.main(new String[] { Fluid_StreamLines_Custom.class.getName() });
436+
PApplet.main(new String[] { Fluid_StreamLines_CustomRender.class.getName() });
437437
}
438438
}

examples/OpticalFlow_ExportPFM/Demo_OpticalFlowDraw_PFM/Demo_OpticalFlowDraw_PFM.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void writePFM(DwGLTexture tex){
211211

212212
// write file
213213
pfm_w.write(filename, pfm_w.float_array, w, h);
214-
System.out.println("pfm-file: "+filename);
214+
System.out.println("pfm-file: "+filename.getAbsolutePath());
215215

216216
// optionally check data
217217
if(pmf_debug_check){

examples/OpticalFlow_ExportPFM/Demo_OpticalFlowMovie_PFM/Demo_OpticalFlowMovie_PFM.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void draw() {
155155
// display_mode = 0 --> lines, along the velocity direction
156156
// display_mode = 1 --> lines, normal to the velocity direction
157157
opticalflow.param.display_mode = (mousePressed && mouseButton == CENTER) ? 1 : 0;
158-
opticalflow.renderVelocityStreams(pg_oflow, 10);
158+
opticalflow.renderVelocityStreams(pg_oflow, Math.round(pmf_scale * 4));
159159

160160

161161

@@ -272,7 +272,7 @@ public void writePFM(DwGLTexture tex){
272272

273273
// write file
274274
pfm_w.write(filename, pfm_w.float_array, w, h);
275-
System.out.println("pfm-file: "+filename);
275+
System.out.println("pfm-file: "+filename.getAbsolutePath());
276276

277277
// optionally check data
278278
if(pmf_debug_check){

examples/Skylight_BulletPhysics_Basic/Skylight_BulletPhysics_Basic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public void saveScreenshot(){
665665
File file = capture.createFilename();
666666
// pg_aa.save(file.getAbsolutePath());
667667
save(file.getAbsolutePath());
668-
System.out.println(file);
668+
System.out.println(file.getAbsolutePath());
669669
}
670670

671671

examples/Skylight_BulletPhysics_Breakable/BreakableBody.java

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.bulletphysics.linearmath.Transform;
1111
import com.bulletphysics.util.ObjectArrayList;
12+
1213
import com.thomasdiewald.pixelflow.java.sampling.DwSampling;
1314

1415
import bRigid.BBox;
@@ -36,7 +37,7 @@ public class BreakableBody{
3637
float mass = 0;
3738
float thickness = 0;
3839
float mass_mult = 1f;
39-
float[] color = {255,255,255};
40+
float[] bcolor = {255,255,255};
4041

4142
public BreakableBody(PApplet papplet, MyBPhysics physics, PShape group_bulletbodies){
4243
this.papplet = papplet;
@@ -54,15 +55,15 @@ public void remove(){
5455
group_bulletbodies.removeChild(idx);
5556
}
5657
}
57-
public void initBody(Vector3f dim, PMatrix3D matp5, float[] color){
58-
initBody(dim, matp5, color, 1);
58+
public void initBody(Vector3f dim, PMatrix3D matp5, float[] bcolor){
59+
initBody(dim, matp5, bcolor, 1);
5960
}
6061

61-
public void initBody(Vector3f dim, PMatrix3D matp5, float[] color, float mass_mult){
62+
public void initBody(Vector3f dim, PMatrix3D matp5, float[] bcolor, float mass_mult){
6263
this.mass_mult = mass_mult;
63-
this.color[0] = color[0];
64-
this.color[1] = color[1];
65-
this.color[2] = color[2];
64+
this.bcolor[0] = bcolor[0];
65+
this.bcolor[1] = bcolor[1];
66+
this.bcolor[2] = bcolor[2];
6667

6768
float x_min = -(dim.x * 0.5f);
6869
float x_max = +(dim.x * 0.5f);
@@ -90,10 +91,10 @@ public void initBody(Vector3f dim, PMatrix3D matp5, float[] color, float mass_mu
9091
// body.rigidBody.setDamping(0.2f, 0.2f);
9192

9293
body.displayShape = papplet.createShape(PConstants.BOX, dim.x, dim.y, dim.z);
93-
body.displayShape.setFill(papplet.color(color[0], color[1], color[2]));
94+
body.displayShape.setFill(colorARGB(bcolor[0], bcolor[1], bcolor[2]));
9495
body.displayShape.setFill(true);
9596
body.displayShape.setStrokeWeight(1f);
96-
body.displayShape.setStroke(papplet.color(color[0]*0.5f, color[1]*0.5f, color[2]*0.5f, 96));
97+
body.displayShape.setStroke(colorARGB(bcolor[0]*0.5f, bcolor[1]*0.5f, bcolor[2]*0.5f, 96));
9798
body.displayShape.setStroke(false);
9899
body.displayShape.setName("window| [wire]");
99100

@@ -257,7 +258,7 @@ public void createCellFracture(Vector3f fracture_center_world){
257258
bbody.body = body_new;
258259
bbody.boundary = cell_polygon;
259260
bbody.thickness = thickness;
260-
bbody.color = color;
261+
bbody.bcolor = bcolor;
261262
bbody.mass = mass_new;
262263
bbody.mass_mult = mass_mult;
263264
bbody.body.rigidBody.setUserPointer(bbody);
@@ -324,14 +325,14 @@ public PShape createCellShape(List<WB_Point> points, float dimz){
324325
cell.addChild(cell_bot);
325326
cell.addChild(cell_side);
326327

327-
float r = color[0];
328-
float g = color[1];
329-
float b = color[2];
328+
float r = bcolor[0];
329+
float g = bcolor[1];
330+
float b = bcolor[2];
330331

331-
cell.setFill(papplet.color(r,g,b));
332+
cell.setFill(colorARGB(r,g,b));
332333
cell.setFill(true);
333334
cell.setStrokeWeight(1f);
334-
cell.setStroke(papplet.color(r*0.5f,g*0.5f,b*0.5f,96));
335+
cell.setStroke(colorARGB(r*0.5f,g*0.5f,b*0.5f, 96));
335336
cell.setStroke(false);
336337

337338
cell.setName("[wire]");
@@ -341,6 +342,8 @@ public PShape createCellShape(List<WB_Point> points, float dimz){
341342

342343

343344

345+
346+
344347

345348

346349
public Transform asBulletTransform(PMatrix3D mat_p5){
@@ -363,7 +366,25 @@ public Transform asBulletTransform(PMatrix3D mat_p5, Transform transform){
363366
}
364367

365368

369+
static protected int colorARGB(float r, float g, float b){
370+
int ir = Math.round(clamp(r, 0, 255));
371+
int ig = Math.round(clamp(g, 0, 255));
372+
int ib = Math.round(clamp(b, 0, 255));
373+
int ia = 255;
374+
return ia << 24 | ir << 16 | ig << 8 | ib;
375+
}
366376

377+
static protected int colorARGB(float r, float g, float b, float a){
378+
int ir = Math.round(clamp(r, 0, 255));
379+
int ig = Math.round(clamp(g, 0, 255));
380+
int ib = Math.round(clamp(b, 0, 255));
381+
int ia = Math.round(clamp(a, 0, 255));
382+
return ia << 24 | ir << 16 | ig << 8 | ib;
383+
}
384+
385+
static final public float clamp(float val, float lo, float hi){
386+
return (val < lo) ? lo : (val > hi) ? hi : val;
387+
}
367388

368389

369390

examples/Skylight_BulletPhysics_Breakable/Skylight_BulletPhysics_Breakable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ public void updateShapes(BObject body){
11021102
public void saveScreenshot(){
11031103
File file = capture.createFilename();
11041104
save(file.getAbsolutePath());
1105-
System.out.println(file);
1105+
System.out.println(file.getAbsolutePath());
11061106
}
11071107

11081108

examples/Skylight_BulletPhysics_CellFracture/Skylight_BulletPhysics_CellFracture.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ public void saveScreenshot(){
836836
File file = capture.createFilename();
837837
// pg_aa.save(file.getAbsolutePath());
838838
save(file.getAbsolutePath());
839-
System.out.println(file);
839+
System.out.println(file.getAbsolutePath());
840840
}
841841

842842

examples/Skylight_BulletPhysics_Cubes/Skylight_BulletPhysics_Cubes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ public void saveScreenshot(){
688688
File file = capture.createFilename();
689689
// pg_aa.save(file.getAbsolutePath());
690690
save(file.getAbsolutePath());
691-
System.out.println(file);
691+
System.out.println(file.getAbsolutePath());
692692
}
693693

694694

examples/Skylight_BulletPhysics_MengerSponge/Skylight_BulletPhysics_MengerSponge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ public void saveScreenshot(){
758758
File file = capture.createFilename();
759759
// pg_aa.save(file.getAbsolutePath());
760760
save(file.getAbsolutePath());
761-
System.out.println(file);
761+
System.out.println(file.getAbsolutePath());
762762
}
763763

764764

examples/Skylight_BulletPhysics_TowerDemolition/Skylight_BulletPhysics_TowerDemolition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ public void saveScreenshot(){
766766
File file = capture.createFilename();
767767
// pg_aa.save(file.getAbsolutePath());
768768
save(file.getAbsolutePath());
769-
System.out.println(file);
769+
System.out.println(file.getAbsolutePath());
770770
}
771771

772772

0 commit comments

Comments
 (0)