本文整理汇总了Java中com.bulletphysics.linearmath.Transform类的典型用法代码示例。如果您正苦于以下问题:Java Transform类的具体用法?Java Transform怎么用?Java Transform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transform类属于com.bulletphysics.linearmath包,在下文中一共展示了Transform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get_plane_equation_transformed
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public static void get_plane_equation_transformed(StaticPlaneShape shape, Transform trans, Vector4f equation) {
get_plane_equation(shape, equation);
Vector3f tmp = Stack.alloc(Vector3f.class);
trans.basis.getRow(0, tmp);
float x = VectorUtil.dot3(tmp, equation);
trans.basis.getRow(1, tmp);
float y = VectorUtil.dot3(tmp, equation);
trans.basis.getRow(2, tmp);
float z = VectorUtil.dot3(tmp, equation);
float w = VectorUtil.dot3(trans.origin, equation) + equation.w;
equation.set(x, y, z, w);
}
示例2: EntityCrazyCube
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public EntityCrazyCube(World world, Vec3f pos){
super(world, getModel0(), pos);
float s=Rand.f()+1;
scale.set(s, s, s);
// model.getMaterial(2).getDiffuse().set(177/256F, 0, 177/256F, 1);
// model.getMaterial(1).getDiffuse().set(0x00C7E7);
// model.getMaterial(1).getAmbient().set(0x00C7E7).a(1);
// model.getMaterial(0).getDiffuse().set(0x0000FF);
float massKg=0.5F*scale.x*scale.y*scale.z;
if(CAM==null) CAM=this;
getPhysicsObj().init(massKg, new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(pos.x, pos.y, pos.z), 0.5F)), new SphereShape(scale.x/2), Vec3f.single(0.9F));
// getPhysicsObj().init(massKg, new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(pos.x, pos.y, pos.z), 0.5F)), new BoxShape(new Vector3f(scale.x/2, scale.y/2, scale.z/2)), Vec3f.single(0.9F));
getPhysicsObj().body.setDamping(0.15F, 0.15F);
getPhysicsObj().hookPos(this.pos);
getPhysicsObj().hookRot(rot);
}
示例3: 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);
}
示例4: initSolverBody
import com.bulletphysics.linearmath.Transform; //导入依赖的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);
}
示例5: SixDofJoint
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
/**
* @param pivotA local translation of the joint connection point in node A
* @param pivotB local translation of the joint connection point in node B
*/
public SixDofJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) {
super(nodeA, nodeB, pivotA, pivotB);
this.useLinearReferenceFrameA = useLinearReferenceFrameA;
Transform transA = new Transform(Converter.convert(rotA));
Converter.convert(pivotA, transA.origin);
Converter.convert(rotA, transA.basis);
Transform transB = new Transform(Converter.convert(rotB));
Converter.convert(pivotB, transB.origin);
Converter.convert(rotB, transB.basis);
constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA);
gatherMotors();
}
示例6: writebackVelocity
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public void writebackVelocity (float timeStep) {
if (invMass != 0f) {
originalBody.setLinearVelocity(linearVelocity);
originalBody.setAngularVelocity(angularVelocity);
Stack stack = Stack.enter();
// correct the position/orientation based on push/turn recovery
Transform newTransform = stack.allocTransform();
Transform curTrans = originalBody.getWorldTransform(stack.allocTransform());
TransformUtil.integrateTransform(curTrans, pushVelocity, turnVelocity, timeStep, newTransform);
originalBody.setWorldTransform(newTransform);
// m_originalBody->setCompanionId(-1);
stack.leave();
}
}
示例7: HingeConstraint
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public HingeConstraint(RigidBody rbA, RigidBody rbB, Transform rbAFrame, Transform rbBFrame) {
super(TypedConstraintType.HINGE_CONSTRAINT_TYPE, rbA, rbB);
this.rbAFrame.set(rbAFrame);
this.rbBFrame.set(rbBFrame);
angularOnly = false;
enableAngularMotor = false;
// flip axis
this.rbBFrame.basis.m02 *= -1f;
this.rbBFrame.basis.m12 *= -1f;
this.rbBFrame.basis.m22 *= -1f;
// start with free
lowerLimit = 1e30f;
upperLimit = -1e30f;
biasFactor = 0.3f;
relaxationFactor = 1.0f;
limitSoftness = 0.9f;
solveLimit = false;
}
示例8: makeDomino
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public boolean makeDomino(float mass, Vector3f inertia, Vector3f loc,
float angle) {
if (cntCreated >= numDominoes)
return false;
int i = cntCreated++;
dominoOrigTransform[i] = new Transform(new Matrix4f(new Quat4f(0,
sin(angle) / (float) Math.sqrt(2), 0, 1), loc, 1.0f));
DefaultMotionState dominoMotion = new DefaultMotionState(
dominoOrigTransform[i]);
RigidBodyConstructionInfo dominoRigidBodyCI = new RigidBodyConstructionInfo(
mass, dominoMotion, dominoShape, inertia);
domino[i] = new RigidBody(dominoRigidBodyCI);
domino[i].setRestitution(0.5f);
world.addRigidBody(domino[i]);
return true;
}
示例9: getAabbSlow
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
@Override
public void getAabbSlow(Transform t, Vector3 aabbMin, Vector3 aabbMax) {
Stack stack = Stack.enter();
childConvexShape.getAabbSlow(t, aabbMin, aabbMax);
Vector3 aabbCenter = stack.allocVector3();
aabbCenter.set(aabbMax).add(aabbMin);
aabbCenter.scl(0.5f);
Vector3 scaledAabbHalfExtends = stack.allocVector3();
scaledAabbHalfExtends.set(aabbMax).sub(aabbMin);
scaledAabbHalfExtends.scl(0.5f * uniformScalingFactor);
aabbMin.set(aabbCenter).sub(scaledAabbHalfExtends);
aabbMax.set(aabbCenter).add(scaledAabbHalfExtends);
stack.leave();
}
示例10: addSingleResult
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
@Override
public float addSingleResult(LocalConvexResult convexResult, boolean normalInWorldSpace) {
// caller already does the filter on the m_closestHitFraction
assert (convexResult.hitFraction <= closestHitFraction);
closestHitFraction = convexResult.hitFraction;
hitCollisionObject = convexResult.hitCollisionObject;
if (normalInWorldSpace) {
hitNormalWorld.set(convexResult.hitNormalLocal);
if (hitNormalWorld.length() > 2) {
System.out.println("CollisionWorld.addSingleResult world " + hitNormalWorld);
}
}
else {
// need to transform normal into worldspace
hitNormalWorld.set(convexResult.hitNormalLocal);
hitCollisionObject.getWorldTransform(Stack.alloc(Transform.class)).basis.transform(hitNormalWorld);
if (hitNormalWorld.length() > 2) {
System.out.println("CollisionWorld.addSingleResult world " + hitNormalWorld);
}
}
hitPointWorld.set(convexResult.hitPointLocal);
return convexResult.hitFraction;
}
示例11: calcPenDepth
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
ConvexShape pConvexA, ConvexShape pConvexB,
Transform transformA, Transform transformB,
Vector3 v, Vector3 wWitnessOnA, Vector3 wWitnessOnB,
IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
float radialmargin = 0f;
// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
GjkEpaSolver.Results results = new GjkEpaSolver.Results();
if (gjkEpaSolver.collide(pConvexA, transformA,
pConvexB, transformB,
radialmargin/*,stackAlloc*/, results)) {
//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
wWitnessOnA.set(results.witnesses[0]);
wWitnessOnB.set(results.witnesses[1]);
return true;
}
return false;
}
示例12: getHingeAngle
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public float getHingeAngle () {
Stack stack = Stack.enter();
Transform centerOfMassA = rbA.getCenterOfMassTransform(stack.allocTransform());
Transform centerOfMassB = rbB.getCenterOfMassTransform(stack.allocTransform());
Vector3 refAxis0 = stack.allocVector3();
MatrixUtil.getColumn(rbAFrame.basis, 0, refAxis0);
refAxis0.mul(centerOfMassA.basis);
Vector3 refAxis1 = stack.allocVector3();
MatrixUtil.getColumn(rbAFrame.basis, 1, refAxis1);
refAxis1.mul(centerOfMassA.basis);
Vector3 swingAxis = stack.allocVector3();
MatrixUtil.getColumn(rbBFrame.basis, 1, swingAxis);
swingAxis.mul(centerOfMassB.basis);
float result = ScalarUtil.atan2Fast(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1));
stack.leave();
return result;
}
示例13: setTimeStepAndCounters
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public void setTimeStepAndCounters(float collisionMarginTriangle, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
this.dispatchInfoPtr = dispatchInfo;
this.collisionMarginTriangle = collisionMarginTriangle;
this.resultOut = resultOut;
// recalc aabbs
Transform convexInTriangleSpace = Stack.alloc(Transform.class);
triBody.getWorldTransform(convexInTriangleSpace);
convexInTriangleSpace.inverse();
convexInTriangleSpace.mul(convexBody.getWorldTransform(Stack.alloc(Transform.class)));
CollisionShape convexShape = (CollisionShape)convexBody.getCollisionShape();
//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
convexShape.getAabb(convexInTriangleSpace, aabbMin, aabbMax);
float extraMargin = collisionMarginTriangle;
Vector3f extra = Stack.alloc(Vector3f.class);
extra.set(extraMargin, extraMargin, extraMargin);
aabbMax.add(extra);
aabbMin.sub(extra);
}
示例14: find_collision
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
public static void find_collision(GImpactBvh boxset0, Transform trans0, GImpactBvh boxset1, Transform trans1, PairSet collision_pairs) {
if (boxset0.getNodeCount() == 0 || boxset1.getNodeCount() == 0) {
return;
}
BoxBoxTransformCache trans_cache_1to0 = Stack.alloc(BoxBoxTransformCache.class);
trans_cache_1to0.calc_from_homogenic(trans0, trans1);
//#ifdef TRI_COLLISION_PROFILING
//bt_begin_gim02_tree_time();
//#endif //TRI_COLLISION_PROFILING
_find_collision_pairs_recursive(
boxset0, boxset1,
collision_pairs, trans_cache_1to0, 0, 0, true);
//#ifdef TRI_COLLISION_PROFILING
//bt_end_gim02_tree_time();
//#endif //TRI_COLLISION_PROFILING
}
示例15: localCreateRigidBody
import com.bulletphysics.linearmath.Transform; //导入依赖的package包/类
private RigidBody localCreateRigidBody(float mass,
Transform startTransform, CollisionShape shape) {
Vector3f localInertia = new Vector3f(0f, 0f, 0f);
shape.calculateLocalInertia(mass, localInertia);
DefaultMotionState myMotionState = new DefaultMotionState(
startTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
myMotionState, shape, localInertia);
RigidBody body = new RigidBody(rbInfo);
body.setRestitution(2f);
body.setDamping(.01f, .3f);
ownerWorld.addRigidBody(body);
return body;
}