本文整理汇总了C++中PlaneObject::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaneObject::getPosition方法的具体用法?C++ PlaneObject::getPosition怎么用?C++ PlaneObject::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaneObject
的用法示例。
在下文中一共展示了PlaneObject::getPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processCamera
/// \param dt Change in time
void StatePlaying::processCamera(float dt)
{
PlaneObject *planeObject = m_objects->getPlaneObject();
Camera * cam = gGame.m_currentCam;
// this should never happen but if it does leave
if (planeObject == NULL || cam == NULL)
return;
// Grab current states
Vector3 cameraPosOld = cam->cameraPos;
Vector3 planePosOld = planeObject->getPosition();
cam->process(dt); // move camera
// Test for camera collision with terrain
const float CameraHeight = 2.0f;
float fTerrainHt = terrain->getHeight(cam->cameraPos.x,cam->cameraPos.z);
if(cam->cameraPos.y - fTerrainHt < CameraHeight)
cam->cameraPos.y = fTerrainHt + CameraHeight;
// location is now above terrain, set it
cam->setAsCamera();
// Tell terrain where the camera is so that it can adjust for LOD
terrain->setCameraPos(cam->cameraPos);
// Set 3D sound parameters based on new camera position and velocity
Vector3 cameraVel = (cam->cameraPos - cameraPosOld) / dt;
gSoundManager.setListenerPosition(cam->cameraPos);
gSoundManager.setListenerVelocity(cameraVel);
gSoundManager.setListenerOrientation(cam->cameraOrient);
}
示例2:
bool Ned3DObjectManager::interactPlaneTerrain(PlaneObject &plane, TerrainObject &terrain)
{
Terrain *terr = terrain.getTerrain();
if(terr == NULL) return false;
//test for plane collision with terrain
Vector3 planePos = plane.getPosition();
EulerAngles planeOrient = plane.getOrientation();
Vector3 disp = planePos - disp;
RotationMatrix planeMatrix;
planeMatrix.setup(plane.getOrientation()); // get plane's orientation
float planeBottom = plane.getBoundingBox().min.y;
float terrainHeight = terr->getHeight(planePos.x,planePos.z);
if(plane.isPlaneAlive() && planeBottom < terrainHeight)
{ //collision
Vector3 viewVector = planeMatrix.objectToInertial(Vector3(0,0,1));
if(viewVector * terr->getNormal(planePos.x,planePos.z) < -0.5f // dot product
|| plane.isCrashing())
{
plane.killPlane();
int partHndl = gParticle.createSystem("planeexplosion");
gParticle.setSystemPos(partHndl, plane.getPosition());
int boomHndl = gSoundManager.requestSoundHandle("Boom.wav");
int boomInst = gSoundManager.requestInstance(boomHndl);
if(boomInst != SoundManager::NOINSTANCE)
{
gSoundManager.setPosition(boomHndl,boomInst,plane.getPosition());
gSoundManager.play(boomHndl,boomInst);
gSoundManager.releaseInstance(boomHndl,boomInst);
}
plane.setSpeed(0.0f);
planePos += 2.0f * viewVector;
planeOrient.pitch = kPi / 4.0f;
planeOrient.bank = kPi / 4.0f;
plane.setOrientation(planeOrient);
}
else planePos.y = terrainHeight + planePos.y - planeBottom;
//plane.setPPosition(planePos);
return true;
}
return false;
}