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


Java PShape类代码示例

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


PShape类属于processing.core包,在下文中一共展示了PShape类的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: createParticleShape

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

示例3: initParticleShapes

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

示例4: 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

示例5: createShape

import processing.core.PShape; //导入依赖的package包/类
private PShape createShape(PApplet papplet, float radius, boolean icosahedron){
    PShape shape;
    
    if(!icosahedron){
      shape = papplet.createShape(PConstants.POINT, 0, 0);
      shape.setStroke(true);
      shape.setStrokeWeight(1);
    } else {
      if(ifs == null){
        ifs = new DwIcosahedron(1);
//        ifs = new DwCube(1);
      }
      shape = papplet.createShape(PShape.GEOMETRY);
      shape.setStroke(false);
      shape.setFill(true);
      DwMeshUtils.createPolyhedronShape(shape, ifs, radius, 3, true);
    }

    return shape;
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:21,代码来源:DwSoftBody3D.java

示例6: 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

示例7: displayGridXY

import processing.core.PShape; //导入依赖的package包/类
private void displayGridXY(PShape pg, PGraphics2D tex){
  pg.beginShape(PConstants.TRIANGLE_STRIP);
  pg.textureMode(PConstants.NORMAL);
  pg.texture(tex);
  pg.fill(material_color);
  pg.noStroke();
  int ix, iy;
  for(iy = 0; iy < nodes_y-1; iy++){
    for(ix = 0; ix < nodes_x; ix++){
      vertex(pg, getNode(ix, iy+0), ix * tx_inv, (iy+0) * ty_inv);
      vertex(pg, getNode(ix, iy+1), ix * tx_inv, (iy+1) * ty_inv);
    }
    ix -= 1; vertex(pg, getNode(ix, iy+1), 0, 0);
    ix  = 0; vertex(pg, getNode(ix, iy+1), 0, 0);
  }
  pg.endShape();
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:18,代码来源:DwSoftGrid2D.java

示例8: 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

示例9: displayGridXY

import processing.core.PShape; //导入依赖的package包/类
private void displayGridXY(PShape pg, float[][] normals, int iz, PGraphics2D tex){
  pg.beginShape(PConstants.TRIANGLE_STRIP);
  pg.textureMode(PConstants.NORMAL);
  pg.texture(tex);
  pg.fill(material_color);
  int ix, iy;
  for(iy = 0; iy < nodes_y-1; iy++){
    for(ix = 0; ix < nodes_x; ix++){
      vertex(pg, getNode3D(ix, iy+0, iz), normals[(iy+0)*nodes_x+ix], ix * tx_inv, (iy+0) * ty_inv);
      vertex(pg, getNode3D(ix, iy+1, iz), normals[(iy+1)*nodes_x+ix], ix * tx_inv, (iy+1) * ty_inv);
    }
    ix -= 1; vertex(pg, getNode3D(ix, iy+1, iz), normals[(iy+1)*nodes_x+ix], 0, 0);
    ix  = 0; vertex(pg, getNode3D(ix, iy+1, iz), normals[(iy+1)*nodes_x+ix], 0, 0);
  }
  pg.endShape();
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:17,代码来源:DwSoftGrid3D.java

示例10: displayGridYZ

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

示例11: displayGridXZ

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

示例12: createShape

import processing.core.PShape; //导入依赖的package包/类
private PShape createShape(PGraphics pg){
  PShape shp = pg.createShape(PConstants.GROUP);

  PShape[] shp_grid = new PShape[6];
  for(int i = 0; i < shp_grid.length; i++){
    shp_grid[i] = pg.createShape();
    shp.addChild(shp_grid[i]);
  }
  
  shp_grid[0].setName("gridXYp");
  shp_grid[1].setName("gridXYn");
  shp_grid[2].setName("gridYZp");
  shp_grid[3].setName("gridYZn");
  shp_grid[4].setName("gridXZp");
  shp_grid[5].setName("gridXZn");

                  displayGridXY(shp_grid[0], normals[0], 0        , texture_XYp);
  if(nodes_z > 1) displayGridXY(shp_grid[1], normals[1], nodes_z-1, texture_XYn);
                  displayGridYZ(shp_grid[2], normals[2], 0        , texture_YZp);
  if(nodes_x > 1) displayGridYZ(shp_grid[3], normals[3], nodes_x-1, texture_YZn);
                  displayGridXZ(shp_grid[4], normals[4], 0        , texture_XZp);
  if(nodes_y > 1) displayGridXZ(shp_grid[5], normals[5], nodes_y-1, texture_XZn);
  return shp;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:25,代码来源:DwSoftGrid3D.java

示例13: updateParticleShapeTransforms

import processing.core.PShape; //导入依赖的package包/类
@Deprecated
static final public void updateParticleShapeTransforms(World world, PShape group_particles, boolean rotate){
  
  int shp_count = group_particles.getChildCount();
  if(shp_count == 0){
    return;
  }
  PShape[] shp_particles = group_particles.getChildren();
  
  int count = world.getParticleCount();
  if (count == 0) return;

  if( count != shp_count ){
    System.out.println("ERROR: Box2dUtils.updateParticleShapeTransforms: particles numbers dont match "+count+" != "+shp_count);
    count = Math.min(count, shp_count);
  }
  
  Vec2[] pos = world.getParticlePositionBuffer();
  Vec2[] vel = world.getParticleVelocityBuffer();
  
  if(rotate){
    for (int i = 0; i < count; i++) {
      shp_particles[i].resetMatrix();
      shp_particles[i].rotate((float)Math.atan2(vel[i].y, vel[i].x));
      shp_particles[i].translate(pos[i].x, pos[i].y);
    }
  } else {
    for (int i = 0; i < count; i++) {
      shp_particles[i].resetMatrix();
      shp_particles[i].translate(pos[i].x, pos[i].y);
    }
  }
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:34,代码来源:DwUtils.java

示例14: updateParticleShapeBuffer

import processing.core.PShape; //导入依赖的package包/类
@Deprecated
static final public int updateParticleShapeBuffer(World world, PShape group_particles){
  int particle_num_old = world.getParticleCount();
  int particle_num_new = 0;
  
  if(particle_num_old == 0){
    return 0;
  }
  
  if(group_particles.getChildCount() == 0){
    return 0;
  }
  
  // The following is way faster, then removing shapes in place.
  // ... even when iterating backwards, a lot of repeated/unnecessary copying 
  // will be needed.

  PShape group = group_particles;
  PShape[] shapes = group.getChildren();
  int[] particle_flag = world.getParticleFlagsBuffer();
  

  // re-map particles, so that zombies are left out
  for(int i = 0; i < particle_num_old; i++){
    if((particle_flag[i] & ParticleType.b2_zombieParticle) == 0){
      shapes[particle_num_new++] = shapes[i];
    }
  }
  
  // remove number of zombies by triming the buffer to the new size
  // unfortunately PShape offers no better way to do this
  for(int i = particle_num_old - 1; i >= particle_num_new; i--){
    group.removeChild(i);
  }
  
  
  int removed = particle_num_old - particle_num_new;
  
  return removed;
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:41,代码来源:DwUtils.java

示例15: replaceShape

import processing.core.PShape; //导入依赖的package包/类
public void replaceShape(PShape shape_new){
  int idx = parent.shape.getChildIndex(shape);
  if(idx != -1){
    parent.shape.removeChild(idx);
  }
  shape = shape_new;
  parent.shape.addChild(shape);
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:9,代码来源:DwFixture.java


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