本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}