本文整理汇总了C++中SetCamera函数的典型用法代码示例。如果您正苦于以下问题:C++ SetCamera函数的具体用法?C++ SetCamera怎么用?C++ SetCamera使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetCamera函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
bool idGameEdit::PlayPlayback( void )
{
// Not playing - so instantly exit
if( !g_playPlayback.GetInteger() && !playbackCamera )
{
return( false );
}
if( !playbackCamera )
{
playbackCamera = static_cast<rvCameraPlayback *>( gameLocal.SpawnEntityType( rvCameraPlayback::GetClassType() ) );
SetCamera( playbackCamera );
common->Printf( "Starting playback play\n" );
}
if( g_currentPlayback.IsModified() )
{
// Spawn is a misnomer - it should be init with new data
playbackCamera->Spawn();
g_currentPlayback.ClearModified();
}
if( !g_playPlayback.GetInteger() )
{
playbackCamera->PostEventMS( &EV_Remove, 0 );
playbackCamera = NULL;
SetCamera( NULL );
}
return( true );
}
示例2: Debug_Log
void Scene::_OnStart()
{
GameObject::_OnStart();
if (!IsEditorGameObject())
{
List<Camera*> cameras = GetComponentsInChildren<Camera>();
Debug_Log("Cameras: " << cameras);
if (!cameras.Empty())
{
Camera *cam = cameras.Front();
SetCamera(cam);
Debug_Log("Found camera: " << cam);
}
else // Create default camera
{
Debug_Log("Creating default camera");
GameObject *m_defaultCamera = new GameObject("DefaultCamera");
m_defaultCamera->transform->SetPosition(Vector3(90));
m_defaultCamera->transform->LookAt(Vector3::Zero);
m_defaultCamera->SetParent(this);
Camera *cam = m_defaultCamera->AddComponent<Camera>();
cam->SetFovDegrees(60.0f); cam->SetZNear(0.1f);
cam->SetZFar(99999.0f);
SetCamera(cam);
}
}
}
示例3: CVector3
void CWorldEditor::CreateWorld()
{
auto screenSize = Palleon::CGraphicDevice::GetInstance().GetScreenSize();
{
auto camera = CTouchFreeCamera::Create();
camera->SetPerspectiveProjection(MAIN_CAMERA_FOV, screenSize.x / screenSize.y, MAIN_CAMERA_NEAR_Z, MAIN_CAMERA_FAR_Z, Palleon::HANDEDNESS_RIGHTHANDED);
camera->SetPosition(CVector3(0, 2, 0));
m_mainCamera = camera;
}
{
auto viewport = Palleon::CViewport::Create();
viewport->SetCamera(m_mainCamera);
m_mainViewport = viewport;
}
{
auto lightDir0 = CVector3(1, -1, 0).Normalize();
auto lightDir1 = CVector3(-1, -1, 0).Normalize();
m_mainViewport->SetEffectParameter("ps_ambientLightColor", Palleon::CEffectParameter(CVector4(0, 0, 0, 0)));
m_mainViewport->SetEffectParameter("ps_dirLightDirection0", Palleon::CEffectParameter(lightDir0));
m_mainViewport->SetEffectParameter("ps_dirLightDirection1", Palleon::CEffectParameter(lightDir1));
m_mainViewport->SetEffectParameter("ps_dirLightColor0", Palleon::CEffectParameter(CVector4(1.0f, 1.0f, 1.0f, 0)));
m_mainViewport->SetEffectParameter("ps_dirLightColor1", Palleon::CEffectParameter(CVector4(1.0f, 1.0f, 1.0f, 0)));
}
{
auto viewport = Palleon::CViewport::Create();
viewport->SetCamera(m_mainCamera);
m_overlayViewport = viewport;
}
}
示例4: GameMain
VOID GameMain()
{
if(KEYDOWN(VK_F1)) pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
if(KEYDOWN(VK_F2)) pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
if(KEYDOWN(VK_F5)) pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
if(KEYDOWN(VK_F6)) pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
if(KEYDOWN(VK_F7)) pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
if(KEYDOWN('J'))
{
g_joint_style = (VG::PathCommand)((int)g_joint_style + 1);
if(g_joint_style > VG::LJOINT_ROUND)
g_joint_style = VG::LJOINT_TOFIRST;
Sleep(100);
}
if(KEYDOWN('S'))
{
g_stroke_style = (VG::StrokeStyle)((int)g_stroke_style + 1);
if(g_stroke_style > VG::SS_LINE_GRAD_Y)
g_stroke_style = VG::SS_LINE_GRAD_LENGTH;
Sleep(100);
}
if(KEYDOWN('1')) g_ending_style = VG::LEND_BUTT;
if(KEYDOWN('2')) g_ending_style = VG::LEND_ROUND;
if(KEYDOWN('3')) g_ending_style = VG::LEND_SQUARE;
if(KEYDOWN('W')) g_line_widh += 0.001f;
if(KEYDOWN('Q')) g_line_widh -= 0.001f;
if(KEYDOWN('A'))
{
Position.z += 5.5f;
SetCamera();
}
if(KEYDOWN('Z'))
{
Position.z -= 5.5f;
SetCamera();
}
if(KEYDOWN(VK_UP)) CameraRotation.x += 0.01f;
if(KEYDOWN(VK_DOWN)) CameraRotation.x -= 0.01f;
if(KEYDOWN(VK_LEFT)) CameraRotation.y += 0.01f;
if(KEYDOWN(VK_RIGHT)) CameraRotation.y -= 0.01f;
if(KEYDOWN('9')) g_dist_tolerance -= 0.05f;
if(KEYDOWN('0')) g_dist_tolerance += 0.05f;
if(KEYDOWN('7')) g_dist_tolerance -= 0.001f;
if(KEYDOWN('8')) g_dist_tolerance += 0.001f;
g_dist_tolerance = max(0.0000001f, g_dist_tolerance);
Render();
}
示例5: keyboardDown
/**
* Called while a keyboard key press is detected
* This GLUT functions is not OpenGL specific, but allows interactivity to our programs
* @param key, the keyboard key that made the event
* @param x, not used
* @param y, not used
*/
void keyboardDown(unsigned char key, int x, int y) {
// We simply check the key argument against characters we care about, in this case A and D
switch(key)
{
case 27: // escape key pressed
exit(0);
break;
case 'd': // Toggle depth test
if ( glIsEnabled( GL_DEPTH_TEST ) ) {
glDisable( GL_DEPTH_TEST );
}
else {
glEnable( GL_DEPTH_TEST );
}
glutPostRedisplay();
break;
case 'p': // Toggle default/ortho/persp view
if ( Camera == CAM_DEFAULT ) {
Camera = CAM_ORTHO;
}
else if ( Camera == CAM_ORTHO ) {
Camera = CAM_PERSP;
}
else {
Camera = CAM_DEFAULT;
}
SetCamera();
glutPostRedisplay();
break;
}
}
示例6: setupLight
/**
* Sets the shader uniforms and generic attributes
* @param program, Shader program object to use
*/
int setupLight() {
SetCamera();
//Sphere
int projHandle = glGetUniformLocation(lightProgramID, "projection_matrix");
if (projHandle == -1) {
fprintf(stderr, "Error updating proj matrix\n");
return 1;
}
glUniformMatrix4fv( projHandle, 1, false, glm::value_ptr(projection) );
sphere = new Sphere(1.0f, 16, 16);
createSphereVAO();
// Uniform lighting variables
int lightambientHandle = glGetUniformLocation(lightProgramID, "light_ambient");
int lightdiffuseHandle = glGetUniformLocation(lightProgramID, "light_diffuse");
int lightspecularHandle = glGetUniformLocation(lightProgramID, "light_specular");
if ( lightambientHandle == -1 ||
lightdiffuseHandle == -1 ||
lightspecularHandle == -1) {
fprintf(stderr, "Error: can't find light uniform variables\n");
return 1;
}
float lightambient[3] = { 0.12f, 0.1f, 0.1f }; // ambient light components
float lightdiffuse[3] = { 0.0f, 1.0f, 0.0f }; // diffuse light components
float lightspecular[3] = { 1.0f, 1.0f, 1.0f }; // specular light components
glUniform3fv(lightambientHandle, 1, lightambient);
glUniform3fv(lightdiffuseHandle, 1, lightdiffuse);
glUniform3fv(lightspecularHandle, 1, lightspecular);
//glUseProgram(lightProgramID);
return 0;
}
示例7: main
void main()
{
PSphere Sphere1;
PLightSource Light1,Light2;
Scene = new Environment;
Sphere1 = new Sphere(Vector(0,0,0),4);
Sphere1->Ambient(0.3);
Sphere1->Diffuse(0.2);
Sphere1->Specular(0.7);
Sphere1->Reflection(0.0);
Sphere1->Refraction(0.0);
Sphere1->PhongSize(30);
Sphere1->DefMaterial.Med = Glass;
Sphere1->Color(Red);
Sphere1->Add(new Bumps(7.0));
Light1 = new PointLight(Vector(-10,8,-20),20);
Light2 = new PointLight(Vector(10,8,-20),20);
Scene->Add(Sphere1);
Scene->Add(Light1);
Scene->Add(Light2);
Background = SkyBlue;
InitNoise();
SetCamera(Vector(0,0,-7),Vector(0,0,1),Vector(0,1,0));
RenderScene(1.5,1.0,300,200,"SAMPLE70.TGA");
DoneNoise();
}
示例8: DrawScene
// DrawScene()
void DrawScene ()
{
dFloat timeStep;
// get the time step
timeStep = timer.GetElapsedSeconds();
// updtate the Newton physics world
NewtonUpdate (nWorld, timeStep);
// read the keyboard
Keyboard ();
// move the camera
dVector target (cameraEyepoint + cameraDir);
SetCamera (cameraEyepoint, target);
// render the scene
GraphicManager::Iterator iter (GraphicManager::GetManager());
for (iter.Begin(); iter; iter ++) {
glPushMatrix();
iter.GetNode()->GetInfo()->Render();
glPopMatrix();
}
}
示例9: Render
void Render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
SetCamera();
DrawBall(GL_FALSE);
DrawLifes();
DrawScores();
DrawCubes();
DrawRoom();
projection.Init(ROOM_HALF_LENGTH - 0.01, X, Y, -ROOM_LENGTH*10);
glPushMatrix();
glMultMatrixf((GLfloat*)projection.shadowMat);
DrawBall(GL_TRUE);
glPopMatrix();
DrawReflector();
RoomCollision();
CubesCollision();
glClearColor(0.3, 0.3, 0.3, 0);
glutSwapBuffers();
}
示例10: display
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetCamera();
switch(GetStyle())
{
case FTGL_BITMAP:
case FTGL_PIXMAP:
glRasterPos2i((long)(w_win / 2 + OX), (long)(h_win / 2 + OY));
glTranslatef(w_win / 2 + OX, h_win / 2 + OY, 0.0);
break;
case FTGL_OUTLINE:
case FTGL_POLYGON:
case FTGL_EXTRUDE:
case FTGL_TEXTURE:
glTranslatef(OX, OY, 0);
tbMatrix();
break;
}
glPushMatrix();
do_display();
glPopMatrix();
glutSwapBuffers();
}
示例11: InitGlContent
bool InitGlContent() {
camera_type = CameraType::FIRST_PERSON;
cam = new tango_gl::Camera();
pointcloud = new Pointcloud();
frustum = new tango_gl::Frustum();
axis = new tango_gl::Axis();
grid = new tango_gl::Grid();
cam_parent_transform = new tango_gl::Transform();
frustum->SetScale(kFrustumScale);
// Set the parent-child camera transfromation.
cam->SetParent(cam_parent_transform);
// Put the grid at the resonable height since the motion
// tracking pose always starts at (0, 0, 0).
grid->SetPosition(kHeightOffset);
grid->SetColor(kGridColor);
SetCamera(CameraType::THIRD_PERSON);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
return true;
}
示例12: GetGeometryRadius
void
ViewerRenderer::ZoomAll()
{
float geomRadius = GetGeometryRadius();
float eye[3], target[3], up[3];
GetCamera(eye, target, up);
float oldView[3];
for (int i = 0; i < 3; i++)
oldView[i] = eye[i] - target[i];
Normalize(oldView);
const float* geomCenter = GetGeometryCenter();
target[0] = geomCenter[0];
target[1] = geomCenter[1];
target[2] = geomCenter[2];
float distEyeToTarget = geomRadius / (tan(GetFieldOfViewRadians() / 2.0f));
for (int i = 0; i < 3; i++)
oldView[i] *= distEyeToTarget;
for (int i = 0; i < 3; i++)
eye[i] = oldView[i] + target[i];
SetCamera(eye, target, up);
}
示例13: do_display
void do_display (void)
{
#ifdef STEREO
/* enclose original rendering code in 2-pass loop */
int i;
for (i=0; i<2; i++)
{
/* select left, right, or default back buffer for drawing */
glDrawBuffer(stereo ? ((i==0) ? GL_BACK_LEFT : GL_BACK_RIGHT) : GL_BACK);
/* select left, right, or default central viewpt for camera */
viewpt = (stereo) ? ((i==0) ? +1 : -1) : 0;
#endif
SetCamera();
draw_logo();
glFlush();
#ifdef STEREO
/* render twice for stereo, or only once for mono */
if (!stereo)
break;
}
#endif
glutSwapBuffers();
}
示例14: CDEBUG
void Engine::Render(const std::vector<uint>& list) {
CDEBUG("render");
const Point res = video->GetResolution();
if (!_isMapLoaded) {
return;
}
tiles->UpdateAnimation(GetTime());
if (cameraTarget) {
const Map::Layer* layer = map.GetLayer(cameraTarget->layerIndex);
SetCamera(Point(
cameraTarget->x + cameraTarget->sprite->nHotw / 2 - res.x / 2 + layer->x,
cameraTarget->y + cameraTarget->sprite->nHoth / 2 - res.y / 2 + layer->y));
}
// Note that we do not clear the screen here. This is intentional.
for (uint i = 0; i < list.size(); i++) {
uint j = list[i];
if (j < map.NumLayers()) {
RenderLayer(j);
RenderEntities(j);
}
}
DoHook(_hookRetrace);
}
示例15: main
void main()
{
Box *b = new Box(Vector(0,-2,5),Vector(8,0,3),Vector(-8,0,3),Vector(0,-3,0));
// Sphere *s = new Sphere(Vector(0,0,5),50);
LightSource *Light1 = new PointLight(Vector(7,10,-10),20);
BmpImage *img = new BmpImage("backgnd.bmp");
ColorMap *cmap = new ColorMap(img);
cmap->Scale = 25;
Scene = new Environment;
b->Mapping = new PlaneMap(Vector(0,-1,-1),Vector(1,0,0));
b->Add(cmap);
b->Ambient(0.3);
b->Diffuse(0.8);
b->Specular(0.3);
b->Reflection(0.0);
b->Refraction(0.0);
b->PhongSize(5);
b->DefMaterial.Med = Glass;
b->DefMaterial.Color = 1;
Scene->Add(b);
Scene->Add(Light1);
Background = SkyBlue;
SetCamera(Vector(0),Vector(0,0,1),Vector(0,1,0));
RenderScene(1.6,1.0,320,200,"SAMP0080.TGA");
}