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


Java Filter类代码示例

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


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

示例1: Create

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
@Override
public void Create()
{
    BodyDef def = new BodyDef();
    def.position.set(new Vec2(x, y));
    def.type = type;
    def.angle = 0;
    this.body = Game.world.createBody(def);
    PolygonShape shape = new PolygonShape();
    shape.setAsBox(w/2, h/2);
    FixtureDef fixture = new FixtureDef();
    Filter filter = new Filter();
    filter.groupIndex = 1;
    fixture.density = 0.1f;
    fixture.setShape(shape);
    fixture.setFilter(filter);
    fixture.isSensor = false;
    fixture.setFriction(0.5f);
    fixture.friction = 1;
    fixture.setUserData(this.sprite);
    Physics.SetPhysicsAccordingly(this.body, fixture, information);
    body.createFixture(fixture);
}
 
开发者ID:Joshuagollaher,项目名称:HawkEngine,代码行数:24,代码来源:SpritePhysics.java

示例2: GroundPhysics

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
public GroundPhysics(float x, float y, float w, float h, BodyType type, Ground ground)
{
	super(new PhysicsInformation(0, 0, false));
	BodyDef def = new BodyDef();
	def.position.set(new Vec2(x, y));
	def.type = type;
	def.angle = 0;
	this.body = Game.world.createBody(def);
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(w/2, h/2);
	FixtureDef fixture = new FixtureDef();
	Filter filter = new Filter();
	filter.groupIndex = 1;
	fixture.density = 0.1f;
	fixture.setShape(shape);
	fixture.setFilter(filter);
	fixture.isSensor = false;
	fixture.setFriction(0.5f);
	fixture.restitution = 0;
	fixture.density = 1;
	fixture.friction = 1;
	fixture.setUserData(ground);
	body.createFixture(fixture);
}
 
开发者ID:Joshuagollaher,项目名称:HawkEngine,代码行数:25,代码来源:GroundPhysics.java

示例3: Create

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
@Override
public void Create()
{
	BodyDef def = new BodyDef();
	def.position.set(new Vec2(x, y));
	def.type = type;
	def.angle = 0;
	this.body = Game.world.createBody(def);
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(w/2, h/2);
	FixtureDef fixture = new FixtureDef();
	Filter filter = new Filter();
	filter.groupIndex = 1;
	fixture.density = 0.1f;
	fixture.setShape(shape);
	fixture.setFilter(filter);
	fixture.isSensor = false;
	fixture.setFriction(0.5f);
	fixture.friction = 1;
	fixture.setUserData(box);
	//Physics.SetPhysicsAccordingly(this.body, fixture, information);
	body.createFixture(fixture);
}
 
开发者ID:Joshuagollaher,项目名称:HawkEngine,代码行数:24,代码来源:BoxPhysics.java

示例4: shouldCollide

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
/**
 * Return true if contact calculations should be performed between these two shapes.
 * @warning for performance reasons this is only called when the AABBs begin to overlap.
 * @param fixtureA
 * @param fixtureB
 * @return
 */
public boolean shouldCollide(Fixture fixtureA, Fixture fixtureB){
	Filter filterA = fixtureA.getFilterData();
	Filter filterB = fixtureB.getFilterData();

	if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0){
		return filterA.groupIndex > 0;
	}

	boolean collide = (filterA.maskBits & filterB.categoryBits) != 0 &&
					  (filterA.categoryBits & filterB.maskBits) != 0;
	return collide;
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:20,代码来源:ContactFilter.java

示例5: serializeFilter

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
public PbFilter.Builder serializeFilter(Filter argFilter) {
  PbFilter.Builder builder = PbFilter.newBuilder();
  builder.setCategoryBits(argFilter.categoryBits);
  builder.setGroupIndex(argFilter.groupIndex);
  builder.setMaskBits(argFilter.maskBits);

  return builder;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:9,代码来源:PbSerializer.java

示例6: setGround

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
private void setGround() {
    BodyDef bd = new BodyDef();
    bd.position.set(Math.max(-groundLength / 2, -10), 0f);
    bd.type = BodyType.STATIC;

    // add chain segments to the ground
    ChainShape shape = new ChainShape();

    ArrayList<Vec2> groundVertices = new ArrayList<Vec2>();

    for (int i = 0; i < groundLength / 5; ++i) {
        Vec2 segment = new Vec2((float) 5 * i, 0f);
        groundVertices.add(segment);
    }

    Vec2[] spec = {};

    shape.createChain(groundVertices.toArray(spec), groundVertices.size());

    FixtureDef fd = new FixtureDef();
    fd.shape = shape;
    Filter filter = new Filter();
    filter.groupIndex = 1;
    fd.filter = filter;
    fd.friction = 0.3f;
    fd.restitution = 0.5f;

    // create the body and add fixture to it
    Body body = world.createBody(bd);
    body.createFixture(fd);
    body.setUserData(new GroundUserData());
}
 
开发者ID:corazza,项目名称:Robot-Evolution,代码行数:33,代码来源:Simulation.java

示例7: setPart

import org.jbox2d.dynamics.Filter; //导入依赖的package包/类
private Body setPart(Part part) {
        // body definition
        BodyDef bd = new BodyDef();
        bd.position.set(0f, -5f);
        bd.angle = 0f;
        // bd.angularDamping = 0.5f;
        bd.type = BodyType.DYNAMIC;

        // define shape of the body.
        PolygonShape Shape = new PolygonShape();
        Shape.setAsBox(part.width / 2, part.height / 2);

        // define fixture of the body.
        FixtureDef fd = new FixtureDef();
        Filter filter = new Filter();
        filter.groupIndex = -1;
        fd.filter = filter;
        fd.shape = Shape;
        fd.density = 0.5f;
        fd.friction = 0.3f;
        fd.restitution = 0.5f;

        // create the body and add fixture to it
        Body body = world.createBody(bd);
        body.createFixture(fd);

        PartUserData userData = new PartUserData();
        userData.chromosome = chromosome;

        body.setUserData(userData);

//        body.m_angularDamping = 0.05f;

        return body;
    }
 
开发者ID:corazza,项目名称:Robot-Evolution,代码行数:36,代码来源:Robot.java


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