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


Java CollisionShape类代码示例

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


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

示例1: setTimeStepAndCounters

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void setTimeStepAndCounters(float collisionMarginTriangle, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
	this.dispatchInfoPtr = dispatchInfo;
	this.collisionMarginTriangle = collisionMarginTriangle;
	this.resultOut = resultOut;

	Stack stack = Stack.enter();
	// recalc aabbs
	Transform convexInTriangleSpace = stack.allocTransform();

	triBody.getWorldTransform(convexInTriangleSpace);
	convexInTriangleSpace.inverse();
	convexInTriangleSpace.mul(convexBody.getWorldTransform(stack.allocTransform()));

	CollisionShape convexShape = (CollisionShape)convexBody.getCollisionShape();
	//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
	convexShape.getAabb(convexInTriangleSpace, aabbMin, aabbMax);
	float extraMargin = collisionMarginTriangle;
	Vector3 extra = stack.allocVector3();
	extra.set(extraMargin, extraMargin, extraMargin);

	aabbMax.add(extra);
	aabbMin.sub(extra);
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:25,代码来源:ConvexTriangleCallback.java

示例2: init

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void init(CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1, boolean isSwapped) {
	super.init(ci);
	
	this.isSwapped = isSwapped;

	CollisionObject colObj = isSwapped ? body1 : body0;
	CollisionObject otherObj = isSwapped ? body0 : body1;
	assert (colObj.getCollisionShape().isCompound());

	CompoundShape compoundShape = (CompoundShape) colObj.getCollisionShape();
	int numChildren = compoundShape.getNumChildShapes();
	int i;

	//childCollisionAlgorithms.resize(numChildren);
	for (i = 0; i < numChildren; i++) {
		CollisionShape tmpShape = colObj.getCollisionShape();
		CollisionShape childShape = compoundShape.getChildShape(i);
		colObj.internalSetTemporaryCollisionShape(childShape);
		childCollisionAlgorithms.add(ci.dispatcher1.findAlgorithm(colObj, otherObj));
		colObj.internalSetTemporaryCollisionShape(tmpShape);
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:23,代码来源:CompoundCollisionAlgorithm.java

示例3: gimpact_vs_compoundshape

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void gimpact_vs_compoundshape(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, CompoundShape shape1, boolean swapped) {
	Stack stack = Stack.enter();
	Transform orgtrans1 = body1.getWorldTransform(stack.allocTransform());
	Transform childtrans1 = stack.allocTransform();
	Transform tmpTrans = stack.allocTransform();

	int i = shape1.getNumChildShapes();
	while ((i--) != 0) {
		CollisionShape colshape1 = shape1.getChildShape(i);
		childtrans1.mul(orgtrans1, shape1.getChildTransform(i, tmpTrans));

		body1.setWorldTransform(childtrans1);

		// collide child shape
		gimpact_vs_shape(body0, body1,
				shape0, colshape1, swapped);

		// restore transforms
		body1.setWorldTransform(orgtrans1);
	}
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:23,代码来源:GImpactCollisionAlgorithm.java

示例4: shape_vs_shape_collision

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
protected void shape_vs_shape_collision(CollisionObject body0, CollisionObject body1, CollisionShape shape0, CollisionShape shape1) {
	CollisionShape tmpShape0 = body0.getCollisionShape();
	CollisionShape tmpShape1 = body1.getCollisionShape();

	body0.internalSetTemporaryCollisionShape(shape0);
	body1.internalSetTemporaryCollisionShape(shape1);

	{
		CollisionAlgorithm algor = newAlgorithm(body0, body1);
		// post :	checkManifold is called

		resultOut.setShapeIdentifiers(part0, triface0, part1, triface1);

		algor.processCollision(body0, body1, dispatchInfo, resultOut);

		//algor.destroy();
		dispatcher.freeCollisionAlgorithm(algor);
	}

	body0.internalSetTemporaryCollisionShape(tmpShape0);
	body1.internalSetTemporaryCollisionShape(tmpShape1);
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:23,代码来源:GImpactCollisionAlgorithm.java

示例5: setTimeStepAndCounters

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void setTimeStepAndCounters(float collisionMarginTriangle, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
	this.dispatchInfoPtr = dispatchInfo;
	this.collisionMarginTriangle = collisionMarginTriangle;
	this.resultOut = resultOut;

	// recalc aabbs
	Transform convexInTriangleSpace = Stack.alloc(Transform.class);

	triBody.getWorldTransform(convexInTriangleSpace);
	convexInTriangleSpace.inverse();
	convexInTriangleSpace.mul(convexBody.getWorldTransform(Stack.alloc(Transform.class)));

	CollisionShape convexShape = (CollisionShape)convexBody.getCollisionShape();
	//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
	convexShape.getAabb(convexInTriangleSpace, aabbMin, aabbMax);
	float extraMargin = collisionMarginTriangle;
	Vector3f extra = Stack.alloc(Vector3f.class);
	extra.set(extraMargin, extraMargin, extraMargin);

	aabbMax.add(extra);
	aabbMin.sub(extra);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:23,代码来源:ConvexTriangleCallback.java

示例6: gimpact_vs_compoundshape

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void gimpact_vs_compoundshape(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, CompoundShape shape1, boolean swapped) {
	Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));
	Transform childtrans1 = Stack.alloc(Transform.class);
	Transform tmpTrans = Stack.alloc(Transform.class);

	int i = shape1.getNumChildShapes();
	while ((i--) != 0) {
		CollisionShape colshape1 = shape1.getChildShape(i);
		childtrans1.mul(orgtrans1, shape1.getChildTransform(i, tmpTrans));

		body1.setWorldTransform(childtrans1);

		// collide child shape
		gimpact_vs_shape(body0, body1,
				shape0, colshape1, swapped);

		// restore transforms
		body1.setWorldTransform(orgtrans1);
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:21,代码来源:GImpactCollisionAlgorithm.java

示例7: localCreateRigidBody

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
private RigidBody localCreateRigidBody(float mass, Transform startTransform, CollisionShape shape) {
	boolean isDynamic = (mass != 0f);

	Vector3f localInertia = new Vector3f();
	localInertia.set(0f, 0f, 0f);
	if (isDynamic) {
		shape.calculateLocalInertia(mass, localInertia);
	}

	DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
	RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
	rbInfo.additionalDamping = true;
	RigidBody body = new RigidBody(rbInfo);

	ownerWorld.addRigidBody(body);

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

示例8: localCreateRigidBody

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
private RigidBody localCreateRigidBody(float mass, Transform startTransform, CollisionShape shape) {
	boolean isDynamic = (mass != 0f);

	Vector3f localInertia = new Vector3f();
	localInertia.set(0f, 0f, 0f);
	if (isDynamic) {
		shape.calculateLocalInertia(mass, localInertia);
	}

	DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
	RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
	RigidBody body = new RigidBody(rbInfo);

	ownerWorld.addRigidBody(body);

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

示例9: addConvexVerticesCollider

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
@Override
public void addConvexVerticesCollider(List<Vector3f> vertices) {
	if (vertices.size() > 0) {
		float mass = 0f;
		Transform startTransform = new Transform();
		// can use a shift
		startTransform.setIdentity();
		startTransform.origin.set(0, 0, -10f);
		
		// this create an internal copy of the vertices
		CollisionShape shape = new ConvexHullShape(vertices);
		collisionShapes.add(shape);

		//btRigidBody* body = m_demoApp->localCreateRigidBody(mass, startTransform,shape);
		localCreateRigidBody(mass, startTransform, shape);
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:BspDemo.java

示例10: gimpact_vs_compoundshape

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void gimpact_vs_compoundshape(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, CompoundShape shape1, boolean swapped) {
           System.out.println("gimpact_vs_compoundshape");
	Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));
	Transform childtrans1 = Stack.alloc(Transform.class);
	Transform tmpTrans = Stack.alloc(Transform.class);

	int i = shape1.getNumChildShapes();
	while ((i--) != 0) {
		CollisionShape colshape1 = shape1.getChildShape(i);
		childtrans1.mul(orgtrans1, shape1.getChildTransform(i, tmpTrans));

		body1.setWorldTransform(childtrans1);

		// collide child shape
		gimpact_vs_shape(body0, body1,
				shape0, colshape1, swapped);

		// restore transforms
		body1.setWorldTransform(orgtrans1);
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:22,代码来源:GImpactCollisionAlgorithm.java

示例11: addConvexVerticesCollider

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
@Override
public void addConvexVerticesCollider(ObjectArrayList<Vector3f> vertices) {
	if (vertices.size() > 0) {
		float mass = 0f;
		Transform startTransform = new Transform();
		// can use a shift
		startTransform.setIdentity();
		startTransform.origin.set(0, 0, -10f);
		
		// this create an internal copy of the vertices
		CollisionShape shape = new ConvexHullShape(vertices);
		collisionShapes.add(shape);

		//btRigidBody* body = m_demoApp->localCreateRigidBody(mass, startTransform,shape);
		localCreateRigidBody(mass, startTransform, shape);
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:BspDemo.java

示例12: addConvexVerticesCollider

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
@Override
public void addConvexVerticesCollider(ObjectArrayList<Vector3f> vertices) {
	if (vertices.size() > 0) {
		float mass = 0f;
		Transform startTransform = new Transform();
		// can use a shift
		startTransform.setIdentity();
		// JAVA NOTE: port change, we want y to be up.
		startTransform.basis.rotX((float) -Math.PI / 2f);
		startTransform.origin.set(0, -10, 0);
		//startTransform.origin.set(0, 0, -10f);
		
		// this create an internal copy of the vertices
		CollisionShape shape = new ConvexHullShape(vertices);
		collisionShapes.add(shape);

		//btRigidBody* body = m_demoApp->localCreateRigidBody(mass, startTransform,shape);
		localCreateRigidBody(mass, startTransform, shape);
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:21,代码来源:CharacterDemo.java

示例13: addCollisionObject

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public RigidBody addCollisionObject(CollisionShape shape, float mass, Vector3f position, Vector3f velocity){
    	
		Transform startTransform = new Transform();
		startTransform.setIdentity();
		startTransform.origin.set(position);
		boolean isDynamic = (mass != 0f);
		Vector3f localInertia = new Vector3f(0, 0, 0);
		if (isDynamic) {
			shape.calculateLocalInertia(mass, localInertia);
		}
		// using motionstate is recommended, it provides
		// interpolation capabilities, and only synchronizes
		// 'active' objects
		DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

		RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
				mass, myMotionState, shape, localInertia);
		RigidBody body = new RigidBody(rbInfo);
//		System.out.println(velocity);
//		body.applyCentralForce(velocity);
		body.setLinearVelocity(velocity);
		dynamicsWorld.addRigidBody(body);

		return body;
        
    }
 
开发者ID:gama-platform,项目名称:gama,代码行数:27,代码来源:PhysicsWorldJBullet.java

示例14: mkStaticGroundPlane

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
protected void mkStaticGroundPlane(DynamicsWorld world) {
    // floor
    float mass = 0;
    CollisionShape shape = new BoxShape(new Vector3f(L, 10, W));

    Transform t = new Transform();
    t.setIdentity();
    t.origin.set(new Vector3f(p.x,p.y-10,p.z));

    MotionState motionState = new DefaultMotionState(t);
    RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(mass, motionState, shape);
    RigidBody body = new RigidBody(info);
    body.setFriction(1f);
    body.setRestitution(.5f);
    world.addRigidBody(body);
}
 
开发者ID:seemywingz,项目名称:Kengine,代码行数:17,代码来源:FloorModel.java

示例15: p3dRuler

import com.bulletphysics.collision.shapes.CollisionShape; //导入依赖的package包/类
public void p3dRuler(){
	float length = 10/2f;
	float width = 10/2f;
	List<Vector3f> vertices = new ArrayList<Vector3f>();
	vertices.add(new Vector3f(-length,0,-width));
	vertices.add(new Vector3f(-length,0,width));
	vertices.add(new Vector3f(length,0,width));
	vertices.add(new Vector3f(length,0,-width));
	Transform startTransform = new Transform();
	startTransform.setIdentity();
	Vector3f translate = new Vector3f();
	startTransform.origin.set(translate);
	CollisionShape shape = new ConvexHullShape(vertices);
	Vector3f localInertia = new Vector3f(0f, 0f, 0f);
	DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
	RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(0f, myMotionState, shape, localInertia);
	RigidBody body = new RigidBody(cInfo);
	body.setGravity(new Vector3f(0,0,0));
	pInterfaceWorld.addRigidBody(body);
	//adding this to another dynamic world*interfaceworld*
}
 
开发者ID:Sivx,项目名称:Sivx-3DDesktop,代码行数:22,代码来源:engine - Copy.java


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