void TutorialApplication::crearEscenario(void)
{
	Ogre::Light* luzPrincipal = mSceneMgr->createLight();
	luzPrincipal->setType(Ogre::Light::LT_DIRECTIONAL);
	luzPrincipal->setPosition(Ogre::Vector3(0, 100, 0));
	luzPrincipal->setDirection(Ogre::Vector3(0, -1, 0));
	luzPrincipal->setDiffuseColour(Ogre::ColourValue(1, 1, 1));
	luzPrincipal->setSpecularColour(Ogre::ColourValue(1, 1, 1));

	Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
	Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		plane, 254, 127, 10, 10, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);

	Ogre::Entity* groundEntity = mSceneMgr->createEntity("ground");
	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
	groundEntity->setCastShadows(false);
	groundEntity->setMaterialName("Custom/TelaBillar");

	PxPhysics* gPhysics = PhysxOgr::PhysxController::getInstance()->getPhysics();
	PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 1, 0, 0), *gPhysics->createMaterial(0.5f, 0.5f, 0.6f));
	mPhysx->getScene()->addActor(*groundPlane);
	
	crearBorde(Ogre::Vector3(-132, 0, 0), Ogre::Vector3(0.1, 0.1, 1.27));
	crearBorde(Ogre::Vector3(132, 0, 0), Ogre::Vector3(0.1, 0.1, 1.27));
	crearBorde(Ogre::Vector3(0, 0, 68.5), Ogre::Vector3(2.54, 0.1, 0.1));
	crearBorde(Ogre::Vector3(0, 0, -68.5), Ogre::Vector3(2.54, 0.1, 0.1));
}
Esempio n. 2
0
void
PhsXWorld::_addCharacter(float mass, float radius, float height, float stepHeight, std::shared_ptr<nau::scene::IScene> &aScene, std::string name) {
    PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());
    PxCapsuleControllerDesc desc;
    //desc.height = 1.3f;
    //desc.radius = 0.35f;
    desc.height = height;
    desc.radius = radius;
    PxVec3 pos = PxMat44(const_cast<float*> (aScene->getTransform().getMatrix())).getPosition();
    desc.position = PxExtendedVec3(pos.x, pos.y, pos.z);
    desc.material = gPhysics->createMaterial(0.5f, 0.5f, 0.6f);
    desc.userData = aScene.get();
    desc.reportCallback = this;
    desc.climbingMode = PxCapsuleClimbingMode::eCONSTRAINED;
    desc.stepOffset = stepHeight;
    desc.upDirection = PxVec3(0, 1, 0);
    //desc.slopeLimit = cosf(DegToRad(80.0f));
    controller = manager->createController(desc);
}
Esempio n. 3
0
		void InitPhysX() {
		        gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
		        gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, PxTolerancesScale() );
		        if(gPhysicsSDK == NULL) {
		                cerr<<"Error create PhysX."<<endl;
		        }
		        PxSceneDesc sceneDesc(gPhysicsSDK->getTolerancesScale());
		        sceneDesc.gravity               = PxVec3(0.0f, -9.8f, 0.0f);
		        sceneDesc.cpuDispatcher = PxDefaultCpuDispatcherCreate(1);
		        sceneDesc.filterShader  = PxDefaultSimulationFilterShader;
		        gScene = gPhysicsSDK->createScene(sceneDesc);
		        PxMaterial* material = gPhysicsSDK->createMaterial(0.5,0.5,0.5);
		        PxTransform planePos =  PxTransform(PxVec3(0.0f),PxQuat(PxHalfPi, PxVec3(0.0f, 0.0f, 1.0f)));
		        PxRigidStatic* plane =  gPhysicsSDK->createRigidStatic(planePos);
		        plane->createShape(PxPlaneGeometry(), *material);
		        gScene->addActor(*plane);
		        PxTransform             boxPos(PxVec3(0.0f, 10.0f, 0.0f));
		        PxBoxGeometry   boxGeometry(PxVec3(2,2,2));
		        gBox = PxCreateDynamic(*gPhysicsSDK, boxPos, boxGeometry, *material, 1.0f);
		        gScene->addActor(*gBox);
		}
Esempio n. 4
0
void
PhsXWorld::_addRigid(float mass, float friction, float restitution, std::shared_ptr<nau::scene::IScene> &aScene, std::string name, nau::math::vec3 aVec) {

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

    if (mass == 0.0f) {
        PxRigidStatic* staticActor;
        if (name.compare("plane") == 0) {
            staticActor = PxCreatePlane(*gPhysics,
                                        PxPlane(0.0f, 1.0f, 0.0f, 0.0f),
                                        *(gPhysics->createMaterial(friction, friction, restitution))
                                       );

        }
        else {
            /*if (name.compare("box") == 0) {
            	staticActor = PxCreateStatic(*gPhysics,
            		PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))),
            		PxBoxGeometry(1.0f,1.0f,1.0f),
            		*(gPhysics->createMaterial(1.0f, 1.0f, 0.6f))
            	);
            }
            else {*/
            staticActor = gPhysics->createRigidStatic(PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))));
            PxTriangleMeshGeometry triGeom;
            triGeom.triangleMesh = gPhysics->createTriangleMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene));
            staticActor->createShape(triGeom, *(gPhysics->createMaterial(friction, friction, restitution)));
            //}
        }
        staticActor->userData = aScene.get();
        m_pDynamicsWorld->addActor(*staticActor);
    }
    else {
        PxRigidDynamic* dynamic;
        //if (name.compare("ball") == 0) {
        //	dynamic = PxCreateDynamic(*gPhysics,
        //		PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))),
        //		PxSphereGeometry(1),
        //		*(gPhysics->createMaterial(0.5f, 0.5f, 0.6f)),
        //		10.0f
        //	);
        //	//dynamic->setLinearVelocity(PxVec3(0, -50, -100));
        //}
        //else {
        PxTransform trans = PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix())));
        dynamic = gPhysics->createRigidDynamic(trans);
        PxConvexMesh * convexMesh = gPhysics->createConvexMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene, false));
        PxConvexMeshGeometry convGeom(convexMesh);
        //PxConvexMeshGeometry convGeom(convexMesh, PxMeshScale(0.5f));
        //convGeom.convexMesh = gPhysics->createConvexMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene, false));

        //PxShape *shape = dynamic->createShape(convGeom, *(gPhysics->createMaterial(0.5f, 0.5f, 0.6f)), PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE);
        PxShape *shape = dynamic->createShape(convGeom, *(gPhysics->createMaterial(friction, friction, restitution)));
        //shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
        //dynamic->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, false);
        //}
        dynamic->userData = aScene.get();
        //dynamic->setAngularDamping(0.5f);
        //dynamic->setLinearVelocity(velocity);

        m_pDynamicsWorld->addActor(*dynamic);
    }
}