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


C++ PhysicsWorld类代码示例

本文整理汇总了C++中PhysicsWorld的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsWorld类的具体用法?C++ PhysicsWorld怎么用?C++ PhysicsWorld使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PhysicsWorld_SetMaxSubSteps_int

static duk_ret_t PhysicsWorld_SetMaxSubSteps_int(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    int steps = (int)duk_require_number(ctx, 0);
    thisObj->SetMaxSubSteps(steps);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例2: CreateTetrahedron

void PhysicsHelper::CreateTetrahedron(PhysicsWorld& world)
{
	Particle* p0 = new Particle(Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), Random::GetF(kParticleHeight, kParticleSpawnVariance + kParticleHeight), Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), kRadius, kInverseMass);
	Particle* p1 = new Particle(Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), Random::GetF(kParticleHeight, kParticleSpawnVariance + kParticleHeight), Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), kRadius, kInverseMass);
	Particle* p2 = new Particle(Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), Random::GetF(kParticleHeight, kParticleSpawnVariance + kParticleHeight), Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), kRadius, kInverseMass);
	Particle* p3 = new Particle(Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), Random::GetF(kParticleHeight, kParticleSpawnVariance + kParticleHeight), Random::GetF(-kParticleSpawnVariance, kParticleSpawnVariance), kRadius, kInverseMass);

	p0->SetVelocity(Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep, Random::GetF(0.0f, kParticleVelocityRange)*kTimeStep, Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep);
	p1->SetVelocity(Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep, Random::GetF(0.0f, kParticleVelocityRange)*kTimeStep, Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep);
	p2->SetVelocity(Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep, Random::GetF(0.0f, kParticleVelocityRange)*kTimeStep, Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep);
	p3->SetVelocity(Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep, Random::GetF(0.0f, kParticleVelocityRange)*kTimeStep, Random::GetF(-kParticleVelocityRange, kParticleVelocityRange)*kTimeStep);

	world.AddParticle(p0);
	world.AddParticle(p1);
	world.AddParticle(p2);
	world.AddParticle(p3);

	Spring* s0 = new Spring(p0, p1, 1.0f);
	Spring* s1 = new Spring(p1, p2, 1.0f);
	Spring* s2 = new Spring(p2, p3, 1.0f);
	Spring* s3 = new Spring(p3, p0, 1.0f);
	Spring* s4 = new Spring(p0, p2, 1.0f);
	Spring* s5 = new Spring(p1, p3, 1.0f);

	world.AddConstraint(s0);
	world.AddConstraint(s1);
	world.AddConstraint(s2);
	world.AddConstraint(s3);
	world.AddConstraint(s4);
	world.AddConstraint(s5);
}
开发者ID:bretthuff22,项目名称:Animation,代码行数:31,代码来源:PhysicsHelper.cpp

示例3: PhysicsWorld_MaxSubSteps

static duk_ret_t PhysicsWorld_MaxSubSteps(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    int ret = thisObj->MaxSubSteps();
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例4: PhysicsWorld_Gravity

static duk_ret_t PhysicsWorld_Gravity(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    float3 ret = thisObj->Gravity();
    PushValueObjectCopy<float3>(ctx, ret, float3_ID, float3_Finalizer);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例5: PhysicsWorld_SetGravity_float3

static duk_ret_t PhysicsWorld_SetGravity_float3(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    float3& gravity = *GetCheckedValueObject<float3>(ctx, 0, float3_ID);
    thisObj->SetGravity(gravity);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例6: PhysicsWorld_IsDebugGeometryEnabled

static duk_ret_t PhysicsWorld_IsDebugGeometryEnabled(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    bool ret = thisObj->IsDebugGeometryEnabled();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例7: PhysicsWorld_SetDebugGeometryEnabled_bool

static duk_ret_t PhysicsWorld_SetDebugGeometryEnabled_bool(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    bool enable = duk_require_boolean(ctx, 0);
    thisObj->SetDebugGeometryEnabled(enable);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例8: main

int main()
{
    PhysicsWorld world;

    auto bigSphereShape = std::make_shared<SphereCollisionShape>(5.0f);
    auto smallSphereShape = std::make_shared<SphereCollisionShape>(1.0f);

    auto bigSphere = std::make_shared<RigidBody>(bigSphereShape);
    bigSphere->transform().setPosition({0, -bigSphereShape->radius(), 0});
    bigSphere->setMass(3.0f);

    auto smallSphere = std::make_shared<RigidBody>(smallSphereShape);
    smallSphere->transform().setPosition({0, 10, 0});

    smallSphere->setLinearVelocity({0, -8, 0});

    world.addRigidBody(bigSphere);
    world.addRigidBody(smallSphere);

    for (auto i = 0; i < 2 * 60; i++) {
        world.update(0.016f);
        std::cout << i << ": SmallBox @ " << smallSphere->transform().position() << "; BigBox @ " << bigSphere->transform().position() << std::endl;
    }

    return 0;
}
开发者ID:mrzzzrm,项目名称:Deliberation2,代码行数:26,代码来源:BasicPhysicsExample.cpp

示例9: PhysicsWorld_SetRunning_bool

static duk_ret_t PhysicsWorld_SetRunning_bool(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    bool enable = duk_require_boolean(ctx, 0);
    thisObj->SetRunning(enable);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例10: SetActive

    void PhysicsBodyObject::SetActive( bool active )
    {
        if( active == Active() )
            return;

        rsk::ActiveObject::SetActive( active );
    //
    //  Encapsulate RSKMAP_ITERATE; duplicate them so only what's needed is run
        PhysicsWorld* world = gGame->GetWorld();
        if( active )
        {
            RSKMAP_ITERATE_VALUE_NAMED( m_Detectors, slot )
            {
                if( slot->active )
                {
                    world->AddBody( slot->area.Self() );
                    CommitDetectorActive( *slot, active );
                }
            }
            return;
        }

        if( world )
        {
            RSKMAP_ITERATE_VALUE_NAMED( m_Detectors, slot )
            {
                CommitDetectorActive( *slot, active );
                world->RemoveBody( slot->area->GetID() );
            }
            return;
        }
开发者ID:rsk78n,项目名称:zoya,代码行数:31,代码来源:physicsbody.cpp

示例11: PhysicsWorld_IsClient

static duk_ret_t PhysicsWorld_IsClient(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    bool ret = thisObj->IsClient();
    duk_push_boolean(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例12: PhysicsWorld_PhysicsUpdatePeriod

static duk_ret_t PhysicsWorld_PhysicsUpdatePeriod(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    float ret = thisObj->PhysicsUpdatePeriod();
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例13: PhysicsWorld_SetPhysicsUpdatePeriod_float

static duk_ret_t PhysicsWorld_SetPhysicsUpdatePeriod_float(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    float updatePeriod = (float)duk_require_number(ctx, 0);
    thisObj->SetPhysicsUpdatePeriod(updatePeriod);
    return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:PhysicsWorldBindings.cpp

示例14: collisionSeparateCallbackFunc

void PhysicsWorld::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data)
{
    PhysicsWorld* world = static_cast<PhysicsWorld*>(data);
    PhysicsContact* contact = static_cast<PhysicsContact*>(arb->data);
    
    world->collisionSeparateCallback(*contact);
    
    delete contact;
}
开发者ID:nichos1983,项目名称:cocos2d-x,代码行数:9,代码来源:CCPhysicsWorld.cpp

示例15: GetEntityID

 MasterEntity::~MasterEntity()
 {
     if( gGame.Exists() )
     {
         PhysicsWorld* world = gGame->GetWorld();
         if( world )
             world->RemoveEntity( GetEntityID() );
     }
 }
开发者ID:rsk78n,项目名称:zoya,代码行数:9,代码来源:masterentity.cpp


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