本文整理汇总了C++中CameraPersp类的典型用法代码示例。如果您正苦于以下问题:C++ CameraPersp类的具体用法?C++ CameraPersp怎么用?C++ CameraPersp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CameraPersp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mLightWorldPosition
InstancedStereoApp::InstancedStereoApp()
: mLightWorldPosition( vec4( 1, 1, 1, 1 ) )
{
CameraPersp host;
host.setEyePoint( vec3( 0, 0, 1 ) );
host.lookAt( vec3( 0 ) );
mRift = hmd::OculusRift::create( hmd::OculusRift::Params().hostCamera( host ).screenPercentage( 1.25f ) );
try {
mShader = gl::GlslProg::create( gl::GlslProg::Format().vertex( loadAsset( "phong.vert" ) ).fragment( loadAsset( "phong.frag" ) ) );
}
catch( const std::exception& e ) {
console() << e.what() << std::endl;
quit();
}
mTeapot = gl::Batch::create( geom::Teapot().subdivisions( 12 ), mShader );
gl::enableVerticalSync( false );
gl::disableAlphaBlending();
gl::enableDepthRead();
gl::enableDepthWrite();
gl::enable( GL_CLIP_DISTANCE0, true );
}
示例2: CameraPersp
void winBodiesApp::setup(){
// cam, lights material
mCam = new CameraPersp(getWindowWidth(), getWindowHeight(), 45.0f);
mCam->lookAt( Vec3f(100, 400, -400), Vec3f(0,0,0) );
mCam->setPerspective( 60.0f, getWindowAspectRatio(), 0.1f, 5000.0f );
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
mLight = new gl::Light(gl::Light::DIRECTIONAL, 0);
mLight->setDirection( Vec3f(0,0.1,0.3));
mLight->setAmbient( Color( 0.2f, 0.2f, 0.2f ) );
mLight->setDiffuse( Color( 1.0f, 1.0f, 1.0f ) );
mLight->update( *mCam );
mLight->enable();
mMaterial1.setSpecular( Color(0.5,0.5,0.5) );
mMaterial1.setDiffuse( Color( 0.33f, 0.24f, 1.0f ) );
mMaterial1.setAmbient( Color( 0.1f, 0.1f, 0.1f ) );
mMaterial1.setShininess( 20.0f );
mMaterial1.apply();
mMaterial2.setSpecular( Color(0,0,0) );
mMaterial2.setDiffuse( Color(1,0,0) );
mMaterial2.setAmbient( Color( 0.4f, 0.0f, 0.0f ) );
mMaterial2.setEmission(Color(1,0,0));
mMaterialG.setSpecular(Color(0,0,0));
mMaterialG.setDiffuse(Color(0,0,0.03));
mMaterialG.setAmbient(Color(0.1,0.1,0.1));
initPhysics();
lastTime = getElapsedSeconds();
}
示例3: Vec2i
void MarionetteZooApp::setupParams()
{
mndl::params::PInterfaceGl::load( "params.xml" );
mParams = mndl::params::PInterfaceGl( "Parameters", Vec2i( 230, 550 ), Vec2i( 50, 50 ) );
mParams.addPersistentSizeAndPosition();
mFps = 0;
mParams.addParam( "Fps", &mFps, "", true );
mParams.addSeparator();
mParams.addText( "Camera" );
mParams.addPersistentParam( "Lock camera (l)", &mCameraLock, false );
mParams.addPersistentParam( "Fov", &mCameraFov, 45.f, "min=20 max=180 step=.1" );
mParams.addPersistentParam( "Eye", &mCameraEyePoint, Vec3f( 0.0f, -20.0f, 0.0f ) );
mParams.addPersistentParam( "Center of Interest", &mCameraCenterOfInterestPoint, Vec3f( 0.0f, 0.0f, 0.1f ) );
mParams.addButton( "Reset camera", [ & ]()
{
mCameraCenterOfInterestPoint = Vec3f( 0.0f, 0.0f, 0.1f );
mCameraFov = 45.f;
mCameraEyePoint = Vec3f( 0.0f, -20.0f, 0.0f );
CameraPersp cam = mMayaCam.getCamera();
cam.setPerspective( mCameraFov, getWindowAspectRatio(), 0.1f, 1000.0f );
cam.setEyePoint( mCameraEyePoint );
cam.setCenterOfInterestPoint( mCameraCenterOfInterestPoint );
mMayaCam.setCurrentCam( cam );
} );
mParams.addSeparator();
mModelTypes = ModelFileManager::getSingleton().getModelTypes();
mParams.addPersistentParam( "Model", mModelTypes, &mModelTypeId, 0 );
if ( mModelTypeId > mModelTypes.size() )
mModelTypeId = 0;
mParams.addButton( "Test model", std::bind( &MarionetteZooApp::testModel, this ) );
}
示例4: draw
void ArcballTestApp::draw()
{
CameraPersp &cam = ( mUsingCameraUi ) ? mDebugCam : mCam;
gl::clear( Color( 0, 0.0f, 0.15f ) );
gl::setMatrices( cam );
// draw the earth
gl::enableDepthRead();
gl::enableDepthWrite();
gl::translate( mEarthSphere.getCenter() );
gl::rotate( mArcball.getQuat() );
mEarthTex->bind();
mEarth->draw();
// draw constraint axis
if( mArcball.isUsingConstraint() ) {
gl::setMatrices( cam );
gl::color( 1, 1, 0 );
gl::translate( mEarthSphere.getCenter() );
gl::rotate( glm::rotation( vec3( 0, 1, 0 ), mArcball.getConstraintAxis() ) );
mConstraintAxis->draw();
}
gl::disableDepthRead();
// draw from vector marker
gl::setMatrices( cam );
gl::color( 0, 1, 0.25f );
gl::translate( mEarthSphere.getCenter() + mArcball.getFromVector() * mEarthSphere.getRadius() );
mMarker->draw();
// draw to vector marker
gl::setMatrices( cam );
gl::color( 1, 0.5f, 0.25f );
gl::translate( mEarthSphere.getCenter() + mArcball.getToVector() * mEarthSphere.getRadius() );
mMarker->draw();
// draw the elliptical axes
gl::setMatricesWindow( getWindowSize() );
gl::color( 1, 0, 0 );
vec2 center, axisA, axisB;
mCam.calcScreenProjection( mEarthSphere, getWindowSize(), ¢er, &axisA, &axisB );
gl::drawLine( center - axisA, center + axisA );
gl::drawLine( center - axisB, center + axisB );
}
示例5: loadImage
void TextureTestApp::setup()
{
// assetフォルダから画像を読み込む
// 幅と高さは2のべき乗でなくてもよい
image = loadImage(loadAsset("imagesFH4XK5GD.jpg"));
// 平行光源を1つ用意
light = std::unique_ptr<gl::Light>(new gl::Light(gl::Light::DIRECTIONAL, 0));
light->setAmbient(Color(0.0, 0.0, 0.0));
light->setDiffuse(Color(1.0, 1.0, 1.0));
light->setDirection(Vec3f(0.0, 0.0, 1.0));
// カメラの準備
camera = CameraPersp(getWindowWidth(), getWindowHeight(),
35.0, 0.5, 1000.0);
camera.lookAt(Vec3f(0.0, 0.0, 700.0),
Vec3f(0.0, 0.0, 0.0));
// テクスチャON
gl::enable(GL_TEXTURE_2D);
// カリングON
gl::enable(GL_CULL_FACE);
// gl::color or 頂点カラーを対象にしてライティングの計算を行う
gl::enable(GL_COLOR_MATERIAL);
// ライティングON
gl::enable(GL_LIGHTING);
// 法線を正規化する
gl::enable(GL_NORMALIZE);
gl::enableDepthRead();
gl::enableDepthWrite();
// ブレンディングゆうこう
gl::enableAlphaBlending(true);
rx = ry = rz = 0.0;
}
示例6: setWindowPos
void cApp::setup(){
setWindowPos( 0, 0 );
setWindowSize( mW*0.5, mH*0.5 );
mExp.setup( mW*mScale, mH*mScale,0, 2999, GL_RGB, mt::getRenderPath() );
mPln.setOctaves(4);
mPln.setSeed(1332);
randSeed( mt::getSeed() );
int count = 0;
for( int i=0; i<100; i++){
StrangeAgent sa;
sa.setRandom();
mSAs.push_back( sa );
for(int j=0; j<sa.points.size(); j++){
mPlnPts.push_back( Vec3f(count*scale,0,0) );
count++;
}
}
total = count;
if( 1 ){
CameraPersp cam;
cam.setNearClip(0.1);
cam.setFarClip(1000000);
cam.setFov(60);
cam.setEyePoint( Vec3f(0,0,-30 ) );
cam.setCenterOfInterestPoint( Vec3f(0,0,0) );
cam.setAspectRatio( (float)mW/mH );
mCamUi.setCurrentCam(cam);
}else{
ortho.setNearClip(0.1);
ortho.setFarClip(1000000);
ortho.setEyePoint( Vec3f(0,0,-7 ) );
ortho.setCenterOfInterestPoint( Vec3f(0,0,0) );
ortho.setAspectRatio( (float)mW/mH );
}
#ifdef RENDER
mExp.startRender();
#endif
}
示例7: setup
void CubeApp::setup()
{
mRenderDescriptor = mtl::RenderPassDescriptor::create();
mCam.lookAt( vec3( 3, 2, 4 ), vec3( 0 ) );
mTexture = mtl::TextureBuffer::create(loadImage(getAssetPath("texture.jpg")),
mtl::TextureBuffer::Format().mipmapLevel(3).flipVertically());
mDepthEnabled = mtl::DepthState::create( mtl::DepthState::Format().depthWriteEnabled() );
mPipeline = mtl::RenderPipelineState::create("batch_vertex", "cube_fragment");
mBatchCube = mtl::Batch::create(geom::Cube(), mPipeline);
}
示例8: updateLayout
void MemExploreApp::updateLayout()
{
int pixelSize = 4;
mFbo = gl::Fbo(getWindowWidth() / pixelSize, getWindowHeight() / pixelSize);
mCamera.setPerspective(60.0f, getWindowAspectRatio(), 0.01f, 100.0f);
mCameraArcball.setCenter(getWindowCenter());
mCameraArcball.setRadius(mIsFullscreen ? 500.0f
: Vec2f(getWindowSize()).length() * 10.0f);
if(mIsFullscreen) hideCursor();
else showCursor();
}
示例9:
void Day57App::update()
{
if (mLowerThresh > mHigherThresh) mHigherThresh = mLowerThresh;
//mParticleController.applyForceToPredators(mZoneRadius, 0.4f, 0.7f);
mParticleController.applyForceToParticles(mZoneRadius, mLowerThresh, mHigherThresh, mAttractStrength, mRepelStrength, mOrientStrength);
if (mCentralGravity) mParticleController.pullToCenter(mCenter);
mParticleController.update(mFlatten);
mEye = vec3(0.0f, 0.0f, mCameraDistance);
mCam.lookAt(mEye, mCenter, mUp);
gl::setMatrices(mCam);
gl::rotate(mSceneRotation);
}
示例10: getWindowAspectRatio
void Day44App::setup()
{
mCam.lookAt(vec3(0,0,5), vec3(0));
mCam.setPerspective(45.f, getWindowAspectRatio(), 1.f, 1000.f);
lightPos = vec3(0.f);
theta = 0.0;
setupGlsl();
mCamUi = CameraUi(&mCam, getWindow());
auto cube = geom::Icosahedron();
auto s = geom::Sphere().subdivisions(128);
auto scal = geom::Scale(0.3,0.3,0.3);
mBatchB = gl::Batch::create(s, mGlsl);
mBatch = gl::Batch::create(cube >> scal, mGlsl);
auto sphere = geom::Sphere();
auto scale = geom::Scale(0.1f,0.1f,0.1f);
auto shader = gl::ShaderDef().color();
auto rotate = geom::Rotate(angleAxis(2.1f, vec3(1.0,0.,0.f)));
mLight = gl::Batch::create(sphere >> scale >> rotate, gl::getStockShader(shader));
gl::enableDepthRead();
gl::enableDepthWrite();
for (int i=0; i < NUM_OBJS; i++)
{
mPositions.push_back(vec3(randFloat(-10.,10),randFloat(-10.,10),randFloat(-10.,10)));
}
setFrameRate(60);
}
示例11: setup
void Corrdinate_spacesApp::setup()
{
vector<Vec3f> positions;
vector<uint32_t> indices;
positions.push_back( Vec3f( -1, 1, 0) ); //0
positions.push_back( Vec3f( -1, -1, 0) ); //1
positions.push_back( Vec3f( 1, -1, 0) ); //2
positions.push_back( Vec3f( 1, 1, 0) ); //3
indices.push_back(1);
indices.push_back(3);
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(3);
// mMesh.appendVertices(positions.data(), positions.size());
// mMesh.appendIndices(indices.data(), indices.size());
gl::VboMesh::Layout layout;
layout.setStaticPositions();
layout.setStaticIndices();
mVboMesh = gl::VboMesh::create( 4, 6, layout, GL_TRIANGLES );
mVboMesh->bufferPositions(positions);
mVboMesh->bufferIndices(indices);
mVboMesh->unbindBuffers();
mCam.setPerspective(60, getWindowAspectRatio(), .1, 10000);
mCam.lookAt( Vec3f(0,0,5), Vec3f(0,0,0), Vec3f::yAxis() );
}
示例12: setupGlsl
void Day61App::setup()
{
mCam.lookAt(vec3(0,15,15), vec3(0));
mCam.setPerspective( 35.0f, 1.0f, 1.f, 1000.0f );
setupGlsl();
mUi = CameraUi(&mCam, getWindow());
setFrameRate(30);
auto scale = geom::Scale(2.,2.,2.);
auto sphere = geom::Sphere().subdivisions(64);
auto rot = geom::Rotate(angleAxis(toRadians(90.f),vec3(1.,0.,0.)));
mBatch = gl::Batch::create(sphere >> geom::Scale(0.7,0.7,0.7), mGlsl);
//CREATE A BATCH WITH A DEFAULT SHADER THAT WILL ACT AS THE DESTINATION COLOUR
auto phong = gl::ShaderDef().lambert().color();
auto shader = gl::getStockShader(phong);
mSolidSphere = gl::Batch::create(sphere, shader);
loadImage();
mPointLights = {
vec3( 3.0f, 0.f, .0f),
vec3( -3.f, 0.f, 3.0f),
vec3( 0.f , 1.f, 2.),
vec3( 0.0f, -3.0f, 0.f)
};
mPos = vec3(0.);
}
示例13: setup
void ParamsBasicApp::setup()
{
ObjLoader loader( (DataSourceRef)loadResource( "Final_sculpture3.obj" ) );
loader.load( &mMesh );
a = 1;
e = 1;
c = 1;
mVBO = gl::VboMesh( mMesh );
mMesh.recalculateNormals();
mCameraDistance = 25;
receiver.setup(3000);
mObjSize = 4;
mEye = Vec3f(-1,0.8f,1);
mLightDirection = Vec3f( -0.54f, -0.27f, -1.07f );
mColor = ColorA( 0.25f, 0.5f, 1.0f, 1.0f );
mCam.setPerspective( 60.0f, getWindowAspectRatio(), 0.1f, 30000.0f );
// setup our default camera, looking down the z-axis
mCam.lookAt( mEye, Vec3f(0,0,0) );
// Setup the parameters
mParams = params::InterfaceGl::create( getWindow(), "App parameters", toPixels( Vec2i( 200, 400 ) ) );
mParams->addParam( "Cube Size", &mObjSize, "min=0.1 max=20.5 step=0.5 keyIncr=z keyDecr=Z" );
mParams->addParam( "Cube Rotation", &mObjOrientation );
//mParams->addParam( "Cube Color", &mColor, "" );
mParams->addSeparator();
mParams->addParam( "Light Direction", &mLightDirection, "" );
mParams->addButton( "Button!", std::bind( &ParamsBasicApp::button, this ) );
mParams->addText( "text", "label=`This is a label without a parameter.`" );
mParams->addParam( "String ", &mString, "" );
mParams->addParam( "Eye Distance", &mCameraDistance, "min=1.0 max=100.0 step=1.0 keyIncr=s keyDecr=w" );
}
示例14: cos
void Day37bApp::update()
{
lightPos.x = 1.f * cos(theta);
lightPos.y = 1.f * sin(theta);
lightPos.z = 1.f * cos(sin(theta)*2.f);
theta += 0.0523;
eyePos = mCam.getEyePoint();
mGlsl->uniform("uLightPos", vec3( gl::getModelView() * lightPos));
cout << lightPos << endl;
}
示例15: update
void kinectPointCloudApp::update()
{
if( mKinect.checkNewDepthFrame() )
mDepthTexture = mKinect.getDepthImage();
// This sample does not use the color data
//if( mKinect.checkNewVideoFrame() )
// mColorTexture = mKinect.getVideoImage();
if( mKinectTilt != mKinect.getTilt() )
mKinect.setTilt( mKinectTilt );
mEye = Vec3f( 0.0f, 0.0f, mCameraDistance );
mCam.lookAt( mEye, mCenter, mUp );
gl::setMatrices( mCam );
}