Пример #1
0
void Apex::Init(PxPhysics* physics, PxCooking* cooking, PxScene* scene)
{
    mErrorCallback = ::new UserErrorCallback("ApexErrors.txt", "a",true, true);
    renderer = SampleRenderer::Renderer;
    m_renderResourceManager = new SampleApexRenderResourceManager(*renderer);

    NxApexSDKDesc     apexDesc;
    NxApexCreateError  errorCode;

    apexDesc.physXSDK = physics;
    apexDesc.cooking = cooking;
    apexDesc.outputStream = mErrorCallback;
    apexDesc.renderResourceManager = m_renderResourceManager;
    if(!apexDesc.isValid())
    {
        return;
    }
    initialized = true;
    gApexSDK = NxCreateApexSDK(apexDesc, &errorCode);
    PX_ASSERT(gApexSDK);
    // Create the APEX scene
    NxApexSceneDesc        apexSceneDesc;
    apexSceneDesc.scene = scene;
    if (!apexSceneDesc.isValid())
	{
		return;
	}
    gApexScene = gApexSDK->createScene(apexSceneDesc);
    if (!gApexScene)
	{
		return;
	}
    
}
Пример #2
0
bool Apex::CreateScene()
{
	PxSceneDesc sceneDesc(mPhysics->getTolerancesScale());
    sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f);

    if(!sceneDesc.cpuDispatcher)
    {
        mCpuDispatcher = PxDefaultCpuDispatcherCreate(mNbThreads);
        if(!mCpuDispatcher)
            return false;
        sceneDesc.cpuDispatcher    = mCpuDispatcher;
    }

    if(!sceneDesc.filterShader)
    {
        sceneDesc.filterShader = PxDefaultSimulationFilterShader;
    }
    
    /*#ifdef PX_WINDOWS
    if(!sceneDesc.gpuDispatcher && mCudaContextManager)
    {
        sceneDesc.gpuDispatcher = mCudaContextManager->getGpuDispatcher();
    }
    #*/
    mProfileZoneManager = &PxProfileZoneManager::createProfileZoneManager(mFoundation);
    pxtask::CudaContextManagerDesc cudaContextManagerDesc;
    mCudaContextManager = pxtask::createCudaContextManager(*mFoundation,cudaContextManagerDesc, mProfileZoneManager);
    sceneDesc.gpuDispatcher = mCudaContextManager->getGpuDispatcher();


	mScene.push_back(mPhysics->createScene(sceneDesc));

    if (!mScene[mCurrentScene])
        return false;


	 NxApexSceneDesc apexSceneDesc;
    // Create the APEX scene...
    
    apexSceneDesc.scene = mScene[mCurrentScene];
	
    if(apexSceneDesc.isValid())
		gApexScene.push_back(gApexSDK->createScene(apexSceneDesc));
    else
        return false;

    if(!gApexScene[mCurrentScene])
        return false;

	gApexScene[mCurrentScene]->setLODResourceBudget(10000.f);

	static const physx::PxU32 viewIDlookAtRightHand = gApexScene[mCurrentScene]->allocViewMatrix(physx::apex::ViewMatrixType::LOOK_AT_LH);
	static const physx::PxU32 projIDperspectiveCubicRightHand = gApexScene[mCurrentScene]->allocProjMatrix(physx::apex::ProjMatrixType::USER_CUSTOMIZED);

	gApexScene[mCurrentScene]->setUseViewProjMatrix(viewIDlookAtRightHand, projIDperspectiveCubicRightHand);
}