本文整理汇总了Java中com.bulletphysics.collision.dispatch.CollisionObject类的典型用法代码示例。如果您正苦于以下问题:Java CollisionObject类的具体用法?Java CollisionObject怎么用?Java CollisionObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollisionObject类属于com.bulletphysics.collision.dispatch包,在下文中一共展示了CollisionObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: predictUnconstraintMotion
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
protected void predictUnconstraintMotion(float timeStep) {
Stack stack = Stack.enter();
Transform tmpTrans = stack.allocTransform();
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
if (!body.isStaticObject()) {
if (body.isActive()) {
body.applyGravity();
body.integrateVelocities(timeStep);
body.applyDamping(timeStep);
body.predictIntegratedTransform(timeStep, body.getInterpolationWorldTransform(tmpTrans));
}
}
}
}
stack.leave();
}
示例2: updateAabbs
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
@Override
public void updateAabbs() {
Stack stack = Stack.enter();
Transform tmpTrans = stack.allocTransform();
// Transform predictedTrans = stack.allocTransform();
Vector3 minAabb = stack.allocVector3(), maxAabb = stack.allocVector3();
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
if (body.isActive() && (!body.isStaticObject())) {
colObj.getCollisionShape().getAabb(colObj.getWorldTransform(tmpTrans), minAabb, maxAabb);
BroadphaseInterface bp = getBroadphase();
bp.setAabb(body.getBroadphaseHandle(), minAabb, maxAabb, dispatcher1);
}
}
}
stack.leave();
}
示例3: synchronizeMotionStates
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
public void synchronizeMotionStates() {
Stack stack = Stack.enter();
Transform tmpTrans = stack.allocTransform();
// todo: iterate over awake simulation islands!
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null && body.getMotionState() != null) {
if (body.getActivationState() != CollisionObject.ISLAND_SLEEPING) {
body.getMotionState().setWorldTransform(body.getWorldTransform(tmpTrans));
}
}
}
stack.leave();
}
示例4: checkCollideWithOverride
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
@Override
public boolean checkCollideWithOverride (CollisionObject co) {
// TODO: change to cast
RigidBody otherRb = RigidBody.upcast(co);
if (otherRb == null) {
return true;
}
for (int i = 0; i < constraintRefs.size(); ++i) {
TypedConstraint c = constraintRefs.getQuick(i);
if (c.getRigidBodyA() == otherRb || c.getRigidBodyB() == otherRb) {
return false;
}
}
return true;
}
示例5: gimpact_vs_compoundshape
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
public void gimpact_vs_compoundshape(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, CompoundShape shape1, boolean swapped) {
Stack stack = Stack.enter();
Transform orgtrans1 = body1.getWorldTransform(stack.allocTransform());
Transform childtrans1 = stack.allocTransform();
Transform tmpTrans = stack.allocTransform();
int i = shape1.getNumChildShapes();
while ((i--) != 0) {
CollisionShape colshape1 = shape1.getChildShape(i);
childtrans1.mul(orgtrans1, shape1.getChildTransform(i, tmpTrans));
body1.setWorldTransform(childtrans1);
// collide child shape
gimpact_vs_shape(body0, body1,
shape0, colshape1, swapped);
// restore transforms
body1.setWorldTransform(orgtrans1);
}
stack.leave();
}
示例6: gimpact_vs_concave
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
public void gimpact_vs_concave(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, ConcaveShape shape1, boolean swapped) {
// create the callback
GImpactTriangleCallback tricallback = new GImpactTriangleCallback();
tricallback.algorithm = this;
tricallback.body0 = body0;
tricallback.body1 = body1;
tricallback.gimpactshape0 = shape0;
tricallback.swapped = swapped;
tricallback.margin = shape1.getMargin();
// getting the trimesh AABB
Stack stack = Stack.enter();
Transform gimpactInConcaveSpace = stack.allocTransform();
body1.getWorldTransform(gimpactInConcaveSpace);
gimpactInConcaveSpace.inverse();
gimpactInConcaveSpace.mul(body0.getWorldTransform(stack.allocTransform()));
Vector3 minAABB = stack.allocVector3(), maxAABB = stack.allocVector3();
shape0.getAabb(gimpactInConcaveSpace, minAABB, maxAABB);
shape1.processAllTriangles(tricallback, minAABB, maxAABB);
stack.leave();
}
示例7: shape_vs_shape_collision
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
protected void shape_vs_shape_collision(CollisionObject body0, CollisionObject body1, CollisionShape shape0, CollisionShape shape1) {
CollisionShape tmpShape0 = body0.getCollisionShape();
CollisionShape tmpShape1 = body1.getCollisionShape();
body0.internalSetTemporaryCollisionShape(shape0);
body1.internalSetTemporaryCollisionShape(shape1);
{
CollisionAlgorithm algor = newAlgorithm(body0, body1);
// post : checkManifold is called
resultOut.setShapeIdentifiers(part0, triface0, part1, triface1);
algor.processCollision(body0, body1, dispatchInfo, resultOut);
//algor.destroy();
dispatcher.freeCollisionAlgorithm(algor);
}
body0.internalSetTemporaryCollisionShape(tmpShape0);
body1.internalSetTemporaryCollisionShape(tmpShape1);
}
示例8: predictUnconstraintMotion
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
protected void predictUnconstraintMotion(float timeStep) {
BulletStats.pushProfile("predictUnconstraintMotion");
try {
Transform tmpTrans = Stack.alloc(Transform.class);
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
if (!body.isStaticOrKinematicObject()) {
if (body.isActive()) {
body.integrateVelocities(timeStep);
// damping
body.applyDamping(timeStep);
body.predictIntegratedTransform(timeStep, body.getInterpolationWorldTransform(tmpTrans));
}
}
}
}
}
finally {
BulletStats.popProfile();
}
}
示例9: predictUnconstraintMotion
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
protected void predictUnconstraintMotion(float timeStep) {
Transform tmpTrans = Stack.alloc(Transform.class);
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
if (!body.isStaticObject()) {
if (body.isActive()) {
body.applyGravity();
body.integrateVelocities(timeStep);
body.applyDamping(timeStep);
body.predictIntegratedTransform(timeStep, body.getInterpolationWorldTransform(tmpTrans));
}
}
}
}
}
示例10: updateAabbs
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
@Override
public void updateAabbs() {
Transform tmpTrans = Stack.alloc(Transform.class);
Transform predictedTrans = Stack.alloc(Transform.class);
Vector3f minAabb = Stack.alloc(Vector3f.class), maxAabb = Stack.alloc(Vector3f.class);
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject colObj = collisionObjects.getQuick(i);
RigidBody body = RigidBody.upcast(colObj);
if (body != null) {
if (body.isActive() && (!body.isStaticObject())) {
colObj.getCollisionShape().getAabb(colObj.getWorldTransform(tmpTrans), minAabb, maxAabb);
BroadphaseInterface bp = getBroadphase();
bp.setAabb(body.getBroadphaseHandle(), minAabb, maxAabb, dispatcher1);
}
}
}
}
示例11: checkCollideWithOverride
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
@Override
public boolean checkCollideWithOverride(CollisionObject co) {
// TODO: change to cast
RigidBody otherRb = RigidBody.upcast(co);
if (otherRb == null) {
return true;
}
for (int i = 0; i < constraintRefs.size(); ++i) {
TypedConstraint c = constraintRefs.getQuick(i);
if (c.getRigidBodyA() == otherRb || c.getRigidBodyB() == otherRb) {
return false;
}
}
return true;
}
示例12: initSolverBody
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
private void initSolverBody(SolverBody solverBody, CollisionObject collisionObject) {
RigidBody rb = RigidBody.upcast(collisionObject);
if (rb != null) {
rb.getAngularVelocity(solverBody.angularVelocity);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(Stack.alloc(Transform.class)).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass = rb.getInvMass();
rb.getLinearVelocity(solverBody.linearVelocity);
solverBody.originalBody = rb;
solverBody.angularFactor = rb.getAngularFactor();
}
else {
solverBody.angularVelocity.set(0f, 0f, 0f);
solverBody.centerOfMassPosition.set(collisionObject.getWorldTransform(Stack.alloc(Transform.class)).origin);
solverBody.friction = collisionObject.getFriction();
solverBody.invMass = 0f;
solverBody.linearVelocity.set(0f, 0f, 0f);
solverBody.originalBody = null;
solverBody.angularFactor = 1f;
}
solverBody.pushVelocity.set(0f, 0f, 0f);
solverBody.turnVelocity.set(0f, 0f, 0f);
}
示例13: gimpact_vs_compoundshape
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
public void gimpact_vs_compoundshape(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, CompoundShape shape1, boolean swapped) {
Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));
Transform childtrans1 = Stack.alloc(Transform.class);
Transform tmpTrans = Stack.alloc(Transform.class);
int i = shape1.getNumChildShapes();
while ((i--) != 0) {
CollisionShape colshape1 = shape1.getChildShape(i);
childtrans1.mul(orgtrans1, shape1.getChildTransform(i, tmpTrans));
body1.setWorldTransform(childtrans1);
// collide child shape
gimpact_vs_shape(body0, body1,
shape0, colshape1, swapped);
// restore transforms
body1.setWorldTransform(orgtrans1);
}
}
示例14: gimpact_vs_concave
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
public void gimpact_vs_concave(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, ConcaveShape shape1, boolean swapped) {
// create the callback
GImpactTriangleCallback tricallback = new GImpactTriangleCallback();
tricallback.algorithm = this;
tricallback.body0 = body0;
tricallback.body1 = body1;
tricallback.gimpactshape0 = shape0;
tricallback.swapped = swapped;
tricallback.margin = shape1.getMargin();
// getting the trimesh AABB
Transform gimpactInConcaveSpace = Stack.alloc(Transform.class);
body1.getWorldTransform(gimpactInConcaveSpace);
gimpactInConcaveSpace.inverse();
gimpactInConcaveSpace.mul(body0.getWorldTransform(Stack.alloc(Transform.class)));
Vector3f minAABB = Stack.alloc(Vector3f.class), maxAABB = Stack.alloc(Vector3f.class);
shape0.getAabb(gimpactInConcaveSpace, minAABB, maxAABB);
shape1.processAllTriangles(tricallback, minAABB, maxAABB);
}
示例15: contactProcessed
import com.bulletphysics.collision.dispatch.CollisionObject; //导入依赖的package包/类
@Override
public boolean contactProcessed(ManifoldPoint arg0, Object obj1, Object obj2)
{
CollisionObject o1 = (CollisionObject) obj1;
CollisionObject o2 = (CollisionObject) obj2;
for (PhysicsBody body : watchList)
{
if (body.body == o1)
{
body.collidedWith(o2);
}
else if (body.body == o2)
{
body.collidedWith(o1);
}
}
return false;
}