本文整理汇总了Java中com.bulletphysics.linearmath.Transform.setIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java Transform.setIdentity方法的具体用法?Java Transform.setIdentity怎么用?Java Transform.setIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.linearmath.Transform
的用法示例。
在下文中一共展示了Transform.setIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPhysics
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void initPhysics() {
Transform startTranform = new Transform();
startTranform.setIdentity();
startTranform.origin.set(5, -35, -4);
collisionShape = new CapsuleShape(0.5f, 1);
ghostObject = new PairCachingGhostObject();
ghostObject.setWorldTransform(startTranform);
// set getOverlappingPairCache & setInternalGhostPairCallback
ghostObject.setCollisionShape(collisionShape);
ghostObject.setCollisionFlags(CollisionFlags.CHARACTER_OBJECT);
characterController = new KinematicCharacterController(ghostObject, collisionShape, 0.5f);
characterController.setGravity(10);
characterController.setMaxJumpHeight(1.5f);
}
示例2: calculateLocalInertia
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void calculateLocalInertia (float mass, Vector3 inertia) {
// approximation: take the inertia from the aabb for now
Stack stack = Stack.enter();
Transform ident = stack.allocTransform();
ident.setIdentity();
Vector3 aabbMin = stack.allocVector3(), aabbMax = stack.allocVector3();
getAabb(ident, aabbMin, aabbMax);
Vector3 halfExtents = stack.allocVector3();
halfExtents.set(aabbMax).sub(aabbMin);
halfExtents.scl(0.5f);
float lx = 2f * halfExtents.x;
float ly = 2f * halfExtents.y;
float lz = 2f * halfExtents.z;
inertia.x = (mass / 12f) * (ly * ly + lz * lz);
inertia.y = (mass / 12f) * (lx * lx + lz * lz);
inertia.z = (mass / 12f) * (lx * lx + ly * ly);
stack.leave();
}
示例3: localGetSupportingVertex
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public Vector3 localGetSupportingVertex (Vector3 vec, Vector3 out) {
Stack stack = Stack.enter();
Vector3 tmp = stack.allocVector3();
Vector3 supportVertex = out;
Transform ident = stack.allocTransform();
ident.setIdentity();
SupportVertexCallback supportCallback = new SupportVertexCallback(vec, ident);
Vector3 aabbMax = stack.allocVector3();
aabbMax.set(1e30f, 1e30f, 1e30f);
tmp.set(aabbMax).scl(-1);
processAllTriangles(supportCallback, tmp, aabbMax);
supportCallback.getSupportVertexLocal(supportVertex);
stack.leave();
return out;
}
示例4: getBoundingSphere
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public float getBoundingSphere (Vector3 center) {
Stack stack = Stack.enter();
Vector3 tmp = stack.allocVector3();
Transform tr = stack.allocTransform();
tr.setIdentity();
Vector3 aabbMin = stack.allocVector3(), aabbMax = stack.allocVector3();
getAabb(tr, aabbMin, aabbMax);
tmp.set(aabbMax).sub(aabbMin);
float radius = tmp.len() * 0.5f;
tmp.set(aabbMin).add(aabbMax);
center.set(tmp).scl(0.5f);
stack.leave();
return radius;
}
示例5: rayTest
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public void rayTest(Vector3 rayFromWorld, Vector3 rayToWorld, CollisionWorld.RayResultCallback resultCallback) {
Stack stack = Stack.enter();
Transform rayFromTrans = stack.allocTransform();
rayFromTrans.setIdentity();
rayFromTrans.origin.set(rayFromWorld);
Transform rayToTrans = stack.allocTransform();
rayToTrans.setIdentity();
rayToTrans.origin.set(rayToWorld);
Transform tmpTrans = stack.allocTransform();
for (int i=0; i<overlappingObjects.size(); i++) {
CollisionObject collisionObject = overlappingObjects.getQuick(i);
// only perform raycast if filterMask matches
if (resultCallback.needsCollision(collisionObject.getBroadphaseHandle())) {
CollisionWorld.rayTestSingle(rayFromTrans, rayToTrans,
collisionObject,
collisionObject.getCollisionShape(),
collisionObject.getWorldTransform(tmpTrans),
resultCallback);
}
}
stack.leave();
}
示例6: calculateLocalInertia
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void calculateLocalInertia(float mass, Vector3f inertia) {
// approximation: take the inertia from the aabb for now
Transform ident = Stack.alloc(Transform.class);
ident.setIdentity();
Vector3f aabbMin = Stack.alloc(Vector3f.class), aabbMax = Stack.alloc(Vector3f.class);
getAabb(ident, aabbMin, aabbMax);
Vector3f halfExtents = Stack.alloc(Vector3f.class);
halfExtents.sub(aabbMax, aabbMin);
halfExtents.scale(0.5f);
float lx = 2f * halfExtents.x;
float ly = 2f * halfExtents.y;
float lz = 2f * halfExtents.z;
inertia.x = (mass / 12f) * (ly * ly + lz * lz);
inertia.y = (mass / 12f) * (lx * lx + lz * lz);
inertia.z = (mass / 12f) * (lx * lx + ly * ly);
}
示例7: calculateLocalInertia
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void calculateLocalInertia(float mass, Vector3f inertia) {
// not yet, return box inertia
float margin = getMargin();
Transform ident = Stack.alloc(Transform.class);
ident.setIdentity();
Vector3f aabbMin = Stack.alloc(Vector3f.class), aabbMax = Stack.alloc(Vector3f.class);
getAabb(ident, aabbMin, aabbMax);
Vector3f halfExtents = Stack.alloc(Vector3f.class);
halfExtents.sub(aabbMax, aabbMin);
halfExtents.scale(0.5f);
float lx = 2f * (halfExtents.x + margin);
float ly = 2f * (halfExtents.y + margin);
float lz = 2f * (halfExtents.z + margin);
float x2 = lx * lx;
float y2 = ly * ly;
float z2 = lz * lz;
float scaledmass = mass * 0.08333333f;
inertia.set(y2 + z2, x2 + z2, x2 + y2);
inertia.scale(scaledmass);
}
示例8: rayTest
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public void rayTest(Vector3f rayFromWorld, Vector3f rayToWorld, CollisionWorld.RayResultCallback resultCallback) {
Transform rayFromTrans = Stack.alloc(Transform.class);
rayFromTrans.setIdentity();
rayFromTrans.origin.set(rayFromWorld);
Transform rayToTrans = Stack.alloc(Transform.class);
rayToTrans.setIdentity();
rayToTrans.origin.set(rayToWorld);
Transform tmpTrans = Stack.alloc(Transform.class);
for (int i=0; i<overlappingObjects.size(); i++) {
CollisionObject collisionObject = overlappingObjects.getQuick(i);
// only perform raycast if filterMask matches
if (resultCallback.needsCollision(collisionObject.getBroadphaseHandle())) {
CollisionWorld.rayTestSingle(rayFromTrans, rayToTrans,
collisionObject,
collisionObject.getCollisionShape(),
collisionObject.getWorldTransform(tmpTrans),
resultCallback);
}
}
}
示例9: calculateLocalInertia
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void calculateLocalInertia(float mass, Vector3 inertia) {
// not yet, return box inertia
Stack stack = Stack.enter();
float margin = getMargin();
Transform ident = stack.allocTransform();
ident.setIdentity();
Vector3 aabbMin = stack.allocVector3(), aabbMax = stack.allocVector3();
getAabb(ident, aabbMin, aabbMax);
Vector3 halfExtents = stack.allocVector3();
halfExtents.set(aabbMax).sub(aabbMin);
halfExtents.scl(0.5f);
float lx = 2f * (halfExtents.x + margin);
float ly = 2f * (halfExtents.y + margin);
float lz = 2f * (halfExtents.z + margin);
float x2 = lx * lx;
float y2 = ly * ly;
float z2 = lz * lz;
float scaledmass = mass * 0.08333333f;
inertia.set(y2 + z2, x2 + z2, x2 + y2);
inertia.scl(scaledmass);
stack.leave();
}
示例10: calculateLocalInertia
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void calculateLocalInertia (float mass, Vector3 inertia) {
Stack stack = Stack.enter();
Transform identity = stack.allocTransform();
identity.setIdentity();
Vector3 aabbMin = stack.allocVector3(), aabbMax = stack.allocVector3();
getAabb(identity, aabbMin, aabbMax);
Vector3 halfExtents = stack.allocVector3();
halfExtents.set(aabbMax).sub(aabbMin);
halfExtents.scl(0.5f);
float margin = getMargin();
float lx = 2f * (halfExtents.x + margin);
float ly = 2f * (halfExtents.y + margin);
float lz = 2f * (halfExtents.z + margin);
float x2 = lx * lx;
float y2 = ly * ly;
float z2 = lz * lz;
float scaledmass = mass * 0.08333333f;
inertia.set(y2 + z2, x2 + z2, x2 + y2);
inertia.scl(scaledmass);
// inertia.x() = scaledmass * (y2+z2);
// inertia.y() = scaledmass * (x2+z2);
// inertia.z() = scaledmass * (x2+y2);
stack.leave();
}
示例11: setupRigidBodies
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
private void setupRigidBodies(Vector3f positionOffset, float scale) {
Transform offset = new Transform();
offset.setIdentity();
offset.origin.set(positionOffset);
createBodyPart(BodyPart.MAIN, offset, scale, new Vector3f(0.0f, 1.0f,
0.0f));
createBodyPart(BodyPart.SPINE, offset, scale, new Vector3f(0.0f, 1.2f,
0.0f));
createBodyPart(BodyPart.HEAD, offset, scale, new Vector3f(0.0f, 1.6f,
0.0f));
createBodyPart(BodyPart.LEFT_UPPER_LEG, offset, scale, new Vector3f(
-0.18f, 0.65f, 0.0f));
createBodyPart(BodyPart.LEFT_LOWER_LEG, offset, scale, new Vector3f(
-0.18f, 0.2f, 0.0f));
createBodyPart(BodyPart.RIGHT_UPPER_LEG, offset, scale, new Vector3f(
0.18f, 0.65f, 0.0f));
createBodyPart(BodyPart.RIGHT_LOWER_LEG, offset, scale, new Vector3f(
0.18f, 0.2f, 0.0f));
createBodyPart(BodyPart.LEFT_UPPER_ARM, offset, scale, new Vector3f(
-0.35f, 1.45f, 0.0f), new Vector3f(M_PI_2, 0.0f, 0.0f));
createBodyPart(BodyPart.LEFT_LOWER_ARM, offset, scale, new Vector3f(
-0.7f, 1.45f, 0.0f), new Vector3f(M_PI_2, 0.0f, 0.0f));
createBodyPart(BodyPart.RIGHT_UPPER_ARM, offset, scale, new Vector3f(
0.35f, 1.45f, 0.0f), new Vector3f(-M_PI_2, 0.0f, 0.0f));
createBodyPart(BodyPart.RIGHT_LOWER_ARM, offset, scale, new Vector3f(
0.7f, 1.45f, 0.0f), new Vector3f(-M_PI_2, 0.0f, 0.0f));
// Setup some damping on the m_bodies
for (RigidBody body : bodies.values()) {
body.setDeactivationTime(0);
body.setSleepingThresholds(0, 0);
}
}
示例12: stepUp
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
protected void stepUp(CollisionWorld world) {
// phase 1: up
Transform start = Stack.alloc(Transform.class);
Transform end = Stack.alloc(Transform.class);
targetPosition.scaleAdd(stepHeight + (verticalOffset > 0.0?verticalOffset:0.0f), upAxisDirection[upAxis], currentPosition);
start.setIdentity ();
end.setIdentity ();
/* FIXME: Handle penetration properly */
start.origin.scaleAdd(convexShape.getMargin() + addedMargin, upAxisDirection[upAxis], currentPosition);
end.origin.set(targetPosition);
// Find only sloped/flat surface hits, avoid wall and ceiling hits...
Vector3f up = Stack.alloc(Vector3f.class);
up.scale(-1f, upAxisDirection[upAxis]);
KinematicClosestNotMeConvexResultCallback callback = new KinematicClosestNotMeConvexResultCallback(ghostObject, up, 0.0f);
callback.collisionFilterGroup = getGhostObject().getBroadphaseHandle().collisionFilterGroup;
callback.collisionFilterMask = getGhostObject().getBroadphaseHandle().collisionFilterMask;
if (useGhostObjectSweepTest) {
ghostObject.convexSweepTest(convexShape, start, end, callback, world.getDispatchInfo().allowedCcdPenetration);
}
else {
world.convexSweepTest(convexShape, start, end, callback);
}
if (callback.hasHit()) {
// we moved up only a fraction of the step height
currentStepOffset = stepHeight * callback.closestHitFraction;
currentPosition.interpolate(currentPosition, targetPosition, callback.closestHitFraction);
verticalVelocity = 0.0f;
verticalOffset = 0.0f;
}
else {
currentStepOffset = stepHeight;
currentPosition.set(targetPosition);
}
}
示例13: createBodyPart
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
private void createBodyPart(BodyPart bodyPart, Transform offset,
float scale, Vector3f origin, Vector3f angles) {
Transform transform = new Transform();
transform.setIdentity();
transform.origin.set(scale * origin.x, scale * origin.y, scale
* origin.z);
transform.basis.rotX(angles.x);
transform.basis.rotY(angles.y);
transform.basis.rotZ(angles.z);
transform.mul(offset);
bodies.put(bodyPart,
localCreateRigidBody(1.0f, transform, shapes.get(bodyPart)));
}
示例14: calculateLocalInertia
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void calculateLocalInertia(float mass, Vector3f inertia) {
// as an approximation, take the inertia of the box that bounds the spheres
Transform ident = Stack.alloc(Transform.class);
ident.setIdentity();
float radius = getRadius();
Vector3f halfExtents = Stack.alloc(Vector3f.class);
halfExtents.set(radius, radius, radius);
VectorUtil.setCoord(halfExtents, getUpAxis(), radius + getHalfHeight());
float margin = BulletGlobals.CONVEX_DISTANCE_MARGIN;
float lx = 2f * (halfExtents.x + margin);
float ly = 2f * (halfExtents.y + margin);
float lz = 2f * (halfExtents.z + margin);
float x2 = lx * lx;
float y2 = ly * ly;
float z2 = lz * lz;
float scaledmass = mass * 0.08333333f;
inertia.x = scaledmass * (y2 + z2);
inertia.y = scaledmass * (x2 + z2);
inertia.z = scaledmass * (x2 + y2);
}
示例15: init
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
super.init(config);
BroadphaseInterface broadphase = new DbvtBroadphase();
DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
CollisionDispatcher dispatcher = new CollisionDispatcher(
collisionConfiguration);
SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
world = new DiscreteDynamicsWorld(dispatcher, broadphase, solver,
collisionConfiguration);
world.setGravity(new Vector3f(0, 0, 0));
Transform groundTransform = new Transform();
groundTransform.setIdentity();
Transform trans1 = new Transform();
trans1.setIdentity();
Transform trans2 = new Transform();
trans2.setIdentity();
CylinderShapeZ top = new CylinderShapeZ(new Vector3f(1, 1, .125f));
CapsuleShapeZ pin = new CapsuleShapeZ(.05f, 1.5f);
top.setMargin(.01f);
pin.setMargin(.01f);
gyroShape = new CompoundShape();
gyroShape.addChildShape(trans1, top);
gyroShape.addChildShape(trans2, pin);
Vector3f localInertia = new Vector3f();
top.calculateLocalInertia(1, localInertia);
gyroOrigTransform = new Transform[cntGyro];
gyro = new RigidBody[cntGyro];
gyroAngularVelocity = new Vector3f[cntGyro];
for (int i = 0; i < cntGyro; i++) {
gyroOrigTransform[i] = new Transform(new Matrix4f(new Quat4f(0, 0,
0, 1), new Vector3f(-cntGyro * 5 + i * 10, 0, 0), 1.0f));
DefaultMotionState gyroMotion = new DefaultMotionState(
gyroOrigTransform[i]);
gyro[i] = new RigidBody(1, gyroMotion, gyroShape, localInertia);
gyro[i].setCenterOfMassTransform(gyroOrigTransform[i]);
float k = 3f + 7f * i / cntGyro;
gyroAngularVelocity[i] = new Vector3f(15 * k, 25 * k, 35 * k);
gyro[i].setAngularVelocity(gyroAngularVelocity[i]);
gyro[i].setFriction(.5f);
gyro[i].setDamping(0.3f, .7f);
world.addRigidBody(gyro[i]);
}
}