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


Java CollisionDispatcher类代码示例

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


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

示例1: setUp

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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.dispatch.CollisionDispatcher; //导入依赖的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.dispatch.CollisionDispatcher; //导入依赖的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: initialize

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的package包/类
public static void initialize() {
	destroy();
	logger.info("Physics System initilize");

	worldBounds = fromString(EngineCore.getProperty("physics.world_bounds", "-10000,-10000,-10000,10000,10000,10000"));
	maxWorldObjectCount = EngineCore.getProperty("physics.max_world_object_count", 4096);

	collisionConfiguration = new DefaultCollisionConfiguration();
	dispatcher = new CollisionDispatcher(collisionConfiguration);
	constraintSolver = new SequentialImpulseConstraintSolver();
	
	//BroadphaseInterface broadphase = new DbvtBroadphase();
	BroadphaseInterface broadphase = new AxisSweep3(worldBounds.getMin().toVecmathVec3f(), worldBounds.getMax().toVecmathVec3f(), maxWorldObjectCount);

	seed = ((SequentialImpulseConstraintSolver)constraintSolver).getRandSeed();
	world = new DiscreteDynamicsWorld(dispatcher, broadphase, constraintSolver, collisionConfiguration);
	
	world.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
	
	world.setGravity(new javax.vecmath.Vector3f(0,-9.82f,0.0f));
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:22,代码来源:PhysicsSystem.java

示例5: initializePhysics

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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

示例6: BulletPhysics

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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

示例7: PhysicsEngine

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的package包/类
/**
 * Initializes the JBullet physics engine. {@link #onResume()}, {@link #onPause()} and
 * {@link #onDestroy()} have to be called from the corresponding life cycle methods. By default
 * this is all handled by {@link de.fabmax.lightgl.GfxEngine} if physics simulation was enabled
 * on engine creation.
 *
 * @see de.fabmax.lightgl.GfxEngine#GfxEngine(android.content.Context, boolean)
 * @see de.fabmax.lightgl.GfxEngine#getPhysicsEngine()
 */
public PhysicsEngine() {
    // init collision stuff
    CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
    CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);

    // maximum size of the collision world.
    Vector3f worldAabbMin = new Vector3f(-100, -100, -100);
    Vector3f worldAabbMax = new Vector3f(100, 100, 100);
    BroadphaseInterface broadphase = new AxisSweep3(worldAabbMin, worldAabbMax);

    SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();

    mWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
    mWorld.setGravity(new Vector3f(0, -G, 0));
}
 
开发者ID:fabmax,项目名称:LightGL,代码行数:25,代码来源:PhysicsEngine.java

示例8: PhysicsWorldJbullet

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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

示例9: stepSimulation

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的package包/类
/**
 * maxSubSteps/fixedTimeStep for interpolation is currently ignored for SimpleDynamicsWorld, use DiscreteDynamicsWorld instead.
 */
@Override
public int stepSimulation(float timeStep, int maxSubSteps, float fixedTimeStep) {
	// apply gravity, predict motion
	predictUnconstraintMotion(timeStep);

	DispatcherInfo dispatchInfo = getDispatchInfo();
	dispatchInfo.timeStep = timeStep;
	dispatchInfo.stepCount = 0;
	dispatchInfo.debugDraw = getDebugDrawer();

	// perform collision detection
	performDiscreteCollisionDetection();

	// solve contact constraints
	int numManifolds = dispatcher1.getNumManifolds();
	if (numManifolds != 0)
	{
		ObjectArrayList<PersistentManifold> manifoldPtr = ((CollisionDispatcher)dispatcher1).getInternalManifoldPointer();

		ContactSolverInfo infoGlobal = new ContactSolverInfo();
		infoGlobal.timeStep = timeStep;
		constraintSolver.prepareSolve(0,numManifolds);
		constraintSolver.solveGroup(null,0,manifoldPtr, 0, numManifolds, null,0,0,infoGlobal,debugDrawer/*, m_stackAlloc*/,dispatcher1);
		constraintSolver.allSolved(infoGlobal,debugDrawer/*, m_stackAlloc*/);
	}

	// integrate transforms
	integrateTransforms(timeStep);

	updateAabbs();

	synchronizeMotionStates();

	clearForces();

	return 1;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:41,代码来源:SimpleDynamicsWorld.java

示例10: registerAlgorithm

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的package包/类
/**
 * Use this function for register the algorithm externally.
 */
public static void registerAlgorithm(CollisionDispatcher dispatcher) {
	CreateFunc createFunc = new CreateFunc();

	for (int i=0; i<BroadphaseNativeType.MAX_BROADPHASE_COLLISION_TYPES.ordinal(); i++) {
		dispatcher.registerCollisionCreateFunc(BroadphaseNativeType.GIMPACT_SHAPE_PROXYTYPE.ordinal(), i, createFunc);
	}

	for (int i=0; i<BroadphaseNativeType.MAX_BROADPHASE_COLLISION_TYPES.ordinal(); i++) {
		dispatcher.registerCollisionCreateFunc(i, BroadphaseNativeType.GIMPACT_SHAPE_PROXYTYPE.ordinal(), createFunc);
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:15,代码来源:GImpactCollisionAlgorithm.java

示例11: PhysicsEngine

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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

示例12: initWorld

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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

示例13: initPhysics

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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();

	//#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,代码行数:38,代码来源:GenericJointDemo.java

示例14: initPhysics

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的package包/类
public void initPhysics() {
	// Setup the basic world
	time = 0.0f;
	cyclePeriod = 2000.0f; // in milliseconds
	muscleStrength = 0.05f;

	setCameraDistance(5.0f);
	
	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();

	ConstraintSolver constraintSolver = new SequentialImpulseConstraintSolver();

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

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

	// Spawn one TestRig
	Vector3f startOffset = new Vector3f(1.0f, 0.5f, 0.0f);
	spawnTestRig(startOffset, false);
	startOffset.set(-2.0f, 0.5f, 0.0f);
	spawnTestRig(startOffset, true);

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

示例15: initPhysics

import com.bulletphysics.collision.dispatch.CollisionDispatcher; //导入依赖的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();
	//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,代码行数:30,代码来源:BspDemo.java


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