Author Topic: Multiple Viewport/Camera concept  (Read 168 times)

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on a game that won an AGS Award!
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
Multiple Viewport/Camera concept
« on: 05 Apr 2019, 14:02 »
As I was working on a multiple viewport/camera prototype initially I thought that drawing will be the most complicated part, but now when it's working for one viewport/camera it may be expanded into multiple ones relatively easily.

Instead it appears I did not think the organizational matter through.

By default there should be 1 viewport and 1 camera which I called "primary" and which always exist.
Assuming user can create more viewports and cameras in script at will,

1) What does Viewport and Cameras belong to, Game or Room? Viewport may belong to game, while Camera to the room for example, or both belong to game or room.
2) Should Cameras reset when the room changes? Should viewports?
3) Or should cameras and or viewports remember their state in rooms and restore themselves when player enters them?


UPD As a default plan I could make they fully rely on script control, that at least would allow users to script them whichever the like.
« Last Edit: 05 Apr 2019, 20:21 by Crimson Wizard »

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on a game that won an AGS Award!
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
Re: Multiple Viewport/Camera concept
« Reply #1 on: 15 Apr 2019, 15:28 »
If anyone wants to try this out, here's working build: https://www.dropbox.com/s/gt4pswg9u9saqm1/ags350--multicam-test.zip?dl=0
should be copied over latest 3.5.0 WIP.

Demo game source: https://www.dropbox.com/s/zp0e4cidkate0rc/test--multiviewport.zip?dl=0

Spoiler: ShowHide




Script API is mostly in place, and I think it's generally working, except for software renderer and few lesser things.

New script commands:
Code: Adventure Game Studio
  1.   /// Gets the Camera by index.
  2.   Camera *Room.Cameras[];
  3.   /// Gets the number of cameras.
  4.   int Room.CameraCount;
  5.   /// Creates a new Camera.
  6.   Camera *Room.CreateCamera();
  7.   /// Removes an existing camera; primary camera will never be removed
  8.   void Room.RemoveCamera(int id);
  9.  
  10.  
  11.   /// Gets a Viewport by index.
  12.   Viewport *Screen.Viewports[];
  13.   /// Gets the number of viewports.
  14.   int Screen.ViewportCount;
  15.   /// Creates a new Viewport.
  16.   Viewport *Screen.CreateViewport();
  17.   /// Removes an existing viewport; primary viewport will never be removed
  18.   void Screen.RemoveViewport(int id);
  19.  
  20.  
  21.   /// Gets/sets the room camera displayed in this viewport.
  22.   Camera *Viewport.Camera;
  23.   /// Gets/sets whether the viewport is drawn on screen.
  24.   bool Viewport.Visible;
  25.  


The Viewport and Camera pointer is a reference to internal objects. When internal viewport or camera gets destroyed (e.g. by calling RemoveCamera) all pointers to that camera are invalidated and any action with them with result in failure.

« Last Edit: 17 Apr 2019, 21:39 by Crimson Wizard »

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for an AGS Award!
Re: Multiple Viewport/Camera concept
« Reply #2 on: 15 Apr 2019, 16:30 »
Holy moly macaroni
No more military army stuff. I'm alive and back.

Retro Wolf

  • The Viscount of Vaporware
    • Retro Wolf worked on a game that was nominated for an AGS Award!
Re: Multiple Viewport/Camera concept
« Reply #3 on: 16 Apr 2019, 13:54 »
That's really cool! Awesome work CW!