Multiple Viewport/Camera concept

Started by Crimson Wizard, Fri 05/04/2019 14:02:40

Previous topic - Next topic

Crimson Wizard

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.

Crimson Wizard

#1
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

[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

  /// 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.


Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Retro Wolf

That's really cool! Awesome work CW!

SMF spam blocked by CleanTalk