本文整理汇总了C++中IPhysicalEntity::AddGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicalEntity::AddGeometry方法的具体用法?C++ IPhysicalEntity::AddGeometry怎么用?C++ IPhysicalEntity::AddGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicalEntity
的用法示例。
在下文中一共展示了IPhysicalEntity::AddGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddBox
int CVehicleMovementAerodynamic::AddBox(Vec3 *_pvPos,Vec3 *_pvSize,float _fMass,int _iID/*=-1*/)
{
IPhysicalEntity* pPhysics = GetPhysics();
IGeomManager *pGeomManager = gEnv->pPhysicalWorld->GetGeomManager();
primitives::box Box;
Box.Basis.SetIdentity();
Box.center.Set(0.0f,0.0f,0.0f);
Box.size = (*_pvSize) / 2.0f;
Box.bOriented = 0;
IGeometry *pGeometry = pGeomManager->CreatePrimitive(primitives::box::type,&Box);
phys_geometry *pPhysGeometry = pGeomManager->RegisterGeometry(pGeometry);
pGeometry->Release();
pe_geomparams partpos;
partpos.pos = *_pvPos;
partpos.mass = _fMass;
int id = pPhysics->AddGeometry(pPhysGeometry,&partpos,_iID);
pGeomManager->UnregisterGeometry(pPhysGeometry);
return id;
}
示例2: Physicalize
void CPickAndThrowProxy::Physicalize()
{
IEntity* pPlayerEntity = m_player.GetEntity();
IPhysicalEntity* pPlayerPhysics = pPlayerEntity->GetPhysics();
const bool bPhysicsChanged = (pPlayerPhysics != m_pLastPlayerPhysics);
// Don't create it again if already exists and its associated physic entity is the same
if ((m_pPickNThrowProxy && !bPhysicsChanged) || !g_pGameCVars->pl_pickAndThrow.useProxies)
return;
CRY_ASSERT(m_pParams != NULL);
if (!m_pParams)
return;
if (bPhysicsChanged)
Unphysicalize();
pe_params_pos pp;
pp.pos = pPlayerEntity->GetWorldPos();
pp.iSimClass = SC_ACTIVE_RIGID;
IPhysicalEntity* pPickNThrowProxy = gEnv->pPhysicalWorld->CreatePhysicalEntity(PE_ARTICULATED, &pp, pPlayerEntity, PHYS_FOREIGN_ID_ENTITY);
phys_geometry *pGeom = NULL;
switch(m_pParams->proxyShape)
{
case ePS_Capsule :
{
primitives::capsule prim;
prim.axis.Set(0,0,1);
prim.center.zero();
prim.r = m_pParams->fRadius;
prim.hh = m_pParams->fHeight;
IGeometry *pPrimGeom = gEnv->pPhysicalWorld->GetGeomManager()->CreatePrimitive(primitives::capsule::type, &prim);
pGeom = gEnv->pPhysicalWorld->GetGeomManager()->RegisterGeometry(pPrimGeom, 0);
pGeom->nRefCount = 0;
pPrimGeom->Release();
} break;
case ePS_Sphere :
{
primitives::sphere prim;
prim.center.zero();
prim.r = m_pParams->fRadius;
IGeometry *pPrimGeom = gEnv->pPhysicalWorld->GetGeomManager()->CreatePrimitive(primitives::sphere::type, &prim);
pGeom = gEnv->pPhysicalWorld->GetGeomManager()->RegisterGeometry(pPrimGeom, 0);
pGeom->nRefCount = 0;
pPrimGeom->Release();
} break;
case ePS_Cylinder :
{
primitives::cylinder prim;
prim.axis.Set(0,0,1);
prim.center.zero();
prim.r = m_pParams->fRadius;
prim.hh = m_pParams->fHeight;
IGeometry *pPrimGeom = gEnv->pPhysicalWorld->GetGeomManager()->CreatePrimitive(primitives::cylinder::type, &prim);
pGeom = gEnv->pPhysicalWorld->GetGeomManager()->RegisterGeometry(pPrimGeom, 0);
pGeom->nRefCount = 0;
pPrimGeom->Release();
} break;
default:
CRY_ASSERT_MESSAGE(false, "Invalid proxy shape?");
}
if (pGeom)
{
CRY_ASSERT(pPlayerEntity->GetPhysics() && (pPlayerEntity->GetPhysics()->GetType() == PE_LIVING));
pe_params_articulated_body pab;
pab.pHost = pPlayerPhysics;
m_pLastPlayerPhysics = pPlayerPhysics;
pab.posHostPivot = m_pParams->vPosPivot;
pab.bGrounded = 1;
pab.nJointsAlloc = 1;
pPickNThrowProxy->SetParams(&pab);
pe_articgeomparams gp;
gp.pos.zero();
gp.flags = CPickAndThrowProxy::geom_colltype_proxy;
gp.flagsCollider = 0;
gp.mass = 0.0f;
pPickNThrowProxy->AddGeometry(pGeom, &gp);
m_pPickNThrowProxy = pPickNThrowProxy;
}
}