当前位置: 首页>>代码示例>>Java>>正文


Java DbvtBroadphase类代码示例

本文整理汇总了Java中com.bulletphysics.collision.broadphase.DbvtBroadphase的典型用法代码示例。如果您正苦于以下问题:Java DbvtBroadphase类的具体用法?Java DbvtBroadphase怎么用?Java DbvtBroadphase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DbvtBroadphase类属于com.bulletphysics.collision.broadphase包,在下文中一共展示了DbvtBroadphase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
/**
 * Set up the physics engine for the scene.
 */
public void setUp() {
    // Create a DBVT broadphase to broadly check collisions using the AABB technique which ensures good performance
    BroadphaseInterface broadphase = new DbvtBroadphase();

    // Set up a collision configuration and dispatcher
    CollisionConfiguration collisionConfig = new DefaultCollisionConfiguration();
    CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfig);

    // Configure a constraint solver
    ConstraintSolver solver = new SequentialImpulseConstraintSolver();

    // Create and configure the Bullet physics dynamic world
    this.bulletDynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
    this.bulletDynamicsWorld.setGravity(new Vector3f(0, -9.81f, 0));
}
 
开发者ID:timvisee,项目名称:key-barricade,代码行数:19,代码来源:ScenePhysicsEngine.java

示例2: Scene

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public Scene() {
	sun = new DirectionalLight(vec3(-1.0f, -1.0f, 0.2f), vec3(2.0f, 2.0f, 2.0f), Settings.ENABLE_SHADOWS, 30, Settings.SHADOW_RESOLUTION);
	
	//setup bullet
	BroadphaseInterface broadphase = new DbvtBroadphase();
	DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
	CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);

	SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();

	world = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);

	// set the gravity of our world
	world.setGravity(new Vector3f(0, -9.8f, 0));
	
	//setup jbox2D
	world2D = new World(new Vector2(0, -9.8f));	
	world2D.setContactListener(this);
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:20,代码来源:Scene.java

示例3: Screen

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public Screen() {
    /*
     Set the color to black
     */
    glClearColor(0, 0, 0, 1);
    BroadphaseInterface broadphase = new DbvtBroadphase();
    CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
    CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
    ConstraintSolver solver = new SequentialImpulseConstraintSolver();
    physicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
    physicsWorld.setGravity(new Vector3f(0, -10 /* m/s2 */, 0));
    
    /*
     initialize the entities list
     */
    entities = new LinkedList<>();

    camera = new Camera(1280, 720, 67f, 0.1f, 1000000000000f);

    //call the create method
    create();
}
 
开发者ID:StavrosSkourtis,项目名称:SuperHornet,代码行数:23,代码来源:Screen.java

示例4: initializePhysics

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
protected void initializePhysics(){
    // JBullet Stuff
    DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
    CollisionDispatcher dispatcher = new CollisionDispatcher(
            collisionConfiguration);
    float bound = 800;
    Vector3f worldAabbMin = new Vector3f(-bound, -bound, -bound);
    Vector3f worldAabbMax = new Vector3f(bound, bound, bound);
    int maxProxies = 5000;
    AxisSweep3 overlappingPairCache =
            new AxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
    BroadphaseInterface broadphase = new DbvtBroadphase();
    SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
    world = new DiscreteDynamicsWorld(
            dispatcher,overlappingPairCache, solver,
            collisionConfiguration);
    world.setGravity(new Vector3f(0, -9.8f, 0));
}
 
开发者ID:seemywingz,项目名称:Kengine,代码行数:19,代码来源:Scene.java

示例5: BulletPhysics

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public BulletPhysics(WorldProvider world) {
    collisionGroupManager = CoreRegistry.get(CollisionGroupManager.class);

    _broadphase = new DbvtBroadphase();
    _broadphase.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
    _defaultCollisionConfiguration = new DefaultCollisionConfiguration();
    _dispatcher = new CollisionDispatcher(_defaultCollisionConfiguration);
    _sequentialImpulseConstraintSolver = new SequentialImpulseConstraintSolver();
    _discreteDynamicsWorld = new DiscreteDynamicsWorld(_dispatcher, _broadphase, _sequentialImpulseConstraintSolver, _defaultCollisionConfiguration);
    _discreteDynamicsWorld.setGravity(new Vector3f(0f, -15f, 0f));
    blockEntityRegistry = CoreRegistry.get(BlockEntityRegistry.class);
    CoreRegistry.get(EventSystem.class).registerEventReceiver(this, BlockChangedEvent.class, BlockComponent.class);

    PhysicsWorldWrapper wrapper = new PhysicsWorldWrapper(world);
    VoxelWorldShape worldShape = new VoxelWorldShape(wrapper);

    Matrix3f rot = new Matrix3f();
    rot.setIdentity();
    DefaultMotionState blockMotionState = new DefaultMotionState(new Transform(new Matrix4f(rot, new Vector3f(0, 0, 0), 1.0f)));
    RigidBodyConstructionInfo blockConsInf = new RigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f());
    RigidBody rigidBody = new RigidBody(blockConsInf);
    rigidBody.setCollisionFlags(CollisionFlags.STATIC_OBJECT | rigidBody.getCollisionFlags());
    _discreteDynamicsWorld.addRigidBody(rigidBody, combineGroups(StandardCollisionGroup.WORLD), (short)(CollisionFilterGroups.ALL_FILTER ^ CollisionFilterGroups.STATIC_FILTER));
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:25,代码来源:BulletPhysics.java

示例6: PhysicsWorldJbullet

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public PhysicsWorldJbullet(){
	BroadphaseInterface broadphase=new DbvtBroadphase();
	CollisionConfiguration collisionConfiguration=new DefaultCollisionConfiguration();
	CollisionDispatcher dispatcher=new CollisionDispatcher(collisionConfiguration);
	ConstraintSolver constraintSolver=new SequentialImpulseConstraintSolver();
	
	bulletWorld=new DiscreteDynamicsWorld(dispatcher, broadphase, constraintSolver, collisionConfiguration);
	setGravity(0, -9.81F, 0);
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:10,代码来源:PhysicsWorldJbullet.java

示例7: PhysicsSpace

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
/**
 * 
 */
public PhysicsSpace() {
	// TODO: Comments on stuff.
	broadPhase = new DbvtBroadphase();
	collisionConfiguration = new DefaultCollisionConfiguration();
	dispatcher = new CollisionDispatcher(collisionConfiguration);

	solver = new SequentialImpulseConstraintSolver();
	
	dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadPhase, solver, collisionConfiguration);
	dynamicsWorld.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
	dynamicsWorld.setGravity(new Vector3f(0, -10, 0));
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:16,代码来源:PhysicsSpace.java

示例8: PhysicsEngine

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public PhysicsEngine() {
	broadphase = new DbvtBroadphase();
	collisionConfiguration = new DefaultCollisionConfiguration();
	dispatcher = new CollisionDispatcher(collisionConfiguration);
	solver = new SequentialImpulseConstraintSolver();
	dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
	dynamicsWorld.setGravity(new Vector3f(0, -9.81f, 0));
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:9,代码来源:PhysicsEngine.java

示例9: initWorld

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
protected void initWorld() {
    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, -1, 0));

    groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 1);

    DefaultMotionState groundMotionState = new DefaultMotionState(
            new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1),
                    new Vector3f(0, -1, 0), 1.0f)));

    RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(
            0, groundMotionState, groundShape, new Vector3f(0, 0, 0));
    groundRigidBody = new RigidBody(groundRigidBodyCI);

    world.addRigidBody(groundRigidBody);

    dollOne = new RagDollShape(world, new Vector3f(0.0f, 30.0f, 0.0f), 5.0f);
    dollTwo = new RagDollShape(world, new Vector3f(10.0f, 30.0f, 0.0f),
            5.0f);

    dollOne.setLinearSpeed(new Vector3f(30f, 0f, 0f));
    dollTwo.setLinearSpeed(new Vector3f(-30f, 0f, 0f));

    dollOne.saveState();
    dollTwo.saveState();
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:36,代码来源:Ragdoll.java

示例10: initPhysics

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public void initPhysics() {
	// Setup the basic world
	DefaultCollisionConfiguration collision_config = new DefaultCollisionConfiguration();

	CollisionDispatcher dispatcher = new CollisionDispatcher(collision_config);

	Vector3f worldAabbMin = new Vector3f(-10000, -10000, -10000);
	Vector3f worldAabbMax = new Vector3f(10000, 10000, 10000);
	//BroadphaseInterface overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax);
	//BroadphaseInterface overlappingPairCache = new SimpleBroadphase();
	BroadphaseInterface overlappingPairCache = new DbvtBroadphase();

	//#ifdef USE_ODE_QUICKSTEP
	//btConstraintSolver* constraintSolver = new OdeConstraintSolver();
	//#else
	ConstraintSolver constraintSolver = new SequentialImpulseConstraintSolver();
	//#endif

	dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collision_config);

	dynamicsWorld.setGravity(new Vector3f(0f, -30f, 0f));

	dynamicsWorld.setDebugDrawer(new GLDebugDrawer(gl));

	// Setup a big ground box
	{
		CollisionShape groundShape = new BoxShape(new Vector3f(200f, 10f, 200f));
		Transform groundTransform = new Transform();
		groundTransform.setIdentity();
		groundTransform.origin.set(0f, -15f, 0f);
		localCreateRigidBody(0f, groundTransform, groundShape);
	}

	// Spawn one ragdoll
	spawnRagdoll();

	clientResetScene();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:39,代码来源:GenericJointDemo.java

示例11: initPhysics

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
public void initPhysics() throws Exception {
	cameraUp.set(0f, 0f, 1f);
	forwardAxis = 1;

	setCameraDistance(22f);

	// Setup a Physics Simulation Environment

	collisionConfiguration = new DefaultCollisionConfiguration();
	// btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
	dispatcher = new CollisionDispatcher(collisionConfiguration);
	Vector3f worldMin = new Vector3f(-1000f,-1000f,-1000f);
	Vector3f worldMax = new Vector3f(1000f,1000f,1000f);
	//broadphase = new AxisSweep3(worldMin, worldMax);
	//broadphase = new SimpleBroadphase();
	broadphase = new DbvtBroadphase();
	//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
	solver = new SequentialImpulseConstraintSolver();
	//ConstraintSolver* solver = new OdeConstraintSolver;
	dynamicsWorld = new DiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);

	Vector3f gravity = new Vector3f();
	gravity.negate(cameraUp);
	gravity.scale(10f);
	dynamicsWorld.setGravity(gravity);

	new BspToBulletConverter().convertBsp(getClass().getResourceAsStream("exported.bsp.txt"));
	
	clientResetScene();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:31,代码来源:BspDemo.java

示例12: init

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的package包/类
@Override
public void init(RunConfig config) throws InvalidTestFormatException {
    super.init(config);
    numBricks = towerRotSize * towerHeight;

    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, gravityY, 0));

    groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 0);
    Vector3f brickSize = new Vector3f(1f, 1f, 1f);
    brickShape = new BoxShape(brickSize);

    DefaultMotionState groundMotion = new DefaultMotionState(new Transform(
            new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0),
                    1.0f)));

    RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(
            0, groundMotion, groundShape, new Vector3f(0, 0, 0));
    ground = new RigidBody(groundRigidBodyCI);
    world.addRigidBody(ground);
    zero3f = new Vector3f(0, 0, 0);
    Vector3f dominoInertia = new Vector3f(0, 0, 0);
    brickShape.calculateLocalInertia(brickMass, dominoInertia);

    brickOrigTransform = new Transform[numBricks];
    brick = new RigidBody[numBricks];
    float radius = 1.3f * towerRotSize * brickSize.z;
    Quat4f rotY = new Quat4f(0f, 1f, 0f, 0f);
    float posY = brickSize.y;
    Vector3f offsetPosition = new Vector3f(0.8f, 0f, 0f);
    int currentBrick = 0;
    for (int n = 0; n < towerHeight; n++) {
        for (int i = 0; i < towerRotSize; i++) {
            Vector3f position = new Vector3f();
            position.add(offsetPosition);
            position.add(rotate(rotY, new Vector3f(0.0f, posY, radius)));
            Transform trans = new Transform(new Matrix4f(rotY, position,
                    1.0f));
            makeBrick(currentBrick++, brickMass, dominoInertia, trans);
            rotY.mul(new Quat4f(0f, 1f, 0f, (float) Math.PI
                    / (towerRotSize * 0.5f)));
        }

        posY += brickSize.y * 2.0f;
        rotY.mul(new Quat4f(0f, 1f, 0f, (float) Math.PI
                / (float) towerRotSize));
    }
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:58,代码来源:BreakingTheTower.java

示例13: init

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的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]);
    }
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:55,代码来源:Gyroscope.java

示例14: init

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的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, gravityY, 0));

    groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 0);
    ballShape = new SphereShape(10);
    brickShape = new BoxShape(new Vector3f(sz, sz, sz));

    DefaultMotionState groundMotion = new DefaultMotionState(new Transform(
            new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0),
                    1.0f)));

    RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(
            0, groundMotion, groundShape, new Vector3f(0, 0, 0));
    ground = new RigidBody(groundRigidBodyCI);

    world.addRigidBody(ground);

    ballOrigTransform = new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1),
            new Vector3f(sz * wallLen, 8, 30), 1.0f));
    DefaultMotionState ballMotion = new DefaultMotionState(
            ballOrigTransform);
    Vector3f ballInertia = new Vector3f(1000, 1000, 1000);
    ballShape.calculateLocalInertia(ballMass, ballInertia);
    RigidBodyConstructionInfo ballRigidBodyCI = new RigidBodyConstructionInfo(
            ballMass, ballMotion, ballShape, ballInertia);
    ball = new RigidBody(ballRigidBodyCI);
    ballLinearVelocity = new Vector3f(0, 20, -150);
    ballAngularVelocity = new Vector3f(50, 50, 50);
    ball.setLinearVelocity(ballLinearVelocity);
    ball.setAngularVelocity(ballAngularVelocity);
    world.addRigidBody(ball);

    zero3f = new Vector3f(0, 0, 0);
    Vector3f brickInertia = new Vector3f(0, 0, 0);
    brickShape.calculateLocalInertia(brickMass, brickInertia);
    brickInertia.x *= 20;
    brickInertia.y *= 20;
    brickInertia.z *= 20;

    wallWidth = 3;
    numBricks = wallHeight * wallLen * wallWidth;

    brickOrigTransform = new Transform[numBricks];
    brick = new RigidBody[numBricks];

    float offsetW = 0;
    for (int w = 0; w < wallWidth; w++) {
        float offsetH = 0;
        for (int h = 0; h < wallHeight; h++) {
            float offsetL = 0;
            for (int i = 0; i < wallLen; i++) {
                makeBrick(w * wallHeight * wallLen + h * wallLen + i,
                        brickMass, brickInertia, new Vector3f(offsetL,
                                offsetH + sz, offsetW), 0);
                offsetL += 2 * sz;
            }
            offsetH += 2 * sz;
        }
        offsetW += 2 * sz;
    }
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:75,代码来源:BreakingTheWall.java

示例15: init

import com.bulletphysics.collision.broadphase.DbvtBroadphase; //导入依赖的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, gravityY, 0));

    groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 1);
    ballShape = new SphereShape(1);

    DefaultMotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0), 1.0f)));

    RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0, 0, 0));
    ground = new RigidBody(groundRigidBodyCI);
    ground.setRestitution(1f);
    world.addRigidBody(ground);

    zero3f = new Vector3f(0, 0, 0);
    ballLinearVelocity = new Vector3f(0, -5 , 0);
    ballOrigTransform = new Transform[cntBalls];
    ball = new RigidBody[cntBalls];
    dmt = new DefaultMotionState[cntBalls];
    for(int i = 0; i < cntBalls; i++) {
        ballOrigTransform[i] = new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(3 * i, 10, 0), 1.0f));
        dmt[i] = new DefaultMotionState(ballOrigTransform[i]);

        Vector3f ballInertia = new Vector3f(0, 0, 0);
        ballShape.calculateLocalInertia(mass, ballInertia);

        RigidBodyConstructionInfo ballRigidBodyCI = new RigidBodyConstructionInfo(mass, dmt[i], ballShape, ballInertia);

        ball[i] = new RigidBody(ballRigidBodyCI);
        ball[i].setRestitution(1 - .1f * i / cntBalls);
        ball[i].setDamping(.5f * i / cntBalls, .5f * i / cntBalls);
        ball[i].setFriction(.75f - .5f * i / cntBalls);
        ball[i].setLinearVelocity(ballLinearVelocity);
        world.addRigidBody(ball[i]);
    }
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:47,代码来源:FallingBall.java


注:本文中的com.bulletphysics.collision.broadphase.DbvtBroadphase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。