本文整理汇总了C++中Capsule类的典型用法代码示例。如果您正苦于以下问题:C++ Capsule类的具体用法?C++ Capsule怎么用?C++ Capsule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Capsule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tVector2D
void CHuman::Update(float fElapsedTime)
{
CEnemy::Update( fElapsedTime );
m_nCollisionWithStaticObjectsSphere.m_Center = tVector2D(GetPosX(), GetPosY());
for( unsigned int i = 0; i < CGamePlayState::GetInstance()->m_StoreWalls.size(); i++)
{
Capsule* temp = CGamePlayState::GetInstance()->m_StoreWalls[i];
tVector2D ClosestPoint = ClosestPointOnALine(temp->GetStartPoint(), temp->GetEndPoint(), tVector2D( GetPosX(), GetPosY()));
// Create a circle based on clsoest point with capsule radius
Circle testCircle;
testCircle.m_Center = ClosestPoint;
testCircle.m_fRadius = temp->GetRadius();
if( GetSphere()->CheckCollision(testCircle) )
{
tVector2D sphere2_to_1 = GetSphere()->m_Center - testCircle.m_Center;
sphere2_to_1 = Vector2DNormalize(sphere2_to_1);
float dist = GetSphere()->m_fRadius + testCircle.m_fRadius;
tVector2D scaler = (sphere2_to_1 * (dist * 0.01f));
tVector2D newpos = GetSphere()->m_Center + scaler;
SetPosX(newpos.fX);
SetPosY(newpos.fY);
}
}
}
示例2: Capsule_Centroid_const
static QScriptValue Capsule_Centroid_const(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 0) { printf("Error! Invalid number of arguments passed to function Capsule_Centroid_const in file %s, line %d!\nExpected 0, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
float3 ret = This.Centroid();
return qScriptValueFromValue(engine, ret);
}
示例3: Capsule_Intersects_Polyhedron_const
static QScriptValue Capsule_Intersects_Polyhedron_const(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) { printf("Error! Invalid number of arguments passed to function Capsule_Intersects_Polyhedron_const in file %s, line %d!\nExpected 1, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
Polyhedron polyhedron = qscriptvalue_cast<Polyhedron>(context->argument(0));
bool ret = This.Intersects(polyhedron);
return qScriptValueFromValue(engine, ret);
}
示例4: Capsule_toString_const
static QScriptValue Capsule_toString_const(QScriptContext *context, QScriptEngine *engine)
{
Capsule This;
if (context->argumentCount() > 0) This = qscriptvalue_cast<Capsule>(context->argument(0)); // Qt oddity (bug?): Sometimes the built-in toString() function doesn't give us this from thisObject, but as the first argument.
else This = qscriptvalue_cast<Capsule>(context->thisObject());
QString ret = This.toString();
return qScriptValueFromValue(engine, ret);
}
示例5: TestIntersection
//----------------------------------------------------------------------------
bool Mgc::TestIntersection (const Capsule& rkC0, const Capsule& rkC1)
{
Real fSqrDist = SqrDistance(rkC0.Segment(),rkC1.Segment());
Real fRSum = rkC0.Radius() + rkC1.Radius();
Real fRSumSqr = fRSum*fRSum;
return fSqrDist <= fRSumSqr;
}
示例6: Capsule_Contains_Frustum_const
static QScriptValue Capsule_Contains_Frustum_const(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) { printf("Error! Invalid number of arguments passed to function Capsule_Contains_Frustum_const in file %s, line %d!\nExpected 1, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
Frustum frustum = qscriptvalue_cast<Frustum>(context->argument(0));
bool ret = This.Contains(frustum);
return qScriptValueFromValue(engine, ret);
}
示例7: Capsule_SetFrom_Sphere
static QScriptValue Capsule_SetFrom_Sphere(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) { printf("Error! Invalid number of arguments passed to function Capsule_SetFrom_Sphere in file %s, line %d!\nExpected 1, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
Sphere s = qscriptvalue_cast<Sphere>(context->argument(0));
This.SetFrom(s);
ToExistingScriptValue_Capsule(engine, This, context->thisObject());
return QScriptValue();
}
示例8: Capsule_Transform_float4x4
static QScriptValue Capsule_Transform_float4x4(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) { printf("Error! Invalid number of arguments passed to function Capsule_Transform_float4x4 in file %s, line %d!\nExpected 1, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
float4x4 transform = qscriptvalue_cast<float4x4>(context->argument(0));
This.Transform(transform);
ToExistingScriptValue_Capsule(engine, This, context->thisObject());
return QScriptValue();
}
示例9: Capsule_Scale_float3_float
static QScriptValue Capsule_Scale_float3_float(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 2) { printf("Error! Invalid number of arguments passed to function Capsule_Scale_float3_float in file %s, line %d!\nExpected 2, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
float3 centerPoint = qscriptvalue_cast<float3>(context->argument(0));
float scaleFactor = qscriptvalue_cast<float>(context->argument(1));
This.Scale(centerPoint, scaleFactor);
ToExistingScriptValue_Capsule(engine, This, context->thisObject());
return QScriptValue();
}
示例10: Capsule_UniformPointPerhapsInside_float_float_float_const
static QScriptValue Capsule_UniformPointPerhapsInside_float_float_float_const(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 3) { printf("Error! Invalid number of arguments passed to function Capsule_UniformPointPerhapsInside_float_float_float_const in file %s, line %d!\nExpected 3, but got %d!\n", __FILE__, __LINE__, context->argumentCount()); PrintCallStack(context->backtrace()); return QScriptValue(); }
Capsule This = qscriptvalue_cast<Capsule>(context->thisObject());
float l = qscriptvalue_cast<float>(context->argument(0));
float x = qscriptvalue_cast<float>(context->argument(1));
float y = qscriptvalue_cast<float>(context->argument(2));
float3 ret = This.UniformPointPerhapsInside(l, x, y);
return qScriptValueFromValue(engine, ret);
}
示例11: raycast_capsule
PxU32 raycast_capsule(GU_RAY_FUNC_PARAMS)
{
PX_UNUSED(maxHits);
PX_ASSERT(geom.getType() == PxGeometryType::eCAPSULE);
PX_ASSERT(maxHits && hits);
const PxCapsuleGeometry& capsuleGeom = static_cast<const PxCapsuleGeometry&>(geom);
// TODO: PT: could we simplify this ?
Capsule capsule;
getCapsuleSegment(pose, capsuleGeom, capsule);
capsule.radius = capsuleGeom.radius;
PxReal t;
if(!intersectRayCapsule(rayOrigin, rayDir, capsule, t))
return 0;
if(t>maxDist)
return 0;
// PT: we can't avoid computing the position here since it's needed to compute the normal anyway
hits->position = rayOrigin + rayDir*t; // PT: will be rayOrigin for t=0.0f (i.e. what the spec wants)
hits->distance = t;
hits->faceIndex = 0xffffffff;
hits->u = 0.0f;
hits->v = 0.0f;
// Compute additional information if needed
PxHitFlags outFlags = PxHitFlag::eDISTANCE|PxHitFlag::ePOSITION;
if(hitFlags & PxHitFlag::eNORMAL)
{
outFlags |= PxHitFlag::eNORMAL;
if(t==0.0f)
{
hits->normal = -rayDir;
}
else
{
PxReal capsuleT;
distancePointSegmentSquared(capsule, hits->position, &capsuleT);
capsule.computePoint(hits->normal, capsuleT);
hits->normal = hits->position - hits->normal; //this should never be zero. It should have a magnitude of the capsule radius.
hits->normal.normalize();
}
}
else
{
hits->normal = PxVec3(0.0f);
}
hits->flags = outFlags;
return 1;
}
示例12: matMulMat
void computeBV<OBB>(const Capsule& s, OBB& bv)
{
Vec3f R[3];
matMulMat(s.getRotation(), s.getLocalRotation(), R);
Vec3f T = matMulVec(s.getRotation(), s.getLocalTranslation()) + s.getTranslation();
bv.To = T;
bv.axis[0] = Vec3f(R[0][0], R[1][0], R[2][0]);
bv.axis[1] = Vec3f(R[0][1], R[1][1], R[2][1]);
bv.axis[2] = Vec3f(R[0][2], R[1][2], R[2][2]);
bv.extent = Vec3f(s.radius, s.radius, s.lz / 2 + s.radius);
}
示例13: main
int main(int argc, char *argv[]) {
string dataSheetFileName(argv[1]);
fstream dataSheet (dataSheetFileName);
int iBlockSize, jBlockSize, kBlockSize, blockSize; // physical
dataSheet >> iBlockSize >> jBlockSize >> kBlockSize;
Capsule *cube = new Capsule(iBlockSize, jBlockSize, kBlockSize);
for (int i = 0; i < iBlockSize; i++) {
for (int j = 0; j < jBlockSize; j++) {
for (int k = 0; k < kBlockSize; k++) {
int zID = cube->mortonIndex(i, j, k);
dataSheet >> cube->b_block[zID];
}
}
}
/*
for (int i = 0; i < iBlockSize; i++) {
for (int j = 0; j < jBlockSize; j++) {
for (int k = 0; k < kBlockSize; k++) {
int zID =
i * cube->iPadBlockSize * cube->jPadBlockSize
+ j * cube->kPadBlockSize + k;
// cout << i << "\t" << j << "\t" << k << "\t" << zID << endl;
dataSheet >> cube->b_block[zID];
}
}
}
*/
int subCubeSize = atoi(argv[2]);
int t0 = clock();
cube->GS_block_interior_update_009(1, subCubeSize);
// cube->GS_Regular_block_update_02(subCubeSize);
// cube->GS_Z_block_update_02(subCubeSize);
int t1 = clock();
// cout << endl;
// cout << cube->padBlockSize << endl;
// cout << oct << cube->iMask<< endl;
// cout << cube->jMask<< endl;
// cout << cube->kMask<< endl;
//
// cout << cube->i_interleave.size() << endl;
// cout << cube->j_interleave.size() << endl;
// cout << cube->k_interleave.size() << endl;
double t = 1.0 * (t1-t0) / CLOCKS_PER_SEC;
cout << "Time Elapsed, " <<subCubeSize << "," << t << endl;
delete cube;
dataSheet.close();
return 0;
}
示例14: ComputeMovement
void CGuard::Update(float fElapsedTime)
{
if(CheckForPlayer())
{
ComputeMovement(fElapsedTime);
this->addTime(fElapsedTime);
CBase::Update(fElapsedTime);
}
else
CEnemy::Update( fElapsedTime );
m_nCollisionWithStaticObjectsSphere.m_Center = tVector2D(GetPosX(), GetPosY());
for( unsigned int i = 0; i < CGamePlayState::GetInstance()->m_StoreWalls.size(); i++)
{
Capsule* temp = CGamePlayState::GetInstance()->m_StoreWalls[i];
tVector2D ClosestPoint = ClosestPointOnALine(temp->GetStartPoint(), temp->GetEndPoint(), tVector2D( GetPosX(), GetPosY()));
// Create a circle based on clsoest point with capsule radius
Circle testCircle;
testCircle.m_Center = ClosestPoint;
testCircle.m_fRadius = temp->GetRadius();
if( GetSphere()->CheckCollision(testCircle) )
{
tVector2D sphere2_to_1 = GetSphere()->m_Center - testCircle.m_Center;
sphere2_to_1 = Vector2DNormalize(sphere2_to_1);
float dist = GetSphere()->m_fRadius + testCircle.m_fRadius;
tVector2D scaler = (sphere2_to_1 * (dist * 0.01f));
tVector2D newpos = GetSphere()->m_Center + scaler;
SetPosX(newpos.fX);
SetPosY(newpos.fY);
}
}
if( CSGD_DirectInput::GetInstance()->KeyPressed(DIK_1))
{
IsUndead = true;
AnimManager::GetInstance()->SetAnimation( GetAnimID(), "Zombie Walking" );
}
if( CSGD_DirectInput::GetInstance()->KeyPressed(DIK_2))
{
IsUndead = false;
AnimManager::GetInstance()->SetAnimation( GetAnimID(), "Person Walking" );
}
}
示例15: Enclose
void Sphere::Enclose(const Capsule &capsule)
{
// Capsule is a convex object spanned by the endpoint spheres - enclosing
// the endpoint spheres will also cause this Sphere to enclose the middle
// section since Sphere is convex as well.
float da = pos.DistanceSq(capsule.l.a);
float db = pos.DistanceSq(capsule.l.b);
// Enclose the farther Sphere of the Capsule first, and the closer one second to retain the tightest fit.
if (da > db)
{
Enclose(capsule.SphereA());
Enclose(capsule.SphereB());
}
else
{
Enclose(capsule.SphereB());
Enclose(capsule.SphereA());
}
}