Java源码示例:processing.core.PShape

示例1
protected void buildHeadModel() {
	// load model
	skullObj = p.loadShape( FileUtil.getPath("models/skull-realistic.obj"));
	objOrig = p.loadShape( FileUtil.getPath("models/Trump_lowPoly_updated.obj"));
	obj = p.loadShape( FileUtil.getPath("models/Trump_lowPoly_updated.obj"));
	
	PShapeUtil.scaleShapeToHeight(skullObj, p.height * 0.78f * 2f);
	PShapeUtil.scaleShapeToHeight(objOrig, p.height * 0.7f * 2f);
	PShapeUtil.scaleShapeToHeight(obj, p.height * 0.7f * 2f);
	
	// get centers of each face
	objFaceCenters = new PVector[obj.getChildCount()];
	for (int i = 0; i < obj.getChildren().length; i++ ) {
		PShape child = obj.getChild(i);
		if(child.getVertexCount() == 3) {
			objFaceCenters[i] = MathUtil.computeTriangleCenter( child.getVertex(0), child.getVertex(1), child.getVertex(2) ).copy();
		} else {
			objFaceCenters[i] = MathUtil.computeQuadCenter( child.getVertex(0), child.getVertex(1), child.getVertex(2), child.getVertex(3) ).copy();
		}
	}
	
	maxHeadExtent = PShapeUtil.getMaxExtent(obj);
}
 
示例2
public PShape createParticleShape(DwParticle3D particle){
   
    PShape shp_particle = papplet.createShape(PShape.GEOMETRY);
    
    shp_particle.resetMatrix();
    shp_particle.translate(particle.cx, particle.cy, particle.cz);
    shp_particle.rotateX(papplet.random(PConstants.TWO_PI));
    shp_particle.rotateY(papplet.random(PConstants.TWO_PI));
    shp_particle.rotateZ(papplet.random(PConstants.TWO_PI));
    shp_particle.setStroke(false);
//    shp_particle.setFill(papplet.color(160));
    
    if(ifs == null) ifs = new DwIcosahedron(1);
//    if(ifs == null) ifs = new DwCube(1);
    DwMeshUtils.createPolyhedronShape(shp_particle, ifs, 1, 3, true);

    return shp_particle;
  }
 
示例3
public void initParticleShapes(){
  papplet.shapeMode(PConstants.CORNER);
  shp_particlesystem = papplet.createShape(PShape.GROUP);
  
  PImage sprite = createSprite(0);
  papplet.colorMode(PConstants.HSB, 360, 100, 100);
  
  for (int i = 0; i < PARTICLE_COUNT; i++) {
    PShape shp_particle = createParticleShape(particles[i], sprite);
    particles[i].setShape(shp_particle);
    if(i != IDX_MOUSE_PARTICLE){
      shp_particlesystem.addChild(shp_particle);
    }
  }
  papplet.colorMode(PConstants.RGB, 255, 255, 255);
}
 
示例4
public PShape createGridXY(int lines, float s){
  PShape shp_gridxy = createShape();
  shp_gridxy.beginShape(LINES);
  shp_gridxy.stroke(0);
  shp_gridxy.strokeWeight(1f);
  float d = lines*s;
  for(int i = 0; i <= lines; i++){
    shp_gridxy.vertex(-d,-i*s,0); shp_gridxy.vertex(d,-i*s,0);
    shp_gridxy.vertex(-d,+i*s,0); shp_gridxy.vertex(d,+i*s,0);
    
    shp_gridxy.vertex(-i*s,-d,0); shp_gridxy.vertex(-i*s,d,0);
    shp_gridxy.vertex(+i*s,-d,0); shp_gridxy.vertex(+i*s,d,0);
  }
  shp_gridxy.endShape();
  return shp_gridxy;
}
 
示例5
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;
}
 
示例6
public void exportVertices() {
	String export = "";
	for( int i=0; i < _shapeGroups.size(); i++ ) {
		export += "#group#\n";
		ArrayList<PShape> curGroup = _shapeGroups.get(i);
		for( int j=0; j < curGroup.size(); j++ ) {
			PShape curShape = curGroup.get(j);
			PVector vertex;
			export += "#poly#";
			for (int k = 0; k < curShape.getVertexCount(); k++) {
				vertex = curShape.getVertex(k);
				if( k > 0 ) export += ",";
				export += vertex.x+","+vertex.y;
			}
			export += "\n";
		}
	}
	FileUtil.writeTextToFile(FileUtil.haxademicDataPath() + "text/mapping/mapping-"+SystemUtil.getTimestamp()+".txt", export);
}
 
示例7
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);
	}
}
 
示例8
public static void exportMesh(PShape mesh) {
	StringBuilder verts = new StringBuilder();
	StringBuilder faces = new StringBuilder();
	final int vertsNum = mesh.getVertexCount();
	final PVector v = new PVector();
	for(int i=0; i < vertsNum; i+=3) {
		mesh.getVertex(i, v);
		verts.append("v " + v.x + " " + v.y + " " + v.z + "\n");
		mesh.getVertex(i+1, v);
		verts.append("v " + v.x + " " + v.y + " " + v.z + "\n");
		mesh.getVertex(i+2, v);
		verts.append("v " + v.x + " " + v.y + " " + v.z + "\n");
		faces.append("f " + (i+1) + " " + (i+2) + " " + (i+3) + "\n");
	}
	String outputStr = "o Sphere\n";
	outputStr += verts;
	outputStr += faces;
	FileUtil.writeTextToFile(FileUtil.haxademicOutputPath() + "text/model-"+SystemUtil.getTimestamp()+".obj", outputStr);
}
 
示例9
private void displayGridXZ(PShape pg, float[][] normals, int iy, PGraphics2D tex){
  pg.beginShape(PConstants.TRIANGLE_STRIP);
  pg.textureMode(PConstants.NORMAL);
  pg.texture(tex);
  pg.fill(material_color);
  int iz, ix;
  for(iz = 0; iz < nodes_z-1; iz++){
    for(ix = 0; ix < nodes_x; ix++){
      vertex(pg, getNode3D(ix, iy, iz+0), normals[(iz+0)*nodes_x+ix], ix * tx_inv, (iz+0) * tz_inv);
      vertex(pg, getNode3D(ix, iy, iz+1), normals[(iz+1)*nodes_x+ix], ix * tx_inv, (iz+1) * tz_inv);
    }
    ix -= 1; vertex(pg, getNode3D(ix, iy, iz+1), normals[(iz+1)*nodes_x+ix], 0, 0);
    ix  = 0; vertex(pg, getNode3D(ix, iy, iz+1), normals[(iz+1)*nodes_x+ix], 0, 0);
  }
  pg.endShape();
}
 
示例10
public void addFillToShape(PShape shape, float oscMult) {
	for (int i = 0; i < shape.getVertexCount(); i++) {
		PVector vertex = shape.getVertex(i);
		float zFade = P.map(vertex.z, 50, -50, 1, 0);
		int fillReplace = P.p.color(
			(127 + 127f * P.sin(vertex.x * oscMult)) * zFade,
			(127 + 127f * P.sin(vertex.y * oscMult)) * zFade,
			(127 + 127f * P.sin(vertex.z * oscMult)) * zFade
		);
		shape.setFill(i, fillReplace);
		shape.noStroke();
	}
	for (int j = 0; j < shape.getChildCount(); j++) {
		addFillToShape(shape.getChild(j), oscMult);
	}
}
 
示例11
public static PShape createIcosahedron(PGraphics pg, int level, PImage img) {
	// the icosahedron is created with positions, normals and texture coordinates in the above class
	Icosahedron ico = new Icosahedron(level);
	pg.textureMode(P.NORMAL); // set textureMode to normalized (range 0 to 1);
	PShape mesh = pg.createShape(); // create the initial PShape
	mesh.beginShape(P.TRIANGLES); // define the PShape type: TRIANGLES
	mesh.noStroke();
	if(img != null) mesh.texture(img);

	// put all the vertices, uv texture coordinates and normals into the PShape
	for (int i=0; i<ico.positions.size(); i++) {
		PVector pos = ico.positions.get(i);
		PVector t = ico.texCoords.get(i);
		PVector n = ico.normals.get(i);
		mesh.normal(n.x, n.y, n.z);
		mesh.vertex(pos.x, pos.y, pos.z, t.x, t.y);
	}
	mesh.endShape();
	return mesh;
}
 
示例12
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;
}
 
示例13
public void mousePressed() {
	super.mousePressed();
	_isPressed = true;
	
	
	// find closest vertex to mouse
	float closestPoint = 10;
	PShape curShape = null;
	PVector curVertex = null;
	for (int i=0; i < _shapes.size(); i++) {
		curShape = _shapes.get(i);
		for (int j = 0; j < curShape.getVertexCount(); j++) {
			curVertex = curShape.getVertex(j);
			float mouseDistToVertex = MathUtil.getDistance(p.mouseX, p.mouseY, curVertex.x, curVertex.y);
			if( mouseDistToVertex < closestPoint ) {
				// set z to 1 so that we know that we're dragging (this is a silly hack)
				curShape.setVertex(j, curShape.getVertex(j).x, curShape.getVertex(j).y, 1);
				_draggingShapes.add( curShape );
			}
		}
	}
}
 
示例14
private void displayGridYZ(PShape pg, float[][] normals, int ix, PGraphics2D tex){
  pg.beginShape(PConstants.TRIANGLE_STRIP);
  pg.textureMode(PConstants.NORMAL);
  pg.texture(tex);
  pg.fill(material_color);
  int iz, iy;
  for(iz = 0; iz < nodes_z-1; iz++){
    for(iy = 0; iy < nodes_y; iy++){
      vertex(pg, getNode3D(ix, iy, iz+0), normals[(iz+0)*nodes_y+iy], iy * ty_inv, (iz+0) * tz_inv);
      vertex(pg, getNode3D(ix, iy, iz+1), normals[(iz+1)*nodes_y+iy], iy * ty_inv, (iz+1) * tz_inv);
    }
    iy -= 1; vertex(pg, getNode3D(ix, iy, iz+1), normals[(iz+1)*nodes_y+iy], 0, 0);
    iy  = 0; vertex(pg, getNode3D(ix, iy, iz+1), normals[(iz+1)*nodes_y+iy], 0, 0);
  }
  pg.endShape();
}
 
示例15
public void initParticleShapes(){
  papplet.shapeMode(PConstants.CORNER);
  shp_particlesystem = papplet.createShape(PShape.GROUP);
  
  PImage sprite = createSprite();
  for (int i = 0; i < PARTICLE_COUNT; i++) {
    PShape shp_particle = createParticleShape(particles[i], sprite);
    particles[i].setShape(shp_particle);
    shp_particlesystem.addChild(shp_particle);
  }
}
 
示例16
public void removeShapeChild( PShape parent, PShape child ) {
	for( int i = 0; i < parent.getChildCount(); i++ ) {
	// for( PShape child: parent.getChildren() ) {
		if( parent.getChild(i) == child ) {
			parent.removeChild(i);
		}
	}
}
 
示例17
protected void firstFrame()	{
	// build text
	textToPShape = new TextToPShape(TextToPShape.QUALITY_MEDIUM);
	String fontFile = DemoAssets.fontOpenSansPath;
	
	// build extruded words
	words = new PShape[] {
		textToPShape.stringToShape3d("IMPEACH", 100, fontFile),
		textToPShape.stringToShape3d("THE", 100, fontFile),
		textToPShape.stringToShape3d("MOTHER", 100, fontFile),
		textToPShape.stringToShape3d("FUCKER", 100, fontFile),
	};
	// size the words
	PShapeUtil.scaleShapeToWidth(words[0], 760);
	PShapeUtil.scaleShapeToWidth(words[1], 250);
	PShapeUtil.scaleShapeToWidth(words[2], 690);
	PShapeUtil.scaleShapeToWidth(words[3], 650);
	
	// move the words
	PShapeUtil.offsetShapeVertices(words[0], 0, -300, 0);
	PShapeUtil.offsetShapeVertices(words[1], 0, -80, 0);
	PShapeUtil.offsetShapeVertices(words[2], 0, 70, 0);
	PShapeUtil.offsetShapeVertices(words[3], 0, 250, 0);

	// apply color & UV
	for (int i = 0; i < words.length; i++) {
		PShapeUtil.addTextureUVToShape(words[i], null);
		addFillToShape(words[i], 0.02f);
	}
	
	// load displacement shader & texture
	wobbleShader = new PShaderHotSwap(
		FileUtil.getPath("haxademic/shaders/vertex/mesh-2d-deform-vert.glsl"),
		FileUtil.getPath("haxademic/shaders/vertex/mesh-2d-deform-frag.glsl") 
	);
	displaceTexture = new SimplexNoiseTexture(256, 256);
	DebugView.setTexture("displacement map", displaceTexture.texture());
}
 
示例18
public static PShape addShapesByColor(PShape shape, float searchR, float searchG, float searchB, PShape container, float closenessThreshold) {
		for (int j = 0; j < shape.getChildCount(); j++) {
			PShape subShape = shape.getChild(j);
			if(colorMatchNormalized(searchR, searchG, searchB, subShape.getFill(0), closenessThreshold)) {
				container.addChild(subShape);
			}
//			getShapeFromColor(shape.getChild(j), searchR, searchG, searchB);
		}
		return container;
	}
 
示例19
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;
}
 
示例20
protected void drawSvg(PShape shape, float shapeSize, boolean stroke) {
	if(stroke) setStroke();
	else setFill();
	pg.rotate(P.HALF_PI);
	float shapeScale = MathUtil.scaleToTarget(shape.height, shapeSize);
	pg.shape(shape, 0, 0, shape.width * shapeScale, shape.height * shapeScale);
	
	setStroke();
}
 
示例21
public static void offsetShapeVertices(PShape s, float xOffset, float yOffset, float zOffset) {
	for (int i = 0; i < s.getVertexCount(); i++) {
		PVector vertex = s.getVertex(i);
		s.setVertex(i, vertex.x + xOffset, vertex.y + yOffset, vertex.z + zOffset);
	}
	for (int i = 0; i < s.getChildCount(); i++) {
		PShape subShape = s.getChild(i);
		offsetShapeVertices(subShape, xOffset, yOffset, zOffset);
	}
}
 
示例22
public void updateSpheres(){
  PShape[] shp_spheres = shp_samples_spheres.getChildren();
  for(int i = 0; i < shp_spheres.length; i++){
    PShape shp_sphere = shp_spheres[i];
    MyPoissonSample sample = pds.samples.get(i);
    sample.updateAnimation();
    shp_sphere.resetMatrix();
    shp_sphere.scale(sample.anim_rad);
    shp_sphere.translate(sample.x(), sample.y(), sample.z());
  }
}
 
示例23
void addShape(MyPoissonSample sample){
    PShape shp_point = createShape(POINT, sample.x(), sample.y(), sample.z());
    shp_point.setStroke(color(255));
    shp_point.setStrokeWeight(3);
    shp_samples_points.addChild(shp_point);
    

    if(ifs == null){
      ifs = new DwIcosahedron(2); verts_per_face = 3;
//      ifs = new DwCube(3); verts_per_face = 4;
    }
    PShape shp_sphere = createShape(PShape.GEOMETRY);
    shp_sphere.setStroke(false);
    shp_sphere.setFill(color(255));
    
    colorMode(HSB, 360, 1, 1);
    float hsb_h = 15 + (float)(Math.random() - 0.5f) * 45 ;
    float hsb_s = (float) Math.random() * 0.99f + 0.01f;
    float hsb_b = hsb_s*3;
    
    shp_sphere.setFill(color(hsb_h, hsb_s, hsb_b));
    colorMode(RGB);
    
    shp_sphere.resetMatrix();
    shp_sphere.translate(sample.x(), sample.y(), sample.z());
    
    boolean flat_shading = random(1) > 0.5f;
   
    DwMeshUtils.createPolyhedronShape(shp_sphere, ifs, sample.rad(), verts_per_face, flat_shading);
    
    shp_samples_spheres.addChild(shp_sphere);
  }
 
示例24
static public void createPolyhedronShapeNormals(PShape shape, DwIndexedFaceSetAble ifs, float scale, float normal_len){

    shape.beginShape(PConstants.LINES);
    shape.stroke(0);
    
    int  [][] faces = ifs.getFaces();
    float[][] verts = ifs.getVerts();
    
    for(int[] face : faces){
      float nx = 0, ny = 0, nz = 0;

      int num_verts = face.length;
      
      // compute face normal
      for(int i = 0; i < num_verts; i++){
        int vi = face[i];
        nx += verts[vi][0];
        ny += verts[vi][1];
        nz += verts[vi][2];
      }
      nx /= num_verts;
      ny /= num_verts;
      nz /= num_verts;
      
      float ax = nx*scale;
      float ay = ny*scale;
      float az = nz*scale;
      float bx = ax + nx*normal_len;
      float by = ay + ny*normal_len;
      float bz = az + nz*normal_len;
      shape.vertex(ax, ay, az);
      shape.vertex(bx, by, bz);
    }
    shape.endShape();
  }
 
示例25
public void toggleDisplayWireFrame(){
  DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME;
  for (BObject body : physics.rigidBodies) {
    PShape shp = body.displayShape;
    String name = shp.getName();
    if(name != null && name.contains("[wire]")){
      shp.setFill(!DISPLAY_WIREFRAME);
      shp.setStroke(DISPLAY_WIREFRAME);
    }
  }
  skylight.reset();
}
 
示例26
public void record(PShape ... shapes){
  parent.beginRecord(this);
  for(PShape shp : shapes){
    parent.shape(shp);
  }
  parent.endRecord();
}
 
示例27
public SvgCollection(String dir) {
	// load svgs
	ArrayList<String> files = FileUtil.getFilesInDirOfType(FileUtil.haxademicDataPath() + dir, "svg");
	P.println("Loading and analyzing "+files.size()+" svgs");
	
	_svgs = new ArrayList<SvgRanked>();
	for (String file : files) {
		PShape shape = p.loadShape( FileUtil.haxademicDataPath() + dir + file );
		SvgRanked rankedSvg = new SvgRanked(shape, 1.0f, file);
		if(file.indexOf("black-dot.svg") != -1) {
			_blackDot = rankedSvg;
		} else if(file.indexOf("_white-dot.svg") != -1) {
			_whiteDot = rankedSvg;
		} else {
			// add normal svgs
			_svgs.add(rankedSvg);
			
			// add scaled versions
			// if(file.indexOf("scaled-100") != -1) {
				shape = p.loadShape( FileUtil.haxademicDataPath() + dir + file );
				rankedSvg = new SvgRanked(shape, 0.8f, file);
				_svgs.add(rankedSvg);
			// }
		}
	}
	
	// sort icons for easy pixel whiteness comparison/redrawing 
	Collections.sort(_svgs, new CustomComparator());
	
	// debug print whiteness analysis
	for (int i = 0; i < _svgs.size() - 1; i++) {
		P.println(i, "whiteness:", _svgs.get(i).whiteness, " | whitenessOrig:", _svgs.get(i).whitenessOrig);
	}
}
 
示例28
public void createScene(){
  
  int scale = 5;
  
  int src_w = pg_src.width;
  int src_h = pg_src.height;
  
  int num_x = src_w/scale;
  int num_y = src_h/scale;

  pg_src_small     = (PGraphics2D) createGraphics(num_x, num_y, P2D);
  pg_src_small_tmp = (PGraphics2D) createGraphics(num_x, num_y, P2D);
  
  pg_src_small.loadPixels();
  
  opticalflow.resize(src_w, src_h);
  
  pg_src_tmp = (PGraphics2D) createGraphics(src_w, src_h, P2D);
  
  tex_vel_small.resize(context, opticalflow.frameCurr.velocity);
  tex_vel_small.resize(context, num_x, num_y);
  
  pg_oflow = (PGraphics2D) createGraphics(src_w, src_h, P2D);

  group_cubes = createShape(GROUP);
  shp_cubes = new PShape[num_x * num_y];
  
  for(int y = 0; y < num_y; y++){
    for(int x = 0; x < num_x; x++){
      int idx = y * num_x + x;

      PShape shp_cube = createShape(BOX, 1, 1, 1);
      shp_cube.setStroke(false);
      shp_cube.setStroke(color(0));
      shp_cube.setFill(true);
      shp_cubes[idx] = shp_cube;
      group_cubes.addChild(shp_cube);
    }
  }
}
 
示例29
protected void firstFrame() {
	// config build shapes
	float shapeSize = 100;
	float spacing = 120;
	float strokeWeight = 3;
	p.sphereDetail(8);
	
	// grid of shapes
	// boxes
	shapes.add(PShapeUtil.createBox(shapeSize, shapeSize, shapeSize, p.color(0, 255, 255)));
	lastShape().scale(1, 1, 0.5f);
	lastShape().translate(spacing*-2.5f, spacing*-1, 0);
	shapes.add(PShapeUtil.createBox(shapeSize, shapeSize, shapeSize, spacing*-1.5f, spacing*-1, 0, 0, p.color(255, 0, 255), strokeWeight));
	shapes.add(PShapeUtil.createBox(shapeSize, shapeSize, shapeSize, spacing*-0.5f, spacing*-1, 0, p.color(255), p.color(1), strokeWeight));
	// spheres
	shapes.add(PShapeUtil.createSphere(shapeSize, p.color(0, 255, 255)));
	lastShape().translate(spacing*0.5f, spacing*-1, 0);
	shapes.add(PShapeUtil.createSphere(shapeSize, spacing*1.5f, spacing*-1, 0, 0, p.color(255, 0, 255), strokeWeight));
	shapes.add(PShapeUtil.createSphere(shapeSize, spacing*2.5f, spacing*-1, 0, p.color(255), p.color(1), strokeWeight));
	// rect
	shapes.add(PShapeUtil.createRect(shapeSize, shapeSize, p.color(0, 255, 255)));
	lastShape().translate(spacing*-2.5f, spacing*1, 0);
	shapes.add(PShapeUtil.createRect(shapeSize, shapeSize, spacing*-1.5f, spacing*1, 0, 0, p.color(255, 0, 255), strokeWeight));
	shapes.add(PShapeUtil.createRect(shapeSize, shapeSize, spacing*-0.5f, spacing*1, 0, p.color(255), p.color(1), strokeWeight));
	// ellipse
	shapes.add(PShapeUtil.createEllipse(shapeSize, shapeSize, p.color(0, 255, 255)));
	lastShape().translate(spacing*0.5f, spacing*1, 0);
	shapes.add(PShapeUtil.createEllipse(shapeSize, shapeSize, spacing*1.5f, spacing*1, 0, 0, p.color(255, 0, 255), strokeWeight));
	shapes.add(PShapeUtil.createEllipse(shapeSize, shapeSize, spacing*2.5f, spacing*1, 0, p.color(255), p.color(1), strokeWeight));

	// outer sphere
	shapes.add(PShapeUtil.createSphere(3000, p.color(180, 180, 0)));
	PShape innerSphere = PShapeCopy.copyShape(lastShape());
	PShapeUtil.setBasicShapeStyles(innerSphere, 0, p.color(0), 10);
	innerSphere.scale(0.6f);
	shapes.add(innerSphere);
}
 
示例30
public static float getMaxAbsY(PShape shape, float maxAbsYVertex) {
	// find mesh size height. this should only be used after centering the mesh
	for (int i = 0; i < shape.getVertexCount(); i++) {
		if(P.abs(shape.getVertex(i).y) > maxAbsYVertex) maxAbsYVertex = P.abs(shape.getVertex(i).y);
	}
	for (int j = 0; j < shape.getChildCount(); j++) {
		maxAbsYVertex = getMaxAbsY(shape.getChild(j), maxAbsYVertex);
	}
	return maxAbsYVertex;
}