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


Java RayCastCallback类代码示例

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


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

示例1: raycast

import org.jbox2d.callbacks.RayCastCallback; //导入依赖的package包/类
@Override
public IPhysicsBody raycast(final Vector2f start, Vector2f target, final RaycastFilter filter) {
	final RaycastCbClosure c = new RaycastCbClosure();
	final RayCastCallback callback = new RayCastCallback() {
		@Override public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal,
				float fraction) {
			if( fixture.isSensor() || !(fixture.m_body.getUserData() instanceof Box2dPhysicsBody) )
				return -1;
			
			IPhysicsBody b = (IPhysicsBody) fixture.m_body.getUserData();
			
			if( filter.accept(b) ) {
				c.update(start, b);
			}
			return -1;
		}
	};
	
	physicsWorld.raycast(callback, Box2dPhysicsBody.toBox2dCS(start.x, start.y), Box2dPhysicsBody.toBox2dCS(target.x, target.y));
	
	return c.foundBody;
}
 
开发者ID:lowkey42,项目名称:java-jumpandrun-dev,代码行数:23,代码来源:Box2dPhysicalWorld.java

示例2: raycast

import org.jbox2d.callbacks.RayCastCallback; //导入依赖的package包/类
/**
 * Ray-cast the world for all fixtures and particles in the path of the ray. Your callback
 * controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes
 * that contain the starting point.
 * 
 * @param callback a user implemented callback class.
 * @param particleCallback the particle callback class.
 * @param point1 the ray starting point
 * @param point2 the ray ending point
 */
public void raycast(RayCastCallback callback, ParticleRaycastCallback particleCallback,
    Vec2 point1, Vec2 point2) {
  wrcwrapper.broadPhase = m_contactManager.m_broadPhase;
  wrcwrapper.callback = callback;
  input.maxFraction = 1.0f;
  input.p1.set(point1);
  input.p2.set(point2);
  m_contactManager.m_broadPhase.raycast(wrcwrapper, input);
  m_particleSystem.raycast(particleCallback, point1, point2);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:21,代码来源:World.java

示例3: RaycastAll

import org.jbox2d.callbacks.RayCastCallback; //导入依赖的package包/类
public static RaycastHitInformation[] RaycastAll(Vector2 start, Vector2 end)
{
	final ArrayList<RaycastHitInformation> information = new ArrayList<RaycastHitInformation>();

	RayCastCallback callback = new RayCastCallback()
	{

		@Override
		public float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) {
			// System.out.println("hit an object in reportFixture");
			RaycastHitInformation info = new RaycastHitInformation();
			info.hit = true;
			info.hitObject = ((GameObject) fixture.getUserData());
			info.normal = new Vector2(normal.x, normal.y);
			info.point = new Vector2(point.x, point.y);
			info.fraction = fraction;

			information.add(info);

			return fraction;
		}
	};
	Game.world.raycast(callback, new Vec2( start.x, start.y ), new Vec2( end.x, end.y ) );
	RaycastHitInformation[] toReturn = new RaycastHitInformation[ information.size() ];
	for(int i = 0; i < information.size(); i++)
	{
		toReturn[i] = information.get(i);
	}
	return toReturn;
}
 
开发者ID:Joshuagollaher,项目名称:HawkEngine,代码行数:31,代码来源:Physics.java

示例4: raycast

import org.jbox2d.callbacks.RayCastCallback; //导入依赖的package包/类
/**
 * Ray-cast the world for all fixtures in the path of the ray. Your callback
 * controls whether you get the closest point, any point, or n-points.
 * The ray-cast ignores shapes that contain the starting point.
 * 
 * @param callback
 *            a user implemented callback class.
 * @param point1
 *            the ray starting point
 * @param point2
 *            the ray ending point
 */
public void raycast(RayCastCallback callback, Vec2 point1, Vec2 point2) {
	wrcwrapper.broadPhase = m_contactManager.m_broadPhase;
	wrcwrapper.callback = callback;
	input.maxFraction = 1.0f;
	input.p1.set(point1);
	input.p2.set(point2);
	m_contactManager.m_broadPhase.raycast(wrcwrapper, input);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:World.java

示例5: raycast

import org.jbox2d.callbacks.RayCastCallback; //导入依赖的package包/类
/**
 * Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you
 * get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the
 * starting point.
 * 
 * @param callback a user implemented callback class.
 * @param point1 the ray starting point
 * @param point2 the ray ending point
 */
public void raycast(RayCastCallback callback, Vector2 point1, Vector2 point2) {
  wrcwrapper.broadPhase = m_contactManager.m_broadPhase;
  wrcwrapper.callback = callback;
  input.maxFraction = 1.0f;
  input.p1.set(point1);
  input.p2.set(point2);
  m_contactManager.m_broadPhase.raycast(wrcwrapper, input);
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:18,代码来源:World.java

示例6: raycast

import org.jbox2d.callbacks.RayCastCallback; //导入依赖的package包/类
/**
 * Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you
 * get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the
 * starting point.
 * 
 * @param callback a user implemented callback class.
 * @param point1 the ray starting point
 * @param point2 the ray ending point
 */
public void raycast(RayCastCallback callback, Vec2 point1, Vec2 point2) {
  wrcwrapper.broadPhase = m_contactManager.m_broadPhase;
  wrcwrapper.callback = callback;
  input.maxFraction = 1.0f;
  input.p1.set(point1);
  input.p2.set(point2);
  m_contactManager.m_broadPhase.raycast(wrcwrapper, input);
}
 
开发者ID:weimingtom,项目名称:jbox2d,代码行数:18,代码来源:World.java


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