本文整理汇总了C++中setCamera函数的典型用法代码示例。如果您正苦于以下问题:C++ setCamera函数的具体用法?C++ setCamera怎么用?C++ setCamera使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCamera函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCamera
void RenderPanel::setViewController( ViewController* controller )
{
view_controller_ = controller;
if( view_controller_ )
{
setCamera( view_controller_->getCamera() );
view_controller_->activate();
}
else
{
setCamera( NULL );
}
}
示例2: setCamera
//==============================================================================
//
//------------------------------------------------------------------------------
void Camera::setCamera(CameraBace* moveToCamera,int frame) {
//if(_moveToCamera != nullptr) return;
if(frame == 0) {
setCamera(moveToCamera);
return;
}
_moveToCamera = moveToCamera;
_maxFrame = frame;
_nowFrame = 0;
memcpy(_destCamera,_currentCam,sizeof(CameraBace));
memcpy(_defaultCam,_currentCam,sizeof(CameraBace));
setCamera(_defaultCam);
}
示例3: glClearColor
void Camera::renderCubeMap(VisualizationParameterSet& visParams)
{
// cube map has only to be build if a reflective object is chosen
if(!graphicsManager->doEnvRendering())
return;
// set clear color once
Surface* backgroundSurface = simulation->getBackgroundSurface();
glClearColor(backgroundSurface->color[0], backgroundSurface->color[1],
backgroundSurface->color[2], backgroundSurface->color[3]);
// cube map rendering
for(int generateCubeMap = 6; generateCubeMap > 0; generateCubeMap--)
{
glClear(default_clear);
graphicsManager->setCubeMapPerspective();
setCamera(visParams, generateCubeMap);
graphicsManager->updateLights(true, false, visParams.provideUniforms);
graphicsManager->renderEnvironment(maxRange);
// prepare surface properties
glCallList(graphicsManager->enableStateDL[visParams.surfaceStyle]);
rootNode->draw(visParams);
glCallList(graphicsManager->disableStateDL[visParams.surfaceStyle]);
graphicsManager->revertLightTextureUnits(visParams.provideUniforms);
glFlush();
// save image to cubemap file
graphicsManager->handleCubeMapping(generateCubeMap, simulation->getFilename());
}
}
示例4: keyboard
void keyboard(unsigned char k, int x, int y) {
switch (k) {
case 27: exit(0);
}
setCamera();
}
示例5: a
void Camera::rotateCamera(int i){
float ang = 3.0*i;
AngleAxis<float> a((ang*M_PI)/180.0, Vector3f::UnitY() );
Matrix3f m;
Vector3f v1, v2, v3;
Vector3f eyeOld;
float dist;
eyeOld = eye;
// Define axis of rotation
m = AngleAxisf((0.0*M_PI)/180.0, Vector3f::UnitX())
* AngleAxisf((ang*M_PI)/180.0, Vector3f::UnitY())
* AngleAxisf((0.0*M_PI)/180.0, Vector3f::UnitZ());
// Find vector from eye to aim and use as rotation point around origin
v1 << aim - eye;
dist = v1.norm();
// Rotate point and find vector between the original point and the rotated point
v2 << v1;
v2 << m * v2;
v2 << v2 - v1;
// Apply the difference to the eye
v3 << eye + v2;
v3 << v3 - aim;
v3.normalize();
eye << dist * v3 + aim;
eye(1) = eyeOld(1);
setCamera();
}
示例6: setCamera
void ::CameraContral::riseCameraTo(float h)
{
mHeight = h;
mHeight = (mHeight > 100.0f)? 100.0f: mHeight;
mHeight = (mHeight < 10.0f)? 10.0f: mHeight;
setCamera();
}
示例7: extrinsicPath
bool
CameraSystem::readFromDirectory(const std::string& directory)
{
if (!boost::filesystem::is_directory(directory))
{
return false;
}
// read extrinsic data
boost::filesystem::path extrinsicPath(directory);
extrinsicPath /= "camera_system_extrinsics.txt";
std::vector<std::string> cameraNames;
readFromTextFile(extrinsicPath.string(), cameraNames);
// read intrinsic data
for (size_t i = 0; i < cameraNames.size(); ++i)
{
boost::filesystem::path calibPath(directory);
calibPath /= cameraNames.at(i) + "_camera_calib.yaml";
CameraPtr camera = CameraFactory::instance()->generateCameraFromYamlFile(calibPath.string());
if (!camera)
{
return false;
}
setCamera(i, camera);
}
return true;
}
示例8: maxV
void CameraManager::updateCurrent_(float dt) {
glm::vec3 dx = target_ - current_;
glm::vec3 maxV(getParam("camera.maxVx"),
getParam("camera.maxVy"),
getParam("camera.maxVz"));
// If we're trying to move faster than we're allowed,
// clip our velocity in that direction.
if (fabs(dx.x) > maxV.x * dt) {
dx.x = dx.x < 0 ?
-1 * maxV.x * dt :
maxV.x * dt;
}
if (fabs(dx.y) > maxV.y * dt) {
dx.y = dx.y < 0 ?
-1 * maxV.y * dt :
maxV.y * dt;
}
if (fabs(dx.z) > maxV.z * dt)
{
dx.z = dx.z < 0 ?
-1 * maxV.z * dt :
maxV.z * dt;
}
current_ = current_ + dx;
setCamera(current_);
}
示例9: setCamera
bool BattleScene::init()
{
Layer::init();
currentLayer = this;
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565);
setCamera();
controlCamera();
setCameraMask(2);
createBackground();
enableTouch();
initUILayer();
GameMaster::create();
MessageDispatchCenter::getInstance()->registerMessage(MessageType::BLOOD_MINUS, [](Actor * heroActor)
{
uiLayer->bloodDrop(heroActor);
});
MessageDispatchCenter::getInstance()->registerMessage(MessageType::ANGRY_CHANGE, [](Actor * heroActor)
{
uiLayer->angryChange(heroActor);
});
scheduleUpdate();
return true;
}
示例10: cameraOrbit
/* Function: cameraOrbit
* Description: Rotates the entire camera about a point using the mouse.
* Input: x - X Coordinate of the mouse
* y - Y Coordinate of the mouse
* Output: None
*/
void cameraOrbit(int x, int y)
{
point mouse;
mouse.x = x - mousePos.x;
mouse.y = y - mousePos.y;
Phi += mouse.x * 0.01;
Theta += mouse.y * 0.01;
if (Phi > (2 * PI))
Phi -= 2 * PI;
if (Phi < 0)
Phi += 2 * PI;
if (Theta > (PI / 2 - 0.01)) // dont let the point enter the north pole
Theta = PI / 2 - 0.01;
if (Theta < (-PI / 2 + 0.01))
Theta = -PI / 2 + 0.01;
// Recompute camera position
cameraPos.x = lineOfSight.x + (R * cos(Phi) * cos(Theta));
cameraPos.y = lineOfSight.y + (R * sin(Theta));
cameraPos.z = lineOfSight.z + (-R * sin(Phi) * cos(Theta));
setCamera();
} //end cameraOrbit
示例11: onDisplay
void onDisplay ()
/* pre: glut window needs to be refreshed
post: model is drawn */
{
/* clears requested bits (color and depth) in glut window */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//if(wireframe)glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
// else glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
/* draw entire scene into cleared window */
glPushMatrix();
setCamera();
Display();
glPopMatrix();
/* check for any errors when rendering */
GLenum errorCode = glGetError();
if (errorCode == GL_NO_ERROR)
{
/* double-buffering - swap the back and front buffers */
glFlush();
glutSwapBuffers();
}
else
{
ReportError(errorCode);
}
}
示例12: setCamera
Camera::Camera(const Vector2f &worldMax,
const Vector2f &screenMax)
{
setCamera(Vector2f::ZERO, worldMax,
Vector2f::ZERO, screenMax,
Vector2f::ZERO, worldMax);
}
示例13: handleDisplay
/**
Callback that occurs when glut thinks its time to redraw the window.
*/
void handleDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// update the light position
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
setCamera();
// draw the light source
drawLightSource();
// draw the wall background
drawBackdropGeometry();
// draw scene objects
glColor3f(0.0,0.0,1.0);
drawScene();
// calc and draw shadows
if (shadowsOn && light0On)
{
calculateShadows(floorPlane);
drawShadows();
calculateShadows(wallPlane);
drawShadows();
}
glFlush();
glutSwapBuffers();
}
示例14: glShadeModel
///////////////////////////////////////////////////////////////////////////////
// initialize OpenGL states and scene
///////////////////////////////////////////////////////////////////////////////
void ModelGL::init()
{
glShadeModel(GL_SMOOTH); // shading mathod: GL_SMOOTH or GL_FLAT
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
// enable /disable features
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
//glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
// track material ambient and diffuse from surface color, call it before glEnable(GL_COLOR_MATERIAL)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
//glEnable(GL_COLOR_MATERIAL);
glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); // background color
glClearStencil(0); // clear stencil buffer
glClearDepth(1.0f); // 0 is near, 1 is far
glDepthFunc(GL_LEQUAL);
initLights();
setCamera(0, 0, 8, 0, 0, 0);
listId = createEarthDL();
}
示例15: createRenderable
TexturePtr LinearGradient::createAsTexture(int width, int height)
{
const float w = static_cast<float>(width);
const float h = static_cast<float>(height);
const float sa = std::abs(std::sin(-angle_ / 180.0f * static_cast<float>(M_PI)));
const float ca = std::abs(std::cos(-angle_ / 180.0f * static_cast<float>(M_PI)));
//const float length = std::min(ca < FLT_EPSILON ? FLT_MAX : width / ca, sa < FLT_EPSILON ? FLT_MAX : height / sa);
//const float length = std::min(ca < FLT_EPSILON ? w : 2.0f * ca * w, sa < FLT_EPSILON ? h : 2.0f * sa * h);
WindowPtr wnd = WindowManager::getMainWindow();
CameraPtr cam = std::make_shared<Camera>("ortho_lg", 0, width, 0, height);
auto grad = createRenderable();
grad->setCamera(cam);
grad->setScale(ca < FLT_EPSILON ? w : 2.0f * w / ca, sa < FLT_EPSILON ? h : 2.0f * h / sa);
grad->setPosition(w/2.0f, h/2.0f);
RenderTargetPtr rt = RenderTarget::create(width, height);
rt->getTexture()->setFiltering(-1, Texture::Filtering::LINEAR, Texture::Filtering::LINEAR, Texture::Filtering::POINT);
rt->getTexture()->setAddressModes(-1, Texture::AddressMode::CLAMP, Texture::AddressMode::CLAMP);
rt->setCentre(Blittable::Centre::TOP_LEFT);
rt->setClearColor(Color(0,0,0,0));
{
RenderTarget::RenderScope rs(rt, rect(0, 0, width, height));
grad->preRender(wnd);
wnd->render(grad.get());
}
return rt->getTexture();
}