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


Java RayCastOutput类代码示例

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


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

示例1: raycast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
@Override
public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) {
  assert (childIndex < m_count);

  final EdgeShape edgeShape = pool0;

  int i1 = childIndex;
  int i2 = childIndex + 1;
  if (i2 == m_count) {
    i2 = 0;
  }
  Vec2 v = m_vertices[i1];
  edgeShape.m_vertex1.x = v.x;
  edgeShape.m_vertex1.y = v.y;
  Vec2 v1 = m_vertices[i2];
  edgeShape.m_vertex2.x = v1.x;
  edgeShape.m_vertex2.y = v1.y;

  return edgeShape.raycast(output, input, xf, 0);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:21,代码来源:ChainShape.java

示例2: raycastCallback

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
public float raycastCallback(final RayCastInput input,
		DynamicTreeNode proxyId) {
	Actor actor = (Actor) proxyId.userData;

	RayCastOutput output = new RayCastOutput();
	boolean hit = actor.aabb.raycast(output, input, m_world.getPool());

	if (hit) {
		m_rayCastOutput = output;
		m_rayActor = actor;
		m_rayActor.fraction = output.fraction;
		return output.fraction;
	}

	return input.maxFraction;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:DynamicTreeTest.java

示例3: raycast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
@Override
public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) {
  assert (childIndex < m_count);

  final EdgeShape edgeShape = pool0;

  int i1 = childIndex;
  int i2 = childIndex + 1;
  if (i2 == m_count) {
    i2 = 0;
  }
  Vector2 v = m_vertices[i1];
  edgeShape.m_vertex1.x = v.x;
  edgeShape.m_vertex1.y = v.y;
  Vector2 v1 = m_vertices[i2];
  edgeShape.m_vertex2.x = v1.x;
  edgeShape.m_vertex2.y = v1.y;

  return edgeShape.raycast(output, input, xf, 0);
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:21,代码来源:ChainShape.java

示例4: raycastCallback

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
public float raycastCallback(final RayCastInput input,
		int proxyId) {
	Actor actor = (Actor) m_tree.getUserData(proxyId);

	RayCastOutput output = new RayCastOutput();
	boolean hit = actor.aabb.raycast(output, input, getWorld().getPool());

	if (hit) {
		m_rayCastOutput = output;
		m_rayActor = actor;
		m_rayActor.fraction = output.fraction;
		return output.fraction;
	}

	return input.maxFraction;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:17,代码来源:DynamicTreeTest.java

示例5: raycastCallback

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
public float raycastCallback(final RayCastInput input,
		DynamicTreeNode proxyId) {
	Actor actor = (Actor) proxyId.userData;

	RayCastOutput output = new RayCastOutput();
	boolean hit = actor.aabb.raycast(output, input, getWorld().getPool());

	if (hit) {
		m_rayCastOutput = output;
		m_rayActor = actor;
		m_rayActor.fraction = output.fraction;
		return output.fraction;
	}

	return input.maxFraction;
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:17,代码来源:DynamicTreeTest.java

示例6: raycast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
/**
 * @see Shape#raycast(org.jbox2d.collision.RayCastOutput,
 *      org.jbox2d.collision.RayCastInput, org.jbox2d.common.Transform, int)
 */
@Override
public final boolean raycast(RayCastOutput argOutput, RayCastInput argInput, Transform argTransform) {
	
	final Vec2 position = pool1;
	final Vec2 s = pool2;
	final Vec2 r = pool3;
	
	Mat22.mulToOut(argTransform.R, m_p, position);
	position.addLocal(argTransform.position);
	s.set(argInput.p1).subLocal(position);
	final float b = Vec2.dot(s, s) - m_radius * m_radius;
	
	// Solve quadratic equation.
	r.set(argInput.p2).subLocal(argInput.p1);
	final float c = Vec2.dot(s, r);
	final float rr = Vec2.dot(r, r);
	final float sigma = c * c - rr * b;
	
	// Check for negative discriminant and short segment.
	if (sigma < 0.0f || rr < Settings.EPSILON) {
		return false;
	}
	
	// Find the point of intersection of the line with the circle.
	float a = -(c + MathUtils.sqrt(sigma));
	
	// Is the intersection point on the segment?
	if (0.0f <= a && a <= argInput.maxFraction * rr) {
		a /= rr;
		argOutput.fraction = a;
		argOutput.normal.set(r).mulLocal(a);
		argOutput.normal.addLocal(s);
		argOutput.normal.normalize();
		return true;
	}
	
	return false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:43,代码来源:CircleShape.java

示例7: initTest

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
/**
 * @see org.jbox2d.testbed.framework.TestbedTest#initTest()
 */
@Override
public void initTest() {
	worldExtent = 15.0f;
	m_proxyExtent = 0.5f;

	m_tree = new DynamicTree();

	for (int i = 0; i < e_actorCount; ++i) {
		Actor actor = m_actors[i] = new Actor();
		GetRandomAABB(actor.aabb);
		actor.proxyId = m_tree.createProxy(actor.aabb, actor);
	}

	m_stepCount = 0;

	float h = worldExtent;
	m_queryAABB = new AABB();
	m_queryAABB.lowerBound.set(-3.0f, -4.0f + h);
	m_queryAABB.upperBound.set(5.0f, 6.0f + h);

	m_rayCastInput = new RayCastInput();
	m_rayCastInput.p1.set(-5.0f, 5.0f + h);
	m_rayCastInput.p2.set(7.0f, -4.0f + h);
	// m_rayCastInput.p1.set(0.0f, 2.0f + h);
	// m_rayCastInput.p2.set(0.0f, -2.0f + h);
	m_rayCastInput.maxFraction = 1.0f;

	m_rayCastOutput = new RayCastOutput();

	m_automated = false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:DynamicTreeTest.java

示例8: RayCast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
public void RayCast() {
	m_rayActor = null;

	RayCastInput input = m_rayCastInput;

	// Ray cast against the dynamic tree.
	m_tree.raycast(this, input);

	// Brute force ray cast.
	Actor bruteActor = null;
	RayCastOutput bruteOutput = new RayCastOutput();
	for (int i = 0; i < e_actorCount; ++i) {
		if (m_actors[i].proxyId == null) {
			continue;
		}

		RayCastOutput output = new RayCastOutput();
		boolean hit = m_actors[i].aabb.raycast(output, input,
				m_world.getPool());
		if (hit) {
			bruteActor = m_actors[i];
			bruteOutput = output;
		    //input.set(m_rayCastInput);
		}
	}

	if (bruteActor != null) {
		assert (MathUtils.abs(bruteOutput.fraction
				- m_rayCastOutput.fraction) <= Settings.EPSILON);
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:DynamicTreeTest.java

示例9: initTest

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
@Override
public void initTest(boolean argDeserialized) {
	worldExtent = 15.0f;
	m_proxyExtent = 0.5f;

	m_tree = new DynamicTree();

	for (int i = 0; i < e_actorCount; ++i) {
		Actor actor = m_actors[i] = new Actor();
		GetRandomAABB(actor.aabb);
		actor.proxyId = m_tree.createProxy(actor.aabb, actor);
	}

	m_stepCount = 0;

	float h = worldExtent;
	m_queryAABB = new AABB();
	m_queryAABB.lowerBound.set(-3.0f, -4.0f + h);
	m_queryAABB.upperBound.set(5.0f, 6.0f + h);

	m_rayCastInput = new RayCastInput();
	m_rayCastInput.p1.set(-5.0f, 5.0f + h);
	m_rayCastInput.p2.set(7.0f, -4.0f + h);
	// m_rayCastInput.p1.set(0.0f, 2.0f + h);
	// m_rayCastInput.p2.set(0.0f, -2.0f + h);
	m_rayCastInput.maxFraction = 1.0f;

	m_rayCastOutput = new RayCastOutput();

	m_automated = false;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:32,代码来源:DynamicTreeTest.java

示例10: RayCast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
public void RayCast() {
	m_rayActor = null;

	RayCastInput input = new RayCastInput();
	input.set(m_rayCastInput);

	// Ray cast against the dynamic tree.
	m_tree.raycast(this, input);

	// Brute force ray cast.
	Actor bruteActor = null;
	RayCastOutput bruteOutput = new RayCastOutput();
	for (int i = 0; i < e_actorCount; ++i) {
		if (m_actors[i].proxyId == -1) {
			continue;
		}

		RayCastOutput output = new RayCastOutput();
		boolean hit = m_actors[i].aabb.raycast(output, input,
				getWorld().getPool());
		if (hit) {
			bruteActor = m_actors[i];
			bruteOutput = output;
			input.maxFraction = output.fraction;
		}
	}

	if (bruteActor != null) {
	  if(MathUtils.abs(bruteOutput.fraction
                   - m_rayCastOutput.fraction) > Settings.EPSILON) {
	    System.out.println("wrong!");
	    assert (MathUtils.abs(bruteOutput.fraction
             - m_rayCastOutput.fraction) <= 20 * Settings.EPSILON);
	  }
		
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:38,代码来源:DynamicTreeTest.java

示例11: initTest

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
/**
 * @see org.jbox2d.testbed.framework.TestbedTest#initTest(boolean)
 */
@Override
public void initTest(boolean argDeserialized) {
	worldExtent = 15.0f;
	m_proxyExtent = 0.5f;

	m_tree = new DynamicTree();

	for (int i = 0; i < e_actorCount; ++i) {
		Actor actor = m_actors[i] = new Actor();
		GetRandomAABB(actor.aabb);
		actor.proxyId = m_tree.createProxy(actor.aabb, actor);
	}

	m_stepCount = 0;

	float h = worldExtent;
	m_queryAABB = new AABB();
	m_queryAABB.lowerBound.set(-3.0f, -4.0f + h);
	m_queryAABB.upperBound.set(5.0f, 6.0f + h);

	m_rayCastInput = new RayCastInput();
	m_rayCastInput.p1.set(-5.0f, 5.0f + h);
	m_rayCastInput.p2.set(7.0f, -4.0f + h);
	// m_rayCastInput.p1.set(0.0f, 2.0f + h);
	// m_rayCastInput.p2.set(0.0f, -2.0f + h);
	m_rayCastInput.maxFraction = 1.0f;

	m_rayCastOutput = new RayCastOutput();

	m_automated = false;
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:35,代码来源:DynamicTreeTest.java

示例12: RayCast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
public void RayCast() {
	m_rayActor = null;

	RayCastInput input = new RayCastInput();
	input.set(m_rayCastInput);

	// Ray cast against the dynamic tree.
	m_tree.raycast(this, input);

	// Brute force ray cast.
	Actor bruteActor = null;
	RayCastOutput bruteOutput = new RayCastOutput();
	for (int i = 0; i < e_actorCount; ++i) {
		if (m_actors[i].proxyId == null) {
			continue;
		}

		RayCastOutput output = new RayCastOutput();
		boolean hit = m_actors[i].aabb.raycast(output, input,
				getWorld().getPool());
		if (hit) {
			bruteActor = m_actors[i];
			bruteOutput = output;
			input.maxFraction = output.fraction;
		    //input.set(m_rayCastInput);
		}
	}

	if (bruteActor != null) {
		assert (MathUtils.abs(bruteOutput.fraction
				- m_rayCastOutput.fraction) <= Settings.EPSILON);
	}
}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:34,代码来源:DynamicTreeTest.java

示例13: raycast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
@Override
public boolean raycast(RayCastOutput output, RayCastInput input, Transform transform, int childIndex) {
    return false;
}
 
开发者ID:cburschka,项目名称:PhysLayout,代码行数:5,代码来源:ShapelessShape.java

示例14: raycast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
/**
 * Cast a ray against a child shape.
 * 
 * @param argOutput the ray-cast results.
 * @param argInput the ray-cast input parameters.
 * @param argTransform the transform to be applied to the shape.
 * @param argChildIndex the child shape index
 * @return if hit
 */
public abstract boolean raycast(RayCastOutput output, RayCastInput input, Transform transform,
    int childIndex);
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:12,代码来源:Shape.java

示例15: raycast

import org.jbox2d.collision.RayCastOutput; //导入依赖的package包/类
/**
 * Cast a ray against this shape.
 * 
 * @param output the ray-cast results.
 * @param input the ray-cast input parameters.
 * @param output
 * @param input
 */
public boolean raycast(RayCastOutput output, RayCastInput input, int childIndex) {
  return m_shape.raycast(output, input, m_body.m_xf, childIndex);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:12,代码来源:Fixture.java


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