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


Java PShape.getChildCount方法代码示例

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


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

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

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

示例3: removeChilds

import processing.core.PShape; //导入方法依赖的package包/类
private void removeChilds(PShape shp){
  if(shp == null){
    return;
  }
  int num_childs = shp.getChildCount();
  for(int i = num_childs-1; i >= 0; i--){
    removeChilds(shp.getChild(i));
    shp.removeChild(i);
  }
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:11,代码来源:DwSoftBody.java

示例4: printChilds

import processing.core.PShape; //导入方法依赖的package包/类
protected void printChilds(PShape shp, String indent){
  if(shp == null){
    return;
  }
  int num_childs = shp.getChildCount();
  
  System.out.println(indent+shp.getName()+": "+num_childs);
  for(int i = num_childs-1; i >= 0; i--){
    printChilds(shp.getChild(i), indent+"  ");
  }
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:12,代码来源:DwSoftBody.java


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