Adventure Game Studio

AGS Development => Engine Development => Topic started by: Crimson Wizard on Fri 05/04/2019 14:02:40

Title: Multiple Viewport/Camera concept
Post by: Crimson Wizard on Fri 05/04/2019 14:02:40
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.
Title: Re: Multiple Viewport/Camera concept
Post by: Crimson Wizard on Mon 15/04/2019 15:28:00
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
(https://i.imgur.com/w8ShCLx.gif)
(https://i.imgur.com/1bMv6sI.gif)
[close]


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 (ags) Select

  /// Gets the Camera by index.
  Camera *Room.Cameras[];
  /// Gets the number of cameras.
  int Room.CameraCount;
  /// Creates a new Camera.
  Camera *Room.CreateCamera();
  /// Removes an existing camera; primary camera will never be removed
  void Room.RemoveCamera(int id);


  /// Gets a Viewport by index.
  Viewport *Screen.Viewports[];
  /// Gets the number of viewports.
  int Screen.ViewportCount;
  /// Creates a new Viewport.
  Viewport *Screen.CreateViewport();
  /// Removes an existing viewport; primary viewport will never be removed
  void Screen.RemoveViewport(int id);


  /// Gets/sets the room camera displayed in this viewport.
  Camera *Viewport.Camera;
  /// Gets/sets whether the viewport is drawn on screen.
  bool Viewport.Visible;



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.

Title: Re: Multiple Viewport/Camera concept
Post by: Dualnames on Mon 15/04/2019 16:30:27
Holy moly macaroni
Title: Re: Multiple Viewport/Camera concept
Post by: Retro Wolf on Tue 16/04/2019 13:54:48
That's really cool! Awesome work CW!