bool PhysXPhysics::VInitialize()
{
	VLoadPhysicsConfigXml();
	int version = PX_PHYSICS_VERSION;
	m_pFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, m_allocatorCallback, m_errorCallback);
	m_pPhysicsSdk = PxCreatePhysics(PX_PHYSICS_VERSION, *m_pFoundation, PxTolerancesScale(), true);

	if (!m_pPhysicsSdk)
	{
		BE_ERROR("Error Creating PhysX device.");
		return false;
	}

	PxSceneDesc sceneDesc(m_pPhysicsSdk->getTolerancesScale());

	sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f); //Set Gravity
	m_pDispatcher = PxDefaultCpuDispatcherCreate(2);
	sceneDesc.cpuDispatcher = m_pDispatcher;
	sceneDesc.filterShader = PxDefaultSimulationFilterShader;

	m_pScene = m_pPhysicsSdk->createScene(sceneDesc);

#ifdef ENABLE_PHYSX_PVD
	ConnectPVD();
#endif
	
	return true;
}
Exemple #2
0
PxCooking* getDefaultCooking( PxFoundation* foundation )
{ 
    PxTolerancesScale scale = PxTolerancesScale();
    PxCookingParams params( scale );
    // disable mesh cleaning - perform mesh validation on development configurations
    params.meshPreprocessParams |= PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH;
    // disable edge precompute, edges are set for each triangle, slows contact generation
    //params.meshPreprocessParams |= PxMeshPreprocessingFlag::eDISABLE_ACTIVE_EDGES_PRECOMPUTE;
    // lower hierarchy for internal mesh
    params.meshCookingHint = PxMeshCookingHint::eCOOKING_PERFORMANCE;
    return PxCreateCooking( PX_PHYSICS_VERSION, *foundation, params ); 
}
Exemple #3
0
void Physics::SetUpPhysX()
{
	PxAllocatorCallback *myCallback = new myAllocator();
	g_PhysicsFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, *myCallback, gDefaultErrorCallback);
	g_Physics = PxCreatePhysics(PX_PHYSICS_VERSION, *g_PhysicsFoundation, PxTolerancesScale());
	PxInitExtensions(*g_Physics);
	//create physics material
	g_PhysicsMaterial = g_Physics->createMaterial(0.5f, 0.5f, 0.5f);
	PxSceneDesc sceneDesc(g_Physics->getTolerancesScale());
	sceneDesc.gravity = PxVec3(0, -10.0f, 0);
	sceneDesc.filterShader = &physx::PxDefaultSimulationFilterShader;
	sceneDesc.cpuDispatcher = PxDefaultCpuDispatcherCreate(1);
	g_PhysicsScene = g_Physics->createScene(sceneDesc);
}
// Set up PhysX
void InitializePhysX() {
	gFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, gAllocator, gErrorCallback);

	gPvd = PxCreatePvd(*gFoundation);
	PxPvdTransport* transport = PxDefaultPvdSocketTransportCreate("127.0.0.1", 5425, 10);
	gPvd->connect(*transport, PxPvdInstrumentationFlag::eALL);

	gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, PxTolerancesScale(), true, gPvd);

	PxSceneDesc sceneDesc(gPhysics->getTolerancesScale());
	sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f);
	gDispatcher = PxDefaultCpuDispatcherCreate(2);
	sceneDesc.cpuDispatcher = gDispatcher;
	sceneDesc.filterShader = contactReportFilterShader/*PxDefaultSimulationFilterShader*/;
	sceneDesc.simulationEventCallback = &gContactReportCallback;	// contact callback
	sceneDesc.contactModifyCallback = &gModContactReportCallback;	// modification contact callback
	gScene = gPhysics->createScene(sceneDesc);

	PxPvdSceneClient* pvdClient = gScene->getScenePvdClient();
	if (pvdClient)
	{
		pvdClient->setScenePvdFlag(PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS, true);
		pvdClient->setScenePvdFlag(PxPvdSceneFlag::eTRANSMIT_CONTACTS, true);
		pvdClient->setScenePvdFlag(PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true);
	}
	gMaterial = gPhysics->createMaterial(0.5f, 0.5f, 0.6f);

	// add some physics objects
	AddPhyObjects();

	createChain(PxTransform(PxVec3(10.0f, 30.0f, -30.0f)), 5, PxBoxGeometry(2.0f, 0.5f, 0.5f), 4.0f, createLimitedSpherical);
	createChain(PxTransform(PxVec3(0.0f, 30.0f, -30.0f)), 5, PxBoxGeometry(2.0f, 0.5f, 0.5f), 4.0f, createBreakableFixed);
	createChain(PxTransform(PxVec3(-10.0f, 30.0f, -30.0f)), 5, PxBoxGeometry(2.0f, 0.5f, 0.5f), 4.0f, createDampedD6);

	gScene->setVisualizationParameter(PxVisualizationParameter::eSCALE, 1.0f);
	gScene->setVisualizationParameter(PxVisualizationParameter::eACTOR_AXES, 1.0f);
	gScene->setVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES, 2.0f);
	gScene->setVisualizationParameter(PxVisualizationParameter::eCONTACT_NORMAL, 2.0f);


}
Exemple #5
0
// **initPx_Foundation_Physics_Extensions**
void kzsPhysXFramework::initPx_Foundation_Physics_Extensions()
{
	printf( "creating Foundation\n" );
	// create foundation object with default error and allocator callbacks.
	mFoundation = PxCreateFoundation( PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback );
	if ( !mFoundation ) cerr << "PxCreateFoundation failed!" << endl;

	
	printf( "creating Physics\n" );
	// create Physics oject with the created foundation and with a 'default' scale tolerance.
	gPhysicsSDK = PxCreatePhysics( PX_PHYSICS_VERSION, *mFoundation, PxTolerancesScale() );
	if ( gPhysicsSDK == NULL )
	{
		cerr << "Error creating PhysX3 divice." << endl;
		cerr << "Existing..." << endl;
		exit( 1 );
	}
	
	PxInitExtensions( *gPhysicsSDK );
	if ( !PxInitExtensions( *gPhysicsSDK ) )cerr << "PxInitExtensions failed!" << endl;
}
Exemple #6
0
void JF::JFCPhysXDevice::DeviceInit()
{
	// 1) 
	m_Foundation = PxCreateFoundation(PX_PHYSICS_VERSION, m_Allocator, m_ErrorCallback);

	// 2) 프로파일러 생성
	PxProfileZoneManager* profileZoneManager = &PxProfileZoneManager::createProfileZoneManager(m_Foundation);
	m_Physics = PxCreatePhysics(PX_PHYSICS_VERSION, *m_Foundation, PxTolerancesScale(), true, profileZoneManager);

	// 3) 그래픽 디버거 연결.
	if (m_Physics->getPvdConnectionManager())
	{
		m_Physics->getVisualDebugger()->setVisualizeConstraints(true);
		m_Physics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_CONTACTS, true);
		m_Physics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_SCENEQUERIES, true);
		m_Connection = PxVisualDebuggerExt::createConnection(m_Physics->getPvdConnectionManager(), "127.0.0.1", 5425, 10);
	}

	// 4)
	m_Dispatcher = PxDefaultCpuDispatcherCreate(2);
}
Exemple #7
0
void Game::InitializePhysX()
{
	//Create the foundation of the physX SDK to check for SDK Version validity and create Allocation and Error callbacks
	foundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gMyPhysXErrorReporter);
	
	//If in debug mode, activate the Profiling Manager
#if _DEBUG
	mProfileZoneManager = &physx::PxProfileZoneManager::createProfileZoneManager(foundation);
	
	if(!mProfileZoneManager)
		printf("PxProfileZoneManager::createProfileZoneManager failed!");

	gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, 
		physx::PxTolerancesScale(), true, mProfileZoneManager);	
#else
	gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale(), false, NULL);
#endif
	
#ifdef USE_PHYSX_COOKING
	physx::PxCookingParams pa = physx::PxCookingParams(gPhysicsSDK->getTolerancesScale());
	PhysXCookingWrapper::CreateCooking(PX_PHYSICS_VERSION, *foundation, pa);
#endif // USE_PHYSX_COOKING
Exemple #8
0
bool Apex::InitPhysX()
{
    static PxDefaultErrorCallback gDefaultErrorCallback;
    static PxDefaultAllocator gDefaultAllocatorCallback;

    mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
    if(!mFoundation)
        return false;

    bool recordMemoryAllocations = true;

    mPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *mFoundation,
                PxTolerancesScale(), recordMemoryAllocations);
    if(!mPhysics)
        return false;

    mCooking = PxCreateCooking(PX_PHYSICS_VERSION, *mFoundation, PxCookingParams());
    if (!mCooking)
        return false;

    if (!PxInitExtensions(*mPhysics))
        return false;
    

    //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[mCurrentScene] = mPhysics->createScene(sceneDesc);
    //if (!mScene[mCurrentScene])
    //    return false;
    
    defaultMaterial = mPhysics->createMaterial(0.5f, 0.5f, 0.1f);    //static friction, dynamic friction, restitution
    if(!defaultMaterial)
        return false;

    // Create a plane
    PxRigidStatic* plane = PxCreatePlane(*mPhysics, PxPlane(PxVec3(0,1,0), 700), *defaultMaterial);
    if (!plane)
        return false;

    //mScene[mCurrentScene]->addActor(*plane);

    // Create a heightfield
    PhysXHeightfield* heightfield = new PhysXHeightfield();
    //heightfield->InitHeightfield(mPhysics, mScene[mCurrentScene], "terrain5.raw");

    // check if PvdConnection manager is available on this platform
    if(mPhysics->getPvdConnectionManager() == NULL)
	{
        return true;
	}

    // setup connection parameters
    const char*     pvd_host_ip = "127.0.0.1";  // IP of the PC which is running PVD
    int             port        = 5425;         // TCP port to connect to, where PVD is listening
    unsigned int    timeout     = 100;          // timeout in milliseconds to wait for PVD to respond,
                                                // consoles and remote PCs need a higher timeout.
    PxVisualDebuggerConnectionFlags connectionFlags = PxVisualDebuggerExt::getAllConnectionFlags();

    // and now try to connect
    pvdConnection = PxVisualDebuggerExt::createConnection(mPhysics->getPvdConnectionManager(),
        pvd_host_ip, port, timeout, connectionFlags);

    mPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlags::eTRANSMIT_CONTACTS, true);

    return true;
}
Exemple #9
0
void InitializePhysX(vector<PhysXObject*>* &cubeList)
{
    allActors = new vector<PhysXObject*>;

    PxFoundation* foundation = PxCreateFoundation(PX_PHYSICS_VERSION,
                               gDefaultAllocatorCallback, gDefaultErrorCallback);
    gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale());

    if(gPhysicsSDK == NULL)
    {
        exit(1);
    }

    PxInitExtensions(*gPhysicsSDK);

    PxSceneDesc sceneDesc(gPhysicsSDK->getTolerancesScale());

    sceneDesc.gravity=PxVec3(0.0f, -9.8f, 0.0f);

    if(!sceneDesc.cpuDispatcher)
    {
        PxDefaultCpuDispatcher* mCpuDispatcher = PxDefaultCpuDispatcherCreate(3);

        sceneDesc.cpuDispatcher = mCpuDispatcher;
    }

    if(!sceneDesc.filterShader)
        sceneDesc.filterShader = gDefaultFilterShader;

    gScene = gPhysicsSDK->createScene(sceneDesc);

    gScene->setVisualizationParameter(PxVisualizationParameter::eSCALE, 1.0);
    gScene->setVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES, 1.0f);


    //1) Create Planes
    PxMaterial* mMaterial = gPhysicsSDK->createMaterial(0.5, 0.5, 0.5);

    for(int i = 0; i < 1; i++)
    {
        PhysXObject* plane = new PhysXObject;
        plane->actor = gPhysicsSDK->createRigidStatic(planePoses[i]);

        PxShape* shape = plane->actor->createShape(PxPlaneGeometry(), *mMaterial);

        gScene->addActor(*(plane->actor));
        allActors->push_back(plane);
        planes.push_back(plane);
    }

    //2) Create Planets
    PxReal planetDensity = 1.0f;
    PxVec3 planetDimensions(2,2,2);
    PxBoxGeometry planetGeom(planetDimensions);
    PxTransform planetTransform;

    for(int i = 0; i < PLANET_NUM; i++)
    {
        planetTransform = planetTransforms[i];
        PhysXObject* planet = new PhysXObject;
        planet->actor = PxCreateStatic(*gPhysicsSDK, planetTransform, planetGeom, *mMaterial);

        EnableGravity(planet->actor);

        gScene->addActor(*(planet->actor));
        allActors->push_back(planet);
        planets.push_back(planet);

        //HACK:
        /* Create the joint handlers for distance limiting
        /* We need to do this because a distance joint attached to an actor
        /* seems to void collisions between those two actors (i.e. "phases through")
        /* So we make another actor in the same position to hold the position

        PhysXObject* newHandle = new PhysXObject;
        newHandle->actor = PxCreateStatic(*gPhysicsSDK, tran, boxgeom, *mMaterial);

        gScene->addActor(*(newHandle->actor));
        planetJointHandles.push_back(newHandle);
        //We also don't need to worry about drawing the joints, for obvious reasons
        */
    }

    //3) Create Cubes
    PxReal density = 1.0f;
    PxTransform transform(PxVec3(0.0f, 0.0f, 0.0f), PxQuat::createIdentity());
    PxVec3 dimensions(0.5, 0.5, 0.5);
    PxBoxGeometry geometry(dimensions);

    for(int i = 0; i < BLOCK_NUM; i++)
    {
        srand((time(NULL) * i) + time(NULL));

        transform.p = PxVec3((float)((rand() % (2 * PLANET_HEIGHT)) - PLANET_HEIGHT),
                             (float)((rand() % (2 * PLANET_HEIGHT)) - PLANET_HEIGHT),
                             (float)((rand() % (2 * PLANET_HEIGHT)) - PLANET_HEIGHT));

        PhysXObject* cube = new PhysXObject;

        cube->actor = PxCreateDynamic(*gPhysicsSDK, transform, geometry, *mMaterial, density);

        //Create Distance Joints between planets here
        //Not included for run time optimizations
        //End creating distance joints

        //Create D6 Joints between planets here
        //Not included for run time optimizations
        //End creating distance joints

        cube->actor->isRigidDynamic()->setAngularDamping(0.75);
        cube->actor->isRigidDynamic()->setLinearVelocity(PxVec3(0,0,0));

        gScene->addActor(*(cube->actor));
        allActors->push_back(cube);
        boxes.push_back(cube);
    }

    cubeList = allActors;
}
Exemple #10
0
void GameWorld::init()
{
	gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback);
	if (!gFoundation) {
		printf("PxCreateFoundation failed!");
	}
	gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, PxTolerancesScale(), true);
	if (!PxInitExtensions(*gPhysics)) {
		printf("init error pxinit\n");
	}
	gCooking = PxCreateCooking(PX_PHYSICS_VERSION, *gFoundation, PxCookingParams(gPhysics->getTolerancesScale()));
	if (!gCooking) {
		printf("PxCreateCooking failed!\n");
	}
	PxSceneDesc sceneDesc(gPhysics->getTolerancesScale());
	sceneDesc.gravity = PxVec3(0.0f, -98.0f, 0.0f);
	gDispatcher = PxDefaultCpuDispatcherCreate(2);
	sceneDesc.cpuDispatcher = gDispatcher;
	sceneDesc.filterShader = PxDefaultSimulationFilterShader;
	gScene = gPhysics->createScene(sceneDesc);
	gMaterial = gPhysics->createMaterial(0.5f, 0.5f, 0.6f);
	PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 0, 1, 400), *gMaterial);
	gScene->addActor(*groundPlane);
	groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 0, -1, 400), *gMaterial);
	gScene->addActor(*groundPlane);
	groundPlane = PxCreatePlane(*gPhysics, PxPlane(1, 0, 0, 280), *gMaterial);
	gScene->addActor(*groundPlane);
	groundPlane = PxCreatePlane(*gPhysics, PxPlane(-1, 0, 0, 280), *gMaterial);
	gScene->addActor(*groundPlane);
	groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, -1, 0, 600), *gMaterial);
	gScene->addActor(*groundPlane);
	groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 1, 0, -1), *gMaterial);
	gScene->addActor(*groundPlane);
	gGround.loadFromObj(GROUND_FILE);
	gGround.cookingMesh(*gPhysics, *gCooking);
	gGround.createActor(*gMaterial, *gPhysics);
	gScene->addActor(*(gGround.actor));

	//包围盒
	box.loadFromObj(BOX_FILE);

	//初始化飞球
	pxFlyBall = new PxFlyBall(Color4f(1.0, 200 / 255.0, 0), 5.0);
	Material mtl;
	PerlinImage perlinYellow = createPerlinLightYelloImage(40, 40, 6, 1.8);
	PerlinTexture(perlinYellow, mtl.kd_texid);
	mtl.ka = Color4f(1, 1, 1, 1);
	mtl.kd = Color4f(1, 1, 1, 1);
	mtl.ks = Color4f(1, 1, 1, 1);
	pxFlyBall->mtl = mtl;
	pxFlyBall->createPxBall(*gPhysics, PxTransform(PxVec3(rand() % 500 - 250, 100, rand() % 700 - 350)), *gMaterial);
	pxFlyBall->pxActor->setAngularDamping(0.5);
	perlinYellow.clear();
	gScene->addActor(*(pxFlyBall->pxActor));

	//初始化白球
	pxControlBall = new PxControlBall(Color4f(1.0, 1.0, 1.0), 5.0);
	PerlinImage perlinGray = createPerlinGrayImage(40, 40, 6, 1.8);
	PerlinTexture(perlinGray, mtl.kd_texid);
	mtl.ka = Color4f(1, 1, 1, 1);
	mtl.kd = Color4f(1, 1, 1, 1);
	mtl.ks = Color4f(0, 0, 0, 0);
	pxControlBall->mtl = mtl;
	pxControlBall->createPxBall(*gPhysics, PxTransform(PxVec3(0, 50, 0)), *gMaterial);
	pxControlBall->pxActor->setAngularDamping(0.5);
	perlinGray.clear();
	gScene->addActor(*(pxControlBall->pxActor));
	
	GLfloat light1PosType[] = { -5.0,1.0,5.0,0.0 };
	GLfloat whiteColor[] = { 1.0,1.0,1.0,1.0 };
	GLfloat darkColor[] = { 0.4,0.4,0.4,1 };
	GLfloat specColor[] = { 1,1,1,1 };
	GLfloat lightColor[] = { 1,1,1,1 };
	GLfloat globalAmbient[] = { 0.2,0.2,0.2,1.0 };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);
	glLightfv(GL_LIGHT1, GL_AMBIENT, darkColor);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor);
	glLightfv(GL_LIGHT1, GL_SPECULAR, specColor);
	glLightfv(GL_LIGHT1, GL_POSITION, light1PosType);
}
void Gameplay::entityInit(Object * p)
{
    // load config
    _config = new TiXmlDocument( "./cfg/config.xml" );
    _config->LoadFile();

    // read pitch shift option    
    TiXmlElement* xmlSound = Gameplay::iGameplay->getConfigElement( "sound" ); assert( xmlSound );
    int pitchShift;
    xmlSound->Attribute( "pitchShift", &pitchShift );
    _pitchShiftIsEnabled = ( pitchShift != 0 );   

	// read cheats option    
    TiXmlElement* details = Gameplay::iGameplay->getConfigElement( "details" ); assert( details );
    int cheats;
    details->Attribute( "cheats", &cheats );
    _cheatsEnabled = ( cheats != 0 );  

	// read free jumping mode  
    int freemode;
    details->Attribute( "freemode", &freemode );
    _freeModeIsEnabled = ( freemode != 0 ); 

	// read meters / feet mode  
    int units;
    details->Attribute( "units", &units );
    _feetModeIsEnabled = ( units != 0 ); 

    // setup random number generation
    getCore()->getRandToolkit()->setSeed( GetTickCount() );


    // retrieve interfaces
    queryInterface( "Engine", &iEngine ); assert( iEngine );
    queryInterface( "Gui", &iGui ); assert( iGui );
    queryInterface( "Language", &iLanguage ); assert( iLanguage );
    queryInterface( "Input", &iInput ); assert( iInput );
    queryInterface( "Audio", &iAudio ); assert( iAudio );
    if( !iAudio || !iInput || !iLanguage || !iGui || !iEngine )
    {
        throw Exception( "One or more core modules are not found, so gameplay will Crash Right Now!" );
    }

    // check language module
    if( wcscmp( iLanguage->getVersionString(), ::version.getVersionString() ) != 0 )
    {
        // incompatible module? - show no localization data
        iLanguage->reset();
    }

	getCore()->logMessage("Version: %ls (Clean)", ::version.getVersionString());

    // create input device
    _inputDevice = iInput->createInputDevice();
    createActionMap();

    // create physics resources
	foundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
    gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale() );
	pxCooking = PxCreateCooking(PX_PHYSICS_VERSION, *foundation, PxCookingParams(PxTolerancesScale()));
	PxInitExtensions(*gPhysicsSDK);

	//PHYSX3
    //NxGetPhysicsSDK()->setParameter( NX_VISUALIZATION_SCALE, 100.0f );
    //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_ACTOR_AXES, 1 );
    //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_COLLISION_SHAPES, 1 );
    //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_COLLISION_STATIC, 1 );
    //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_COLLISION_DYNAMIC,1 );

    // generate user community events from XML documents
    generateUserCommunityEvents();

    // open index
    TiXmlDocument* index = new TiXmlDocument( "./usr/index.xml" );
    index->LoadFile();

    // enumerate career nodes
    TiXmlNode* child = index->FirstChild();
    if( child ) do 
    {
        if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "career" ) == 0 )
        {
            _careers.push_back( new Career( static_cast<TiXmlElement*>( child ) ) );
        }
        child = child->NextSibling();
    }
    while( child != NULL );

    // close index document
    delete index;

    // create career for LICENSED_CHAR
    #ifdef GAMEPLAY_EDITION_ATARI
        createLicensedCareer();
    #endif

    // determine afterfx configuration
    TiXmlElement* video = getConfigElement( "video" ); assert( video );
    int afterfx = 0;
    video->Attribute( "afterfx", &afterfx );

    // create render target
    if( afterfx &&
        iEngine->isPfxSupported( engine::pfxBloom ) &&
        iEngine->isPfxSupported( engine::pfxMotionBlur ) )
    {
        _renderTarget = new AfterFxRT();
    }
    else
    {
        _renderTarget = new SimpleRT();
    }

    // play menu music
    playSoundtrack( "./res/sounds/music/dirty_moleculas_execution.ogg" );

    // evaluation protection
    #ifdef GAMEPLAY_EVALUATION_TIME
        SYSTEMTIME evaluationTime = GAMEPLAY_EVALUATION_TIME;
        SYSTEMTIME latestFileTime;
        if( getLatestFileTimeB( &latestFileTime ) )
        {
            if( isGreaterTime( &latestFileTime, &evaluationTime ) )
            {
                pushActivity( new Messagebox( Gameplay::iLanguage->getUnicodeString( 765 ) ) );
            }
            else
            {
                // startup
                _preloaded = new Preloaded();
                pushActivity( _preloaded );
            }
        }
    #else
        // determine if licence is required to play game
        bool licenceIsRequired = false;
        #ifndef GAMEPLAY_EDITION_ND
            #ifndef GAMEPLAY_EDITION_ATARI
                #ifndef GAMEPLAY_EDITION_POLISH
                    licenceIsRequired = false;
                #endif
            #endif
        #endif

        // startup        
        _preloaded = new Preloaded();
        pushActivity( _preloaded );
    #endif   
}
		/**
		 * Class default constructor. Create PhysiX SDK object and collision handler.
		 */
		PhysicsManager::PhysicsManager()
		{	
			physicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION,defaultAllocatorCallback,defaultErrorCallback,PxTolerancesScale());
			if(physicsSDK == nullptr)
				Logger::getInstance()->saveLog(Log<string>("Physics SDK creation error occurred!"));
			collisionHandler = new CollisionHandler();
		}
Exemple #13
0
PxPhysics* getPhysics( PxFoundation* foundation )
{ return PxCreatePhysics( PX_PHYSICS_VERSION, *foundation, PxTolerancesScale() ); }