本文整理汇总了C++中PlaneObject::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaneObject::setPosition方法的具体用法?C++ PlaneObject::setPosition怎么用?C++ PlaneObject::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaneObject
的用法示例。
在下文中一共展示了PlaneObject::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToOptiXScene
void OptiXRenderer::convertToOptiXScene(optix::Context context, int width, int height, float film_location) {
// Setup lighting
// TODO For now, we assume just one light
context->setEntryPointCount( 1 );
context->setRayGenerationProgram( 0, mScene->mLights[0]->getOptiXLight(context) );
// Exception program
context->setExceptionProgram( 0, context->createProgramFromPTXFile( "ptx/PhotonTracer.ptx", "exception" ) );
// Miss program
context->setMissProgram( 0, context->createProgramFromPTXFile( "ptx/PhotonTracer.ptx", "miss" ) );
// Geometry group
optix::GeometryGroup geometrygroup = context->createGeometryGroup();
geometrygroup->setChildCount( mScene->mObjects.size() + 1 );
geometrygroup->setAcceleration( context->createAcceleration("Bvh","Bvh") );
// Add objects
for(std::vector<RenderObject*>::size_type i = 0; i != mScene->mObjects.size(); i++) {
optix::GeometryInstance gi = context->createGeometryInstance();
// TODO we only support 1 material type per object
gi->setMaterialCount(1);
gi->setGeometry( mScene->mObjects[i]->getOptiXGeometry(context));
gi->setMaterial(0, mScene->mObjects[i]->getOptiXMaterial(context));
geometrygroup->setChild(i, gi);
}
// Create Camera
//
mCameraMat = new CameraMaterial(width, height, 1);
PlaneObject* plane = new PlaneObject(mCameraMat);
plane->setPosition(0, 0, film_location); //-65
mCameraObject = plane;
// Convert to OptiX
optix::GeometryInstance gi = context->createGeometryInstance();
gi->setMaterialCount(1);
gi->setGeometry( mCameraObject->getOptiXGeometry(context));
mCameraMatOptiX = mCameraObject->getOptiXMaterial(context);
mCameraMatOptiX["width"]->setInt(width);
mCameraMatOptiX["height"]->setInt(height);
gi->setMaterial(0, mCameraMatOptiX);
geometrygroup->setChild(mScene->mObjects.size(), gi);
context["top_object"]->set(geometrygroup);
}
示例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.setPosition(planePos);
return true;
}
return false;
}