本文整理汇总了Java中com.jme3.collision.CollisionResults.addCollision方法的典型用法代码示例。如果您正苦于以下问题:Java CollisionResults.addCollision方法的具体用法?Java CollisionResults.addCollision怎么用?Java CollisionResults.addCollision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.collision.CollisionResults
的用法示例。
在下文中一共展示了CollisionResults.addCollision方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collideWith
import com.jme3.collision.CollisionResults; //导入方法依赖的package包/类
public int collideWith(Collidable other, CollisionResults results) {
if (other instanceof BoundingVolume) {
BoundingVolume bv = (BoundingVolume) other;
return bv.collideWith(this, results);
} else if (other instanceof AbstractTriangle) {
AbstractTriangle tri = (AbstractTriangle) other;
float d = intersects(tri.get1(), tri.get2(), tri.get3());
if (Float.isInfinite(d) || Float.isNaN(d)) {
return 0;
}
Vector3f point = new Vector3f(direction).multLocal(d).addLocal(origin);
results.addCollision(new CollisionResult(point, d));
return 1;
} else {
throw new UnsupportedCollisionException();
}
}
示例2: collideWith
import com.jme3.collision.CollisionResults; //导入方法依赖的package包/类
public int collideWith(Collidable other, CollisionResults results) {
if (other instanceof Ray) {
Ray ray = (Ray) other;
return collideWithRay(ray, results);
} else if (other instanceof Triangle) {
Triangle t = (Triangle) other;
if (intersects(t.get1(), t.get2(), t.get3())) {
CollisionResult r = new CollisionResult();
results.addCollision(r);
return 1;
}
return 0;
} else {
throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName());
}
}
示例3: intersectWhere
import com.jme3.collision.CollisionResults; //导入方法依赖的package包/类
public final void intersectWhere(Ray r, Geometry[] geoms, float sceneMin, float sceneMax,
CollisionResults results){
for (OCTTriangle t : tris){
float d = r.intersects(t.get1(), t.get2(), t.get3());
if (Float.isInfinite(d))
continue;
Vector3f contactPoint = new Vector3f(r.getDirection()).multLocal(d).addLocal(r.getOrigin());
CollisionResult result = new CollisionResult(geoms[t.getGeometryIndex()],
contactPoint,
d,
t.getTriangleIndex());
results.addCollision(result);
}
for (int i = 0; i < 8; i++){
Octnode child = children[i];
if (child == null)
continue;
if (child.bbox.intersects(r)){
child.intersectWhere(r, geoms, sceneMin, sceneMax, results);
}
}
}
示例4: collideWith
import com.jme3.collision.CollisionResults; //导入方法依赖的package包/类
public int collideWith(Collidable other, CollisionResults results) {
if (other instanceof Ray) {
Ray ray = (Ray) other;
return collideWithRay(ray, results);
} else if (other instanceof Triangle){
Triangle t = (Triangle) other;
float r2 = radius * radius;
float d1 = center.distanceSquared(t.get1());
float d2 = center.distanceSquared(t.get2());
float d3 = center.distanceSquared(t.get3());
if (d1 <= r2 || d2 <= r2 || d3 <= r2) {
CollisionResult r = new CollisionResult();
r.setDistance(FastMath.sqrt(Math.min(Math.min(d1, d2), d3)) - radius);
results.addCollision(r);
return 1;
}
return 0;
} else {
throw new UnsupportedCollisionException();
}
}
示例5: intersectBrute
import com.jme3.collision.CollisionResults; //导入方法依赖的package包/类
public final int intersectBrute(Ray r,
Matrix4f worldMatrix,
BIHTree tree,
float sceneMin,
float sceneMax,
CollisionResults results) {
float tHit = Float.POSITIVE_INFINITY;
Vector3f v1 = new Vector3f(),
v2 = new Vector3f(),
v3 = new Vector3f();
int cols = 0;
TempVars vars = TempVars.get();
ArrayList<BIHStackData> stack = vars.bihStack;
stack.clear();
stack.add(new BIHStackData(this, 0, 0));
stackloop:
while (stack.size() > 0) {
BIHStackData data = stack.remove(stack.size() - 1);
BIHNode node = data.node;
leafloop:
while (node.axis != 3) { // while node is not a leaf
BIHNode nearNode, farNode;
nearNode = node.left;
farNode = node.right;
stack.add(new BIHStackData(farNode, 0, 0));
node = nearNode;
}
// a leaf
for (int i = node.leftIndex; i <= node.rightIndex; i++) {
tree.getTriangle(i, v1, v2, v3);
if (worldMatrix != null) {
worldMatrix.mult(v1, v1);
worldMatrix.mult(v2, v2);
worldMatrix.mult(v3, v3);
}
float t = r.intersects(v1, v2, v3);
if (t < tHit) {
tHit = t;
Vector3f contactPoint = new Vector3f(r.direction).multLocal(tHit).addLocal(r.origin);
CollisionResult cr = new CollisionResult(contactPoint, tHit);
cr.setTriangleIndex(tree.getTriangleIndex(i));
results.addCollision(cr);
cols++;
}
}
}
vars.release();
return cols;
}
示例6: intersectBrute
import com.jme3.collision.CollisionResults; //导入方法依赖的package包/类
public final int intersectBrute(Ray r,
Matrix4f worldMatrix,
BIHTree tree,
float sceneMin,
float sceneMax,
CollisionResults results) {
float tHit = Float.POSITIVE_INFINITY;
TempVars vars = TempVars.get();
Vector3f v1 = vars.vect1,
v2 = vars.vect2,
v3 = vars.vect3;
int cols = 0;
ArrayList<BIHStackData> stack = vars.bihStack;
stack.clear();
stack.add(new BIHStackData(this, 0, 0));
stackloop:
while (stack.size() > 0) {
BIHStackData data = stack.remove(stack.size() - 1);
BIHNode node = data.node;
leafloop:
while (node.axis != 3) { // while node is not a leaf
BIHNode nearNode, farNode;
nearNode = node.left;
farNode = node.right;
stack.add(new BIHStackData(farNode, 0, 0));
node = nearNode;
}
// a leaf
for (int i = node.leftIndex; i <= node.rightIndex; i++) {
tree.getTriangle(i, v1, v2, v3);
if (worldMatrix != null) {
worldMatrix.mult(v1, v1);
worldMatrix.mult(v2, v2);
worldMatrix.mult(v3, v3);
}
float t = r.intersects(v1, v2, v3);
if (t < tHit) {
tHit = t;
Vector3f contactPoint = new Vector3f(r.direction).multLocal(tHit).addLocal(r.origin);
CollisionResult cr = new CollisionResult(contactPoint, tHit);
cr.setTriangleIndex(tree.getTriangleIndex(i));
results.addCollision(cr);
cols++;
}
}
}
vars.release();
return cols;
}