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


Java Transform.mul方法代码示例

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


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

示例1: setTimeStepAndCounters

import com.bulletphysics.linearmath.Transform; //导入方法依赖的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: gimpact_vs_concave

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public void gimpact_vs_concave(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, ConcaveShape shape1, boolean swapped) {
	// create the callback
	GImpactTriangleCallback tricallback = new GImpactTriangleCallback();
	tricallback.algorithm = this;
	tricallback.body0 = body0;
	tricallback.body1 = body1;
	tricallback.gimpactshape0 = shape0;
	tricallback.swapped = swapped;
	tricallback.margin = shape1.getMargin();

	// getting the trimesh AABB
	Stack stack = Stack.enter();
	Transform gimpactInConcaveSpace = stack.allocTransform();

	body1.getWorldTransform(gimpactInConcaveSpace);
	gimpactInConcaveSpace.inverse();
	gimpactInConcaveSpace.mul(body0.getWorldTransform(stack.allocTransform()));

	Vector3 minAABB = stack.allocVector3(), maxAABB = stack.allocVector3();
	shape0.getAabb(gimpactInConcaveSpace, minAABB, maxAABB);

	shape1.processAllTriangles(tricallback, minAABB, maxAABB);
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:25,代码来源:GImpactCollisionAlgorithm.java

示例3: setTimeStepAndCounters

import com.bulletphysics.linearmath.Transform; //导入方法依赖的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

示例4: gimpact_vs_compoundshape

import com.bulletphysics.linearmath.Transform; //导入方法依赖的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

示例5: gimpact_vs_concave

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public void gimpact_vs_concave(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, ConcaveShape shape1, boolean swapped) {
	// create the callback
	GImpactTriangleCallback tricallback = new GImpactTriangleCallback();
	tricallback.algorithm = this;
	tricallback.body0 = body0;
	tricallback.body1 = body1;
	tricallback.gimpactshape0 = shape0;
	tricallback.swapped = swapped;
	tricallback.margin = shape1.getMargin();

	// getting the trimesh AABB
	Transform gimpactInConcaveSpace = Stack.alloc(Transform.class);

	body1.getWorldTransform(gimpactInConcaveSpace);
	gimpactInConcaveSpace.inverse();
	gimpactInConcaveSpace.mul(body0.getWorldTransform(Stack.alloc(Transform.class)));

	Vector3f minAABB = Stack.alloc(Vector3f.class), maxAABB = Stack.alloc(Vector3f.class);
	shape0.getAabb(gimpactInConcaveSpace, minAABB, maxAABB);

	shape1.processAllTriangles(tricallback, minAABB, maxAABB);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:23,代码来源:GImpactCollisionAlgorithm.java

示例6: collideTT

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
public static void collideTT (Node root0, Transform xform0, Node root1, Transform xform1, ICollide policy) {
	Stack stack = Stack.enter();
	Transform xform = stack.allocTransform();
	xform.inverse(xform0);
	xform.mul(xform1);
	collideTT(root0, root1, xform, policy);
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:9,代码来源:Dbvt.java

示例7: calc_from_homogenic

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
/** Calc the transformation relative 1 to 0. Inverts matrics by transposing. */
public void calc_from_homogenic (Transform trans0, Transform trans1) {
	Stack stack = Stack.enter();
	Transform temp_trans = stack.allocTransform();
	temp_trans.inverse(trans0);
	temp_trans.mul(trans1);

	T1to0.set(temp_trans.origin);
	R1to0.set(temp_trans.basis);

	calc_absolute_matrix();
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:14,代码来源:BoxCollision.java

示例8: createBodyPart

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
private void createBodyPart(BodyPart bodyPart, Transform offset,
        float scale, Vector3f origin) {
    Transform transform = new Transform();
    transform.setIdentity();
    transform.origin.set(scale * origin.x, scale * origin.y, scale
            * origin.z);
    transform.mul(offset);
    bodies.put(bodyPart,
            localCreateRigidBody(1.0f, transform, shapes.get(bodyPart)));
}
 
开发者ID:android-workloads,项目名称:JACWfA,代码行数:11,代码来源:Ragdoll.java

示例9: gimpact_vs_shape_find_pairs

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
protected void gimpact_vs_shape_find_pairs(Transform trans0, Transform trans1, GImpactShapeInterface shape0, CollisionShape shape1, IntArray collided_primitives) {
	Stack stack = Stack.enter();
	AABB boxshape = stack.allocAABB();

	if (shape0.hasBoxSet()) {
		Transform trans1to0 = stack.allocTransform();
		trans1to0.inverse(trans0);
		trans1to0.mul(trans1);

		shape1.getAabb(trans1to0, boxshape.min, boxshape.max);

		shape0.getBoxSet().boxQuery(boxshape, collided_primitives);
	}
	else {
		shape1.getAabb(trans1, boxshape.min, boxshape.max);

		AABB boxshape0 = stack.allocAABB();
		int i = shape0.getNumChildShapes();

		while ((i--) != 0) {
			shape0.getChildAabb(i, trans0, boxshape0.min, boxshape0.max);

			if (boxshape.has_collision(boxshape0)) {
				collided_primitives.add(i);
			}
		}
	}
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:30,代码来源:GImpactCollisionAlgorithm.java

示例10: calc_from_homogenic

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
/**
 * Calc the transformation relative  1 to 0. Inverts matrics by transposing.
 */
public void calc_from_homogenic(Transform trans0, Transform trans1) {
	Transform temp_trans = Stack.alloc(Transform.class);
	temp_trans.inverse(trans0);
	temp_trans.mul(trans1);

	T1to0.set(temp_trans.origin);
	R1to0.set(temp_trans.basis);

	calc_absolute_matrix();
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:14,代码来源:BoxCollision.java

示例11: gimpact_vs_shape_find_pairs

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
protected void gimpact_vs_shape_find_pairs(Transform trans0, Transform trans1, GImpactShapeInterface shape0, CollisionShape shape1, IntArrayList collided_primitives) {
	AABB boxshape = Stack.alloc(AABB.class);

	if (shape0.hasBoxSet()) {
		Transform trans1to0 = Stack.alloc(Transform.class);
		trans1to0.inverse(trans0);
		trans1to0.mul(trans1);

		shape1.getAabb(trans1to0, boxshape.min, boxshape.max);

		shape0.getBoxSet().boxQuery(boxshape, collided_primitives);
	}
	else {
		shape1.getAabb(trans1, boxshape.min, boxshape.max);

		AABB boxshape0 = Stack.alloc(AABB.class);
		int i = shape0.getNumChildShapes();

		while ((i--) != 0) {
			shape0.getChildAabb(i, trans0, boxshape0.min, boxshape0.max);

			if (boxshape.has_collision(boxshape0)) {
				collided_primitives.add(i);
			}
		}
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:28,代码来源:GImpactCollisionAlgorithm.java

示例12: getWorldTransform

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public Transform getWorldTransform(Transform out){
	out.inverse(centerOfMassOffset);
	out.mul(graphicsWorldTrans);
	return out;
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:7,代码来源:MotionStateM.java

示例13: processCollision

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void processCollision (CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo,
	ManifoldResult resultOut) {
	if (manifoldPtr == null) {
		return;
	}

	Stack stack = Stack.enter();
	Transform tmpTrans = stack.allocTransform();

	CollisionObject convexObj = isSwapped ? body1 : body0;
	CollisionObject planeObj = isSwapped ? body0 : body1;

	ConvexShape convexShape = (ConvexShape)convexObj.getCollisionShape();
	StaticPlaneShape planeShape = (StaticPlaneShape)planeObj.getCollisionShape();

	boolean hasCollision = false;
	Vector3 planeNormal = planeShape.getPlaneNormal(stack.allocVector3());
	float planeConstant = planeShape.getPlaneConstant();

	Transform planeInConvex = stack.allocTransform();
	convexObj.getWorldTransform(planeInConvex);
	planeInConvex.inverse();
	planeInConvex.mul(planeObj.getWorldTransform(tmpTrans));

	Transform convexInPlaneTrans = stack.allocTransform();
	convexInPlaneTrans.inverse(planeObj.getWorldTransform(tmpTrans));
	convexInPlaneTrans.mul(convexObj.getWorldTransform(tmpTrans));

	Vector3 tmp = stack.allocVector3();
	tmp.set(planeNormal).scl(-1);
	tmp.mul(planeInConvex.basis);

	Vector3 vtx = convexShape.localGetSupportingVertex(tmp, stack.allocVector3());
	Vector3 vtxInPlane = stack.alloc(vtx);
	convexInPlaneTrans.transform(vtxInPlane);

	float distance = (planeNormal.dot(vtxInPlane) - planeConstant);

	Vector3 vtxInPlaneProjected = stack.allocVector3();
	tmp.set(planeNormal).scl(distance);
	vtxInPlaneProjected.set(vtxInPlane).sub(tmp);

	Vector3 vtxInPlaneWorld = stack.alloc(vtxInPlaneProjected);
	planeObj.getWorldTransform(tmpTrans).transform(vtxInPlaneWorld);

	hasCollision = distance < manifoldPtr.getContactBreakingThreshold();
	resultOut.setPersistentManifold(manifoldPtr);
	if (hasCollision) {
		// report a contact. internally this will be kept persistent, and contact reduction is done
		Vector3 normalOnSurfaceB = stack.alloc(planeNormal);
		normalOnSurfaceB.mul(planeObj.getWorldTransform(tmpTrans).basis);

		Vector3 pOnB = stack.alloc(vtxInPlaneWorld);
		resultOut.addContactPoint(normalOnSurfaceB, pOnB, distance);
	}
	if (ownManifold) {
		if (manifoldPtr.getNumContacts() != 0) {
			resultOut.refreshContactPoints();
		}
	}
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:64,代码来源:ConvexPlaneCollisionAlgorithm.java

示例14: calculateTimeOfImpact

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public float calculateTimeOfImpact (CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo,
	ManifoldResult resultOut) {
	Stack stack = Stack.enter();
	Vector3 tmp = stack.allocVector3();

	CollisionObject convexbody = isSwapped ? body1 : body0;
	CollisionObject triBody = isSwapped ? body0 : body1;

	// quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast)

	// only perform CCD above a certain threshold, this prevents blocking on the long run
	// because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame...
	tmp.set(convexbody.getInterpolationWorldTransform(stack.allocTransform()).origin)
		.sub(convexbody.getWorldTransform(stack.allocTransform()).origin);
	float squareMot0 = tmp.len2();
	if (squareMot0 < convexbody.getCcdSquareMotionThreshold()) {
		stack.leave();
		return 1f;
	}

	Transform tmpTrans = stack.allocTransform();

	// const btVector3& from = convexbody->m_worldTransform.getOrigin();
	// btVector3 to = convexbody->m_interpolationWorldTransform.getOrigin();
	// todo: only do if the motion exceeds the 'radius'

	Transform triInv = triBody.getWorldTransform(stack.allocTransform());
	triInv.inverse();

	Transform convexFromLocal = stack.allocTransform();
	convexFromLocal.mul(triInv, convexbody.getWorldTransform(tmpTrans));

	Transform convexToLocal = stack.allocTransform();
	convexToLocal.mul(triInv, convexbody.getInterpolationWorldTransform(tmpTrans));

	if (triBody.getCollisionShape().isConcave()) {
		Vector3 rayAabbMin = stack.alloc(convexFromLocal.origin);
		VectorUtil.setMin(rayAabbMin, convexToLocal.origin);

		Vector3 rayAabbMax = stack.alloc(convexFromLocal.origin);
		VectorUtil.setMax(rayAabbMax, convexToLocal.origin);

		float ccdRadius0 = convexbody.getCcdSweptSphereRadius();

		tmp.set(ccdRadius0, ccdRadius0, ccdRadius0);
		rayAabbMin.sub(tmp);
		rayAabbMax.add(tmp);

		float curHitFraction = 1f; // is this available?
		LocalTriangleSphereCastCallback raycastCallback = new LocalTriangleSphereCastCallback(convexFromLocal, convexToLocal,
			convexbody.getCcdSweptSphereRadius(), curHitFraction);

		raycastCallback.hitFraction = convexbody.getHitFraction();

		CollisionObject concavebody = triBody;

		ConcaveShape triangleMesh = (ConcaveShape)concavebody.getCollisionShape();

		if (triangleMesh != null) {
			triangleMesh.processAllTriangles(raycastCallback, rayAabbMin, rayAabbMax);
		}

		if (raycastCallback.hitFraction < convexbody.getHitFraction()) {
			convexbody.setHitFraction(raycastCallback.hitFraction);
			stack.leave();
			return raycastCallback.hitFraction;
		}
	}

	stack.leave();
	return 1f;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:74,代码来源:ConvexConcaveCollisionAlgorithm.java

示例15: processCollision

import com.bulletphysics.linearmath.Transform; //导入方法依赖的package包/类
@Override
public void processCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
    Stack stack = Stack.enter();
	CollisionObject colObj = isSwapped ? body1 : body0;
	CollisionObject otherObj = isSwapped ? body0 : body1;

	assert (colObj.getCollisionShape().isCompound());
	CompoundShape compoundShape = (CompoundShape) colObj.getCollisionShape();

	// We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
	// If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
	// given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
	// determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
	// then use each overlapping node AABB against Tree0
	// and vise versa.

	Transform tmpTrans = stack.allocTransform();
	Transform orgTrans = stack.allocTransform();
	Transform childTrans = stack.allocTransform();
	Transform orgInterpolationTrans = stack.allocTransform();
	Transform newChildWorldTrans = stack.allocTransform();

	int numChildren = childCollisionAlgorithms.size();
	int i;
	for (i = 0; i < numChildren; i++) {
		// temporarily exchange parent btCollisionShape with childShape, and recurse
		CollisionShape childShape = compoundShape.getChildShape(i);

		// backup
		colObj.getWorldTransform(orgTrans);
		colObj.getInterpolationWorldTransform(orgInterpolationTrans);

		compoundShape.getChildTransform(i, childTrans);
		newChildWorldTrans.mul(orgTrans, childTrans);
		colObj.setWorldTransform(newChildWorldTrans);
		colObj.setInterpolationWorldTransform(newChildWorldTrans);
		
		// the contactpoint is still projected back using the original inverted worldtrans
		CollisionShape tmpShape = colObj.getCollisionShape();
		colObj.internalSetTemporaryCollisionShape(childShape);
		childCollisionAlgorithms.getQuick(i).processCollision(colObj, otherObj, dispatchInfo, resultOut);
		// revert back
		colObj.internalSetTemporaryCollisionShape(tmpShape);
		colObj.setWorldTransform(orgTrans);
		colObj.setInterpolationWorldTransform(orgInterpolationTrans);
	}
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:49,代码来源:CompoundCollisionAlgorithm.java


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