summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/CameraDirector.h
blob: 6cd59da74503b61e57d5be3910e3457a424ef779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*  Starshatter: The Open Source Project
    Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
    Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
    Copyright (c) 1997-2006, Destroyer Studios LLC.

    AUTHOR:       John DiCamillo


    OVERVIEW
    ========
    Camera Director singleton manages the main view camera based on the current ship
*/

#ifndef CameraDirector_h
#define CameraDirector_h

#include "Types.h"
#include "Camera.h"
#include "SimObject.h"
#include "List.h"

// +--------------------------------------------------------------------+

class HUDView;
class Orbital;
class Ship;
class Sim;

// +--------------------------------------------------------------------+

class CameraDirector : public SimObserver
{
public:
    static const char* TYPENAME() { return "CameraDirector"; }

    enum CAM_MODE  {
        MODE_NONE,

        MODE_COCKPIT,
        MODE_CHASE,
        MODE_TARGET,
        MODE_THREAT,
        MODE_ORBIT,
        MODE_VIRTUAL,
        MODE_TRANSLATE,
        MODE_ZOOM,
        MODE_DOCKING,
        MODE_DROP,

        MODE_LAST
    };

    // CONSTRUCTORS:
    CameraDirector();
    virtual ~CameraDirector();

    int operator == (const CameraDirector& that) const { return this == &that; }

    static CameraDirector* GetInstance();

    // CAMERA:
    static  int       GetCameraMode();
    static  void      SetCameraMode(int m, double trans_time=1);
    static  const char* GetModeName();

    static  double    GetRangeLimit();
    static  void      SetRangeLimit(double r);
    static  void      SetRangeLimits(double min, double max);

    virtual void      Reset();
    virtual void      SetMode(int m, double trans_time=1);
    virtual int       GetMode() const            { return requested_mode > MODE_NONE ? requested_mode : mode; }
    virtual Camera*   GetCamera()                { return &camera; }
    virtual Ship*     GetShip()                  { return ship;    }
    virtual void      SetShip(Ship* s);

    virtual void      VirtualHead(double az, double el);
    virtual void      VirtualHeadOffset(double x, double y, double z);
    virtual void      VirtualAzimuth(double delta);
    virtual void      VirtualElevation(double delta);
    virtual void      ExternalAzimuth(double delta);
    virtual void      ExternalElevation(double delta);
    virtual void      ExternalRange(double delta);
    virtual void      SetOrbitPoint(double az, double el, double range);
    virtual void      SetOrbitRates(double az_rate, double el_rate, double r_rate);

    static  bool      IsViewCentered();

    virtual void      CycleViewObject();

    virtual Orbital*  GetViewOrbital() const { return external_body; }
    virtual Ship*     GetViewObject()  const { return external_ship; }

    virtual void      SetViewOrbital(Orbital* orb);
    virtual void      SetViewObject(Ship* obj,                 bool quick=false);
    virtual void      SetViewObjectGroup(ListIter<Ship> group, bool quick=false);
    virtual void      ClearGroup();

    // BEHAVIORS:
    virtual void      ExecFrame(double s);
    virtual void      Transition(double s);

    // SimObserver:
    virtual bool         Update(SimObject* obj);
    virtual const char*  GetObserverName() const;

protected:
    virtual void      Cockpit(double s);
    virtual void      Chase(double s);
    virtual void      Target(double s);
    virtual void      Threat(double s);
    virtual void      Virtual(double s);
    virtual void      Orbit(double s);
    virtual void      Docking(double s);
    virtual void      Drop(double s);

    int               mode;
    int               requested_mode;
    int               old_mode;
    Camera            camera;

    Ship*             ship;

    SimRegion*        region;
    Orbital*          external_body;
    Ship*             external_ship;
    List<Ship>        external_group;
    Point             external_point;

    Point             base_loc;

    double            virt_az;
    double            virt_el;
    double            virt_x;
    double            virt_y;
    double            virt_z;
    double            azimuth;
    double            elevation;
    double            az_rate;
    double            el_rate;
    double            range_rate;
    double            range;
    double            range_min;
    double            range_max;
    double            base_range;
    double            transition;

    Sim*              sim;
    HUDView*          hud;

    static CameraDirector* instance;
};

#endif  // CameraDirector_h