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


Java Collision.getPointStates方法代码示例

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


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

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

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

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

示例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;
    cp.separation = worldManifold.separations[i];
    ++pointCount;
  }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:28,代码来源:TestbedTest.java

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