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 ); }
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); } } }
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; } }
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(); }
/** * 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; } }
/** * 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; }
// XBMC tells us we should get ready // to start rendering. This function // is called once when the screensaver // is activated by XBMC. extern "C" void Start() { // SetupGradientBackground( D3DCOLOR_RGBA(255,0,0,255), D3DCOLOR_RGBA(0,0,0,255) ); SetCamera(); return; }
void SetupRenderState() { SetCamera(); SetMaterial(); d3dSetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); d3dSetRenderState( D3DRS_LIGHTING, TRUE ); d3dSetRenderState( D3DRS_ZENABLE, TRUE); //D3DZB_TRUE ); d3dSetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ); d3dSetRenderState( D3DRS_NORMALIZENORMALS, FALSE ); d3dSetRenderState( D3DRS_SPECULARENABLE, g_shininess > 0 ); if(world.isWireframe) d3dSetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); else d3dSetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); if (world.isTextureMode) { d3dSetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); d3dSetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); d3dSetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); d3dSetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); d3dSetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); d3dSetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); d3dSetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_NONE); d3dSetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); d3dSetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); d3dSetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); d3dSetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); g_pd3dDevice->SetTexture( 0, g_Texture ); g_pd3dDevice->SetTexture( 1, NULL ); } }
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(); }
// 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(); } }
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(); }
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(); }
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; }
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); }
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(); }
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); }
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"); }
void OnCameraClear(wxCommandEvent& evt) { SetCamera(sCameraInfo(), false); // Pass event on to next handler evt.Skip(); }
bool InitGlContent() { cam_parent_transform = new tango_gl::Transform(); cam = new tango_gl::Camera(); axis = new tango_gl::Axis(); frustum = new tango_gl::Frustum(); trace_motion = new tango_gl::Trace(); trace_adf = new tango_gl::Trace(); grid = new tango_gl::Grid(); frustum->SetScale(kFrustumScale); // Set the parent-child camera transfromation. cam->SetParent(cam_parent_transform); SetCamera(CameraType::THIRD_PERSON); // Set trace's color to show motion tracking trajectory. trace_motion->SetColor(kTraceMotionColor); // Set trace's color to show motion tracking trajectory. trace_adf->SetColor(kTraceADFColor); grid->SetColor(kGridColor); return true; }
void myinit(int numFontFiles) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.13, 0.17, 0.32, 0.0); glColor3f(1.0, 1.0, 1.0); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glEnable(GL_DEPTH_TEST); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(1.0, 1.0); // ???? SetCamera(); tbInit(GLUT_LEFT_BUTTON); tbAnimate(GL_FALSE); setUpFonts(numFontFiles); // Configure the SimpleLayout simpleLayout.SetLineLength(InitialLineLength); simpleLayout.SetFont(fonts[current_font]); }
/******************************************************************************* 関数名: void DrawGame(void) 引数: なし 戻り値: なし 説明: ゲームの描画関数 *******************************************************************************/ void DrawGame(void) { //カメラの設置 SetCamera(); //ステージの描画処理 DrawStageManager(); DrawMeshDome(); //DrawModel(); DrawParticle(); DrawEnemy(); DrawEnemyBullet(); DrawItemBullet(); if( IsDebugMode()) DrawPlayer(); DrawPlayerBullet(); DrawGun(); DrawShadow(); //DrawBillBoard(); DrawTime(); DrawGunSight(); DrawNumBullet(); DrawNumLife(); DrawClock(); DrawEnemyNum(); }
void myReshape(int w, int h) { glMatrixMode (GL_MODELVIEW); glViewport (0, 0, w, h); glLoadIdentity(); SetCamera(); }
/// <summary> /// カメラ、ライト、フォグ、画質の設定を初期設定に戻します。 /// </summary> /// <returns> /// なし /// </returns> inline void ResetScene() { SetAmbientLight(ColorF(0.1)); SetAmbientLightForward(ColorF(0.1)); SetLight(0, Light::Default()); for (uint32 i = 1; i <= MaxLightIndex; ++i) { SetLight(i, Light::None()); } SetLightForward(0, Light::Default()); for (uint32 i = 1; i <= MaxLightIndexForward; ++i) { SetLightForward(i, Light::None()); } SetFog(Fog::None()); SetFogForward(Fog::None()); SetCamera(Camera()); SetAntiAliasing(AntiAliasing::Default); SetLightBufferQuality(100); }
/** * TurnRight() * 戦車を右に旋回させる。 */ void Tank::TurnRight() { rotBody += turn; PRINTF("rotBody=%.02f\n", rotBody); SetCamera(); }
CPUTCameraControllerOrthographic::CPUTCameraControllerOrthographic() { mCamera = CPUTCamera::Create(CPUT_ORTHOGRAPHIC); SetCamera(mCamera); mCamera->Release(); mZoomRatio = 0.5f; mViewportDim = float2(1.0f, 1.0f); }
/** * TurnLeft() * 戦車を左に旋回させる。 */ void Tank::TurnLeft() { rotBody -= turn; PRINTF("rotBody=%.02f\n", rotBody); SetCamera(); }
/** * Initialize() */ bool Tank::Initialize() { vPos.y = TANK_BODY_H * 0.5f; speed = 1.0f; turn = D3DXToRadian(4.0f); shotInter = 0.0f; rotBody = 0.0f; rotHead = 0.0f; SetCamera(); //// メッシュ準備 // 本体 LPDIRECT3DDEVICE9 pDev = GameMain::GetD3DDevice(); HRESULT hr; hr = D3DXCreateBox(pDev, TANK_BODY_W, TANK_BODY_H, TANK_BODY_D, &pMeshBody, NULL); if (FAILED(hr)) { return false; } // 頭 hr = D3DXCreateBox(pDev, TANK_HEAD_W, TANK_HEAD_H, TANK_HEAD_D, &pMeshHead, NULL); if (FAILED(hr)) { return false; } // 砲塔 hr = D3DXCreateBox(pDev, TANK_GUN_W, TANK_GUN_H, TANK_GUN_D, &pMeshGun, NULL); if (FAILED(hr)) { return false; } //// マテリアル準備 ZeroMemory(&material, sizeof(D3DMATERIAL9)); material.Diffuse.r = material.Ambient.r = 0.0f; material.Diffuse.g = material.Ambient.g = 0.5f; material.Diffuse.b = material.Ambient.b = 0.2f; material.Diffuse.a = material.Ambient.a = 1.0f; return true; }
void ezRemoteEngineProcessViewContext::HandleViewMessage(const ezEditorEngineViewMsg* pMsg) { if (pMsg->GetDynamicRTTI()->IsDerivedFrom<ezActivateRemoteViewMsgToEngine>()) { if (m_hView.IsInvalidated()) { m_hView = ezEditorEngineProcessApp::GetSingleton()->CreateRemoteWindowAndView(&m_Camera); } s_pActiveRemoteViewContext = this; ezView* pView = nullptr; if (ezRenderWorld::TryGetView(m_hView, pView)) { ezEngineProcessDocumentContext* pDocumentContext = GetDocumentContext(); pView->SetWorld(pDocumentContext->GetWorld()); pView->SetCamera(&m_Camera); s_uiActiveViewID = pMsg->m_uiViewID; } } // ignore all messages for views that are currently not activated if (pMsg->m_uiViewID != s_uiActiveViewID) return; if (pMsg->GetDynamicRTTI()->IsDerivedFrom<ezViewRedrawMsgToEngine>()) { const ezViewRedrawMsgToEngine* pMsg2 = static_cast<const ezViewRedrawMsgToEngine*>(pMsg); SetCamera(pMsg2); // skip the on-message redraw, in remote mode it will just render as fast as it can // Redraw(false); #ifdef BUILDSYSTEM_ENABLE_MIXEDREALITY_SUPPORT auto pHoloFramework = ezMixedRealityFramework::GetSingleton(); if (pHoloFramework) { if (pMsg2->m_bUseCameraTransformOnDevice) { ezMat4 m = pMsg2->m_ViewMatrix; m.SetRow(1, -pMsg2->m_ViewMatrix.GetRow(2)); m.SetRow(2, pMsg2->m_ViewMatrix.GetRow(1)); ezTransform tf; tf.SetFromMat4(m); tf.m_vScale.Set(0.5f / (1.0f + tf.m_vPosition.GetLength())); tf.m_vPosition.SetZero(); pHoloFramework->SetAdditionalCameraTransform(tf); } else { pHoloFramework->SetAdditionalCameraTransform(ezTransform::IdentityTransform()); } } #endif } }
void OnCameraSet(wxCommandEvent& evt) { AtlasMessage::qGetView qryView; qryView.Post(); SetCamera(qryView.info, true); // Pass event on to next handler evt.Skip(); }
bool initOpenCV() { HRESULT hr = Setup(); if (FAILED(hr)) return false; hr = SetCamera(); //hr = SetExposureTime(true, 363); if (FAILED(hr)) return false; proc = new ProcessCamera(); return true; }