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


Java PairCachingGhostObject.setCollisionShape方法代码示例

本文整理汇总了Java中com.bulletphysics.collision.dispatch.PairCachingGhostObject.setCollisionShape方法的典型用法代码示例。如果您正苦于以下问题:Java PairCachingGhostObject.setCollisionShape方法的具体用法?Java PairCachingGhostObject.setCollisionShape怎么用?Java PairCachingGhostObject.setCollisionShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bulletphysics.collision.dispatch.PairCachingGhostObject的用法示例。


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

示例1: initPhysics

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入方法依赖的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);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:19,代码来源:Player.java

示例2: initPhysics

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入方法依赖的package包/类
public void initPhysics() throws Exception {
	CollisionShape groundShape = new BoxShape(new Vector3f(50, 3, 50));
	collisionShapes.add(groundShape);

	collisionConfiguration = new DefaultCollisionConfiguration();
	dispatcher = new CollisionDispatcher(collisionConfiguration);
	Vector3f worldMin = new Vector3f(-1000f,-1000f,-1000f);
	Vector3f worldMax = new Vector3f(1000f,1000f,1000f);
	AxisSweep3 sweepBP = new AxisSweep3(worldMin, worldMax);
	overlappingPairCache = sweepBP;

	constraintSolver = new SequentialImpulseConstraintSolver();
	dynamicsWorld = new DiscreteDynamicsWorld(dispatcher,overlappingPairCache,constraintSolver,collisionConfiguration);

	Transform startTransform = new Transform();
	startTransform.setIdentity();
	startTransform.origin.set(0.0f, 4.0f, 0.0f);

	ghostObject = new PairCachingGhostObject();
	ghostObject.setWorldTransform(startTransform);
	sweepBP.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
	float characterHeight = 1.75f * characterScale;
	float characterWidth = 1.75f * characterScale;
	ConvexShape capsule = new CapsuleShape(characterWidth, characterHeight);
	ghostObject.setCollisionShape(capsule);
	ghostObject.setCollisionFlags(CollisionFlags.CHARACTER_OBJECT);

	float stepHeight = 0.35f * characterScale;
	character = new KinematicCharacterController(ghostObject, capsule, stepHeight);

	new BspToBulletConverter().convertBsp(getClass().getResourceAsStream("/com/bulletphysics/demos/bsp/exported.bsp.txt"));

	dynamicsWorld.addCollisionObject(ghostObject, CollisionFilterGroups.CHARACTER_FILTER, (short)(CollisionFilterGroups.STATIC_FILTER | CollisionFilterGroups.DEFAULT_FILTER));

	dynamicsWorld.addAction(character);
	
	clientResetScene();

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

示例3: KinematicCharacterControllerComponent

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入方法依赖的package包/类
public KinematicCharacterControllerComponent(boolean gravity, float radius, float height, float stepHeight, Vector3f position, int jumpKey, int forwardKey, int backKey, int leftKey, int rightKey) {
	shape = new CapsuleShape(radius,height);
	ghostObject = new PairCachingGhostObject();
	
	ghostObject.setWorldTransform(PhysicsSystem.createTransform(position, null));
	ghostObject.setCollisionShape(shape);
	ghostObject.setCollisionFlags(CollisionFlags.CHARACTER_OBJECT);
	
	// http://hub.jmonkeyengine.org/javadoc/com/jme3/bullet/control/BetterCharacterControl.html
	character = new KinematicCharacterController(ghostObject,shape ,stepHeight);
	
	if (gravity) {
		character.setJumpSpeed(5.0f);
		character.setFallSpeed(500.0f);
	} else {
		character.setJumpSpeed(0.0f);
		character.setFallSpeed(0.0f);
		character.setGravity(0);
	}
	
	this.gravity = gravity;

	PhysicsSystem.getWorld().addCollisionObject(ghostObject,CollisionFilterGroups.CHARACTER_FILTER,(short)(CollisionFilterGroups.STATIC_FILTER | CollisionFilterGroups.DEFAULT_FILTER));
	PhysicsSystem.getWorld().addAction(character);
	
	this.jumpKey = jumpKey;
	this.forwardKey = forwardKey;
	this.backKey = backKey;
	this.leftKey = leftKey;
	this.rightKey = rightKey;
	
	this.height = height;
	
	initFeet();
	
	lastWalkPosition.set(position);
	wasOnGround = character.onGround();
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:39,代码来源:KinematicCharacterControllerComponent.java

示例4: createCollider

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入方法依赖的package包/类
private PairCachingGhostObject createCollider(Vector3f pos, ConvexShape shape, short groups, short filters, int collisionFlags) {
    Transform startTransform = new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), pos, 1.0f));
    PairCachingGhostObject result = new PairCachingGhostObject();
    result.setWorldTransform(startTransform);
    result.setCollisionShape(shape);
    result.setCollisionFlags(collisionFlags);
    _discreteDynamicsWorld.addCollisionObject(result, groups, filters);
    return result;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:10,代码来源:BulletPhysics.java


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