Java Code Examples for processing.core.PShape#noFill()

The following examples show how to use processing.core.PShape#noFill() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shapes.java    From haxademic with MIT License 6 votes vote down vote up
public static PShape createSheetPoints(int detail, float width, float height) {
	PShape sh = P.p.createShape();
	sh.beginShape(PConstants.POINTS);
	sh.stroke(255);
	sh.strokeWeight(1);
	sh.noFill();
	float cellW = width / detail;
	float cellH = height / detail;
	// int numVertices = 0;
	for (int col = 0; col < detail; col++) {
		for (int row = 0; row < detail; row++) {
			float xU = col * cellW;
			float yV = row * cellH;
			float x = -width/2f + col * cellW;
			float y = -height/2f + row * cellH;
			float z = 0;
			sh.normal(x, y, z);
			sh.vertex(x, y, z, P.map(xU, 0, width, 0, 1), P.map(yV, 0, height, 0, 1));
			// numVertices += 1;
		}
	}
	// P.println("createSheet() vertices:", numVertices);
	sh.endShape(); 
	return sh;
}
 
Example 2
Source File: PShapeUtil.java    From haxademic with MIT License 6 votes vote down vote up
public static void addTestStrokeToShape(PShape shape, float strokeWeight, float oscMult) {
	for (int i = 0; i < shape.getVertexCount(); i++) {
		PVector vertex = shape.getVertex(i);
		int strokeReplace = P.p.color(
				127 + 127f * P.sin(vertex.x * oscMult),
				127 + 127f * P.sin(vertex.y * oscMult),
				127 + 127f * P.sin(vertex.z * oscMult)
				);
		shape.noFill();
		shape.setStrokeWeight(i, 4);
		shape.setStroke(strokeReplace);
	}
	for (int j = 0; j < shape.getChildCount(); j++) {
		addTestStrokeToShape(shape.getChild(j), strokeWeight, oscMult);
	}
}
 
Example 3
Source File: PShapeUtil.java    From haxademic with MIT License 6 votes vote down vote up
public static PShape svgToUniformPointsShape(String fileName, float spacing) {
	// load svg and polygonize with Geomerative
	if(!RG.initialized()) RG.init(P.p);
	RShape rShape = RG.loadShape(fileName);
	rShape = RG.centerIn(rShape, P.p.g);

	RG.setPolygonizer(RG.UNIFORMLENGTH);
	RG.setPolygonizerLength(spacing);
	RPoint[] points = rShape.getPoints();

	// create PShape
	PShape svg = P.p.createShape();
	svg.beginShape(PConstants.POINTS);
	svg.stroke(255);
	svg.strokeWeight(1);
	svg.noFill();

	for(int i=0; i < points.length; i++){
		svg.vertex(points[i].x, points[i].y);
	}
	svg.endShape(P.CLOSE);

	return svg;
}
 
Example 4
Source File: ParticleSystem.java    From PixelFlow with MIT License 5 votes vote down vote up
public PShape createParticleShape(DwParticle2D particle, PImage pimg_sprite){
  
  final float rad = 2;

  PShape shp_sprite = papplet.createShape();
  shp_sprite.beginShape(PConstants.QUADS);
  shp_sprite.noStroke();
  shp_sprite.noFill();
  shp_sprite.tint(255,10,10);
  if(particle.idx == IDX_MOUSE_PARTICLE){
    shp_sprite.tint(200,100,100);
  } else {
    float r = 0 + papplet.random(-30, 30);
    float g = 100;
    float b = 100;
    shp_sprite.tint(r,g,b);
  }
  shp_sprite.textureMode(PConstants.NORMAL);
  shp_sprite.texture(pimg_sprite);
  shp_sprite.normal(0, 0, 1);
  shp_sprite.vertex(-rad, -rad, 0, 0);
  shp_sprite.vertex(+rad, -rad, 1, 0);
  shp_sprite.vertex(+rad, +rad, 1, 1);
  shp_sprite.vertex(-rad, +rad, 0, 1);
  shp_sprite.endShape();
  
  return shp_sprite;
}
 
Example 5
Source File: Demo_LinesDeformAndTextureFiler_Tunnel.java    From haxademic with MIT License 5 votes vote down vote up
protected void firstFrame() {
	// load texture
	noiseBuffer = p.createGraphics(p.width, p.height, PRenderers.P2D);
	noiseTexture = new TextureShader(TextureShader.noise_simplex_2d_iq, 0.0005f);
	DebugView.setTexture("noiseBuffer", noiseBuffer);
	
	// build sheet mesh
	shape = p.createShape(P.GROUP);
	int rows = 200;
	int circleSegments = 200;
	float radius = 200;
	float segmentRads = P.TWO_PI / (float) circleSegments;
	for (int y = 0; y < rows; y++) {
		PShape line = P.p.createShape();
		line.beginShape();
		line.stroke(255);
		line.strokeWeight(1);
		line.noFill();
		for (int i = 0; i <= circleSegments; i++) {
			line.vertex(radius * P.sin(segmentRads * i), y * 10f, radius * P.cos(segmentRads * i));
		}
		line.endShape();
		shape.addChild(line);
	}
	PShapeUtil.centerShape(shape);
	PShapeUtil.scaleShapeToHeight(shape, p.height * 2f);
	PShapeUtil.addTextureUVSpherical(shape, noiseBuffer);
	shapeExtent = PShapeUtil.getMaxExtent(shape);
	shape.disableStyle();

	shape.setTexture(noiseBuffer);
	DebugView.setValue("shape.getVertexCount();", PShapeUtil.vertexCount(shape));
}
 
Example 6
Source File: Demo_LinesDeformAndTextureFilter.java    From haxademic with MIT License 5 votes vote down vote up
protected void firstFrame() {
	// load texture
	perlin = new PerlinTexture(p, 256, 256);
	texture = perlin.texture();
	DebugView.setTexture("texture", texture);
	
	// build sheet mesh
	shape = p.createShape(P.GROUP);
	int rows = 200;
	int cols = 500;
	for (int y = 0; y < rows; y++) {
		PShape line = P.p.createShape();
		line.beginShape();
		line.stroke(255);
		line.strokeWeight(1);
		line.noFill();
		for (int x = 0; x < cols; x++) {
			line.vertex(x * 10f, y * 10f, 0);
		}
		line.endShape();
		shape.addChild(line);
	}
	PShapeUtil.centerShape(shape);
	PShapeUtil.scaleShapeToHeight(shape, p.height * 2f);
	PShapeUtil.addTextureUVToShape(shape, texture);
	shapeExtent = PShapeUtil.getMaxExtent(shape);
	shape.disableStyle();

	shape.setTexture(texture);
	DebugView.setValue("shape.getVertexCount();", PShapeUtil.vertexCount(shape));
}
 
Example 7
Source File: Demo_RuttEtraGPU.java    From haxademic with MIT License 5 votes vote down vote up
protected void firstFrame() {
	// set up webcam
	WebCam.instance().setDelegate(this);

	webcamBuffer = p.createGraphics(p.width, p.height, PRenderers.P2D);
	webcamLerped = p.createGraphics(p.width, p.height, PRenderers.P2D);

	// build sheet mesh
	shape = p.createShape(P.GROUP);
	int rows = 100;
	int cols = 200;
	for (int y = 0; y < rows; y++) {
		PShape line = P.p.createShape();
		line.beginShape();
		line.stroke(255);
		line.strokeWeight(1);
		line.noFill();
		for (int x = 0; x < cols; x++) {
			line.vertex(x * 10f, y * 10f, 0);
		}
		line.endShape();
		shape.addChild(line);
	}
	PShapeUtil.centerShape(shape);
	PShapeUtil.scaleShapeToHeight(shape, p.height * 0.5f);
	PShapeUtil.addTextureUVToShape(shape, webcamBuffer);
	shapeExtent = PShapeUtil.getMaxExtent(shape);
	shape.disableStyle();

	shape.setTexture(webcamBuffer);
	DebugView.setValue("shape.getVertexCount();", PShapeUtil.vertexCount(shape));
}
 
Example 8
Source File: KinectShaderVertexDeform.java    From haxademic with MIT License 5 votes vote down vote up
PShape createSheet(int detail, PImage tex) {
	p.textureMode(NORMAL);
	PShape sh = p.createShape();
	sh.beginShape(QUADS);
	sh.noStroke();
	sh.noFill();
	sh.texture(tex);
	float cellW = tex.width / detail;
	float cellH = tex.height / detail;
	int numVertices = 0;
	for (int col = 0; col < tex.width; col += cellW) {
		for (int row = 0; row < tex.height; row += cellH) {
			float xU = col;
			float yV = row;
			float x = -tex.width/2f + xU;
			float y = -tex.height/2f + yV;
			float z = 0;
			sh.normal(x, y, z);
			sh.vertex(x, y, z, 					P.map(xU, 0, tex.width, 0, 1f), P.map(yV, 0, tex.height, 0, 1f));
			sh.vertex(x, y + cellH, z, 			P.map(xU, 0, tex.width, 0, 1f), P.map(yV + cellH, 0, tex.height, 0, 1f));    
			sh.vertex(x + cellW, y + cellH, z,	P.map(xU + cellW, 0, tex.width, 0, 1f), P.map(yV + cellH, 0, tex.height, 0, 1f));    
			sh.vertex(x + cellW, y, z, 			P.map(xU + cellW, 0, tex.width, 0, 1f), P.map(yV, 0, tex.height, 0, 1f));
			numVertices++;
		}
	}
	P.println(numVertices, "vertices");
	sh.endShape(); 
	return sh;
}
 
Example 9
Source File: PShapeUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static PShape meshShapeToPointsShape(PShape origShape) {
	PShape newShape = P.p.createShape();
	newShape.beginShape(PConstants.POINTS);
	newShape.stroke(255);
	newShape.strokeWeight(1);
	newShape.noFill();
	addVerticesToPointShape(origShape, newShape);
	newShape.endShape();
	return newShape;
}
 
Example 10
Source File: TextureEQLinesTerrain.java    From haxademic with MIT License 5 votes vote down vote up
public TextureEQLinesTerrain( int width, int height ) {
	super(width, height);
	
	// build scrolling audio map history
	eqHistory = PG.newPG(256, 256, false, false);
	eqHistory.noSmooth();
	OpenGLUtil.setTextureQualityLow(eqHistory);
	eqHistoryCopy = PG.newPG(256, 256);
	eqHistoryCopy.noSmooth();
	OpenGLUtil.setTextureQualityLow(eqHistoryCopy);

	// build sheet mesh
	shape = P.p.createShape(P.GROUP);
	int rows = eqHistory.height;
	int cols = eqHistory.width;
	for (int y = 0; y < rows; y++) {
		PShape line = P.p.createShape();
		line.beginShape();
		line.stroke(255);
		line.strokeWeight(1);
		line.noFill();
		for (int x = 0; x < cols; x++) {
			line.vertex(x * 20f, y * 20f, 0);
		}
		line.endShape();
		shape.addChild(line);
	}

	// normalize & texture mesh
	PShapeUtil.centerShape(shape);
	PShapeUtil.scaleShapeToHeight(shape, height * 1f);
	PShapeUtil.addTextureUVToShape(shape, eqHistory);
	shapeExtent = PShapeUtil.getMaxExtent(shape);
	shape.disableStyle();
	shape.setTexture(eqHistory);
}
 
Example 11
Source File: ParticleSystem.java    From PixelFlow with MIT License 4 votes vote down vote up
public PShape createParticleShape(DwParticle2D particle, PImage sprite_img){
    
    final float rad = particle.rad;

    PShape shp_particle = papplet.createShape(PShape.GROUP);
    
    if( PARTICLE_SHAPE_IDX >= 0 && PARTICLE_SHAPE_IDX < 4){
      
      PShape sprite = papplet.createShape(PShape.GEOMETRY);
      sprite.beginShape(PConstants.QUAD);
      sprite.noStroke();
      sprite.noFill();
      sprite.textureMode(PConstants.NORMAL);
      sprite.texture(sprite_img);
      sprite.normal(0, 0, 1);
      sprite.vertex(-rad, -rad, 0, 0);
      sprite.vertex(+rad, -rad, 1, 0);
      sprite.vertex(+rad, +rad, 1, 1);
      sprite.vertex(-rad, +rad, 0, 1);
      sprite.endShape();
      
      shp_particle.addChild(sprite);
    }
    else if( PARTICLE_SHAPE_IDX == 4){   
      
      float threshold1 = 1;   // radius shortening for arc segments
      float threshold2 = 140; // arc between segments
      
      double arc1 = Math.acos(Math.max((rad-threshold1), 0) / rad);
      double arc2 = (180 - threshold2) * Math.PI / 180;
      double arc = Math.min(arc1, arc2);
      
      int num_vtx = (int)Math.ceil(2*Math.PI/arc);
      
//      System.out.println(num_vtx);

      PShape circle = papplet.createShape(PShape.GEOMETRY);
      circle.beginShape();
      circle.noStroke();
      circle.fill(200,100);
      for(int i = 0; i < num_vtx; i++){
        float vx = (float) Math.cos(i * 2*Math.PI/num_vtx) * rad;
        float vy = (float) Math.sin(i * 2*Math.PI/num_vtx) * rad;
        circle.vertex(vx, vy);
      }
      circle.endShape(PConstants.CLOSE);

      PShape line = papplet.createShape(PShape.GEOMETRY);
      line.beginShape(PConstants.LINES);
      line.stroke(0, 100);
      line.strokeWeight(1);
      line.vertex(0, 0);
      line.vertex(-(rad-1), 0);
      line.endShape();
      
//      PShape circle = papplet.createShape(PConstants.ELLIPSE, 0, 0, rad*2, rad*2);
//      circle.setStroke(false);
//      circle.setFill(papplet.color(200,100));
//
//      PShape line = papplet.createShape(PConstants.LINE, 0, 0, -(rad-1), 0);
//      line.setStroke(papplet.color(0,200));
//      line.setStrokeWeight(1); 
      
      shp_particle.addChild(circle);
      shp_particle.addChild(line);
    }
    
    return shp_particle;
    
  }
 
Example 12
Source File: ParticleSystem.java    From PixelFlow with MIT License 4 votes vote down vote up
public PShape createParticleShape(DwParticle2D particle, PImage sprite_img){
    
    final float rad = particle.rad;

    PShape shp_particle = papplet.createShape(PShape.GROUP);
    
    if( PARTICLE_SHAPE_IDX >= 0 && PARTICLE_SHAPE_IDX < 4){
      
      PShape sprite = papplet.createShape(PShape.GEOMETRY);
      sprite.beginShape(PConstants.QUAD);
      sprite.noStroke();
      sprite.noFill();
      sprite.textureMode(PConstants.NORMAL);
      sprite.texture(sprite_img);
      sprite.normal(0, 0, 1);
      sprite.vertex(-rad, -rad, 0, 0);
      sprite.vertex(+rad, -rad, 1, 0);
      sprite.vertex(+rad, +rad, 1, 1);
      sprite.vertex(-rad, +rad, 0, 1);
      sprite.endShape();
      
      shp_particle.addChild(sprite);
    }
    else if( PARTICLE_SHAPE_IDX == 4){   
      
      float threshold1 = 1;   // radius shortening for arc segments
      float threshold2 = 140; // arc between segments
      
      double arc1 = Math.acos(Math.max((rad-threshold1), 0) / rad);
      double arc2 = (180 - threshold2) * Math.PI / 180;
      double arc = Math.min(arc1, arc2);
      
      int num_vtx = (int)Math.ceil(2*Math.PI/arc);
      
//      System.out.println(num_vtx);

      PShape circle = papplet.createShape(PShape.GEOMETRY);
      circle.beginShape();
      circle.noStroke();
      circle.fill(200,100);
      for(int i = 0; i < num_vtx; i++){
        float vx = (float) Math.cos(i * 2*Math.PI/num_vtx) * rad;
        float vy = (float) Math.sin(i * 2*Math.PI/num_vtx) * rad;
        circle.vertex(vx, vy);
      }
      circle.endShape(PConstants.CLOSE);

      PShape line = papplet.createShape(PShape.GEOMETRY);
      line.beginShape(PConstants.LINES);
      line.stroke(0, 100);
      line.strokeWeight(1);
      line.vertex(0, 0);
      line.vertex(-(rad-1), 0);
      line.endShape();
      
//      PShape circle = papplet.createShape(PConstants.ELLIPSE, 0, 0, rad*2, rad*2);
//      circle.setStroke(false);
//      circle.setFill(papplet.color(200,100));
//
//      PShape line = papplet.createShape(PConstants.LINE, 0, 0, -(rad-1), 0);
//      line.setStroke(papplet.color(0,200));
//      line.setStrokeWeight(1); 
      
      shp_particle.addChild(circle);
      shp_particle.addChild(line);
    }
    
    return shp_particle;
    
  }
 
Example 13
Source File: Softbody3D_ParticleCollisionSystem.java    From PixelFlow with MIT License 4 votes vote down vote up
public void displayAABB(float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(192);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  shape(shp_aabb);
}
 
Example 14
Source File: Softbody3D_Playground.java    From PixelFlow with MIT License 4 votes vote down vote up
public void displayAABB(float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(192);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  shape(shp_aabb);
}
 
Example 15
Source File: Softbody3D_Cloth.java    From PixelFlow with MIT License 4 votes vote down vote up
public void displayAABB(float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(64);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  shape(shp_aabb);
}
 
Example 16
Source File: Skylight_ClothSimulation.java    From PixelFlow with MIT License 4 votes vote down vote up
public void displayAABB(PGraphics3D canvas, float[] aabb){
  if(shp_aabb == null){
    float xmin = aabb[0], xmax = aabb[3];
    float ymin = aabb[1], ymax = aabb[4];
    float zmin = aabb[2], zmax = aabb[5];
    
    shp_aabb = createShape(GROUP);
    
    PShape plane_zmin = createShape();
    plane_zmin.beginShape(QUAD);
    plane_zmin.stroke(0);
    plane_zmin.strokeWeight(1);
    plane_zmin.fill(16,96,192);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymin, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmax, ymax, zmin);
    plane_zmin.normal(0, 0, 1); plane_zmin.vertex(xmin, ymax, zmin);
    plane_zmin.endShape(CLOSE);
    shp_aabb.addChild(plane_zmin);
    
    PShape plane_zmax = createShape();
    plane_zmax.beginShape(QUAD);
    plane_zmax.noFill();
    plane_zmax.stroke(0);
    plane_zmax.strokeWeight(1);
    plane_zmax.vertex(xmin, ymin, zmax);
    plane_zmax.vertex(xmax, ymin, zmax);
    plane_zmax.vertex(xmax, ymax, zmax);
    plane_zmax.vertex(xmin, ymax, zmax);
    plane_zmax.endShape(CLOSE);
    shp_aabb.addChild(plane_zmax);
    
    PShape vert_lines = createShape();
    vert_lines.beginShape(LINES);
    vert_lines.stroke(0);
    vert_lines.strokeWeight(1);
    vert_lines.vertex(xmin, ymin, zmin);  vert_lines.vertex(xmin, ymin, zmax);
    vert_lines.vertex(xmax, ymin, zmin);  vert_lines.vertex(xmax, ymin, zmax);
    vert_lines.vertex(xmax, ymax, zmin);  vert_lines.vertex(xmax, ymax, zmax);
    vert_lines.vertex(xmin, ymax, zmin);  vert_lines.vertex(xmin, ymax, zmax);
    vert_lines.endShape();
    shp_aabb.addChild(vert_lines);
    
    PShape corners = createShape();
    corners.beginShape(POINTS);
    corners.stroke(0);
    corners.strokeWeight(7);
    corners.vertex(xmin, ymin, zmin);  corners.vertex(xmin, ymin, zmax);
    corners.vertex(xmax, ymin, zmin);  corners.vertex(xmax, ymin, zmax);
    corners.vertex(xmax, ymax, zmin);  corners.vertex(xmax, ymax, zmax);
    corners.vertex(xmin, ymax, zmin);  corners.vertex(xmin, ymax, zmax);
    corners.endShape();
    shp_aabb.addChild(corners);
  }
  canvas.shape(shp_aabb);
}