Ticket #3871: atlas_cinematics_v0.1.patch
File atlas_cinematics_v0.1.patch, 44.1 KB (added by , 8 years ago) |
---|
-
source/graphics/CinemaManager.cpp
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
47 47 48 48 49 49 CCinemaManager::CCinemaManager() 50 : m_DrawPaths(false) 50 : m_DrawPaths(false), m_DrawCamera(false), m_SelectedPathCameraTime(0.0f) 51 51 { 52 52 } 53 53 … … 182 182 DrawBars(); 183 183 return; 184 184 } 185 186 // TODO: replace to iterator for better perfomance 187 if (!selectedPath.empty() && HasPath(selectedPath)) 188 m_CinematicSimulationData.m_Paths[selectedPath].Draw(true); 185 189 186 190 if (!m_DrawPaths) 187 191 return; … … 188 192 189 193 // draw all paths 190 194 for (const std::pair<CStrW, CCinemaPath>& p : m_CinematicSimulationData.m_Paths) 191 p.second.Draw(); 195 if (p.first != selectedPath) 196 p.second.Draw(); 197 198 if (m_DrawCamera) 199 DrawCamera(); 192 200 } 193 201 194 202 void CCinemaManager::DrawBars() const … … 242 250 #endif 243 251 } 244 252 253 void CCinemaManager::DrawCamera() 254 { 255 if (selectedPath.empty() || !HasPath(selectedPath)) 256 return; 257 const CCinemaPath& path = m_CinematicSimulationData.m_Paths[selectedPath]; 258 if (path.GetTargetSpline().GetAllNodes().empty()) 259 return; 260 CCamera dummyCamera(*g_Game->GetView()->GetCamera()); 261 CVector3D targetPosition = path.GetTargetSpline().GetPosition(m_SelectedPathCameraTime); 262 CVector3D cameraPosition = path.GetPosition(m_SelectedPathCameraTime); 263 dummyCamera.LookAt(cameraPosition, targetPosition, CVector3D(0.0f, 1.0f, 0.0f)); 264 265 266 #if CONFIG2_GLES 267 #warning TODO : do something about CCinemaPath on GLES 268 #else 269 glColor4f(0.9f, 0.9f, 0.9f, 1.0f); 270 271 CVector3D corners[4]; 272 dummyCamera.GetCameraPlanePoints(10.0f, corners); 273 CMatrix3D orientation = dummyCamera.GetOrientation(); 274 for (int i = 0; i < 4; ++i) 275 { 276 corners[i] = (orientation.Transform(corners[i]) - cameraPosition) * 5.0f + cameraPosition; 277 } 278 279 for (int i = 0; i < 4; ++i) 280 { 281 glBegin(GL_LINE_STRIP); 282 glVertex3f(cameraPosition.X, cameraPosition.Y, cameraPosition.Z); 283 CVector3D cornerPosition = corners[i]; 284 glVertex3f(cornerPosition.X, cornerPosition.Y, cornerPosition.Z); 285 glEnd(); 286 } 287 288 glBegin(GL_LINE_LOOP); 289 for (int i = 0; i < 4; ++i) 290 { 291 CVector3D cornerPosition = corners[i]; 292 glVertex3f(cornerPosition.X, cornerPosition.Y, cornerPosition.Z); 293 } 294 glEnd(); 295 296 glBegin(GL_LINE_STRIP); 297 glVertex3f(cameraPosition.X, cameraPosition.Y, cameraPosition.Z); 298 glVertex3f(targetPosition.X, targetPosition.Y, targetPosition.Z); 299 glEnd(); 300 301 #endif 302 } 303 245 304 InReaction cinema_manager_handler(const SDL_Event_* ev) 246 305 { 247 306 // put any events that must be processed even if inactive here … … 255 314 256 315 InReaction CCinemaManager::HandleEvent(const SDL_Event_* ev) 257 316 { 317 static float speedMultiplier = 30; 258 318 switch (ev->ev.type) 259 319 { 260 320 case SDL_MOUSEBUTTONDOWN: … … 261 321 case SDL_MOUSEBUTTONUP: 262 322 if (GetEnabled() && !m_CinematicSimulationData.m_Paused) 263 323 return IN_HANDLED; 324 case SDL_KEYUP: 325 { 326 if (selectedPath.empty() || !HasPath(selectedPath)) 327 break; 328 CCinemaPath& path = m_CinematicSimulationData.m_Paths[selectedPath]; 329 switch (ev->ev.key.keysym.sym) 330 { 331 case SDLK_RSHIFT: 332 case SDLK_LSHIFT: 333 { 334 speedMultiplier = 1; 335 break; 336 } 337 case SDLK_b: 338 { 339 CVector3D target = g_Game->GetView()->GetCamera()->GetFocus() + CVector3D(0.0f, 1.0f, 0.0f); 340 TNSpline targetSpline = path.GetTargetSpline(); 341 targetSpline.AddNode( 342 CFixedVector3D(fixed::FromFloat(target.X), fixed::FromFloat(target.Y), fixed::FromFloat(target.Z)), 343 CFixedVector3D(fixed::Zero(), fixed::Zero(), fixed::Zero()), fixed::FromInt(3) 344 ); 345 path = CCinemaPath(*path.GetData(), path, targetSpline); 346 LOGMESSAGERENDER("Target node added at (%0.3f, %0.3f, %0.3f)", target.X, target.Y, target.Z); 347 break; 348 } 349 case SDLK_v: 350 { 351 TNSpline targetSpline = path.GetTargetSpline(); 352 path = CCinemaPath(*path.GetData(), path, targetSpline); 353 if (targetSpline.GetAllNodes().size() > 1) 354 targetSpline.RemoveNode(targetSpline.GetAllNodes().size() - 1); 355 break; 356 } 357 case SDLK_n: 358 { 359 CVector3D node = g_Game->GetView()->GetCamera()->GetFocus() + CVector3D(0.0f, 2.0f, 0.0f); 360 TNSpline positionSpline = path; 361 positionSpline.AddNode( 362 CFixedVector3D(fixed::FromFloat(node.X), fixed::FromFloat(node.Y), fixed::FromFloat(node.Z)), 363 CFixedVector3D(fixed::Zero(), fixed::Zero(), fixed::Zero()), fixed::FromInt(3) 364 ); 365 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 366 LOGMESSAGERENDER("Position node added at (%0.3f, %0.3f, %0.3f)", node.X, node.Y, node.Z); 367 break; 368 } 369 case SDLK_m: 370 { 371 TNSpline positionSpline = path; 372 if (positionSpline.GetAllNodes().size() > 1) 373 positionSpline.RemoveNode(positionSpline.GetAllNodes().size() - 1); 374 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 375 break; 376 } 377 } 378 } 379 case SDL_KEYDOWN: 380 { 381 if (selectedPath.empty() || !HasPath(selectedPath)) 382 break; 383 CCinemaPath& path = m_CinematicSimulationData.m_Paths[selectedPath]; 384 CFixedVector3D zero(fixed::Zero(), fixed::Zero(), fixed::Zero()); 385 386 TNSpline positionSpline = path; 387 int positionCount = path.GetAllNodes().size(); 388 fixed positionDeltaTime = positionCount > 1 ? positionSpline.GetAllNodes()[positionCount - 2].Distance : fixed::FromInt(3); 389 390 TNSpline targetSpline = path.GetTargetSpline(); 391 int targetCount = targetSpline.GetAllNodes().size(); 392 fixed targetDeltaTime = targetCount > 1 ? targetSpline.GetAllNodes()[targetCount - 2].Distance : fixed::FromInt(3); 393 394 // TODO: remove tmp-hacks 395 switch (ev->ev.key.keysym.sym) 396 { 397 case SDLK_RSHIFT: 398 case SDLK_LSHIFT: 399 { 400 speedMultiplier = 20; 401 break; 402 } 403 // POSITION 404 case SDLK_u: 405 { 406 CFixedVector3D node = positionSpline.GetAllNodes().back().Position; 407 node += CFixedVector3D(fixed::Zero(), fixed::FromFloat(0.2f * speedMultiplier), fixed::Zero()); 408 positionSpline.RemoveNode(positionCount - 1); 409 positionSpline.AddNode(node, zero, positionDeltaTime); 410 positionSpline.BuildSpline(); 411 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 412 break; 413 } 414 case SDLK_o: 415 { 416 CFixedVector3D node = positionSpline.GetAllNodes().back().Position; 417 node += CFixedVector3D(fixed::Zero(), fixed::FromFloat(-0.2f * speedMultiplier), fixed::Zero()); 418 positionSpline.RemoveNode(positionCount - 1); 419 positionSpline.AddNode(node, zero, positionDeltaTime); 420 positionSpline.BuildSpline(); 421 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 422 break; 423 } 424 case SDLK_j: 425 { 426 CFixedVector3D node = positionSpline.GetAllNodes().back().Position; 427 node += CFixedVector3D(fixed::FromFloat(0.2f * speedMultiplier), fixed::Zero(), fixed::Zero()); 428 positionSpline.RemoveNode(positionCount - 1); 429 positionSpline.AddNode(node, zero, positionDeltaTime); 430 positionSpline.BuildSpline(); 431 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 432 break; 433 } 434 case SDLK_l: 435 { 436 CFixedVector3D node = positionSpline.GetAllNodes().back().Position; 437 node += CFixedVector3D(fixed::FromFloat(-0.2f * speedMultiplier), fixed::Zero(), fixed::Zero()); 438 positionSpline.RemoveNode(positionCount - 1); 439 positionSpline.AddNode(node, zero, positionDeltaTime); 440 positionSpline.BuildSpline(); 441 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 442 break; 443 } 444 case SDLK_i: 445 { 446 CFixedVector3D node = positionSpline.GetAllNodes().back().Position; 447 node += CFixedVector3D(fixed::Zero(), fixed::Zero(), fixed::FromFloat(0.2f * speedMultiplier)); 448 positionSpline.RemoveNode(positionCount - 1); 449 positionSpline.AddNode(node, zero, positionDeltaTime); 450 positionSpline.BuildSpline(); 451 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 452 break; 453 } 454 case SDLK_k: 455 { 456 CFixedVector3D node = positionSpline.GetAllNodes().back().Position; 457 node += CFixedVector3D(fixed::Zero(), fixed::Zero(), fixed::FromFloat(-0.2f * speedMultiplier)); 458 positionSpline.RemoveNode(positionCount - 1); 459 positionSpline.AddNode(node, zero, positionDeltaTime); 460 positionSpline.BuildSpline(); 461 path = CCinemaPath(*path.GetData(), positionSpline, path.GetTargetSpline()); 462 break; 463 } 464 // TARGET 465 case SDLK_r: 466 { 467 CFixedVector3D node = targetSpline.GetAllNodes().back().Position; 468 node += CFixedVector3D(fixed::Zero(), fixed::FromFloat(0.2f * speedMultiplier), fixed::Zero()); 469 targetSpline.RemoveNode(targetCount - 1); 470 targetSpline.AddNode(node, zero, targetDeltaTime); 471 targetSpline.BuildSpline(); 472 path = CCinemaPath(*path.GetData(), positionSpline, targetSpline); 473 break; 474 } 475 case SDLK_y: 476 { 477 CFixedVector3D node = targetSpline.GetAllNodes().back().Position; 478 node += CFixedVector3D(fixed::Zero(), fixed::FromFloat(-0.2f * speedMultiplier), fixed::Zero()); 479 targetSpline.RemoveNode(targetCount - 1); 480 targetSpline.AddNode(node, zero, targetDeltaTime); 481 targetSpline.BuildSpline(); 482 path = CCinemaPath(*path.GetData(), positionSpline, targetSpline); 483 break; 484 } 485 case SDLK_f: 486 { 487 CFixedVector3D node = targetSpline.GetAllNodes().back().Position; 488 node += CFixedVector3D(fixed::FromFloat(0.2f * speedMultiplier), fixed::Zero(), fixed::Zero()); 489 targetSpline.RemoveNode(targetCount - 1); 490 targetSpline.AddNode(node, zero, targetDeltaTime); 491 targetSpline.BuildSpline(); 492 path = CCinemaPath(*path.GetData(), positionSpline, targetSpline); 493 break; 494 } 495 case SDLK_h: 496 { 497 CFixedVector3D node = targetSpline.GetAllNodes().back().Position; 498 node += CFixedVector3D(fixed::FromFloat(-0.2f * speedMultiplier), fixed::Zero(), fixed::Zero()); 499 targetSpline.RemoveNode(targetCount - 1); 500 targetSpline.AddNode(node, zero, targetDeltaTime); 501 targetSpline.BuildSpline(); 502 path = CCinemaPath(*path.GetData(), positionSpline, targetSpline); 503 break; 504 } 505 case SDLK_t: 506 { 507 CFixedVector3D node = targetSpline.GetAllNodes().back().Position; 508 node += CFixedVector3D(fixed::Zero(), fixed::Zero(), fixed::FromFloat(0.2f * speedMultiplier)); 509 targetSpline.RemoveNode(targetCount - 1); 510 targetSpline.AddNode(node, zero, targetDeltaTime); 511 targetSpline.BuildSpline(); 512 path = CCinemaPath(*path.GetData(), positionSpline, targetSpline); 513 break; 514 } 515 case SDLK_g: 516 { 517 CFixedVector3D node = targetSpline.GetAllNodes().back().Position; 518 node += CFixedVector3D(fixed::Zero(), fixed::Zero(), fixed::FromFloat(-0.2f * speedMultiplier)); 519 targetSpline.RemoveNode(targetCount - 1); 520 targetSpline.AddNode(node, zero, targetDeltaTime); 521 targetSpline.BuildSpline(); 522 path = CCinemaPath(*path.GetData(), positionSpline, targetSpline); 523 break; 524 } 525 } 526 break; 527 } 264 528 default: 265 529 return IN_PASS; 266 530 } 531 return IN_PASS; 267 532 } 268 533 269 534 bool CCinemaManager::GetEnabled() const … … 295 560 { 296 561 m_DrawPaths = drawPath; 297 562 } 563 564 bool CCinemaManager::GetCameraDrawing() const 565 { 566 return m_DrawCamera; 567 } 568 569 void CCinemaManager::SetCameraDrawing(const bool drawCamera) 570 { 571 m_DrawCamera = drawCamera; 572 } 573 574 void CCinemaManager::SelectPath(const CStrW& pathName) 575 { 576 selectedPath = pathName; 577 SetSelectedPathCameraTime(0.0f); 578 } 579 580 float CCinemaManager::GetSelectedPathCameraTime() const 581 { 582 return m_SelectedPathCameraTime; 583 } 584 585 void CCinemaManager::SetSelectedPathCameraTime(const float cameraTime) 586 { 587 m_SelectedPathCameraTime = cameraTime; 588 } 589 No newline at end of file -
source/graphics/CinemaManager.h
105 105 */ 106 106 void Render(); 107 107 void DrawBars() const; 108 void DrawCamera(); 108 109 109 110 /** 110 111 * Get current enable state of the cinema manager … … 130 131 bool GetPathsDrawing() const; 131 132 void SetPathsDrawing(const bool drawPath); 132 133 134 bool GetCameraDrawing() const; 135 void SetCameraDrawing(const bool drawCamera); 136 137 float GetSelectedPathCameraTime() const; 138 void SetSelectedPathCameraTime(const float cameraTime); 139 140 void SelectPath(const CStrW& pathName); 141 133 142 private: 134 bool m_DrawPaths; 143 bool m_DrawPaths, m_DrawCamera; 144 CStrW selectedPath; 145 float m_SelectedPathCameraTime; 135 146 136 147 // Cinematic data is accessed from the simulation 137 148 CinematicSimulationData m_CinematicSimulationData; -
source/graphics/CinemaPath.cpp
86 86 } 87 87 } 88 88 89 void CCinemaPath::Draw( ) const89 void CCinemaPath::Draw(bool selected) const 90 90 { 91 DrawSpline(*this, CVector4D(0.2f, 0.2f, 1.f, 0.5f), 100, true); 92 DrawNodes(*this, CVector4D(0.5f, 1.0f, 0.f, 0.5f)); 91 CVector4D positionSplineColor(0.2f, 0.2f, 1.f, 0.5f); 92 CVector4D positionNodeColor(positionSplineColor); 93 if (selected) 94 { 95 positionSplineColor = CVector4D(0.4f, 0.4f, 1.f, 0.5f); 96 positionNodeColor = CVector4D(0.5f, 1.0f, 0.f, 0.5f); 97 } 93 98 99 DrawSpline(*this, positionSplineColor, 100, true); 100 DrawNodes(*this, positionNodeColor); 101 94 102 if (!m_LookAtTarget) 95 103 return; 96 104 97 DrawSpline(m_TargetSpline, CVector4D(1.0f, 0.2f, 0.2f, 0.5f), 100, true); 98 DrawNodes(m_TargetSpline, CVector4D(1.0f, 0.5f, 0.f, 0.5f)); 105 CVector4D targetSplineColor(1.0f, 0.2f, 0.2f, 0.5f); 106 CVector4D targetNodeColor(targetSplineColor); 107 if (selected) 108 { 109 targetSplineColor = CVector4D(1.0f, 0.4f, 0.4f, 0.5f); 110 targetNodeColor = CVector4D(1.0f, 0.5f, 0.f, 0.5f); 111 } 112 113 DrawSpline(m_TargetSpline, targetSplineColor, 100, true); 114 DrawNodes(m_TargetSpline, targetNodeColor); 99 115 } 100 116 101 117 void CCinemaPath::DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const -
source/graphics/CinemaPath.h
83 83 84 84 public: 85 85 86 void Draw( ) const;86 void Draw(bool selected = false) const; 87 87 void DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const; 88 88 void DrawNodes(const RNSpline& spline, const CVector4D& RGBA) const; 89 89 -
source/simulation2/components/CCmpCinemaManager.cpp
214 214 } 215 215 } 216 216 217 virtual void AddCinemaPath(const CCinemaPath& path) 218 { 219 if (!g_Game || !g_Game->GetView()) 220 return; 221 LOGWARNING("ADDED"); 222 /*g_Game->GetView()->GetCinema()->AddPathToQueue(name); 223 CinematicSimulationData* pCinematicSimulationData = g_Game->GetView()->GetCinema()->GetCinematicSimulationData(); 224 if (pCinematicSimulationData->m_PathQueue.size() == 1) 225 pCinematicSimulationData->m_PathQueue.front().Reset(); 226 pCinematicSimulationData->m_TotalTime += pCinematicSimulationData->m_Paths[name].GetDuration();*/ 227 } 228 217 229 virtual void AddCinemaPathToQueue(const CStrW& name) 218 230 { 219 231 if (!g_Game || !g_Game->GetView()) -
source/simulation2/components/ICmpCinemaManager.cpp
22 22 #include "simulation2/system/InterfaceScripted.h" 23 23 24 24 BEGIN_INTERFACE_WRAPPER(CinemaManager) 25 DEFINE_INTERFACE_METHOD_1("AddCinemaPath", void, ICmpCinemaManager, AddCinemaPath, CCinemaPath) 25 26 DEFINE_INTERFACE_METHOD_1("AddCinemaPathToQueue", void, ICmpCinemaManager, AddCinemaPathToQueue, CStrW) 26 27 DEFINE_INTERFACE_METHOD_0("Play", void, ICmpCinemaManager, Play) 27 28 DEFINE_INTERFACE_METHOD_0("Stop", void, ICmpCinemaManager, Stop) -
source/simulation2/components/ICmpCinemaManager.h
18 18 #ifndef INCLUDED_ICMPCINEMAMANAGER 19 19 #define INCLUDED_ICMPCINEMAMANAGER 20 20 21 #include "graphics/CinemaPath.h" 21 22 #include "simulation2/system/Interface.h" 22 23 23 24 #include "ps/CStr.h" … … 31 32 { 32 33 public: 33 34 // TODO: add path name and description 35 virtual void AddCinemaPath(const CCinemaPath& path) = 0; 34 36 virtual void AddCinemaPathToQueue(const CStrW& name) = 0; 35 37 36 38 virtual void Play() = 0; -
source/simulation2/scripting/EngineScriptConversions.cpp
20 20 #include "scriptinterface/ScriptInterface.h" 21 21 #include "scriptinterface/ScriptExtraHeaders.h" // for typed arrays 22 22 23 #include "graphics/CinemaPath.h" 23 24 #include "maths/Fixed.h" 24 25 #include "maths/FixedVector2D.h" 25 26 #include "maths/FixedVector3D.h" … … 317 318 } 318 319 ret.setObject(*obj); 319 320 } 321 322 //////////////////////////////////////////////////////////////// 323 // Cinematics types: 324 325 template<> bool ScriptInterface::FromJSVal<CCinemaPath>(JSContext* cx, JS::HandleValue v, CCinemaPath& out) 326 { 327 JSAutoRequest rq(cx); 328 if (!v.isObject()) 329 FAIL("Argument must be an object"); 330 331 /*JS::RootedObject obj(cx, &v.toObject()); 332 JS::RootedValue templateName(cx); 333 JS::RootedValue id(cx); 334 JS::RootedValue player(cx); 335 JS::RootedValue position(cx); 336 JS::RootedValue rotation(cx); 337 338 // TODO: Report type errors 339 if (!JS_GetProperty(cx, obj, "player", &player) || !FromJSVal(cx, player, out.playerID)) 340 FAIL("Failed to read Entity.player property"); 341 if (!JS_GetProperty(cx, obj, "templateName", &templateName) || !FromJSVal(cx, templateName, out.templateName)) 342 FAIL("Failed to read Entity.templateName property"); 343 if (!JS_GetProperty(cx, obj, "id", &id) || !FromJSVal(cx, id, out.entityID)) 344 FAIL("Failed to read Entity.id property"); 345 if (!JS_GetProperty(cx, obj, "position", &position) || !FromJSVal(cx, position, out.position)) 346 FAIL("Failed to read Entity.position property"); 347 if (!JS_GetProperty(cx, obj, "rotation", &rotation) || !FromJSVal(cx, rotation, out.rotation)) 348 FAIL("Failed to read Entity.rotation property");*/ 349 350 return true; 351 } -
source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp
26 26 27 27 #include "ScenarioEditor.h" 28 28 29 #include "Sections/Cinema/Cinema.h" 29 30 #include "Sections/Environment/Environment.h" 30 31 #include "Sections/Map/Map.h" 31 32 #include "Sections/Object/Object.h" … … 290 291 ADD_SIDEBAR(TerrainSidebar, _T("terrain.png"), _("Terrain")); 291 292 ADD_SIDEBAR(ObjectSidebar, _T("object.png"), _("Object")); 292 293 ADD_SIDEBAR(EnvironmentSidebar, _T("environment.png"), _("Environment")); 294 ADD_SIDEBAR(CinemaSidebar, _T("cinematic.png"), _("Cinema")); 293 295 294 296 #undef ADD_SIDEBAR 295 297 -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp
1 /* Copyright (C) 2016 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "Cinema.h" 21 22 #include "GameInterface/Messages.h" 23 #include "ScenarioEditor/ScenarioEditor.h" 24 #include "General/Observable.h" 25 #include "CustomControls/ColorDialog/ColorDialog.h" 26 27 using AtlasMessage::Shareable; 28 29 enum { 30 ID_PathsDrawing, 31 ID_CameraDrawing, 32 ID_PathsList, 33 ID_CenterOnPath, 34 ID_AddPath, 35 ID_DeletePath, 36 ID_InfoPathName, 37 ID_CameraTime 38 }; 39 40 // Helper function for adding tooltips 41 static wxWindow* Tooltipped(wxWindow* window, const wxString& tip) 42 { 43 window->SetToolTip(tip); 44 return window; 45 } 46 47 CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer) 48 : Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer) 49 { 50 wxSizer* scrollSizer = new wxBoxSizer(wxVERTICAL); 51 scrolledWindow = new wxScrolledWindow(this); 52 scrolledWindow->SetScrollRate(10, 10); 53 scrolledWindow->SetSizer(scrollSizer); 54 m_MainSizer->Add(scrolledWindow, wxSizerFlags().Proportion(1).Expand()); 55 56 wxSizer* commonSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Common settings")); 57 scrollSizer->Add(commonSizer, wxSizerFlags().Expand()); 58 59 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); 60 gridSizer->AddGrowableCol(1); 61 62 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Draw all paths")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 63 gridSizer->Add(Tooltipped(m_DrawPath = new wxCheckBox(scrolledWindow, ID_PathsDrawing, wxEmptyString), _("Draw all paths"))); 64 65 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Draw camera")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 66 gridSizer->Add(Tooltipped(m_DrawCamera = new wxCheckBox(scrolledWindow, ID_CameraDrawing, wxEmptyString), _("Draw camera at the current path"))); 67 commonSizer->Add(gridSizer, wxSizerFlags().Expand()); 68 69 // Paths list panel 70 wxSizer* pathsSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Paths")); 71 scrollSizer->Add(pathsSizer, wxSizerFlags().Proportion(1).Expand()); 72 73 pathsSizer->Add(m_PathList = new wxListBox(scrolledWindow, ID_PathsList, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT), wxSizerFlags().Proportion(1).Expand()); 74 scrollSizer->AddSpacer(3); 75 pathsSizer->Add(Tooltipped(new wxButton(scrolledWindow, ID_CenterOnPath, _("Center")), _T("Center camera on selected path")), wxSizerFlags().Expand()); 76 pathsSizer->Add(Tooltipped(new wxButton(scrolledWindow, ID_DeletePath, _("Delete")), _T("Delete selected path")), wxSizerFlags().Expand()); 77 78 pathsSizer->Add(m_PathName = new wxTextCtrl(scrolledWindow, wxID_ANY), wxSizerFlags().Expand()); 79 pathsSizer->Add(new wxButton(scrolledWindow, ID_AddPath, _("Add")), wxSizerFlags().Expand()); 80 81 // Path info panel 82 m_PathSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Path")); 83 scrollSizer->Add(m_PathSizer, wxSizerFlags().Expand()); 84 85 gridSizer = new wxFlexGridSizer(2, 5, 5); 86 gridSizer->AddGrowableCol(1); 87 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Name")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 88 gridSizer->Add(Tooltipped(m_InfoPathName = new wxStaticText(scrolledWindow, ID_InfoPathName, _("")), _("Name of the selected path"))); 89 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Camera time")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 90 gridSizer->Add(Tooltipped(m_CameraTime = new wxSlider(scrolledWindow, ID_CameraTime, 0, 0, 500), _("Camera time position of the selected path"))); 91 m_PathSizer->Add(gridSizer, wxSizerFlags().Expand()); 92 } 93 94 void CinemaSidebar::ReloadPathList() 95 { 96 m_InfoPathName->SetLabelText(_("")); 97 98 int index = m_PathList->GetSelection(); 99 wxString pathName; 100 if (index >= 0) 101 pathName = m_PathList->GetString(index); 102 103 AtlasMessage::qGetCinemaPaths query_paths; 104 query_paths.Post(); 105 106 m_PathList->Clear(); 107 for (auto path : *query_paths.paths) 108 m_PathList->Append(*path.name); 109 110 m_InfoPathName->SetLabelText(_("")); 111 if (index < 0 || pathName.empty()) 112 return; 113 114 for (size_t i = 0; i < m_PathList->GetCount(); ++i) 115 if (m_PathList->GetString(i) == pathName) 116 { 117 m_PathList->SetSelection(i); 118 m_InfoPathName->SetLabelText(pathName); 119 } 120 } 121 122 void CinemaSidebar::OnFirstDisplay() 123 { 124 m_DrawPath->SetValue(false); 125 m_DrawCamera->SetValue(false); 126 127 ReloadPathList(); 128 } 129 130 131 void CinemaSidebar::OnMapReload() 132 { 133 m_DrawPath->SetValue(false); 134 m_DrawCamera->SetValue(false); 135 136 ReloadPathList(); 137 } 138 139 void CinemaSidebar::OnTogglePathsDrawing(wxCommandEvent& evt) 140 { 141 POST_COMMAND(SetCinemaPathsDrawing, (evt.IsChecked())); 142 } 143 144 void CinemaSidebar::OnToggleCameraDrawing(wxCommandEvent& evt) 145 { 146 POST_COMMAND(SetCinemaCameraDrawing, (evt.IsChecked())); 147 } 148 149 void CinemaSidebar::OnCenterOnPath(wxCommandEvent&) 150 { 151 int index = m_PathList->GetSelection(); 152 if (index < 0) 153 return; 154 wxString pathName = m_PathList->GetString(index); 155 POST_COMMAND(SetCameraCenterOnCinemaPath, (pathName.ToStdWstring())); 156 } 157 158 void CinemaSidebar::OnAddPath(wxCommandEvent&) 159 { 160 if (m_PathName->GetValue().empty()) 161 return; 162 POST_COMMAND(AddCinemaPath, (m_PathName->GetValue().ToStdWstring())); 163 m_PathName->Clear(); 164 165 ReloadPathList(); 166 } 167 168 void CinemaSidebar::OnDeletePath(wxCommandEvent&) 169 { 170 int index = m_PathList->GetSelection(); 171 if (index < 0) 172 return; 173 wxString pathName = m_PathList->GetString(index); 174 if (pathName.empty()) 175 return; 176 POST_COMMAND(DeleteCinemaPath, (pathName.ToStdWstring())); 177 178 ReloadPathList(); 179 } 180 181 void CinemaSidebar::OnSelectPath(wxCommandEvent&) 182 { 183 m_InfoPathName->SetLabelText(_("")); 184 int index = m_PathList->GetSelection(); 185 if (index < 0) 186 return; 187 wxString pathName = m_PathList->GetString(index); 188 if (pathName.empty()) 189 return; 190 m_InfoPathName->SetLabelText(pathName); 191 m_CameraTime->SetValue(0); 192 POST_COMMAND(SelectCinemaPath, (pathName.ToStdWstring())); 193 } 194 195 void CinemaSidebar::OnChangeCameraTime(wxCommandEvent&) 196 { 197 m_InfoPathName->SetLabelText(_("")); 198 int index = m_PathList->GetSelection(); 199 if (index < 0) 200 return; 201 wxString pathName = m_PathList->GetString(index); 202 if (pathName.empty()) 203 return; 204 POST_COMMAND(SetCinemaCameraTime, (((float)m_CameraTime->GetValue()) / 500.0f)); 205 } 206 207 208 BEGIN_EVENT_TABLE(CinemaSidebar, Sidebar) 209 EVT_CHECKBOX(ID_PathsDrawing, CinemaSidebar::OnTogglePathsDrawing) 210 EVT_CHECKBOX(ID_CameraDrawing, CinemaSidebar::OnToggleCameraDrawing) 211 EVT_BUTTON(ID_CenterOnPath, CinemaSidebar::OnCenterOnPath) 212 EVT_BUTTON(ID_AddPath, CinemaSidebar::OnAddPath) 213 EVT_BUTTON(ID_DeletePath, CinemaSidebar::OnDeletePath) 214 EVT_LISTBOX(ID_PathsList, CinemaSidebar::OnSelectPath) 215 EVT_LISTBOX_DCLICK(ID_PathsList, CinemaSidebar::OnCenterOnPath) 216 EVT_SLIDER(ID_CameraTime, CinemaSidebar::OnChangeCameraTime) 217 END_EVENT_TABLE(); 218 -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.h
1 /* Copyright (C) 2016 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "../Common/Sidebar.h" 19 20 #include "General/Observable.h" 21 22 23 class CinemaSidebar : public Sidebar 24 { 25 public: 26 CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer); 27 28 virtual void OnMapReload(); 29 virtual void OnTogglePathsDrawing(wxCommandEvent& evt); 30 virtual void OnToggleCameraDrawing(wxCommandEvent& evt); 31 virtual void OnCenterOnPath(wxCommandEvent& evt); 32 virtual void OnAddPath(wxCommandEvent& evt); 33 virtual void OnDeletePath(wxCommandEvent& evt); 34 virtual void OnSelectPath(wxCommandEvent& evt); 35 virtual void OnChangeCameraTime(wxCommandEvent& evt); 36 37 void ReloadPathList(); 38 39 protected: 40 virtual void OnFirstDisplay(); 41 42 private: 43 wxScrolledWindow* scrolledWindow; 44 wxCheckBox* m_DrawPath; 45 wxCheckBox* m_DrawCamera; 46 wxListBox* m_PathList; 47 wxSizer* m_PathSizer; 48 wxTextCtrl* m_PathName; 49 wxStaticText* m_InfoPathName; 50 wxSlider* m_CameraTime; 51 52 DECLARE_EVENT_TABLE(); 53 }; -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.cpp
1 /* Copyright (C) 2016 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "Cinema.h" 21 22 #include "GameInterface/Messages.h" 23 #include "ScenarioEditor/ScenarioEditor.h" 24 #include "General/Observable.h" 25 #include "CustomControls/ColorDialog/ColorDialog.h" 26 27 using AtlasMessage::Shareable; 28 29 enum { 30 ID_PathsDrawing, 31 ID_CameraDrawing, 32 ID_PathsList, 33 ID_CenterOnPath, 34 ID_AddPath, 35 ID_DeletePath, 36 ID_InfoPathName, 37 ID_CameraTime 38 }; 39 40 // Helper function for adding tooltips 41 static wxWindow* Tooltipped(wxWindow* window, const wxString& tip) 42 { 43 window->SetToolTip(tip); 44 return window; 45 } 46 47 CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer) 48 : Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer) 49 { 50 wxSizer* scrollSizer = new wxBoxSizer(wxVERTICAL); 51 scrolledWindow = new wxScrolledWindow(this); 52 scrolledWindow->SetScrollRate(10, 10); 53 scrolledWindow->SetSizer(scrollSizer); 54 m_MainSizer->Add(scrolledWindow, wxSizerFlags().Proportion(1).Expand()); 55 56 wxSizer* commonSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Common settings")); 57 scrollSizer->Add(commonSizer, wxSizerFlags().Expand()); 58 59 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); 60 gridSizer->AddGrowableCol(1); 61 62 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Draw all paths")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 63 gridSizer->Add(Tooltipped(m_DrawPath = new wxCheckBox(scrolledWindow, ID_PathsDrawing, wxEmptyString), _("Draw all paths"))); 64 65 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Draw camera")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 66 gridSizer->Add(Tooltipped(m_DrawCamera = new wxCheckBox(scrolledWindow, ID_CameraDrawing, wxEmptyString), _("Draw camera at the current path"))); 67 commonSizer->Add(gridSizer, wxSizerFlags().Expand()); 68 69 // Paths list panel 70 wxSizer* pathsSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Paths")); 71 scrollSizer->Add(pathsSizer, wxSizerFlags().Proportion(1).Expand()); 72 73 pathsSizer->Add(m_PathList = new wxListBox(scrolledWindow, ID_PathsList, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT), wxSizerFlags().Proportion(1).Expand()); 74 scrollSizer->AddSpacer(3); 75 pathsSizer->Add(Tooltipped(new wxButton(scrolledWindow, ID_CenterOnPath, _("Center")), _T("Center camera on selected path")), wxSizerFlags().Expand()); 76 pathsSizer->Add(Tooltipped(new wxButton(scrolledWindow, ID_DeletePath, _("Delete")), _T("Delete selected path")), wxSizerFlags().Expand()); 77 78 pathsSizer->Add(m_PathName = new wxTextCtrl(scrolledWindow, wxID_ANY), wxSizerFlags().Expand()); 79 pathsSizer->Add(new wxButton(scrolledWindow, ID_AddPath, _("Add")), wxSizerFlags().Expand()); 80 81 // Path info panel 82 m_PathSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Path")); 83 scrollSizer->Add(m_PathSizer, wxSizerFlags().Expand()); 84 85 gridSizer = new wxFlexGridSizer(2, 5, 5); 86 gridSizer->AddGrowableCol(1); 87 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Name")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 88 gridSizer->Add(Tooltipped(m_InfoPathName = new wxStaticText(scrolledWindow, ID_InfoPathName, _("")), _("Name of the selected path"))); 89 gridSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Camera time")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 90 gridSizer->Add(Tooltipped(m_CameraTime = new wxSlider(scrolledWindow, ID_CameraTime, 0, 0, 500), _("Camera time position of the selected path"))); 91 m_PathSizer->Add(gridSizer, wxSizerFlags().Expand()); 92 } 93 94 void CinemaSidebar::ReloadPathList() 95 { 96 m_InfoPathName->SetLabelText(_("")); 97 98 int index = m_PathList->GetSelection(); 99 wxString pathName; 100 if (index >= 0) 101 pathName = m_PathList->GetString(index); 102 103 AtlasMessage::qGetCinemaPaths query_paths; 104 query_paths.Post(); 105 106 m_PathList->Clear(); 107 for (auto path : *query_paths.paths) 108 m_PathList->Append(*path.name); 109 110 m_InfoPathName->SetLabelText(_("")); 111 if (index < 0 || pathName.empty()) 112 return; 113 114 for (size_t i = 0; i < m_PathList->GetCount(); ++i) 115 if (m_PathList->GetString(i) == pathName) 116 { 117 m_PathList->SetSelection(i); 118 m_InfoPathName->SetLabelText(pathName); 119 } 120 } 121 122 void CinemaSidebar::OnFirstDisplay() 123 { 124 m_DrawPath->SetValue(false); 125 m_DrawCamera->SetValue(false); 126 127 ReloadPathList(); 128 } 129 130 131 void CinemaSidebar::OnMapReload() 132 { 133 m_DrawPath->SetValue(false); 134 m_DrawCamera->SetValue(false); 135 136 ReloadPathList(); 137 } 138 139 void CinemaSidebar::OnTogglePathsDrawing(wxCommandEvent& evt) 140 { 141 POST_COMMAND(SetCinemaPathsDrawing, (evt.IsChecked())); 142 } 143 144 void CinemaSidebar::OnToggleCameraDrawing(wxCommandEvent& evt) 145 { 146 POST_COMMAND(SetCinemaCameraDrawing, (evt.IsChecked())); 147 } 148 149 void CinemaSidebar::OnCenterOnPath(wxCommandEvent&) 150 { 151 int index = m_PathList->GetSelection(); 152 if (index < 0) 153 return; 154 wxString pathName = m_PathList->GetString(index); 155 POST_COMMAND(SetCameraCenterOnCinemaPath, (pathName.ToStdWstring())); 156 } 157 158 void CinemaSidebar::OnAddPath(wxCommandEvent&) 159 { 160 if (m_PathName->GetValue().empty()) 161 return; 162 POST_COMMAND(AddCinemaPath, (m_PathName->GetValue().ToStdWstring())); 163 m_PathName->Clear(); 164 165 ReloadPathList(); 166 } 167 168 void CinemaSidebar::OnDeletePath(wxCommandEvent&) 169 { 170 int index = m_PathList->GetSelection(); 171 if (index < 0) 172 return; 173 wxString pathName = m_PathList->GetString(index); 174 if (pathName.empty()) 175 return; 176 POST_COMMAND(DeleteCinemaPath, (pathName.ToStdWstring())); 177 178 ReloadPathList(); 179 } 180 181 void CinemaSidebar::OnSelectPath(wxCommandEvent&) 182 { 183 m_InfoPathName->SetLabelText(_("")); 184 int index = m_PathList->GetSelection(); 185 if (index < 0) 186 return; 187 wxString pathName = m_PathList->GetString(index); 188 if (pathName.empty()) 189 return; 190 m_InfoPathName->SetLabelText(pathName); 191 m_CameraTime->SetValue(0); 192 POST_COMMAND(SelectCinemaPath, (pathName.ToStdWstring())); 193 } 194 195 void CinemaSidebar::OnChangeCameraTime(wxCommandEvent&) 196 { 197 m_InfoPathName->SetLabelText(_("")); 198 int index = m_PathList->GetSelection(); 199 if (index < 0) 200 return; 201 wxString pathName = m_PathList->GetString(index); 202 if (pathName.empty()) 203 return; 204 POST_COMMAND(SetCinemaCameraTime, (((float)m_CameraTime->GetValue()) / 500.0f)); 205 } 206 207 208 BEGIN_EVENT_TABLE(CinemaSidebar, Sidebar) 209 EVT_CHECKBOX(ID_PathsDrawing, CinemaSidebar::OnTogglePathsDrawing) 210 EVT_CHECKBOX(ID_CameraDrawing, CinemaSidebar::OnToggleCameraDrawing) 211 EVT_BUTTON(ID_CenterOnPath, CinemaSidebar::OnCenterOnPath) 212 EVT_BUTTON(ID_AddPath, CinemaSidebar::OnAddPath) 213 EVT_BUTTON(ID_DeletePath, CinemaSidebar::OnDeletePath) 214 EVT_LISTBOX(ID_PathsList, CinemaSidebar::OnSelectPath) 215 EVT_LISTBOX_DCLICK(ID_PathsList, CinemaSidebar::OnCenterOnPath) 216 EVT_SLIDER(ID_CameraTime, CinemaSidebar::OnChangeCameraTime) 217 END_EVENT_TABLE(); 218 -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinema/Cinema.h
1 /* Copyright (C) 2016 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "../Common/Sidebar.h" 19 20 #include "General/Observable.h" 21 22 23 class CinemaSidebar : public Sidebar 24 { 25 public: 26 CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer); 27 28 virtual void OnMapReload(); 29 virtual void OnTogglePathsDrawing(wxCommandEvent& evt); 30 virtual void OnToggleCameraDrawing(wxCommandEvent& evt); 31 virtual void OnCenterOnPath(wxCommandEvent& evt); 32 virtual void OnAddPath(wxCommandEvent& evt); 33 virtual void OnDeletePath(wxCommandEvent& evt); 34 virtual void OnSelectPath(wxCommandEvent& evt); 35 virtual void OnChangeCameraTime(wxCommandEvent& evt); 36 37 void ReloadPathList(); 38 39 protected: 40 virtual void OnFirstDisplay(); 41 42 private: 43 wxScrolledWindow* scrolledWindow; 44 wxCheckBox* m_DrawPath; 45 wxCheckBox* m_DrawCamera; 46 wxListBox* m_PathList; 47 wxSizer* m_PathSizer; 48 wxTextCtrl* m_PathName; 49 wxStaticText* m_InfoPathName; 50 wxSlider* m_CameraTime; 51 52 DECLARE_EVENT_TABLE(); 53 }; -
source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp
167 167 else 168 168 ENSURE(false); 169 169 } 170 171 BEGIN_COMMAND(AddCinemaPath) 172 { 173 void Do() 174 { 175 if (g_Game->GetView()->GetCinema()->HasPath(*msg->pathName)) 176 return; 177 CCinemaData pathData; 178 pathData.m_Name = *msg->pathName; 179 pathData.m_Timescale = fixed::FromInt(1); 180 pathData.m_Orientation = L"target"; 181 pathData.m_Mode = L"ease_inout"; 182 pathData.m_Style = L"default"; 183 184 CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus(); 185 CFixedVector3D target(fixed::FromFloat(focus.X), fixed::FromFloat(focus.Y + 1.0f), fixed::FromFloat(focus.Z)); 186 CFixedVector3D position(target + CFixedVector3D(fixed::Zero(), fixed::FromInt(1), fixed::Zero())); 187 CFixedVector3D shift(fixed::FromInt(3), fixed::Zero(), fixed::Zero()); 188 189 TNSpline positionSpline, targetSpline; 190 positionSpline.AddNode(position, CFixedVector3D(), fixed::FromInt(0)); 191 positionSpline.AddNode(position + shift, CFixedVector3D(), fixed::FromInt(3)); 192 targetSpline.AddNode(target, CFixedVector3D(), fixed::FromInt(0)); 193 targetSpline.AddNode(target + shift, CFixedVector3D(), fixed::FromInt(3)); 194 195 // Construct cinema path with data gathered 196 CCinemaPath path(pathData, positionSpline, targetSpline); 197 198 g_Game->GetView()->GetCinema()->AddPath(*msg->pathName, path); 199 } 200 void Redo() 201 { 202 } 203 void Undo() 204 { 205 } 206 }; 207 END_COMMAND(AddCinemaPath) 208 209 BEGIN_COMMAND(DeleteCinemaPath) 210 { 211 void Do() 212 { 213 if (!g_Game->GetView()->GetCinema()->HasPath(*msg->pathName)) 214 return; 215 g_Game->GetView()->GetCinema()->GetCinematicSimulationData()->m_Paths.erase(*msg->pathName); 216 } 217 void Redo() 218 { 219 } 220 void Undo() 221 { 222 } 223 }; 224 END_COMMAND(DeleteCinemaPath) 225 226 BEGIN_COMMAND(SelectCinemaPath) 227 { 228 void Do() 229 { 230 if (!g_Game->GetView()->GetCinema()->HasPath(*msg->pathName)) 231 return; 232 g_Game->GetView()->GetCinema()->SelectPath(*msg->pathName); 233 } 234 void Redo() 235 { 236 } 237 void Undo() 238 { 239 } 240 }; 241 END_COMMAND(SelectCinemaPath) 170 242 171 243 BEGIN_COMMAND(SetCinemaPaths) 172 244 { … … 193 265 msg->paths = GetCurrentPaths(); 194 266 } 195 267 268 BEGIN_COMMAND(SetCinemaPathsDrawing) 269 { 270 void Do() 271 { 272 g_Game->GetView()->GetCinema()->SetPathsDrawing(msg->drawPaths); 273 } 274 void Redo() 275 { 276 } 277 void Undo() 278 { 279 } 280 }; 281 END_COMMAND(SetCinemaPathsDrawing) 282 283 BEGIN_COMMAND(SetCinemaCameraDrawing) 284 { 285 void Do() 286 { 287 g_Game->GetView()->GetCinema()->SetCameraDrawing(msg->drawCamera); 288 } 289 void Redo() 290 { 291 } 292 void Undo() 293 { 294 } 295 }; 296 END_COMMAND(SetCinemaCameraDrawing) 297 298 BEGIN_COMMAND(SetCinemaCameraTime) 299 { 300 void Do() 301 { 302 g_Game->GetView()->GetCinema()->SetSelectedPathCameraTime(msg->cameraTime); 303 } 304 void Redo() 305 { 306 } 307 void Undo() 308 { 309 } 310 }; 311 END_COMMAND(SetCinemaCameraTime) 312 313 BEGIN_COMMAND(SetCameraCenterOnCinemaPath) 314 { 315 void Do() 316 { 317 const CStrW pathName = *msg->pathName; 318 if (!g_Game->GetView()->GetCinema()->HasPath(pathName)) 319 return; 320 const CCinemaPath path = g_Game->GetView()->GetCinema()->GetCinematicSimulationData()->m_Paths[pathName]; 321 CBoundingBoxAligned bb; 322 for (SplineData node : path.GetAllNodes()) 323 bb += node.Position; 324 for (SplineData node : path.GetTargetSpline().GetAllNodes()) 325 bb += node.Position; 326 CVector3D dir(0, 1, -1), target; 327 bb.GetCentre(target); 328 // TODO: calculate view with fov/aspect ratio 329 float distance = std::max((bb[1].X - bb[0].X) / 2.0f, (bb[1].Y - bb[0].Y) / 2.0f); 330 distance = std::max(std::max((bb[1].Z - bb[0].Z) / 2.0f, distance) * 3.0f, 10.0f); 331 g_Game->GetView()->GetCamera()->LookAt(dir * distance + target, target, CVector3D(0, 1, 0)); 332 } 333 void Redo() 334 { 335 } 336 void Undo() 337 { 338 } 339 }; 340 END_COMMAND(SetCameraCenterOnCinemaPath) 341 196 342 } -
source/tools/atlas/GameInterface/Messages.h
646 646 647 647 QUERY(GetCinemaPaths, 648 648 , // no inputs 649 ((std::vector<AtlasMessage::sCinemaPath> 649 ((std::vector<AtlasMessage::sCinemaPath>, paths)) 650 650 ); 651 651 652 652 QUERY(GetCameraInfo, … … 654 654 ((AtlasMessage::sCameraInfo, info)) 655 655 ); 656 656 657 COMMAND(AddCinemaPath, NOMERGE, ((std::wstring, pathName))); 658 659 COMMAND(DeleteCinemaPath, NOMERGE, ((std::wstring, pathName))); 660 661 COMMAND(SelectCinemaPath, NOMERGE, ((std::wstring, pathName))); 662 663 COMMAND(SetCinemaPathsDrawing, NOMERGE, ((bool, drawPaths))); 664 665 COMMAND(SetCinemaCameraDrawing, NOMERGE, ((bool, drawCamera))); 666 667 COMMAND(SetCinemaCameraTime, NOMERGE, ((float, cameraTime))); 668 669 COMMAND(SetCameraCenterOnCinemaPath, NOMERGE, ((std::wstring, pathName))); 670 657 671 COMMAND(SetCinemaPaths, NOMERGE, 658 672 ((std::vector<AtlasMessage::sCinemaPath>, paths)) 659 673 );