• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PxVec3函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PxVec3

	bool CSPhysXObject_Character::create(CSPhysXWorld* world, IPhysicsObjectData data)
	{
		if (!CSPhysXObject::create(world)) return false;

		#define SKINWIDTH	0.0001f
		
		PxF32	gInitialRadius = data.scale.X;
		PxF32	gInitialHeight = data.scale.Y;

		if (data.node)
		{
			gInitialRadius = data.node->getBoundingBox().getExtent().X / 2 * data.scale.X ;
			gInitialHeight = data.node->getBoundingBox().getExtent().Y / 2 * data.scale.Y ;
		}

		PxCapsuleControllerDesc desc;
		desc.position.x			= data.position.X;
		desc.position.y			= data.position.Y;
		desc.position.z			= data.position.Z;
		desc.radius				= gInitialRadius;
		desc.height				= gInitialHeight;
		desc.upDirection		= PxVec3(0,1,0);
		desc.slopeLimit			= cosf(degToRad(45.0f));
		desc.stepOffset			= 0.02f;
		desc.callback			= &gControllerHitReport;
		desc.userData			= (void*)data.userdata;
		desc.scaleCoeff			= 0.9f;
		desc.volumeGrowth		= 1.2f;
		desc.density			= 10;
		desc.material			= getWorld()->getPhysXManager()->m_DefaultMaterial;
		m_Controller			= world->getControllerManager()->createController(*getWorld()->getPhysXManager()->m_PhysicsSDK, getWorld()->getScene(), desc);
		m_Controller->setUserData((void*)data.userdata);
		m_Controller->getActor()->userData = (void*)data.userdata;
		
		PxShape* shapes[10];
		PxU32 nShapes = m_Controller->getActor()->getShapes(shapes, 10);
		while (nShapes--)
		{
			shapes[nShapes]->setSimulationFilterData(getFilterData(data.objecttype));
		}

		CS_CHECK_NULL(m_Controller, CSLOGTYPE::CSL_WARNING, "CSPhysXObject_Character::create() Controller creaation failed");

		// everything went fine
		return true;
	}
开发者ID:SevenGameMaker,项目名称:CobbleStones,代码行数:46,代码来源:CSPhysXObject.cpp


示例2: rot_quat

void PhysActor_PhysX::Rotate(vec4f quat)
{
	if (impl && impl->physActor)
	{
		PxTransform trans = impl->physActor->getGlobalPose();

		PxQuat rot_quat(quat.w, PxVec3(quat.x, quat.y, quat.z));
		
		rot_quat = rot_quat.getNormalized();

		trans.q *= rot_quat;

		trans.q = trans.q.getNormalized();

		impl->physActor->setGlobalPose(trans);
	}
}
开发者ID:qpHalcy0n,项目名称:Quad2012,代码行数:17,代码来源:PhysActor_PhysX.cpp


示例3: createSquashedCuboidMesh

PxConvexMesh* createSquashedCuboidMesh(const PxF32 baseLength, const PxF32 baseDepth, const PxF32 height1, const PxF32 height2, PxPhysics& physics, PxCooking& cooking)
{
	const PxF32 x=baseLength*0.5f;
	const PxF32 z=baseDepth*0.5f;
	PxVec3 verts[8]=
	{
		PxVec3(-x,-0.5f*height1,-z),
		PxVec3(-x,-0.5f*height1,+z),
		PxVec3(+x,-0.5f*height1,-z),
		PxVec3(+x,-0.5f*height1,+z),
		PxVec3(-x,-0.5f*height1+height2,-z),
		PxVec3(-x,+0.5f*height1,+z),
		PxVec3(+x,-0.5f*height1+height2,-z),
		PxVec3(+x,+0.5f*height1,+z)
	};
	PxU32 numVerts=8;

	return createConvexMesh(verts,numVerts,physics,cooking);
}
开发者ID:LiangYue1981816,项目名称:CrossEngine,代码行数:19,代码来源:SampleVehicle_VehicleCooking.cpp


示例4: PxVec3

PxConvexMesh* Vehicle::createChassisMesh(const PxVec3 dims, PxPhysics& physics, PxCooking& cooking)
{
	const PxF32 x = dims.x*0.5f;
	const PxF32 y = dims.y*0.5f;
	const PxF32 z = dims.z*0.5f;
	PxVec3 verts[8] =
	{
		PxVec3(x, y, -z),
		PxVec3(x, y, z),
		PxVec3(x, -y, z),
		PxVec3(x, -y, -z),
		PxVec3(-x, y, -z),
		PxVec3(-x, y, z),
		PxVec3(-x, -y, z),
		PxVec3(-x, -y, -z)
	};

	return createConvexMesh(verts, 8, physics, cooking);
}
开发者ID:BernieMayer,项目名称:King-of-Buggies,代码行数:19,代码来源:Vehicle.cpp


示例5: up

void PlayerController::MovePlayerController(double _dt)
{
	const PxVec3 up(0, 1, 0);
	bool onGround;
	float movementSpeed = 10.0f;
	float rotationSpeed = 1.0f;
	float minDistance = 0.001f;

	if (m_myHitReport->GetPlayerContactNormal().y > 0.3f)
	{
		m_characterYVelocity = -0.1f;
		onGround = true;
	}
	else
	{
		m_characterYVelocity += -1 * _dt;
		onGround = false;
	}

	m_myHitReport->ClearPlayerContactNormal();
	PxVec3 velocity(0, m_characterYVelocity, 0);

	if (glfwGetKey(m_window, GLFW_KEY_LEFT) == GLFW_PRESS)
	{
		m_characterRotation += glm::radians(5.f);
	}
	if (glfwGetKey(m_window, GLFW_KEY_RIGHT) == GLFW_PRESS)
	{
		m_characterRotation -= glm::radians(5.f);
	}
	if (glfwGetKey(m_window, GLFW_KEY_UP) == GLFW_PRESS)
	{
		velocity.z -= movementSpeed * _dt;
	}
	if (glfwGetKey(m_window, GLFW_KEY_DOWN) == GLFW_PRESS)
	{
		velocity.z += movementSpeed * _dt;
	}

	PxControllerFilters filter;

	PxQuat rotation(m_characterRotation, PxVec3(0, 1, 0));
	//velocity = PxVec3(0, m_characterYVelocity, 0);
	m_controller->move(rotation.rotate(velocity), minDistance, _dt, filter);
}
开发者ID:Neucrotic,项目名称:PhysicsAssessment,代码行数:45,代码来源:PlayerController.cpp


示例6: color

void GameWorld::addPxMoveBall(int num)
{
	Color4f color(50 / 255.0, 225 / 255.0, 50 / 255.0);
	for (int i = 0;i < num;i++) {
		PxMoveBall* newball = new PxMoveBall(color, 5.0, 100.0f);
		Material mtl;
		PerlinImage perlinGreen = createPerlinGreenImage(40, 40, 6, 1.8);
		PerlinTexture(perlinGreen, mtl.kd_texid);
		mtl.ka = Color4f(1, 1, 1, 1);
		mtl.kd = Color4f(1, 1, 1, 1);
		newball->mtl = mtl;
		newball->createPxBall(*gPhysics, PxTransform(PxVec3(rand() % 500 - 250, 100, rand() % 700 - 350)), *gMaterial);
		newball->pxActor->setAngularDamping(0.5);
		gScene->addActor(*(newball->pxActor));
		pxMoveBalls.push_back(newball);
		perlinGreen.clear();
	}
}
开发者ID:abucraft,项目名称:opengl-balls,代码行数:18,代码来源:gameWorld.cpp


示例7: transform

void KinematicController::CreatePhyiscsAgent()
{
	PxTransform transform(PxVec3(m_position.x, m_position.y, m_position.z));
	//transform = PxVec3(0, 0, 0);
	float density = 50;

	float halfHeight = m_height / 2;


	PxCapsuleGeometry capsule(m_radius, m_height);
	m_actor = PxCreateDynamic(*m_physicsObject->m_Physics, transform, capsule, *m_physicsObject->m_PhysicsMaterial, density);



	m_physicsObject->m_PhysicsScene->addActor(*m_actor);
	m_physicsObject->m_boxActors.push_back(m_actor);
	
}
开发者ID:monarchshield,项目名称:PhysicsAssesment,代码行数:18,代码来源:KinematicController.cpp


示例8: PxVec3

PxVec3 Scene::getWindAtPoint(const PxVec3& point)
{
    if( !database::LocationInfo::getRecord( _location->getDatabaseId() )->wind )
    {
        return PxVec3( 0,0,0 );
    }

    float windAmbient   = _location->getWindAmbient();
    float windBlast     = _location->getWindBlast();
    float windAmplitude = ( windBlast - windAmbient ) / 2;

    float windMagnitude = windAmbient + windAmplitude + windAmplitude * blast( _windTime );

    PxVec3 windN = wrap( _location->getWindDirection() );
    windN.normalize();

    return windN * windMagnitude;
}
开发者ID:crucifix35,项目名称:base-pro-edition,代码行数:18,代码来源:scene.cpp


示例9: memcpy

void GLES2Renderer::renderQuad(const void* verts, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material)
{
	PxU32 positionStride = 0, colorStride = 0, texcoordStride = 0, normalStride = 0;
	PxU8* locked_positions = static_cast<PxU8*>(m_quadVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride));
	PxU8* locked_texcoords = static_cast<PxU8*>(m_quadVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, texcoordStride));
	PxU8* locked_colors = static_cast<PxU8*>(m_quadVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_COLOR, colorStride));

	// copy indices
	PxU16* locked_indices = static_cast<PxU16*>(m_quadIndexBuffer->lock());
	memcpy(locked_indices, indices, nbIndices * sizeof(PxU16));
	m_quadIndexBuffer->unlock();

	PxU32 windowWidth, windowHeight;
	getWindowSize(windowWidth, windowHeight);
	PxReal windowWidthHalf = windowWidth / 2.0f,
			windowHeightHalf = windowHeight / 2.0f;

	TextVertex* tv = (TextVertex*)verts;
    PxU32 color;
	for(PxU32 i = 0; i < nbVerts; ++i,
									locked_positions += positionStride,
									locked_colors += colorStride,
									locked_texcoords += texcoordStride,
									tv += 1)
	{
		PxVec3 pos = PxVec3(tv->p.x / windowWidthHalf - 1.0f, 1.0f - tv->p.y / windowHeightHalf, 0.0f);
		memcpy(locked_positions, &(pos), sizeof(tv->p));
        color = tv->color;
        RevertColor(color);

		memcpy(locked_colors, &color, sizeof(tv->color));
		memcpy(locked_texcoords, &(tv->u), sizeof(PxReal));
		memcpy(locked_texcoords + sizeof(PxReal), &(tv->v), sizeof(PxReal));
	}
	m_quadVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR);
	m_quadVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0);
	m_quadVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION);

	m_quadMesh->setVertexBufferRange(0, nbVerts);
	m_quadMesh->setIndexBufferRange(0, nbIndices);
	m_quadMesh->bind();
	m_quadMesh->render(material);
	m_quadMesh->unbind();
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:44,代码来源:GLES2Renderer.cpp


示例10: proj1

	PxGeometry& Camera::getPixelFrustum(FDreal pixelXSize, FDreal pixelYSize) {
		
		if (pixelFrustum.isValid()) {
			return pixelFrustum;
		}

		Vector3 proj1(-pixelXSize / 2, -pixelYSize / 2, 1);
		Vector3 proj2(-pixelXSize / 2, pixelYSize / 2, 1);
		Vector3 proj3(pixelXSize / 2, -pixelYSize / 2, 1);
		Vector3 proj4(pixelXSize / 2, pixelYSize / 2, 1);

		fdmath::Matrix44 projInverse;
		fdmath::gluInvertMatrix44(projection, projInverse);

		FDreal len = -100.0f;
		Vector3 view1 = projInverse.transform(proj1).getNormalized() * len;
		Vector3 view2 = projInverse.transform(proj2).getNormalized() * len;
		Vector3 view3 = projInverse.transform(proj3).getNormalized() * len;
		Vector3 view4 = projInverse.transform(proj4).getNormalized() * len;

		static const PxVec3 convexVerts[] = {PxVec3(0,0,0), view1, 
				view2, view3, view4};

		PhysicsSystem* physics = FreeThread__getWorld().
				getSystem<PhysicsSystem>();

		PxConvexMeshDesc convexDesc;
		convexDesc.points.count     = 5;
		convexDesc.points.stride    = sizeof(PxVec3);
		convexDesc.points.data      = convexVerts;
		convexDesc.flags            = PxConvexFlag::eCOMPUTE_CONVEX;
		convexDesc.vertexLimit      = 256;

		PxDefaultMemoryOutputStream buf;
		if (!physics->cooking->cookConvexMesh(convexDesc, buf)) {
			FD_THROW(GenericException("Unable to cook convex pixel mesh!"));
		}
		PxDefaultMemoryInputData input(buf.getData(), buf.getSize());
		PxConvexMesh* convexMesh = physics->physics->createConvexMesh(input);

		pixelFrustum = PxConvexMeshGeometry(convexMesh);

		return pixelFrustum;
	}
开发者ID:andrewoftoronto,项目名称:FreeDynamics,代码行数:44,代码来源:Camera.cpp


示例11: GetOffsetPosition

void CParticleSystem::SetBufferData() {
	if (m_pParticleSystem)
		g_PhysxManager->GetActiveScene()->removeActor(*m_pParticleSystem);

	if (!m_Emitter.m_useSkeleton) {
		m_pParticleSystem = g_PhysxManager->CreateParticleSystem(m_numParticles);
	}

	m_particles.initialize(m_numParticles);

	VEC3 offset = GetOffsetPosition();

	PxVec3 pos = PxVec3(0, 0, 0);

	for (int i = 0; i < m_numParticles; i++) {
		m_particles.indexBuffer[i] = i;
		m_particles.maxLifeTimeBuffer[i] = *m_Emitter.GetLifeTime() + random(*m_Emitter.GetLifeTimeRandomMin(), *m_Emitter.GetLifeTimeRandomMax()); //max time

		pos = *m_Emitter.GetPosition() + PhysxConversion::Vec3ToPxVec3(offset);
		m_particles.positionBuffer[i] = pos;
		m_particles.velocityBuffer[i] = *m_Emitter.GetVelocity();
		m_particles.negativeVelocityBuffer[i] = -*m_Emitter.GetVelocity();
		m_particles.lifeTimeBuffer[i] = m_particles.maxLifeTimeBuffer[i];
		dbg("Particle %d - max lifetime = %f\n", i, m_particles.lifeTimeBuffer[i]);

		m_particles.positionInitBuffer[i] = pos;
		m_particles.velocityInitBuffer[i] = m_initial_velocity;

		m_particles.colorBuffer[i] = PhysxConversion::PxVec4ToVec4(*m_Emitter.GetColor());
		m_particles.colorOriginBuffer[i] = m_particles.colorBuffer[i];
	}

	m_particles.speed_frame = frames_speed;

	m_particles.numParticles = m_numParticles;

	bool ret = true;

	//m_pParticleValidity = (PxU32*)PX_ALLOC(((m_pParticleSystem->getMaxParticles() + 31) >> 5) << 2, "validParticleBitmap");
	if (!m_Emitter.m_useSkeleton) {
		m_pIndexPool = PxParticleExt::createIndexPool(m_numParticles);
		m_pParticleValidity = std::vector<PxU32>(((m_pParticleSystem->getMaxParticles() + 31) >> 5) << 2).data();
		ret = CreateParticles(m_particles);
	}
开发者ID:DopaminaInTheVein,项目名称:ItLightens,代码行数:44,代码来源:ParticleSystem.cpp


示例12: main

int main(int argc, char** argv)
{
	Viewport window("The People of Earth TestBed ***Demo***", 800, 600/*1920, 1080*/, 0);
	GUIEngine guiEngine("Assets/GUI");
	RenderingEngine renderingEngine(window);
	SceneManager sceneManager(&window);
	PhysicsEngine physicsEngine;
	physicsEngine.getPhysicsWorld()->init(PxVec3(0.0f, 0.0f, 0.0f), 20000.0f);
	AudioEngine audioEngine;

	CoreEngine core(60.0, &window, &renderingEngine, &physicsEngine, &audioEngine, &guiEngine, &sceneManager);

	sceneManager.push(new TestScene, Modality::Exclusive);

	core.start();

	return 0;

}
开发者ID:Team-MegaFox,项目名称:People-of-Earth,代码行数:19,代码来源:Source.cpp


示例13: m_transform

void Physx1::MakeBlocks()
{
	PxTransform m_transform(PxVec3(0, 20, 0));
	PxBoxGeometry box(2, 2, 2);
	float density = 50;
	

	m_dynamicActor = PxCreateDynamic(*m_Physics, m_transform, box, *m_PhysicsMaterial, density);
	m_boxActors.push_back(m_dynamicActor);

	int size = m_boxActors.size();

	m_PhysicsScene->addActor(*m_boxActors[size - 1]);

	m_boxCount++;

	std::cout << "Boxes in Scene: " << m_boxCount << "\n";
	
}
开发者ID:monarchshield,项目名称:Physics,代码行数:19,代码来源:Physx1.cpp


示例14: PROFILE_FUNCTION

//apply the calculated movement
void TCompCharacterController::ApplyPendingMoves(float dt) {
	PROFILE_FUNCTION("apply moves");
	std::string toprint = "apply pending moves ";
	toprint = toprint + name;

	if (name == "pj") {
		int i = 0;
	}

	if (m_toMove != VEC3(0.0f, 0.0f, 0.0f)) {
		PROFILE_FUNCTION(name.c_str());
		assert(isValid(m_toMove));
		PxVec3 moved = PxVec3(m_toMove.x, m_toMove.y, m_toMove.z);
		m_last_speed = m_pActor->getActor()->getLinearVelocity();
		m_flagsCollisions = m_pActor->move(moved, 0.0f, dt, m_filterController);
		//clean acceleration & pendent displacement
		m_toMove = VEC3(0.0f, 0.0f, 0.0f);
		m_accel = m_toMove;
	}
}
开发者ID:DopaminaInTheVein,项目名称:ItLightens,代码行数:21,代码来源:comp_charactercontroller.cpp


示例15: PxVec3

void
Spacetime::setState(matrix<double> stateVector) {
	std::vector<PxQuat> theta;
	for (int i = 0; i < joints.size(); i++) {
		PxQuat q = PxQuat::createIdentity();
		if (i == 0) {
			if (DOF > X) { q *= PxQuat(stateVector((i)*DOF+X,0), PxVec3(1,0,0)); }
			if (DOF > Y) { q *= PxQuat(stateVector((i)*DOF+Y,0), PxVec3(0,1,0)); }
			if (DOF > Z) { q *= PxQuat(stateVector((i)*DOF+Z,0), PxVec3(0,0,1)); }
		} else {
			if (DOF > X) { q *= PxQuat(stateVector((i)*DOF+X,0), PxVec3(1,0,0)) * theta[(i-1)*DOF+X]; }
			if (DOF > Y) { q *= PxQuat(stateVector((i)*DOF+Y,0), PxVec3(0,1,0)) * theta[(i-1)*DOF+Y]; }
			if (DOF > Z) { q *= PxQuat(stateVector((i)*DOF+Z,0), PxVec3(0,0,1)) * theta[(i-1)*DOF+Z]; }
		}
		theta.push_back(q);
	}
	dynamic_actors[0]->setGlobalPose(PxTransform(root, PxQuat::createIdentity()));
	PxVec3 lastJointPos = dynamic_actors[0]->getGlobalPose().p + PxVec3(0,0.5,0);
	PxQuat lastJointRot = dynamic_actors[0]->getGlobalPose().q;
	for (int i = 0; i < joints.size(); i++) {
		PxRigidDynamic *current = dynamic_actors[i+1];
		PxVec3 t = theta[i].rotate(-joint_local_positions[i]);
		PxVec3 gPos = lastJointPos + t;
		current->setGlobalPose(PxTransform(gPos, theta[i]));
		lastJointPos = lastJointPos + 2*t;
	}
	for (int i = 0; i < joints.size(); i++) {
		PxRigidDynamic *current = dynamic_actors[i+1];
		PxVec3 angularVelocity;
		if (DOF > X) { angularVelocity[X] = stateVector(joints.size()*DOF + i*DOF+X,0); }
		else		 { angularVelocity[X] = 0.0; }
		if (DOF > Y) { angularVelocity[Y] = stateVector(joints.size()*DOF + i*DOF+Y,0); }
		else		 { angularVelocity[Y] = 0.0; }
		if (DOF > Z) { angularVelocity[Z] = stateVector(joints.size()*DOF + i*DOF+Z,0); }
		else		 { angularVelocity[Z] = 0.0; }
		current->setAngularVelocity(angularVelocity);
		current->setLinearVelocity(PxVec3(0,0,0));
	}
}
开发者ID:flair2005,项目名称:Spacetime-Optimization-of-Articulated-Character-Motion,代码行数:39,代码来源:SpacetimeState.cpp


示例16: myAllocator

void Physx1::setUpPhysX()
{
	m_myCallback = new myAllocator();
	m_PhysicsFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, *m_myCallback, m_defaultErrorCallback);
	m_Physics = PxCreatePhysics(PX_PHYSICS_VERSION, *m_PhysicsFoundation, PxTolerancesScale());
	PxInitExtensions(*m_Physics);
	
	//Create physics material
	m_PhysicsMaterial = m_Physics->createMaterial(0.5f, 0.5f, .5f);
	PxSceneDesc sceneDesc(m_Physics->getTolerancesScale());
	sceneDesc.gravity = PxVec3(0, -10.0f, 0);
	sceneDesc.filterShader = &physx::PxDefaultSimulationFilterShader;
	sceneDesc.cpuDispatcher = PxDefaultCpuDispatcherCreate(1);
	m_PhysicsScene = m_Physics->createScene(sceneDesc);




	
}
开发者ID:monarchshield,项目名称:Physics,代码行数:20,代码来源:Physx1.cpp


示例17: createWedgeConvexMesh

PxConvexMesh* createWedgeConvexMesh(const PxVec3& halfExtents, PxPhysics& physics, PxCooking& cooking)
{
	PxVec3 verts[6]=
	{
		PxVec3(-halfExtents.x, -halfExtents.y, -halfExtents.z),
		PxVec3(-halfExtents.x, -halfExtents.y, +halfExtents.z),
		PxVec3(-halfExtents.x, +halfExtents.y, -halfExtents.z),
		PxVec3(+halfExtents.x, -halfExtents.y, -halfExtents.z),
		PxVec3(+halfExtents.x, -halfExtents.y, +halfExtents.z),
		PxVec3(+halfExtents.x, +halfExtents.y, -halfExtents.z)
	};	
	PxU32 numVerts=6;

	return createConvexMesh(verts,numVerts,physics,cooking);
}
开发者ID:LiangYue1981816,项目名称:CrossEngine,代码行数:15,代码来源:SampleVehicle_VehicleCooking.cpp


示例18: AddPhyObjects

// add some physics objects into the scene
void AddPhyObjects()
{
	PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 1, 0, 0), *gMaterial);
	gScene->addActor(*groundPlane);

	PxShape* shape = gPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
	PxTransform localTm(PxVec3(-3.0f, 5.0f, 0.f));
	PxRigidDynamic* body = gPhysics->createRigidDynamic(localTm);
	body->attachShape(*shape);
	PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
	gScene->addActor(*body);

	shape->release();

	shape = gPhysics->createShape(PxSphereGeometry(1.0f), *gMaterial);
	PxTransform localTmS(PxVec3(3.0f, 5.0f, 0.f));
	body = gPhysics->createRigidDynamic(localTmS);
	body->attachShape(*shape);
	PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
	gScene->addActor(*body);

	shape->release();

	PxRigidDynamic* dynamic = PxCreateDynamic(*gPhysics, PxTransform(PxVec3(0, 20, 20)), PxSphereGeometry(1), *gMaterial, 10.0f);
	dynamic->setAngularDamping(0.5f);
	dynamic->setLinearVelocity(PxVec3(0, -5, -10));
	gScene->addActor(*dynamic);

	// add capsule into the scene
	shape = gPhysics->createShape(PxCapsuleGeometry(1.0f, 3.0f), *gMaterial);
	PxTransform localTmC(PxVec3(3.0f, 5.0f, -3.f));
	body = gPhysics->createRigidDynamic(localTmC);
	body->attachShape(*shape);
	PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
	gScene->addActor(*body);

	// add a static box as the trigger
	shape = gPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
	PxTransform localTmTrigger(PxVec3(0.0f, 1.0f, -10.f));
	body = gPhysics->createRigidDynamic(localTmTrigger);
	shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
	shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
	body->attachShape(*shape);
	body->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
	gScene->addActor(*body);

	shape->release();
}
开发者ID:hanhonglei,项目名称:Course_GamePhysics,代码行数:49,代码来源:Physics.cpp


示例19: mPrimaryScene

MirrorScene::MirrorScene(physx::PxScene &primaryScene,
	physx::PxScene &mirrorScene,
	NxMirrorScene::MirrorFilter &mirrorFilter,
	physx::PxF32 mirrorStaticDistance,
	physx::PxF32 mirrorDynamicDistance,
	physx::PxF32 mirrorDistanceThreshold) 
	: mPrimaryScene(primaryScene)
	, mMirrorScene(mirrorScene)
	, mMirrorFilter(mirrorFilter)
	, mMirrorStaticDistance(mirrorStaticDistance)
	, mMirrorDynamicDistance(mirrorDynamicDistance)
	, mMirrorDistanceThreshold(mirrorDistanceThreshold*mirrorDistanceThreshold)
	, mTriggerActor(NULL)
	, mTriggerMaterial(NULL)
	, mTriggerShapeStatic(NULL)
	, mTriggerShapeDynamic(NULL)
	, mSimulationEventCallback(NULL)
{
	mLastCameraLocation = PxVec3(1e9,1e9,1e9);
	primaryScene.getPhysics().registerDeletionListener(*this,physx::PxDeletionEventFlag::eMEMORY_RELEASE | physx::PxDeletionEventFlag::eUSER_RELEASE);
}
开发者ID:LiangYue1981816,项目名称:CrossEngine,代码行数:21,代码来源:MirrorScene.cpp


示例20: checkPenetration

	bool ParticleChain::checkPenetration(const Ogre::Vector3 &position, Ogre::Vector3 &closestSurfacePos, Ogre::Vector3 &collisionNormal)
	{
		PxShape *hit = nullptr;
		PxVec3 pxPos = Convert::toPx(position);
		if (mPhysXScene->getPxScene()->overlapAny(PxSphereGeometry(0.05f), PxTransform(pxPos), hit))
		{
			PxVec3 actorCenter = hit->getActor().getWorldBounds().getCenter();
			PxVec3 rayDir = actorCenter - pxPos;
			rayDir.normalize();
			PxVec3 rayOrigin = pxPos - rayDir.multiply(PxVec3(0.2f, 0.2f, 0.2f));
			if (mPhysXScene->getPxScene()->overlapAny(PxSphereGeometry(0.05f), PxTransform(rayOrigin), hit)) return false;
			PxRaycastHit rayHit;
			if (mPhysXScene->getPxScene()->raycastSingle(rayOrigin, rayDir,  0.2f, PxSceneQueryFlag::eIMPACT|PxSceneQueryFlag::eNORMAL|PxSceneQueryFlag::eDISTANCE, rayHit))
			{
				closestSurfacePos = Convert::toOgre(rayHit.impact);
				collisionNormal = Convert::toOgre(rayHit.normal);
				return true;
			}
		}
		return false;
	}
开发者ID:JohannKollmann,项目名称:blackstar-engine,代码行数:21,代码来源:FTLParticleChain.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyArg_ParseTuple函数代码示例发布时间:2022-05-30
下一篇:
C++ Puthex函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap