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


Java PShape.addChild方法代码示例

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


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

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

示例2: createShapeParticles

import processing.core.PShape; //导入方法依赖的package包/类
@Override
  public void createShapeParticles(PApplet papplet, boolean icosahedron){
    PShape shp = papplet.createShape(PShape.GROUP);
    for(int i = 0; i < particles.length; i++){
      
      float radius = 1;
//      float radius = particles[i].rad;
      PShape shp_pa = createShape(papplet, radius, icosahedron);
      particles[i].setShape(shp_pa);
      shp.addChild(shp_pa);
    }
    setShapeParticles(papplet, shp);
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:14,代码来源:DwSoftBody3D.java

示例3: createShapeParticles

import processing.core.PShape; //导入方法依赖的package包/类
@Override
  public void createShapeParticles(PApplet papplet, boolean icosahedron){
    PShape shp = papplet.createShape(PShape.GROUP);
    for(int i = 0; i < particles.length; i++){
      float radius = 1;
//      float radius = particles[i].rad;
      PShape shp_pa = createShape(papplet, radius);
      particles[i].setShape(shp_pa);
      shp.addChild(shp_pa);
    }
    setShapeParticles(papplet, shp);
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:13,代码来源:DwSoftBody2D.java

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

示例5: createParticleShape

import processing.core.PShape; //导入方法依赖的package包/类
public PShape createParticleShape(DwParticle2D particle){
  
  final float rad = particle.rad;

  PShape shp_particle = papplet.createShape(PShape.GROUP);
  
  // compute circle resolution, depending on the radius we reduce/increase
  // the number of vertices we need to render
  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);
  
  // actual circle
  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) * 1;
    float vy = (float) Math.sin(i * 2*Math.PI/num_vtx) * 1;
    circle.vertex(vx, vy);
  }
  circle.endShape(PConstants.CLOSE);

  // line, to indicate the velocity-direction of the particle
  PShape line = papplet.createShape(PShape.GEOMETRY);
  line.beginShape(PConstants.LINES);
  line.stroke(255, 100);
  line.strokeWeight(1f/rad);
  line.vertex(0, 0);
  line.vertex(-1, 0);
  line.endShape();
  
  shp_particle.addChild(circle);
  shp_particle.addChild(line);
  
  return shp_particle;
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:44,代码来源:ParticleSystem.java

示例6: createVoronoiCellShape

import processing.core.PShape; //导入方法依赖的package包/类
public PShape createVoronoiCellShape(WB_VoronoiCell3D cell, Vector3f center_of_mass){
    
 
    boolean[] on_bounds = cell.getVerticesOnBoundary();
    
    PShape voronoi_cell = createShape(GROUP);
    
    WB_Mesh mesh = cell.getMesh();
    int[][] faces = mesh.getFacesAsInt();

    int on_boundary = 0;
    for(int j = 0; j < faces.length; j++){
      int[] face = faces[j];
      WB_Vector normal = mesh.getFaceNormal(j);
      
      PShape polygon = createShape();

      polygon.beginShape(POLYGON);
      polygon.normal(normal.xf(), normal.yf(), normal.zf());
      
      for(int k = 0; k < face.length; k++){
        WB_Coord vtx = mesh.getVertex(face[k]);
        
        float x = vtx.xf() - center_of_mass.x;
        float y = vtx.yf() - center_of_mass.y;
        float z = vtx.zf() - center_of_mass.z;
        polygon.vertex(x,y,z);
        
        if(on_bounds[face[k]]){
          on_boundary++;
        }
      }
      
      polygon.endShape(CLOSE);
//      polygon.setFill(true);
//      if(on_boundary == face.length){
//      if(on_boundary > 0){
//        polygon.setFill(color(8));
//      } else {
//        polygon.setFill(color(255,0,0));
//      }
//    
//      polygon.setStroke(false);
      
      
      voronoi_cell.addChild(polygon);
    }

    String wire = "";
    voronoi_cell.setFill(true);
//    if(on_boundary == face.length){
    if(on_boundary > 0){
      voronoi_cell.setFill(color(32));
      wire = "[wire]";
    } else {
      voronoi_cell.setFill(color(255,8,0));
    }
  
    voronoi_cell.setStroke(false);
    voronoi_cell.setStroke(color(64,4,0));
    voronoi_cell.setName("[cvh] "+wire);

    return voronoi_cell;
  }
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:65,代码来源:Skylight_BulletPhysics_CellFracture.java


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