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


Java PairCachingGhostObject类代码示例

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


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

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
public KinematicCharacterController (PairCachingGhostObject ghostObject, ConvexShape convexShape, float stepHeight,
	int upAxis) {
	this.upAxis = upAxis;
	this.addedMargin = 0.02f;
	this.walkDirection.set(0, 0, 0);
	this.useGhostObjectSweepTest = true;
	this.ghostObject = ghostObject;
	this.stepHeight = stepHeight;
	this.turnAngle = 0.0f;
	this.convexShape = convexShape;
	this.useWalkDirection = true;
	this.velocityTimeInterval = 0.0f;
	this.verticalVelocity = 0.0f;
	this.verticalOffset = 0.0f;
	this.gravity = 9.8f; // 1G acceleration
	this.fallSpeed = 55.0f; // Terminal velocity of a sky diver in m/s.
	this.jumpSpeed = 10.0f; // ?
	this.wasOnGround = false;
	setMaxSlope((float)((50.0f / 180.0f) * Math.PI));
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:21,代码来源:KinematicCharacterController.java

示例3: KinematicCharacterController

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
public KinematicCharacterController(PairCachingGhostObject ghostObject, ConvexShape convexShape, float stepHeight, int upAxis) {
	this.upAxis = upAxis;
	this.addedMargin = 0.02f;
	this.walkDirection.set(0, 0, 0);
	this.useGhostObjectSweepTest = true;
	this.ghostObject = ghostObject;
	this.stepHeight = stepHeight;
	this.turnAngle = 0.0f;
	this.convexShape = convexShape;
	this.useWalkDirection = true;
	this.velocityTimeInterval = 0.0f;
	this.verticalVelocity = 0.0f;
	this.verticalOffset = 0.0f;
	this.gravity = 9.8f; // 1G acceleration
	this.fallSpeed = 55.0f; // Terminal velocity of a sky diver in m/s.
	this.jumpSpeed = 10.0f; // ?
	this.wasOnGround = false;
	setMaxSlope((float)((50.0f/180.0f) * Math.PI));
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:20,代码来源:KinematicCharacterController.java

示例4: updateTrigger

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
@ReceiveEvent(components = {TriggerComponent.class, LocationComponent.class})
public void updateTrigger(ChangedComponentEvent event, EntityRef entity) {
    LocationComponent location = entity.getComponent(LocationComponent.class);
    PairCachingGhostObject triggerObj = entityTriggers.get(entity);

    if (triggerObj != null) {
        float scale = location.getWorldScale();
        if (Math.abs(triggerObj.getCollisionShape().getLocalScaling(new Vector3f()).x - scale) > BulletGlobals.SIMD_EPSILON) {
            physics.removeCollider(triggerObj);
            createTrigger(entity);
        } else {
            triggerObj.setWorldTransform(new Transform(new Matrix4f(location.getWorldRotation(), location.getWorldPosition(), 1.0f)));
        }
    }

    // TODO: update if detectGroups changed
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:18,代码来源:PhysicsSystem.java

示例5: 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

示例6: 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

示例7: createTrigger

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
private void createTrigger(EntityRef entity) {
    LocationComponent location = entity.getComponent(LocationComponent.class);
    TriggerComponent trigger = entity.getComponent(TriggerComponent.class);
    ConvexShape shape = getShapeFor(entity);
    if (shape != null) {
        float scale = location.getWorldScale();
        shape.setLocalScaling(new Vector3f(scale, scale, scale));
        List<CollisionGroup> detectGroups = Lists.newArrayList(trigger.detectGroups);
        PairCachingGhostObject triggerObj = physics.createCollider(location.getWorldPosition(), shape, Lists.<CollisionGroup>newArrayList(StandardCollisionGroup.SENSOR), detectGroups, CollisionFlags.NO_CONTACT_RESPONSE);
        triggerObj.setUserPointer(entity);
        entityTriggers.put(entity, triggerObj);
    }
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:14,代码来源:PhysicsSystem.java

示例8: 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

示例9: move

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
private MoveResult move(Vector3f startPosition, Vector3f moveDelta, float stepHeight, float slopeFactor, PairCachingGhostObject collider) {
    steppedUpDist = 0;
    stepped = false;

    MoveResult result = new MoveResult();
    Vector3f position = new Vector3f(startPosition);
    result.finalPosition = position;

    // Actual upwards movement
    if (moveDelta.y > 0) {
        result.hitTop = moveDelta.y - moveUp(moveDelta.y, collider, position) > BulletGlobals.SIMD_EPSILON;
    }
    result.hitHoriz = moveHorizontal(new Vector3f(moveDelta.x, 0, moveDelta.z), collider, position, slopeFactor, stepHeight);
    if (moveDelta.y < 0 || steppedUpDist > 0) {
        float dist = (moveDelta.y < 0) ? moveDelta.y : 0;
        dist -= steppedUpDist;
        result.hitBottom = moveDown(dist, slopeFactor, collider, position);
    }
    if (!result.hitBottom && stepHeight > 0) {
        Vector3f tempPos = new Vector3f(position);
        result.hitBottom = moveDown(-stepHeight, slopeFactor, collider, tempPos);
        // Don't apply step down if nothing to step onto
        if (result.hitBottom) {
            position.set(tempPos);
        }
    }
    return result;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:29,代码来源:BulletCharacterMovementSystem.java

示例10: checkStep

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
private boolean checkStep(PairCachingGhostObject collider, Vector3f position, Vector3f direction, SweepCallback callback, float slopeFactor, float stepHeight) {
    if (!stepped) {
        stepped = true;

        Vector3f lookAheadOffset = new Vector3f(direction);
        lookAheadOffset.y = 0;
        lookAheadOffset.normalize();
        lookAheadOffset.scale(CHECK_FORWARD_DIST);
        boolean hitStep = false;
        float stepSlope = 1f;

        Vector3f fromWorld = new Vector3f(callback.hitPointWorld);
        fromWorld.y += stepHeight + 0.05f;
        fromWorld.add(lookAheadOffset);
        Vector3f toWorld = new Vector3f(callback.hitPointWorld);
        toWorld.y -= 0.05f;
        toWorld.add(lookAheadOffset);
        CollisionWorld.ClosestRayResultCallback rayResult = new CollisionWorld.ClosestRayResultCallback(fromWorld, toWorld);
        CollisionWorld.rayTestSingle(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), fromWorld, 1.0f)), new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), toWorld, 1.0f)), callback.hitCollisionObject, callback.hitCollisionObject.getCollisionShape(), callback.hitCollisionObject.getWorldTransform(new Transform()), rayResult);
        if (rayResult.hasHit()) {
            hitStep = true;
            stepSlope = rayResult.hitNormalWorld.dot(new Vector3f(0, 1, 0));
        }
        fromWorld.add(lookAheadOffset);
        toWorld.add(lookAheadOffset);
        rayResult = new CollisionWorld.ClosestRayResultCallback(fromWorld, toWorld);
        CollisionWorld.rayTestSingle(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), fromWorld, 1.0f)), new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), toWorld, 1.0f)), callback.hitCollisionObject, callback.hitCollisionObject.getCollisionShape(), callback.hitCollisionObject.getWorldTransform(new Transform()), rayResult);
        if (rayResult.hasHit()) {
            hitStep = true;
            stepSlope = Math.min(stepSlope, rayResult.hitNormalWorld.dot(new Vector3f(0, 1, 0)));
        }

        if (hitStep && stepSlope >= slopeFactor) {
            steppedUpDist = moveUp(stepHeight, collider, position);
            return true;
        }
    }
    return false;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:40,代码来源:BulletCharacterMovementSystem.java

示例11: getObjectId

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
/**
 * used internally
 */
public PairCachingGhostObject getObjectId() {
    return gObject;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:PhysicsGhostObject.java

示例12: getGhostObject

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
private PairCachingGhostObject getGhostObject () {
	return ghostObject;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:4,代码来源:KinematicCharacterController.java

示例13: getGhostObject

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
private PairCachingGhostObject getGhostObject() {
	return ghostObject;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:4,代码来源:KinematicCharacterController.java

示例14: setGhostObject

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
public void setGhostObject(PairCachingGhostObject ghostObject) {
	this.ghostObject = ghostObject;
}
 
开发者ID:tinrab,项目名称:zamtrax,代码行数:4,代码来源:CharacterController.java

示例15: getGhostObject

import com.bulletphysics.collision.dispatch.PairCachingGhostObject; //导入依赖的package包/类
/**
 *
 * @return
 */
public PairCachingGhostObject getGhostObject() {
	return this.ghostObject;
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:8,代码来源:Player.java


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