当前位置: 首页>>代码示例>>Java>>正文


Java PShape.vertex方法代码示例

本文整理汇总了Java中processing.core.PShape.vertex方法的典型用法代码示例。如果您正苦于以下问题:Java PShape.vertex方法的具体用法?Java PShape.vertex怎么用?Java PShape.vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.core.PShape的用法示例。


在下文中一共展示了PShape.vertex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addPoint

import processing.core.PShape; //导入方法依赖的package包/类
/**
 * Adds a point to the given shape
 * 
 * @param shape the shape where the point should be added
 * @param index the point index
 * @param addColors add the points colors to the shape if true
 * @param addNormals add the points normals to the shape if true
 */
protected void addPoint(PShape shape, int index, boolean addColors, boolean addNormals) {
	PVector point = points[index];

	if (addNormals && normals != null) {
		PVector normal = normals[index];

		if (addColors) {
			shape.stroke(colors[index]);
			shape.attribNormal("normal", normal.x, normal.y, normal.z);
			shape.vertex(point.x, point.y, point.z);
		} else {
			shape.attribNormal("normal", normal.x, normal.y, normal.z);
			shape.vertex(point.x, point.y, point.z);
		}
	} else if (addColors) {
		shape.stroke(colors[index]);
		shape.vertex(point.x, point.y, point.z);
	} else {
		shape.vertex(point.x, point.y, point.z);
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:30,代码来源:Scan.java

示例2: createGridXY

import processing.core.PShape; //导入方法依赖的package包/类
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;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:17,代码来源:DepthOfField_Demo.java

示例3: vertex

import processing.core.PShape; //导入方法依赖的package包/类
private final void vertex(PShape pg, DwParticle2D p, float tu, float tv){
  if(p.all_springs_deactivated){
    degenerated = true;
    if(lastp != null){
      pg.vertex(lastp.cx,lastp.cy, 0, 0);
    }
  } else {
    if(degenerated){
      pg.vertex(p.cx,p.cy, 0, 0);
      pg.vertex(p.cx,p.cy, 0, 0);
      degenerated = false;
    }
    pg.vertex(p.cx, p.cy, tu, tv);
    lastp = p;
  }
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:17,代码来源:DwSoftGrid2D.java

示例4: vertex

import processing.core.PShape; //导入方法依赖的package包/类
private final void vertex(PShape pg, DwParticle3D p, float[] n, float tu, float tv){
  if(p.all_springs_deactivated){
    degenerated = true;
    if(lastp != null){
      pg.vertex(lastp.cx,lastp.cy,lastp.cz, 0, 0);
    }
  } else {
    if(degenerated){
      pg.vertex(p.cx,p.cy,p.cz, 0, 0);
      pg.vertex(p.cx,p.cy,p.cz, 0, 0);
      degenerated = false;
    }
    pg.normal(n[0], n[1], n[2]); 
    pg.vertex(p.cx, p.cy, p.cz, tu, tv);
    lastp = p;
  }
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:18,代码来源:DwSoftGrid3D.java

示例5: updateShapesCount

import processing.core.PShape; //导入方法依赖的package包/类
protected void updateShapesCount(){
  
  if(particle_num == 0){
    return;
  }
  
  // synchronize buffer size
  int shp_count = shp_particles.getChildCount();
  if(shp_count != particle_num){
    
    // remove shapes, in case group is bigger than actual number
    for(int i = shp_count - 1; i >= particle_num; i--){
      shp_particles.removeChild(i);
    }
    
    // add shapes, in case group is smaller then actual number
    for(int i = shp_count; i < particle_num; i++){
      PShape shp_particle = papplet.createShape();
      shp_particle.beginShape(PConstants.QUADS);
      shp_particle.noFill();
      shp_particle.noStroke();
      shp_particle.textureMode(PConstants.NORMAL); // TODO: report issue
      shp_particle.texture(param.tex_sprite);      // TODO: report issue
      shp_particle.vertex(-1, -1,  0, 0);
      shp_particle.vertex(+1, -1,  1, 0);
      shp_particle.vertex(+1, +1,  1, 1);
      shp_particle.vertex(-1, +1,  0, 1);   
      shp_particle.endShape();
      shp_particles.addChild(shp_particle);
    }
  }
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:33,代码来源:DwParticleRenderP5.java

示例6: calculateMesh

import processing.core.PShape; //导入方法依赖的package包/类
/**
 * Calculates the mesh formed by the section points
 * 
 * @param p the parent Processing applet
 * @param color the mesh color
 * @return the section mesh
 */
public PShape calculateMesh(PApplet p, int color) {
	PShape mesh = p.createShape();
	mesh.beginShape();
	mesh.noStroke();
	mesh.fill(color);

	for (Vec3D point : points) {
		mesh.vertex(point.x, point.y, point.z);
	}

	mesh.endShape(PApplet.CLOSE);

	return mesh;
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:22,代码来源:SculptureSection.java

示例7: createPolyhedronShapeNormals

import processing.core.PShape; //导入方法依赖的package包/类
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();
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:36,代码来源:DwMeshUtils.java

示例8: vertex

import processing.core.PShape; //导入方法依赖的package包/类
static public final void vertex(PShape pg, float[] v0){
  if(pg.is2D()){
    pg.vertex(v0[0], v0[1]); 
  } else {
    pg.vertex(v0[0], v0[1], v0[2]); 
  }
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:8,代码来源:DwDisplayUtils.java

示例9: createParticleShape

import processing.core.PShape; //导入方法依赖的package包/类
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;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:29,代码来源:ParticleSystem.java

示例10: createShape

import processing.core.PShape; //导入方法依赖的package包/类
private PShape createShape(PGraphics pg){
  int     faces_count = mesh.ifs.getFacesCount();
  int[][] faces       = mesh.ifs.getFaces();
  
  float[] n = new float[3]; // normal buffer
  
  PShape shp = pg.createShape();
  shp.beginShape(PConstants.TRIANGLES);
  shp.noStroke();
  shp.fill(material_color);
  for(int i = 0; i < faces_count; i++){
    int v0 = faces[i][0];
    int v1 = faces[i][1];
    int v2 = faces[i][2];
    DwParticle3D p0 = particles[v0]; if(p0.all_springs_deactivated) continue;
    DwParticle3D p1 = particles[v1]; if(p1.all_springs_deactivated) continue;
    DwParticle3D p2 = particles[v2]; if(p2.all_springs_deactivated) continue;
    
    if(FLAT_SHADING){
      n[0] = n[1] = n[2] = 0;
      DwParticle3D.crossAccum(p0, p1, p2, n);
      shp.normal(n[0], n[1], n[2]); 
      shp.vertex(p0.cx, p0.cy, p0.cz);
      shp.vertex(p1.cx, p1.cy, p1.cz);
      shp.vertex(p2.cx, p2.cy, p2.cz);
    } else {
      n = normals[v0];  shp.normal(n[0], n[1], n[2]);  shp.vertex(p0.cx, p0.cy, p0.cz);
      n = normals[v1];  shp.normal(n[0], n[1], n[2]);  shp.vertex(p1.cx, p1.cy, p1.cz);
      n = normals[v2];  shp.normal(n[0], n[1], n[2]);  shp.vertex(p2.cx, p2.cy, p2.cz);
    }
  }
  shp.endShape();
  return shp;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:35,代码来源:DwSoftBall3D.java

示例11: calculateMesh

import processing.core.PShape; //导入方法依赖的package包/类
/**
 * Calculates the sculpture mesh
 */
protected void calculateMesh() {
	if (sections.size() > 1) {
		// Create the sculpture mesh
		mesh = p.createShape(PApplet.GROUP);
		mesh.fill(meshColor);

		// Add the front side
		mesh.addChild(sections.get(0).calculateMesh(p, meshColor));

		// Calculate and add the mesh surface
		PShape surface = p.createShape();
		surface.beginShape(PApplet.TRIANGLES);
		surface.noStroke();
		surface.fill(meshColor);

		for (int i = 0; i < sections.size() - 1; i++) {
			SculptureSection section1 = sections.get(i);
			SculptureSection section2 = sections.get(i + 1);

			for (int j = 0; j < section1.points.length - 1; j++) {
				Vec3D point1 = section1.points[j];
				Vec3D point2 = section1.points[j + 1];
				Vec3D point3 = section2.points[j];
				Vec3D point4 = section2.points[j + 1];
				surface.vertex(point1.x, point1.y, point1.z);
				surface.vertex(point2.x, point2.y, point2.z);
				surface.vertex(point3.x, point3.y, point3.z);
				surface.vertex(point2.x, point2.y, point2.z);
				surface.vertex(point4.x, point4.y, point4.z);
				surface.vertex(point3.x, point3.y, point3.z);
			}

			Vec3D closePoint1 = section1.points[section1.points.length - 1];
			Vec3D closePoint2 = section1.points[0];
			Vec3D closePoint3 = section2.points[section1.points.length - 1];
			Vec3D closePoint4 = section2.points[0];
			surface.vertex(closePoint1.x, closePoint1.y, closePoint1.z);
			surface.vertex(closePoint2.x, closePoint2.y, closePoint2.z);
			surface.vertex(closePoint3.x, closePoint3.y, closePoint3.z);
			surface.vertex(closePoint2.x, closePoint2.y, closePoint2.z);
			surface.vertex(closePoint4.x, closePoint4.y, closePoint4.z);
			surface.vertex(closePoint3.x, closePoint3.y, closePoint3.z);
		}

		surface.endShape();

		mesh.addChild(surface);

		// Add the back side
		mesh.addChild(sections.get(sections.size() - 1).calculateMesh(p, meshColor));
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:56,代码来源:Sculpture.java

示例12: addTriangle

import processing.core.PShape; //导入方法依赖的package包/类
/**
 * Adds a triangle to the given shape if the three Kinect points are connected
 * 
 * @param shape the shape where the triangle should be added
 * @param index1 the first point index
 * @param index2 the second point index
 * @param index3 the third point index
 * @param addColors add the points colors to the shape if true
 * @param addNormals add the points normals to the shape if true
 */
protected void addTriangle(PShape shape, int index1, int index2, int index3, boolean addColors,
		boolean addNormals) {
	PVector point1 = points[index1];
	PVector point2 = points[index2];
	PVector point3 = points[index3];

	if (connected(point1, point2) && connected(point1, point3) && connected(point2, point3)) {
		if (addNormals && normals != null) {
			PVector normal1 = normals[index1];
			PVector normal2 = normals[index2];
			PVector normal3 = normals[index3];

			if (addColors) {
				shape.fill(colors[index1]);
				shape.normal(normal1.x, normal1.y, normal1.z);
				shape.vertex(point1.x, point1.y, point1.z);
				shape.attrib("barycenter", 1.0f, 0.0f, 0.0f);
				shape.fill(colors[index2]);
				shape.normal(normal2.x, normal2.y, normal2.z);
				shape.vertex(point2.x, point2.y, point2.z);
				shape.attrib("barycenter", 0.0f, 1.0f, 0.0f);
				shape.fill(colors[index3]);
				shape.normal(normal3.x, normal3.y, normal3.z);
				shape.vertex(point3.x, point3.y, point3.z);
				shape.attrib("barycenter", 0.0f, 0.0f, 1.0f);
			} else {
				shape.normal(normal1.x, normal1.y, normal1.z);
				shape.vertex(point1.x, point1.y, point1.z);
				shape.attrib("barycenter", 1.0f, 0.0f, 0.0f);
				shape.normal(normal2.x, normal2.y, normal2.z);
				shape.vertex(point2.x, point2.y, point2.z);
				shape.attrib("barycenter", 0.0f, 1.0f, 0.0f);
				shape.normal(normal3.x, normal3.y, normal3.z);
				shape.vertex(point3.x, point3.y, point3.z);
				shape.attrib("barycenter", 0.0f, 0.0f, 1.0f);
			}
		} else if (addColors) {
			shape.fill(colors[index1]);
			shape.vertex(point1.x, point1.y, point1.z);
			shape.attrib("barycenter", 1.0f, 0.0f, 0.0f);
			shape.fill(colors[index2]);
			shape.vertex(point2.x, point2.y, point2.z);
			shape.attrib("barycenter", 0.0f, 1.0f, 0.0f);
			shape.fill(colors[index3]);
			shape.vertex(point3.x, point3.y, point3.z);
			shape.attrib("barycenter", 0.0f, 0.0f, 1.0f);
		} else {
			shape.vertex(point1.x, point1.y, point1.z);
			shape.attrib("barycenter", 1.0f, 0.0f, 0.0f);
			shape.vertex(point2.x, point2.y, point2.z);
			shape.attrib("barycenter", 0.0f, 1.0f, 0.0f);
			shape.vertex(point3.x, point3.y, point3.z);
			shape.attrib("barycenter", 0.0f, 0.0f, 1.0f);
		}
	}
}
 
开发者ID:jagracar,项目名称:kinectSketches,代码行数:67,代码来源:Scan.java

示例13: createPolyhedronShape

import processing.core.PShape; //导入方法依赖的package包/类
static public void createPolyhedronShape(PShape shape, DwIndexedFaceSetAble ifs, float scale, int verts_per_face, boolean smooth){
    
    int type = -1;
    
    switch(verts_per_face){
      case 3: type = PConstants.TRIANGLES; break;
      case 4: type = PConstants.QUADS; break;
      default: return;
    }

    shape.setStroke(false);
    shape.beginShape(type);
//    shape.noStroke();
    
    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
      if(!smooth){
        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;
//        if(type == PConstants.QUADS){
          shape.normal(-nx, -ny, -nz);  // TODO: processing bug i guess
//        } else {
          shape.normal(nx, ny, nz); 
//        }
      }
      
      for(int i = 0; i < num_verts; i++){
//      for(int i = num_verts-1; i >= 0; i--){
        float[] v = verts[face[i]];
        if(smooth){
//          if(type == PConstants.QUADS){
//            shape.normal(-v[0], -v[1], -v[2]);  // TODO: processing bug i guess
//          } else {
            shape.normal(v[0], v[1], v[2]); 
//          }
        }
        shape.vertex(v[0]*scale, v[1]*scale, v[2]*scale);
      }
    }
    shape.endShape();
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:56,代码来源:DwMeshUtils.java

示例14: createParticleShape

import processing.core.PShape; //导入方法依赖的package包/类
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;
    
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:71,代码来源:ParticleSystem.java

示例15: displayAABB

import processing.core.PShape; //导入方法依赖的package包/类
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);
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:57,代码来源:Softbody3D_ParticleCollisionSystem.java


注:本文中的processing.core.PShape.vertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。