本文整理汇总了C#中BulletXNA.BulletCollision.CollisionObject.SetWorldTransform方法的典型用法代码示例。如果您正苦于以下问题:C# CollisionObject.SetWorldTransform方法的具体用法?C# CollisionObject.SetWorldTransform怎么用?C# CollisionObject.SetWorldTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletXNA.BulletCollision.CollisionObject
的用法示例。
在下文中一共展示了CollisionObject.SetWorldTransform方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GImpactVsCompoundshape
public void GImpactVsCompoundshape(CollisionObject body0,
CollisionObject body1,
GImpactShapeInterface shape0,
CompoundShape shape1, bool swapped)
{
IndexedMatrix orgtrans1 = body1.GetWorldTransform();
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
{
BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::GImpactVsCompoundshape");
}
int i = shape1.GetNumChildShapes();
while (i-- != 0)
{
CollisionShape colshape1 = shape1.GetChildShape(i);
IndexedMatrix childtrans1 = orgtrans1 * shape1.GetChildTransform(i);
body1.SetWorldTransform(ref childtrans1);
//collide child shape
GImpactVsShape(body0, body1,
shape0, colshape1, swapped);
//restore transforms
body1.SetWorldTransform(ref orgtrans1);
}
}
示例2: GImpactVsGImpact
//! Collides two gimpact shapes
/*!
\pre shape0 and shape1 couldn't be btGImpactMeshShape objects
*/
public void GImpactVsGImpact(CollisionObject body0,
CollisionObject body1,
GImpactShapeInterface shape0,
GImpactShapeInterface shape1)
{
if (shape0.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE)
{
GImpactMeshShape meshshape0 = shape0 as GImpactMeshShape;
m_part0 = meshshape0.GetMeshPartCount();
while (m_part0-- != 0)
{
GImpactVsGImpact(body0, body1, meshshape0.GetMeshPart(m_part0), shape1);
}
return;
}
if (shape1.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE)
{
GImpactMeshShape meshshape1 = shape1 as GImpactMeshShape;
m_part1 = meshshape1.GetMeshPartCount();
while (m_part1-- != 0)
{
GImpactVsGImpact(body0, body1, shape0, meshshape1.GetMeshPart(m_part1));
}
return;
}
IndexedMatrix orgtrans0 = body0.GetWorldTransform();
IndexedMatrix orgtrans1 = body1.GetWorldTransform();
PairSet pairset = new PairSet();
GImpactVsGImpactFindPairs(ref orgtrans0, ref orgtrans1, shape0, shape1, pairset);
if (pairset.Count == 0) return;
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
{
BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::GImpactVsGImpact [{0}]",pairset.Count);
}
if (shape0.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE_PART &&
shape1.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE_PART)
{
GImpactMeshShapePart shapepart0 = shape0 as GImpactMeshShapePart;
GImpactMeshShapePart shapepart1 = shape1 as GImpactMeshShapePart;
//specialized function
#if BULLET_TRIANGLE_COLLISION
CollideGjkTriangles(body0,body1,shapepart0,shapepart1,&pairset[0].m_index1,pairset.size());
#else
CollideSatTriangles(body0, body1, shapepart0, shapepart1, pairset, pairset.Count);
#endif
return;
}
//general function
shape0.LockChildShapes();
shape1.LockChildShapes();
using(GIM_ShapeRetriever retriever0 = BulletGlobals.GIM_ShapeRetrieverPool.Get())
using (GIM_ShapeRetriever retriever1 = BulletGlobals.GIM_ShapeRetrieverPool.Get())
{
retriever0.Initialize(shape0);
retriever1.Initialize(shape1);
bool child_has_transform0 = shape0.ChildrenHasTransform();
bool child_has_transform1 = shape1.ChildrenHasTransform();
int i = pairset.Count;
while (i-- != 0)
{
GIM_PAIR pair = pairset[i];
m_triface0 = pair.m_index1;
m_triface1 = pair.m_index2;
CollisionShape colshape0 = retriever0.GetChildShape(m_triface0);
CollisionShape colshape1 = retriever1.GetChildShape(m_triface1);
if (child_has_transform0)
{
body0.SetWorldTransform(orgtrans0 * shape0.GetChildTransform(m_triface0));
}
if (child_has_transform1)
{
//.........这里部分代码省略.........
示例3: GImpactVsShape
//.........这里部分代码省略.........
m_part1 = part;
}
else
{
m_part0 = part;
}
return;
}
#if GIMPACT_VS_PLANE_COLLISION
if(shape0.GetGImpactShapeType() == GIMPACT_SHAPE_TYPE.CONST_GIMPACT_TRIMESH_SHAPE_PART &&
shape1.GetShapeType() == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE)
{
GImpactMeshShapePart shapepart = shape0 as GImpactMeshShapePart;
StaticPlaneShape planeshape = shape1 as StaticPlaneShape;
GImpactTrimeshpartVsPlaneCollision(body0, body1, shapepart, planeshape, swapped);
return;
}
#endif
if (shape1.IsCompound())
{
CompoundShape compoundshape = shape1 as CompoundShape;
GImpactVsCompoundshape(body0, body1, shape0, compoundshape, swapped);
return;
}
else if (shape1.IsConcave())
{
ConcaveShape concaveshape = shape1 as ConcaveShape;
GImpactVsConcave(body0, body1, shape0, concaveshape, swapped);
return;
}
IndexedMatrix orgtrans0 = body0.GetWorldTransform();
IndexedMatrix orgtrans1 = body1.GetWorldTransform();
ObjectArray<int> collided_results = new ObjectArray<int>(64);
GImpactVsShapeFindPairs(ref orgtrans0, ref orgtrans1, shape0, shape1, collided_results);
if (collided_results.Count == 0) return;
shape0.LockChildShapes();
using (GIM_ShapeRetriever retriever0 = BulletGlobals.GIM_ShapeRetrieverPool.Get())
{
retriever0.Initialize(shape0);
bool child_has_transform0 = shape0.ChildrenHasTransform();
int i = collided_results.Count;
if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
{
BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::GImpactVsShape [{0}]", collided_results.Count);
}
while (i-- != 0)
{
int child_index = collided_results[i];
if (swapped)
m_triface1 = child_index;
else
m_triface0 = child_index;
CollisionShape colshape0 = retriever0.GetChildShape(child_index);
if (child_has_transform0)
{
body0.SetWorldTransform(orgtrans0 * shape0.GetChildTransform(child_index));
}
//collide two shapes
if (swapped)
{
ShapeVsShapeCollision(body1, body0, shape1, colshape0);
}
else
{
ShapeVsShapeCollision(body0, body1, colshape0, shape1);
}
//restore transforms
if (child_has_transform0)
{
body0.SetWorldTransform(ref orgtrans0);
}
}
shape0.UnlockChildShapes();
}
}
示例4: InitializeDemo
public override void InitializeDemo()
{
// Setup the basic world
SetTexturing(true);
SetShadows(true);
SetCameraDistance(5.0f);
m_collisionConfiguration = new DefaultCollisionConfiguration();
m_dispatcher = new CollisionDispatcher(m_collisionConfiguration);
IndexedVector3 worldAabbMin = new IndexedVector3(-10000,-10000,-10000);
IndexedVector3 worldAabbMax = new IndexedVector3(10000,10000,10000);
//m_broadphase = new AxisSweep3Internal(ref worldAabbMin, ref worldAabbMax, 0xfffe, 0xffff, 16384, null, true);
m_broadphase = new SimpleBroadphase(1000, null);
m_constraintSolver = new SequentialImpulseConstraintSolver();
m_dynamicsWorld = new DiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_constraintSolver, m_collisionConfiguration);
//m_dynamicsWorld.getDispatchInfo().m_useConvexConservativeDistanceUtil = true;
//m_dynamicsWorld.getDispatchInfo().m_convexConservativeDistanceThreshold = 0.01f;
// Setup a big ground box
{
CollisionShape groundShape = new BoxShape(new IndexedVector3(200.0f,10.0f,200.0f));
m_collisionShapes.Add(groundShape);
IndexedMatrix groundTransform = IndexedMatrix.CreateTranslation(0,-10,0);
CollisionObject fixedGround = new CollisionObject();
fixedGround.SetCollisionShape(groundShape);
fixedGround.SetWorldTransform(ref groundTransform);
fixedGround.SetUserPointer("Ground");
m_dynamicsWorld.AddCollisionObject(fixedGround);
}
// Spawn one ragdoll
IndexedVector3 startOffset = new IndexedVector3(1,0.5f,0);
//string filename = @"c:\users\man\bullet\xna-ragdoll-constraints-output.txt";
//FileStream filestream = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
//BulletGlobals.g_streamWriter = new StreamWriter(filestream);
SpawnRagdoll(ref startOffset, BulletGlobals.g_streamWriter);
//startOffset = new IndexedVector3(-1,0.5f,0);
//spawnRagdoll(ref startOffset);
ClientResetScene();
}