コード例 #1
0
ファイル: physXWorld.cpp プロジェクト: david-leal/nau
void
PhsXWorld::_addParticles(nau::render::Pass* pass, std::shared_ptr<nau::scene::IScene> &aScene, std::string name, nau::material::IBuffer* positions) {

    PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());

    float particleDistance = 0.01f;
    // create particle system in PhysX SDK
    particleSystem = gPhysics->createParticleFluid(MAXPARTICLE);
    //particleSystem->setGridSize(5.0f);
    particleSystem->setMaxMotionDistance(0.3f);
    //particleSystem->setRestOffset(particleDistance*0.3f);
    particleSystem->setRestOffset(0.04f);
    //particleSystem->setContactOffset(particleDistance*0.3f * 2);
    particleSystem->setContactOffset(0.036f);
    particleSystem->setDamping(0.0f);
    particleSystem->setRestitution(0.3f);
    particleSystem->setDynamicFriction(0.001f);
    particleSystem->setRestParticleDistance(particleDistance);
    particleSystem->setViscosity(60.0f);
    particleSystem->setStiffness(45.0f);
    //particleSystem->setParticleReadDataFlag(PxParticleReadDataFlag::eVELOCITY_BUFFER, true);

    particleSystem->userData = aScene.get();

    // add particle system to scene, in case creation was successful
    if (particleSystem)
        m_pDynamicsWorld->addActor(*particleSystem);

    particleIndexPool = PxParticleExt::createIndexPool(MAXPARTICLE);
    particlePass = pass;
    particlePositionBuffer = positions;
    createParticles();
}