本文整理匯總了Java中org.jbox2d.particle.ParticleType類的典型用法代碼示例。如果您正苦於以下問題:Java ParticleType類的具體用法?Java ParticleType怎麽用?Java ParticleType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ParticleType類屬於org.jbox2d.particle包,在下文中一共展示了ParticleType類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeLostParticles
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
/**
* removes particles outside the zombie_aabb from the world.
*/
public void removeLostParticles(){
if(zombie_aabb == null){
createZombieBounds();
}
int pcount = getParticleCount();
Vec2[] pverts = getParticlePositionBuffer();
int[] pflags = getParticleFlagsBuffer();
for(int i = 0; i < pcount; i++){
Vec2 vert = pverts[i];
if(vert.x < zombie_aabb.lowerBound.x || vert.x > zombie_aabb.upperBound.x ||
vert.y < zombie_aabb.lowerBound.y || vert.y > zombie_aabb.upperBound.y)
{
pflags[i] |= ParticleType.b2_zombieParticle;
// world.destroyParticle(i); // works also
}
}
}
示例2: step
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
@Override
public void step(TestbedSettings settings) {
super.step(settings);
Vec2 p = circle.getTransform().p;
Vec2 v = circle.getLinearVelocity();
if ((p.x < -10.0f && v.x < 0.0f) || (p.x > 10.0f && v.x > 0.0f)) {
v.x = -v.x;
circle.setLinearVelocity(v);
}
int[] flagsBuffer = m_world.getParticleFlagsBuffer();
for (int i = 0; i < m_world.getParticleCount(); i++) {
flagsBuffer[i] = flags;
}
addTextLine("'a' Clear");
addTextLine("'e' Elastic " + ((flags & ParticleType.b2_elasticParticle) != 0));
addTextLine("'q' Powder " + ((flags & ParticleType.b2_powderParticle) != 0));
addTextLine("'t' Tensile " + ((flags & ParticleType.b2_tensileParticle) != 0));
addTextLine("'v' Viscous " + ((flags & ParticleType.b2_viscousParticle) != 0));
}
示例3: updateParticleShapeBuffer
import org.jbox2d.particle.ParticleType; //導入依賴的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;
}
示例4: DwParticleSpawn
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public DwParticleSpawn(World world, DwViewportTransform transform){
this.world = world;
this.transform = transform;
this.pdestroyer = new DwParticleDestroyer(world, transform);
this.group_def = new ParticleGroupDef();
this.group_def.setColor(new Color3f(1,0.35f, 0.15f));
this.group_def.flags = ParticleType.b2_waterParticle | ParticleType.b2_viscousParticle;
this.group_def.groupFlags = 0;
setCircleShape(30);
}
示例5: keyPressed
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
@Override
public void keyPressed(char keyCar, int keyCode) {
super.keyPressed(keyCar, keyCode);
int toggle = 0;
switch (keyCar) {
case 'a':
flags = 0;
break;
case 'e':
toggle = ParticleType.b2_elasticParticle;
break;
case 'q':
toggle = ParticleType.b2_powderParticle;
break;
case 't':
toggle = ParticleType.b2_tensileParticle;
break;
case 'v':
toggle = ParticleType.b2_viscousParticle;
break;
}
if (toggle != 0) {
if ((flags & toggle) != 0) {
flags = flags & ~toggle;
} else {
flags = flags | toggle;
}
}
}
示例6: keyPressed
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void keyPressed(char keyChar, int keyCode) {
m_drawing = keyChar != 'x';
m_particleFlags = 0;
m_groupFlags = 0;
color.set((byte)127, (byte)127, (byte)127, (byte)50);
switch (keyChar) {
case 'e':
m_particleFlags = ParticleType.b2_elasticParticle;
m_groupFlags = ParticleGroupType.b2_solidParticleGroup;
break;
case 'p':
m_particleFlags = ParticleType.b2_powderParticle;
break;
case 'f':
m_groupFlags =
ParticleGroupType.b2_rigidParticleGroup | ParticleGroupType.b2_solidParticleGroup;
break;
case 's':
m_particleFlags = ParticleType.b2_springParticle;
m_groupFlags = ParticleGroupType.b2_solidParticleGroup;
break;
case 't':
color.set((byte)0, (byte)127, (byte)0, (byte)50);
m_particleFlags = ParticleType.b2_tensileParticle;
break;
case 'v':
color.set((byte)0, (byte)0, (byte)127, (byte)50);
m_particleFlags = ParticleType.b2_viscousParticle;
break;
case 'w':
m_particleFlags = ParticleType.b2_wallParticle;
m_groupFlags = ParticleGroupType.b2_solidParticleGroup;
break;
case 'z':
m_particleFlags = ParticleType.b2_zombieParticle;
break;
}
}
示例7: reset
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void reset(){
// release old resources
release();
// liquid effect
pixelflow = new DwPixelFlow(this);
particle_fluidfx = new DwLiquidFX(pixelflow);
// different render-targets for different bodies/particles/etc...
pg_liquid = (PGraphics2D) createGraphics(width, height, P2D);
pg_liquid.smooth(0);
pg_prigid = (PGraphics2D) createGraphics(width, height, P2D);
pg_prigid.smooth(0);
pg_bodies = (PGraphics2D) createGraphics(width, height, P2D);
pg_bodies.smooth(8);
// box2d/liquidfun world
world = new DwWorld(this, 15);
// particle render settings
world.particles.param.falloff_exp1 = 3f;
world.particles.param.falloff_exp2 = 1f;
world.particles.param.radius_scale = 2;
// callback to group particles by their properties (flags)
world.particles.setParticleRenderGroupCallback(new DwParticleRenderGroupCallback() {
@Override
public int getRenderGroupIndex(int particle_idx, ParticleGroup group, int particle_flag) {
int group_flag = group.getGroupFlags();
boolean is_wall = (particle_flag & ParticleType .b2_wallParticle ) != 0;
boolean is_solid = (group_flag & ParticleGroupType.b2_solidParticleGroup) != 0;
boolean is_rigid = (group_flag & ParticleGroupType.b2_rigidParticleGroup) != 0;
int group_id = 0;
if(is_wall || is_solid || is_rigid){
group_id = 1;
} else {
group_id = 0;
}
return group_id;
}
});
setParticleSpawnProperties(spawn_type);
// create scene: rigid bodies, particles, etc ...
initScene();
}
示例8: setParticleSpawnProperties
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void setParticleSpawnProperties(int type){
spawn_type = type;
int COLOR_MIX = 0;
// COLOR_MIX = ParticleType.b2_colorMixingParticle;
DwParticleSpawn particle_spawn = world.mouse_spawn_particles;
particle_spawn.join_groups = false;
particle_spawn.setCircleShape(30);
colorMode(HSB, 360, 100, 100);
float hsb_s = 100;
float hsb_b = 100;
switch (type) {
case 0:
particle_spawn.group_def.setColor(color(225, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_waterParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 1:
particle_spawn.group_def.setColor(color(100, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_viscousParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 2:
particle_spawn.group_def.setColor(color(0, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_tensileParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 3:
particle_spawn.group_def.setColor(color(60, hsb_s * 0.5f, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_powderParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 4:
particle_spawn.group_def.setColor(color(330, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_wallParticle;
particle_spawn.group_def.groupFlags = ParticleGroupType.b2_solidParticleGroup;
particle_spawn.join_groups = true;
particle_spawn.setCircleShape(20);
break;
}
colorMode(RGB, 255);
}
示例9: setParticleSpawnProperties
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void setParticleSpawnProperties(int type){
spawn_type = type;
int COLOR_MIX = 0;
// COLOR_MIX = ParticleType.b2_colorMixingParticle;
DwParticleSpawn particle_spawn = world.mouse_spawn_particles;
particle_spawn.join_groups = false;
particle_spawn.setCircleShape(40);
colorMode(HSB, 360, 100, 100);
switch (type) {
case 0:
particle_spawn.group_def.setColor(color(225, 96, 96));
particle_spawn.group_def.flags = ParticleType.b2_waterParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 1:
particle_spawn.group_def.setColor(color(100, 96, 96));
particle_spawn.group_def.flags = ParticleType.b2_viscousParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 2:
particle_spawn.group_def.setColor(color(5, 96, 96));
particle_spawn.group_def.flags = ParticleType.b2_tensileParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 3:
particle_spawn.group_def.setColor(color(70, 50, 96));
particle_spawn.group_def.flags = ParticleType.b2_powderParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 4:
particle_spawn.group_def.setColor(color(300, 96, 96));
// particle_spawn.group_def.flags = ParticleType.b2_elasticParticle | ParticleType.b2_springParticle | COLOR_MIX;
particle_spawn.group_def.flags = ParticleType.b2_elasticParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 5:
particle_spawn.group_def.setColor(color(120, 90, 50));
particle_spawn.group_def.flags = ParticleType.b2_wallParticle;
particle_spawn.group_def.groupFlags = ParticleGroupType.b2_solidParticleGroup;
particle_spawn.join_groups = true;
particle_spawn.setCircleShape(15);
break;
}
colorMode(RGB, 255);
}
示例10: setParticleSpawnProperties
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void setParticleSpawnProperties(int type){
spawn_type = type;
int COLOR_MIX = 0;
// COLOR_MIX = ParticleType.b2_colorMixingParticle;
DwParticleSpawn particle_spawn = world.mouse_spawn_particles;
particle_spawn.join_groups = false;
particle_spawn.setCircleShape(40);
colorMode(HSB, 360, 100, 100);
switch (type) {
case 0:
particle_spawn.group_def.setColor(color(225, 100, 100));
particle_spawn.group_def.flags = ParticleType.b2_waterParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 1:
particle_spawn.group_def.setColor(color(100, 100, 100));
particle_spawn.group_def.flags = ParticleType.b2_viscousParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 2:
particle_spawn.group_def.setColor(color(0, 100, 100));
particle_spawn.group_def.flags = ParticleType.b2_tensileParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 3:
particle_spawn.group_def.setColor(color(60, 50, 100));
particle_spawn.group_def.flags = ParticleType.b2_powderParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 4:
particle_spawn.group_def.setColor(color(330, 100, 100));
particle_spawn.group_def.flags = ParticleType.b2_wallParticle;
particle_spawn.group_def.groupFlags = ParticleGroupType.b2_solidParticleGroup;
particle_spawn.join_groups = true;
particle_spawn.setCircleShape(20);
break;
}
colorMode(RGB, 255);
}
示例11: reset
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void reset(){
// release old resources
release();
// liquid effect
pixelflow = new DwPixelFlow(this);
particle_fluidfx = new DwLiquidFX(pixelflow);
// different render-targets for different bodies/particles/etc...
pg_liquid = (PGraphics2D) createGraphics(width, height, P2D);
pg_liquid.smooth(0);
pg_prigid = (PGraphics2D) createGraphics(width, height, P2D);
pg_prigid.smooth(0);
pg_bodies = (PGraphics2D) createGraphics(width, height, P2D);
pg_bodies.smooth(8);
// box2d/liquidfun world
// world.INIT_GL_PARTICLES = false;
world = new DwWorld(this, 15);
// particle render settings
world.particles.param.falloff_exp1 = 3f;
world.particles.param.falloff_exp2 = 1f;
world.particles.param.radius_scale = 2;
// callback to group particles by their properties (flags)
world.particles.setParticleRenderGroupCallback(new DwParticleRenderGroupCallback() {
@Override
public int getRenderGroupIndex(int particle_idx, ParticleGroup group, int particle_flag) {
int group_flag = group.getGroupFlags();
boolean is_wall = (particle_flag & ParticleType .b2_wallParticle ) != 0;
boolean is_solid = (group_flag & ParticleGroupType.b2_solidParticleGroup) != 0;
boolean is_rigid = (group_flag & ParticleGroupType.b2_rigidParticleGroup) != 0;
int group_id = 0;
if(is_wall || is_solid || is_rigid){
group_id = 1;
} else {
group_id = 0;
}
return group_id;
}
});
setParticleSpawnProperties(spawn_type);
// create scene: rigid bodies, particles, etc ...
initScene();
}
示例12: setParticleSpawnProperties
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void setParticleSpawnProperties(int type){
spawn_type = type;
int COLOR_MIX = 0;
// COLOR_MIX = ParticleType.b2_colorMixingParticle;
DwParticleSpawn particle_spawn = world.mouse_spawn_particles;
particle_spawn.join_groups = false;
particle_spawn.setCircleShape(30);
colorMode(HSB, 360, 100, 100);
float hsb_s = 10;
float hsb_b = 20;
switch (type) {
case 0:
particle_spawn.group_def.setColor(color(225, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_waterParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 1:
particle_spawn.group_def.setColor(color(100, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_viscousParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 2:
particle_spawn.group_def.setColor(color(0, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_tensileParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 3:
particle_spawn.group_def.setColor(color(60, hsb_s * 0.5f, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_powderParticle | COLOR_MIX;
particle_spawn.group_def.groupFlags = 0;
break;
case 4:
particle_spawn.group_def.setColor(color(330, hsb_s, hsb_b));
particle_spawn.group_def.flags = ParticleType.b2_wallParticle;
particle_spawn.group_def.groupFlags = ParticleGroupType.b2_solidParticleGroup;
particle_spawn.join_groups = true;
particle_spawn.setCircleShape(20);
break;
}
colorMode(RGB, 255);
}
示例13: initScene
import org.jbox2d.particle.ParticleType; //導入依賴的package包/類
public void initScene() {
float dimx = world.transform.box2d_dimx;
float dimy = world.transform.box2d_dimy;
Vec2 ankerA = new Vec2();
Vec2 ankerB = new Vec2();
createChain(ankerA.set(-10, 10), ankerB.set(+15, 10), 0.5f, 0.5f);
createChain(ankerA.set(-10, 15), ankerB.set(-30, 20), 0.5f, 0.5f);
createChain(ankerA.set(-24,24), ankerB.set(24,26), 0.5f, 0.5f);
emitter0 = new DwParticleEmitter(world, world.transform);
emitter1 = new DwParticleEmitter(world, world.transform);
emitter2 = new DwParticleEmitter(world, world.transform);
emitter3 = new DwParticleEmitter(world, world.transform);
int flags = 0;
flags |= ParticleType.b2_waterParticle;
flags |= ParticleType.b2_viscousParticle;
// flags |= ParticleType.b2_colorMixingParticle;
float hsb_s = 100;
float hsb_b = 100;
colorMode(HSB, 360, 100, 100);
emitter0.setInScreen( 100, 100, 200, -40, color( 5, hsb_s, hsb_b), flags);
emitter1.setInScreen( 50, 50, 200, 0, color( 20, hsb_s, hsb_b), flags);
emitter2.setInScreen(1000, 100, 300, -175, color(115, hsb_s, hsb_b), flags);
emitter3.setInScreen(1100, 700, 400, 120, color(230, hsb_s, hsb_b), flags);
colorMode(RGB, 255);
}