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


Java Collision类代码示例

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


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

示例1: DefaultWorldPool

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public DefaultWorldPool(int argSize, int argContainerSize) {
  vecs = new OrderedStack<Vec2>(argSize, argContainerSize) {
    protected Vec2 newInstance() { return new Vec2(); }
  };
  vec3s = new OrderedStack<Vec3>(argSize, argContainerSize) {
    protected Vec3 newInstance() { return new Vec3(); }
  };
  mats = new OrderedStack<Mat22>(argSize, argContainerSize) {
    protected Mat22 newInstance() { return new Mat22(); }
  };
  aabbs = new OrderedStack<AABB>(argSize, argContainerSize) {
    protected AABB newInstance() { return new AABB(); }
  };
  rots = new OrderedStack<Rot>(argSize, argContainerSize) {
    protected Rot newInstance() { return new Rot(); }
  };
  mat33s = new OrderedStack<Mat33>(argSize, argContainerSize) {
    protected Mat33 newInstance() { return new Mat33(); }
  };

  dist = new Distance();
  collision = new Collision(this);
  toi = new TimeOfImpact(this);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:25,代码来源:DefaultWorldPool.java

示例2: preSolve

import org.jbox2d.collision.Collision; //导入依赖的package包/类
/**
 * @see org.jbox2d.callbacks.ContactListener#preSolve(org.jbox2d.dynamics.contacts.Contact, org.jbox2d.collision.Manifold)
 */
public void preSolve(Contact contact, Manifold oldManifold) {
	Manifold manifold = contact.getManifold();
	
	if(manifold.pointCount == 0){
		return;
	}
	
	Fixture fixtureA = contact.getFixtureA();
	Fixture fixtureB = contact.getFixtureB();
	
	Collision.getPointStates(state1, state2, oldManifold, manifold);
	
	contact.getWorldManifold(worldManifold);
	
	for(int i=0; i<manifold.pointCount && m_pointCount < MAX_CONTACT_POINTS; i++){
		ContactPoint cp = points[m_pointCount];
		cp.fixtureA = fixtureA;
		cp.fixtureB = fixtureB;
		cp.position.set(worldManifold.points[i]);
		cp.normal.set(worldManifold.normal);
		cp.state = state2[i];
		++m_pointCount;
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:TestbedTest.java

示例3: DefaultWorldPool

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public DefaultWorldPool(int argSize, int argContainerSize) {
  vecs = new OrderedStack<Vector2>(argSize, argContainerSize) {
    protected Vector2 newInstance() { return new Vector2(); }
  };
  vec3s = new OrderedStack<Vector3>(argSize, argContainerSize) {
    protected Vector3 newInstance() { return new Vector3(); }
  };
  mats = new OrderedStack<Mat22>(argSize, argContainerSize) {
    protected Mat22 newInstance() { return new Mat22(); }
  };
  aabbs = new OrderedStack<AABB>(argSize, argContainerSize) {
    protected AABB newInstance() { return new AABB(); }
  };
  rots = new OrderedStack<Rot>(argSize, argContainerSize) {
    protected Rot newInstance() { return new Rot(); }
  };
  mat33s = new OrderedStack<Mat33>(argSize, argContainerSize) {
    protected Mat33 newInstance() { return new Mat33(); }
  };

  dist = new Distance();
  collision = new Collision(this);
  toi = new TimeOfImpact(this);
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:25,代码来源:DefaultWorldPool.java

示例4: preSolve

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public void preSolve(Contact contact, Manifold oldManifold) {
  Manifold manifold = contact.getManifold();

  if (manifold.pointCount == 0) {
    return;
  }

  Fixture fixtureA = contact.getFixtureA();
  Fixture fixtureB = contact.getFixtureB();

  Collision.getPointStates(state1, state2, oldManifold, manifold);

  contact.getWorldManifold(worldManifold);

  for (int i = 0; i < manifold.pointCount && pointCount < MAX_CONTACT_POINTS; i++) {
    ContactPoint cp = points[pointCount];
    cp.fixtureA = fixtureA;
    cp.fixtureB = fixtureB;
    cp.position.set(worldManifold.points[i]);
    cp.normal.set(worldManifold.normal);
    cp.state = state2[i];
    cp.normalImpulse = manifold.points[i].normalImpulse;
    cp.tangentImpulse = manifold.points[i].tangentImpulse;
    ++pointCount;
  }
}
 
开发者ID:weimingtom,项目名称:jbox2d,代码行数:27,代码来源:TestbedTest.java

示例5: preSolve

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public void preSolve(Contact contact, Manifold oldManifold) {
	Manifold manifold = contact.getManifold();

	if (manifold.pointCount == 0) {
		return;
	}

	Fixture fixtureA = contact.getFixtureA();
	Fixture fixtureB = contact.getFixtureB();

	Collision.getPointStates(state1, state2, oldManifold, manifold);

	contact.getWorldManifold(worldManifold);

	for (int i = 0; i < manifold.pointCount
			&& pointCount < MAX_CONTACT_POINTS; i++) {
		ContactPoint cp = points[pointCount];
		cp.fixtureA = fixtureA;
		cp.fixtureB = fixtureB;
		cp.position.set(worldManifold.points[i]);
		cp.normal.set(worldManifold.normal);
		cp.state = state2[i];
		++pointCount;
	}
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:26,代码来源:TestbedTest.java

示例6: WorldPool

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public WorldPool(int argSize, int argContainerSize){
	vecs = new OrderedStack<Vec2>(Vec2.class, argSize, argContainerSize);
	vec3s = new OrderedStack<Vec3>(Vec3.class, argSize, argContainerSize);
	mats = new OrderedStack<Mat22>(Mat22.class, argSize, argContainerSize);
	aabbs = new OrderedStack<AABB>(AABB.class, argSize, argContainerSize);
	
	dist = new Distance();
	collision = new Collision(this);
	toi = new TimeOfImpact(this);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:WorldPool.java

示例7: WorldPool

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public WorldPool(int argSize){
  vecs = new PoolingStackVec2(argSize);
  vec3s = new PoolingStackVec3(argSize);
  mats = new PoolingStackMat22(argSize);
  aabbs = new PoolingStackAABB(argSize);
	
	dist = new Distance();
	collision = new Collision(this);
	toi = new TimeOfImpact(this);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:11,代码来源:WorldPool.java

示例8: preSolve

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public void preSolve(Contact contact, Manifold oldManifold) {
  Manifold manifold = contact.getManifold();

  if (manifold.pointCount == 0) {
    return;
  }

  Fixture fixtureA = contact.getFixtureA();
  Fixture fixtureB = contact.getFixtureB();

  Collision.getPointStates(state1, state2, oldManifold, manifold);

  contact.getWorldManifold(worldManifold);

  for (int i = 0; i < manifold.pointCount && pointCount < MAX_CONTACT_POINTS; i++) {
    ContactPoint cp = points[pointCount];
    cp.fixtureA = fixtureA;
    cp.fixtureB = fixtureB;
    cp.position.set(worldManifold.points[i]);
    cp.normal.set(worldManifold.normal);
    cp.state = state2[i];
    cp.normalImpulse = manifold.points[i].normalImpulse;
    cp.tangentImpulse = manifold.points[i].tangentImpulse;
    cp.separation = worldManifold.separations[i];
    ++pointCount;
  }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:28,代码来源:TestbedTest.java

示例9: WorldPool

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public WorldPool(int argSize)
{
	vecs= new PoolingStackVec2(argSize);
	vec3s= new PoolingStackVec3(argSize);
	mats= new PoolingStackMat22(argSize);
	aabbs= new PoolingStackAABB(argSize);

	dist= new Distance();
	collision= new Collision(this);
	toi= new TimeOfImpact(this);
}
 
开发者ID:dragome,项目名称:dragome-examples,代码行数:12,代码来源:WorldPool.java

示例10: DefaultWorldPool

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public DefaultWorldPool(int argSize, int argContainerSize) {
  vecs = new OrderedStack<Vec2>(Vec2.class, argSize, argContainerSize);
  vec3s = new OrderedStack<Vec3>(Vec3.class, argSize, argContainerSize);
  mats = new OrderedStack<Mat22>(Mat22.class, argSize, argContainerSize);
  aabbs = new OrderedStack<AABB>(AABB.class, argSize, argContainerSize);

  dist = new Distance();
  collision = new Collision(this);
  toi = new TimeOfImpact(this);
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:11,代码来源:DefaultWorldPool.java

示例11: getCollision

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public final Collision getCollision() {
  return collision;
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:4,代码来源:DefaultWorldPool.java

示例12: testCollision

import org.jbox2d.collision.Collision; //导入依赖的package包/类
@Test
public void testCollision() {
    Collision theCollision = new Collision(null);
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:5,代码来源:JBox2DTest.java

示例13: getCollision

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public final Collision getCollision(){
	return collision;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:WorldPool.java

示例14: getCollision

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public Collision getCollision()
{
	return collision;
}
 
开发者ID:dragome,项目名称:dragome-examples,代码行数:5,代码来源:WorldPool.java

示例15: preSolve

import org.jbox2d.collision.Collision; //导入依赖的package包/类
public void preSolve(Contact contact, Manifold oldManifold) {
	//do not change world inside here (add/remove objects)
	
	StaticGameObject obja =(StaticGameObject)contact.m_fixtureA.m_body.m_userData;
	StaticGameObject objb =(StaticGameObject)contact.m_fixtureB.m_body.m_userData;
	
	//whether we must handle this impact, even if it was not newly added
	//in this step. setting handle_impact always to true would not cause
	//problems but would only lead to increased network traffic
	boolean handle_impact = false;
	
	if(obja.type == Type.Hole || objb.type == Type.Hole) {
		GamePlayer player = null;
		Fixture player_fixture = null;
		if(obja.type == Type.Player) {
			player = (GamePlayer) obja;
			player_fixture = contact.m_fixtureA;
		} else if(objb.type == Type.Player) {
			player = (GamePlayer) objb;
			player_fixture = contact.m_fixtureB;
		}
		if(player == null || player.m_item_type != ItemType.DontFall) {
			contact.setEnabled(false);
			if(player_fixture != null && player_fixture.m_userData != null) {
				//at this point we must handle the impact even if this conact
				//was not newly added. because the player had the DontFall
				//item, but not anymore.
				handle_impact = true;
				player_fixture.m_userData = null;
			}
		} else {
			//we have a player with the DontFall item: we need a flag to
			//remember this: simply use m_userData and set it to !=null
			player_fixture.m_userData = player_fixture;
		}
	} else if(obja.type == Type.Item || objb.type == Type.Item) {
		contact.setEnabled(false);
	}
	
	contact.getWorldManifold(m_tmp_world_manifold);
	Collision.getPointStates(m_tmp_state1, m_tmp_state2, oldManifold, contact.m_manifold);
	if (m_tmp_state2[0] == PointState.ADD_STATE || handle_impact) {
		
		if(m_impact_count >= m_impacts.length) { //need to resize
			Impact[] new_impacts = new Impact[m_impacts.length*2];
			for(int i=0; i<new_impacts.length; ++i) 
				new_impacts[i] = new Impact();
			for(int i=0; i<m_impact_count; ++i)
				m_impacts[i].copyTo(new_impacts[i]);
			m_impacts = new_impacts;
		}

		Vec2 impact_point = m_tmp_world_manifold.points[0];
		Vec2 normal = m_tmp_world_manifold.normal;
		
		m_impacts[m_impact_count].obja =(StaticGameObject)contact.m_fixtureA.m_body.m_userData;
		m_impacts[m_impact_count].objb =(StaticGameObject)contact.m_fixtureB.m_body.m_userData;
		m_impacts[m_impact_count].impact_point.set(impact_point.x, impact_point.y);
		m_impacts[m_impact_count].normal.set(normal.x, normal.y);
		++m_impact_count;
		
	}
}
 
开发者ID:bkueng,项目名称:clash_of_balls,代码行数:64,代码来源:GameBase.java


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