本文整理汇总了C++中PxVec3函数的典型用法代码示例。如果您正苦于以下问题:C++ PxVec3函数的具体用法?C++ PxVec3怎么用?C++ PxVec3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PxVec3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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";
}
示例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;
}
}
示例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