• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConvexShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: read

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    stepHeight = capsule.readFloat("stepHeight", 1.0f);
    buildObject();
    character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight);
    setGravity(capsule.readFloat("gravity", 9.8f * 3));
    setMaxSlope(capsule.readFloat("maxSlope", 1.0f));
    setFallSpeed(capsule.readFloat("fallSpeed", 55.0f));
    setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f));
    setUpAxis(capsule.readInt("upAxis", 1));
    setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
    setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
    setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:PhysicsCharacter.java


示例2: calcPenDepth

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
											  ConvexShape pConvexA, ConvexShape pConvexB,
											  Transform transformA, Transform transformB,
											  Vector3 v, Vector3 wWitnessOnA, Vector3 wWitnessOnB,
											  IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
	float radialmargin = 0f;

	// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
	
	GjkEpaSolver.Results results = new GjkEpaSolver.Results();
	if (gjkEpaSolver.collide(pConvexA, transformA,
			pConvexB, transformB,
			radialmargin/*,stackAlloc*/, results)) {
		//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
		//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
		wWitnessOnA.set(results.witnesses[0]);
		wWitnessOnB.set(results.witnesses[1]);
		return true;
	}

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


示例3: KinematicCharacterController

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


示例4: calcPenDepth

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
											  ConvexShape pConvexA, ConvexShape pConvexB,
											  Transform transformA, Transform transformB,
											  Vector3f v, Vector3f wWitnessOnA, Vector3f wWitnessOnB,
											  IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
	float radialmargin = 0f;

	// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
	
	GjkEpaSolver.Results results = new GjkEpaSolver.Results();
	if (gjkEpaSolver.collide(pConvexA, transformA,
			pConvexB, transformB,
			radialmargin/*,stackAlloc*/, results)) {
		//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
		//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
		wWitnessOnA.set(results.witnesses[0]);
		wWitnessOnB.set(results.witnesses[1]);
		return true;
	}

	return false;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:24,代码来源:GjkEpaPenetrationDepthSolver.java


示例5: init

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init(/*StackAlloc psa,*/
		Matrix3f wrot0, Vector3f pos0, ConvexShape shape0,
		Matrix3f wrot1, Vector3f pos1, ConvexShape shape1,
		float pmargin) {
	pushStack();
	wrotations[0].set(wrot0);
	positions[0].set(pos0);
	shapes[0] = shape0;
	wrotations[1].set(wrot1);
	positions[1].set(pos1);
	shapes[1] = shape1;
	//sa		=psa;
	//sablock	=sa->beginBlock();
	margin = pmargin;
	failed = false;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:17,代码来源:GjkEpaSolver.java


示例6: KinematicCharacterController

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


示例7: calcPenDepth

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public boolean calcPenDepth(SimplexSolverInterface simplexSolver,
											  ConvexShape pConvexA, ConvexShape pConvexB,
											  Transform transformA, Transform transformB,
											  Vector3f v, Vector3f wWitnessOnA, Vector3f wWitnessOnB,
											  IDebugDraw debugDraw/*, btStackAlloc* stackAlloc*/)
{
	float radialmargin = 0f;

	// JAVA NOTE: 2.70b1: update when GjkEpaSolver2 is ported
	
	GjkEpaSolver.Results results = new GjkEpaSolver.Results();
	if (GjkEpaSolver.collide(pConvexA, transformA,
			pConvexB, transformB,
			radialmargin/*,stackAlloc*/, results)) {
		//debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
		//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
		wWitnessOnA.set(results.witnesses[0]);
		wWitnessOnB.set(results.witnesses[1]);
		return true;
	}

	return false;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:24,代码来源:GjkEpaPenetrationDepthSolver.java


示例8: createRigidBody

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
private void createRigidBody(EntityRef entity) {
    LocationComponent location = entity.getComponent(LocationComponent.class);
    RigidBodyComponent rigidBody = entity.getComponent(RigidBodyComponent.class);
    ConvexShape shape = getShapeFor(entity);
    if (shape != null) {
        float scale = location.getWorldScale();
        shape.setLocalScaling(new Vector3f(scale, scale, scale));

        Vector3f fallInertia = new Vector3f();
        shape.calculateLocalInertia(rigidBody.mass, fallInertia);
        RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(rigidBody.mass, new EntityMotionState(entity), shape, fallInertia);
        RigidBody collider = new RigidBody(info);
        collider.setUserPointer(entity);
        updateKinematicSettings(rigidBody, collider);
        RigidBody oldBody = entityRigidBodies.put(entity, collider);
        physics.addRigidBody(collider, Lists.<CollisionGroup>newArrayList(rigidBody.collisionGroup), rigidBody.collidesWith);
        if (oldBody != null) {
            physics.removeRigidBody(oldBody);
        }
    }
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:22,代码来源:PhysicsSystem.java


示例9: PhysicsCharacter

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
/**
 * @param shape The CollisionShape (no Mesh or CompoundCollisionShapes)
 * @param stepHeight The quantization size for vertical movement
 */
public PhysicsCharacter(CollisionShape shape, float stepHeight) {
    this.collisionShape = shape;
    if (!(shape.getCShape() instanceof ConvexShape)) {
        throw (new UnsupportedOperationException("Kinematic character nodes cannot have mesh collision shapes"));
    }
    this.stepHeight = stepHeight;
    buildObject();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:PhysicsCharacter.java


示例10: setCollisionShape

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
@Override
public void setCollisionShape(CollisionShape collisionShape) {
    if (!(collisionShape.getCShape() instanceof ConvexShape)) {
        throw (new UnsupportedOperationException("Kinematic character nodes cannot have mesh collision shapes"));
    }
    super.setCollisionShape(collisionShape);
    if (gObject == null) {
        buildObject();
    }else{
        gObject.setCollisionShape(collisionShape.getCShape());
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:PhysicsCharacter.java


示例11: sweepTest

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
/**
 * Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults<br/>
 * You have to use different Transforms for start and end (at least distance > 0.4f).
 * SweepTest will not see a collision if it starts INSIDE an object and is moving AWAY from its center.
 */
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end) {
    List<PhysicsSweepTestResult> results = new LinkedList<PhysicsSweepTestResult>();
    if (!(shape.getCShape() instanceof ConvexShape)) {
        Logger.getLogger(PhysicsSpace.class.getName()).log(Level.WARNING, "Trying to sweep test with incompatible mesh shape!");
        return results;
    }
    dynamicsWorld.convexSweepTest((ConvexShape) shape.getCShape(), Converter.convert(start, sweepTrans1), Converter.convert(end, sweepTrans2), new InternalSweepListener(results));
    return results;

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:PhysicsSpace.java


示例12: TriangleConvexcastCallback

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public TriangleConvexcastCallback (ConvexShape convexShape, Transform convexShapeFrom, Transform convexShapeTo,
	Transform triangleToWorld, float triangleCollisionMargin) {
	this.convexShape = convexShape;
	this.convexShapeFrom.set(convexShapeFrom);
	this.convexShapeTo.set(convexShapeTo);
	this.triangleToWorld.set(triangleToWorld);
	this.hitFraction = 1f;
	this.triangleCollisionMargin = triangleCollisionMargin;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:10,代码来源:TriangleConvexcastCallback.java


示例13: init

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init (ConvexShape objectA, ConvexShape objectB, SimplexSolverInterface simplexSolver,
	ConvexPenetrationDepthSolver penetrationDepthSolver) {
	this.cachedSeparatingAxis.set(0f, 0f, 1f);
	this.ignoreMargin = false;
	this.lastUsedMethod = -1;
	this.catchDegeneracies = 1;

	this.penetrationDepthSolver = penetrationDepthSolver;
	this.simplexSolver = simplexSolver;
	this.minkowskiA = objectA;
	this.minkowskiB = objectB;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:13,代码来源:GjkPairDetector.java


示例14: init

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init (/* StackAlloc psa, */
	Matrix3 wrot0, Vector3 pos0, ConvexShape shape0, Matrix3 wrot1, Vector3 pos1, ConvexShape shape1, float pmargin) {
	pushStack();
	wrotations[0].set(wrot0);
	positions[0].set(pos0);
	shapes[0] = shape0;
	wrotations[1].set(wrot1);
	positions[1].set(pos1);
	shapes[1] = shape1;
	// sa =psa;
	// sablock =sa->beginBlock();
	margin = pmargin;
	failed = false;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:15,代码来源:GjkEpaSolver.java


示例15: BridgeTriangleConvexcastCallback

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public BridgeTriangleConvexcastCallback (ConvexShape castShape, Transform from, Transform to,
	ConvexResultCallback resultCallback, CollisionObject collisionObject, TriangleMeshShape triangleMesh,
	Transform triangleToWorld) {
	super(castShape, from, to, triangleToWorld, triangleMesh.getMargin());
	this.resultCallback = resultCallback;
	this.collisionObject = collisionObject;
	this.triangleMesh = triangleMesh;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:9,代码来源:CollisionWorld.java


示例16: TriangleConvexcastCallback

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public TriangleConvexcastCallback(ConvexShape convexShape, Transform convexShapeFrom, Transform convexShapeTo, Transform triangleToWorld, float triangleCollisionMargin) {
	this.convexShape = convexShape;
	this.convexShapeFrom.set(convexShapeFrom);
	this.convexShapeTo.set(convexShapeTo);
	this.triangleToWorld.set(triangleToWorld);
	this.hitFraction = 1f;
	this.triangleCollisionMargin = triangleCollisionMargin;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:9,代码来源:TriangleConvexcastCallback.java


示例17: init

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
public void init(ConvexShape objectA, ConvexShape objectB, SimplexSolverInterface simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver) {
	this.cachedSeparatingAxis.set(0f, 0f, 1f);
	this.ignoreMargin = false;
	this.lastUsedMethod = -1;
	this.catchDegeneracies = 1;
	
	this.penetrationDepthSolver = penetrationDepthSolver;
	this.simplexSolver = simplexSolver;
	this.minkowskiA = objectA;
	this.minkowskiB = objectB;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:12,代码来源:GjkPairDetector.java


示例18: initPhysics

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


示例19: createTrigger

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


示例20: getShapeFor

import com.bulletphysics.collision.shapes.ConvexShape; //导入依赖的package包/类
private ConvexShape getShapeFor(EntityRef entity) {
    BoxShapeComponent box = entity.getComponent(BoxShapeComponent.class);
    if (box != null) {
        Vector3f halfExtents = new Vector3f(box.extents);
        halfExtents.scale(0.5f);
        return new BoxShape(halfExtents);
    }
    SphereShapeComponent sphere = entity.getComponent(SphereShapeComponent.class);
    if (sphere != null) {
        return new SphereShape(sphere.radius);
    }
    CapsuleShapeComponent capsule = entity.getComponent(CapsuleShapeComponent.class);
    if (capsule != null) {
        return new CapsuleShape(capsule.radius, capsule.height);
    }
    CylinderShapeComponent cylinder = entity.getComponent(CylinderShapeComponent.class);
    if (cylinder != null) {
        return new CylinderShape(new Vector3f(cylinder.radius, 0.5f * cylinder.height, cylinder.radius));
    }
    HullShapeComponent hull = entity.getComponent(HullShapeComponent.class);
    if (hull != null) {
        ObjectArrayList<Vector3f> verts = new ObjectArrayList<Vector3f>();
        TFloatIterator iterator = hull.sourceMesh.getVertices().iterator();
        while (iterator.hasNext()) {
            Vector3f newVert = new Vector3f();
            newVert.x = iterator.next();
            newVert.y = iterator.next();
            newVert.z = iterator.next();
            verts.add(newVert);
        }
        return new ConvexHullShape(verts);
    }
    CharacterMovementComponent characterMovementComponent = entity.getComponent(CharacterMovementComponent.class);
    if (characterMovementComponent != null) {
        return new CapsuleShape(characterMovementComponent.radius, characterMovementComponent.height);
    }
    return null;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:39,代码来源:PhysicsSystem.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageParams类代码示例发布时间:2022-05-22
下一篇:
Java BindingHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap