本文整理汇总了C++中PhysicsCollision::addBox方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsCollision::addBox方法的具体用法?C++ PhysicsCollision::addBox怎么用?C++ PhysicsCollision::addBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsCollision
的用法示例。
在下文中一共展示了PhysicsCollision::addBox方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _updatePhysics
void TSStatic::_updatePhysics()
{
SAFE_DELETE( mPhysicsRep );
if ( !PHYSICSMGR || mCollisionType == None )
return;
PhysicsCollision *colShape = NULL;
if ( mCollisionType == Bounds )
{
MatrixF offset( true );
offset.setPosition( mShape->center );
colShape = PHYSICSMGR->createCollision();
colShape->addBox( getObjBox().getExtents() * 0.5f * mObjScale, offset );
}
else
colShape = mShape->buildColShape( mCollisionType == VisibleMesh, getScale() );
if ( colShape )
{
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
mPhysicsRep = PHYSICSMGR->createBody();
mPhysicsRep->init( colShape, 0, 0, this, world );
mPhysicsRep->setTransform( getTransform() );
}
}
示例2: getCollisionData
PhysicsCollision* CollisionComponent::getCollisionData()
{
if ((!PHYSICSMGR || mCollisionType == None) || mOwnerRenderInterface == NULL)
return NULL;
PhysicsCollision *colShape = NULL;
if (mCollisionType == Bounds)
{
MatrixF offset(true);
offset.setPosition(mOwnerRenderInterface->getShape()->center);
colShape = PHYSICSMGR->createCollision();
colShape->addBox(mOwner->getObjBox().getExtents() * 0.5f * mOwner->getScale(), offset);
}
else if (mCollisionType == CollisionMesh || (mCollisionType == VisibleMesh/* && !mOwner->getComponent<AnimatedMesh>()*/))
{
colShape = buildColShapes();
//colShape = mOwnerShapeInstance->getShape()->buildColShape(mCollisionType == VisibleMesh, mOwner->getScale());
}
/*else if (mCollisionType == VisibleMesh && !mOwner->getComponent<AnimatedMesh>())
{
//We don't have support for visible mesh collisions with animated meshes currently in the physics abstraction layer
//so we don't generate anything if we're set to use a visible mesh but have an animated mesh component.
colShape = mOwnerShapeInstance->getShape()->buildColShape(mCollisionType == VisibleMesh, mOwner->getScale());
}*/
else if (mCollisionType == VisibleMesh/* && mOwner->getComponent<AnimatedMesh>()*/)
{
Con::printf("CollisionComponent::updatePhysics: Cannot use visible mesh collisions with an animated mesh!");
}
return colShape;
}
示例3: setTriggerPolyhedron
void Trigger::setTriggerPolyhedron(const Polyhedron& rPolyhedron)
{
mTriggerPolyhedron = rPolyhedron;
if (mTriggerPolyhedron.pointList.size() != 0) {
mObjBox.minExtents.set(1e10, 1e10, 1e10);
mObjBox.maxExtents.set(-1e10, -1e10, -1e10);
for (U32 i = 0; i < mTriggerPolyhedron.pointList.size(); i++) {
mObjBox.minExtents.setMin(mTriggerPolyhedron.pointList[i]);
mObjBox.maxExtents.setMax(mTriggerPolyhedron.pointList[i]);
}
} else {
mObjBox.minExtents.set(-0.5, -0.5, -0.5);
mObjBox.maxExtents.set( 0.5, 0.5, 0.5);
}
MatrixF xform = getTransform();
setTransform(xform);
mClippedList.clear();
mClippedList.mPlaneList = mTriggerPolyhedron.planeList;
// for (U32 i = 0; i < mClippedList.mPlaneList.size(); i++)
// mClippedList.mPlaneList[i].neg();
MatrixF base(true);
base.scale(Point3F(1.0/mObjScale.x,
1.0/mObjScale.y,
1.0/mObjScale.z));
base.mul(mWorldToObj);
mClippedList.setBaseTransform(base);
SAFE_DELETE( mPhysicsRep );
if ( PHYSICSMGR )
{
PhysicsCollision *colShape = PHYSICSMGR->createCollision();
MatrixF colMat( true );
colMat.displace( Point3F( 0, 0, mObjBox.getExtents().z * 0.5f * mObjScale.z ) );
colShape->addBox( mObjBox.getExtents() * 0.5f * mObjScale, colMat );
//MatrixF colMat( true );
//colMat.scale( mObjScale );
//colShape->addConvex( mTriggerPolyhedron.pointList.address(), mTriggerPolyhedron.pointList.size(), colMat );
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
mPhysicsRep = PHYSICSMGR->createBody();
mPhysicsRep->init( colShape, 0, PhysicsBody::BF_TRIGGER | PhysicsBody::BF_KINEMATIC, this, world );
mPhysicsRep->setTransform( getTransform() );
}
}
示例4: prepCollision
void CollisionComponent::prepCollision()
{
if (!mOwner)
return;
// Let the client know that the collision was updated
setMaskBits(ColliderMask);
mOwner->disableCollision();
if ((!PHYSICSMGR || mCollisionType == None) ||
(mOwnerRenderInterface == NULL && (mCollisionType == CollisionMesh || mCollisionType == VisibleMesh)))
return;
PhysicsCollision *colShape = NULL;
if (mCollisionType == Bounds)
{
MatrixF offset(true);
if (mOwnerRenderInterface && mOwnerRenderInterface->getShape())
offset.setPosition(mOwnerRenderInterface->getShape()->center);
colShape = PHYSICSMGR->createCollision();
colShape->addBox(mOwner->getObjBox().getExtents() * 0.5f * mOwner->getScale(), offset);
}
else if (mCollisionType == CollisionMesh || (mCollisionType == VisibleMesh /*&& !mOwner->getComponent<AnimatedMesh>()*/))
{
colShape = buildColShapes();
}
if (colShape)
{
mPhysicsWorld = PHYSICSMGR->getWorld(isServerObject() ? "server" : "client");
if (mPhysicsRep)
{
if (mBlockColliding)
mPhysicsRep->init(colShape, 0, 0, mOwner, mPhysicsWorld);
else
mPhysicsRep->init(colShape, 0, PhysicsBody::BF_TRIGGER, mOwner, mPhysicsWorld);
mPhysicsRep->setTransform(mOwner->getTransform());
}
}
mOwner->enableCollision();
onCollisionChanged.trigger(colShape);
}
示例5: _updatePhysics
void Item::_updatePhysics()
{
SAFE_DELETE( mPhysicsRep );
if ( !PHYSICSMGR )
return;
if (mDataBlock->simpleServerCollision)
{
// We only need the trigger on the server.
if ( isServerObject() )
{
PhysicsCollision *colShape = PHYSICSMGR->createCollision();
colShape->addBox( mObjBox.getExtents() * 0.5f, MatrixF::Identity );
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
mPhysicsRep = PHYSICSMGR->createBody();
mPhysicsRep->init( colShape, 0, PhysicsBody::BF_TRIGGER | PhysicsBody::BF_KINEMATIC, this, world );
mPhysicsRep->setTransform( getTransform() );
}
}
else
{
if ( !mShapeInstance )
return;
PhysicsCollision* colShape = mShapeInstance->getShape()->buildColShape( false, getScale() );
if ( colShape )
{
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
mPhysicsRep = PHYSICSMGR->createBody();
mPhysicsRep->init( colShape, 0, PhysicsBody::BF_KINEMATIC, this, world );
mPhysicsRep->setTransform( getTransform() );
}
}
}