本文整理汇总了Java中com.bulletphysics.linearmath.Transform.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Java Transform.setRotation方法的具体用法?Java Transform.setRotation怎么用?Java Transform.setRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.linearmath.Transform
的用法示例。
在下文中一共展示了Transform.setRotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convexSweepTest
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public void convexSweepTest(ConvexShape castShape, Transform convexFromWorld, Transform convexToWorld, CollisionWorld.ConvexResultCallback resultCallback, float allowedCcdPenetration) {
Stack stack = Stack.enter();
Transform convexFromTrans = stack.allocTransform();
Transform convexToTrans = stack.allocTransform();
convexFromTrans.set(convexFromWorld);
convexToTrans.set(convexToWorld);
Vector3 castShapeAabbMin = stack.allocVector3();
Vector3 castShapeAabbMax = stack.allocVector3();
// compute AABB that encompasses angular movement
{
Vector3 linVel = stack.allocVector3();
Vector3 angVel = stack.allocVector3();
TransformUtil.calculateVelocity(convexFromTrans, convexToTrans, 1f, linVel, angVel);
Transform R = stack.allocTransform();
R.setIdentity();
R.setRotation(convexFromTrans.getRotation(stack.allocQuaternion()));
castShape.calculateTemporalAabb(R, linVel, angVel, 1f, castShapeAabbMin, castShapeAabbMax);
}
Transform tmpTrans = stack.allocTransform();
// go over all objects, and if the ray intersects their aabb + cast shape aabb,
// do a ray-shape query using convexCaster (CCD)
for (int i=0; i<overlappingObjects.size(); i++) {
CollisionObject collisionObject = overlappingObjects.getQuick(i);
// only perform raycast if filterMask matches
if (resultCallback.needsCollision(collisionObject.getBroadphaseHandle())) {
//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
Vector3 collisionObjectAabbMin = stack.allocVector3();
Vector3 collisionObjectAabbMax = stack.allocVector3();
collisionObject.getCollisionShape().getAabb(collisionObject.getWorldTransform(tmpTrans), collisionObjectAabbMin, collisionObjectAabbMax);
AabbUtil2.aabbExpand(collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
float[] hitLambda = new float[]{1f}; // could use resultCallback.closestHitFraction, but needs testing
Vector3 hitNormal = stack.allocVector3();
if (AabbUtil2.rayAabb(convexFromWorld.origin, convexToWorld.origin, collisionObjectAabbMin, collisionObjectAabbMax, hitLambda, hitNormal)) {
CollisionWorld.objectQuerySingle(castShape, convexFromTrans, convexToTrans,
collisionObject,
collisionObject.getCollisionShape(),
collisionObject.getWorldTransform(tmpTrans),
resultCallback,
allowedCcdPenetration);
}
}
}
stack.leave();
}
示例2: convexSweepTest
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
/** convexTest performs a swept convex cast on all objects in the {@link CollisionWorld}, and calls the resultCallback This
* allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback. */
public void convexSweepTest (ConvexShape castShape, Transform convexFromWorld, Transform convexToWorld,
ConvexResultCallback resultCallback) {
Stack stack = Stack.enter();
Transform convexFromTrans = stack.allocTransform();
Transform convexToTrans = stack.allocTransform();
convexFromTrans.set(convexFromWorld);
convexToTrans.set(convexToWorld);
Vector3 castShapeAabbMin = stack.allocVector3();
Vector3 castShapeAabbMax = stack.allocVector3();
// Compute AABB that encompasses angular movement
{
Vector3 linVel = stack.allocVector3();
Vector3 angVel = stack.allocVector3();
TransformUtil.calculateVelocity(convexFromTrans, convexToTrans, 1f, linVel, angVel);
Transform R = stack.allocTransform();
R.setIdentity();
R.setRotation(convexFromTrans.getRotation(stack.allocQuaternion()));
castShape.calculateTemporalAabb(R, linVel, angVel, 1f, castShapeAabbMin, castShapeAabbMax);
}
Transform tmpTrans = stack.allocTransform();
Vector3 collisionObjectAabbMin = stack.allocVector3();
Vector3 collisionObjectAabbMax = stack.allocVector3();
float[] hitLambda = new float[1];
// go over all objects, and if the ray intersects their aabb + cast shape aabb,
// do a ray-shape query using convexCaster (CCD)
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject collisionObject = collisionObjects.getQuick(i);
// only perform raycast if filterMask matches
if (resultCallback.needsCollision(collisionObject.getBroadphaseHandle())) {
// RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
collisionObject.getWorldTransform(tmpTrans);
collisionObject.getCollisionShape().getAabb(tmpTrans, collisionObjectAabbMin, collisionObjectAabbMax);
AabbUtil2.aabbExpand(collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
hitLambda[0] = 1f; // could use resultCallback.closestHitFraction, but needs testing
Vector3 hitNormal = stack.allocVector3();
if (AabbUtil2.rayAabb(convexFromWorld.origin, convexToWorld.origin, collisionObjectAabbMin, collisionObjectAabbMax,
hitLambda, hitNormal)) {
objectQuerySingle(castShape, convexFromTrans, convexToTrans, collisionObject, collisionObject.getCollisionShape(),
tmpTrans, resultCallback, getDispatchInfo().allowedCcdPenetration);
}
}
}
stack.leave();
}
示例3: convexSweepTest
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public void convexSweepTest(ConvexShape castShape, Transform convexFromWorld, Transform convexToWorld, CollisionWorld.ConvexResultCallback resultCallback, float allowedCcdPenetration) {
Transform convexFromTrans = Stack.alloc(Transform.class);
Transform convexToTrans = Stack.alloc(Transform.class);
convexFromTrans.set(convexFromWorld);
convexToTrans.set(convexToWorld);
Vector3f castShapeAabbMin = Stack.alloc(Vector3f.class);
Vector3f castShapeAabbMax = Stack.alloc(Vector3f.class);
// compute AABB that encompasses angular movement
{
Vector3f linVel = Stack.alloc(Vector3f.class);
Vector3f angVel = Stack.alloc(Vector3f.class);
TransformUtil.calculateVelocity(convexFromTrans, convexToTrans, 1f, linVel, angVel);
Transform R = Stack.alloc(Transform.class);
R.setIdentity();
R.setRotation(convexFromTrans.getRotation(Stack.alloc(Quat4f.class)));
castShape.calculateTemporalAabb(R, linVel, angVel, 1f, castShapeAabbMin, castShapeAabbMax);
}
Transform tmpTrans = Stack.alloc(Transform.class);
// go over all objects, and if the ray intersects their aabb + cast shape aabb,
// do a ray-shape query using convexCaster (CCD)
for (int i=0; i<overlappingObjects.size(); i++) {
CollisionObject collisionObject = overlappingObjects.getQuick(i);
// only perform raycast if filterMask matches
if (resultCallback.needsCollision(collisionObject.getBroadphaseHandle())) {
//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
Vector3f collisionObjectAabbMin = Stack.alloc(Vector3f.class);
Vector3f collisionObjectAabbMax = Stack.alloc(Vector3f.class);
collisionObject.getCollisionShape().getAabb(collisionObject.getWorldTransform(tmpTrans), collisionObjectAabbMin, collisionObjectAabbMax);
AabbUtil2.aabbExpand(collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
float[] hitLambda = new float[]{1f}; // could use resultCallback.closestHitFraction, but needs testing
Vector3f hitNormal = Stack.alloc(Vector3f.class);
if (AabbUtil2.rayAabb(convexFromWorld.origin, convexToWorld.origin, collisionObjectAabbMin, collisionObjectAabbMax, hitLambda, hitNormal)) {
CollisionWorld.objectQuerySingle(castShape, convexFromTrans, convexToTrans,
collisionObject,
collisionObject.getCollisionShape(),
collisionObject.getWorldTransform(tmpTrans),
resultCallback,
allowedCcdPenetration);
}
}
}
}
示例4: convexSweepTest
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
/**
* convexTest performs a swept convex cast on all objects in the {@link CollisionWorld}, and calls the resultCallback
* This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
*/
public void convexSweepTest(ConvexShape castShape, Transform convexFromWorld, Transform convexToWorld, ConvexResultCallback resultCallback) {
Transform convexFromTrans = Stack.alloc(Transform.class);
Transform convexToTrans = Stack.alloc(Transform.class);
convexFromTrans.set(convexFromWorld);
convexToTrans.set(convexToWorld);
Vector3f castShapeAabbMin = Stack.alloc(Vector3f.class);
Vector3f castShapeAabbMax = Stack.alloc(Vector3f.class);
// Compute AABB that encompasses angular movement
{
Vector3f linVel = Stack.alloc(Vector3f.class);
Vector3f angVel = Stack.alloc(Vector3f.class);
TransformUtil.calculateVelocity(convexFromTrans, convexToTrans, 1f, linVel, angVel);
Transform R = Stack.alloc(Transform.class);
R.setIdentity();
R.setRotation(convexFromTrans.getRotation(Stack.alloc(Quat4f.class)));
castShape.calculateTemporalAabb(R, linVel, angVel, 1f, castShapeAabbMin, castShapeAabbMax);
}
Transform tmpTrans = Stack.alloc(Transform.class);
Vector3f collisionObjectAabbMin = Stack.alloc(Vector3f.class);
Vector3f collisionObjectAabbMax = Stack.alloc(Vector3f.class);
float[] hitLambda = new float[1];
// go over all objects, and if the ray intersects their aabb + cast shape aabb,
// do a ray-shape query using convexCaster (CCD)
for (int i = 0; i < collisionObjects.size(); i++) {
CollisionObject collisionObject = collisionObjects.getQuick(i);
// only perform raycast if filterMask matches
if (resultCallback.needsCollision(collisionObject.getBroadphaseHandle())) {
//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
collisionObject.getWorldTransform(tmpTrans);
collisionObject.getCollisionShape().getAabb(tmpTrans, collisionObjectAabbMin, collisionObjectAabbMax);
AabbUtil2.aabbExpand(collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
hitLambda[0] = 1f; // could use resultCallback.closestHitFraction, but needs testing
Vector3f hitNormal = Stack.alloc(Vector3f.class);
if (AabbUtil2.rayAabb(convexFromWorld.origin, convexToWorld.origin, collisionObjectAabbMin, collisionObjectAabbMax, hitLambda, hitNormal)) {
objectQuerySingle(castShape, convexFromTrans, convexToTrans,
collisionObject,
collisionObject.getCollisionShape(),
tmpTrans,
resultCallback,
getDispatchInfo().allowedCcdPenetration);
}
}
}
}
示例5: update
import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void update() {
Transform trans = new Transform();
rb.getMotionState().getWorldTransform(trans);
Quat4f rotation = new Quat4f();
rotation.set(new Matrix4f(mat4().rotateY(-angle).getArray()));
trans.setRotation(rotation);
Vector3f velocity = new Vector3f();
rb.getLinearVelocity(velocity);
rb.setWorldTransform(trans);
Vec3 vel = vec3();
if (Input.isKeyDown(GLFW_KEY_UP)) {
vel = vec3(0, 0, -10).rotateYaw(angle);
}
if (Input.isKeyDown(GLFW_KEY_DOWN)) {
vel = vec3(0, 0, -10).rotateYaw(angle).negate();
}
if (Input.isKeyDown(GLFW_KEY_LEFT)) {
angle += 2;
}
if (Input.isKeyDown(GLFW_KEY_RIGHT)) {
angle -= 2;
}
vel.y =velocity.y;
if (Input.isKeyDown(GLFW_KEY_SPACE)) {
vel.y = 10f;
}
this.rb.setLinearVelocity(vel.asv3f());
this.rb.activate();
}