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

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 »

Re: Multiple Viewport/Camera concept
« Reply #1 on: 15 Apr 2019, 15:28 »
If anyone wants to try this out, here's working build:
should be copied over latest 3.5.0 WIP.

Demo game source:

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);
  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);
  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;

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 »


  • AGS Baker
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    • Dualnames worked on one or more games 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

  • Analysis Paralysis
    • Retro Wolf worked on one or more games 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!