22#ifndef QDENGINE_QDCORE_QD_CAMERA_H
23#define QDENGINE_QDCORE_QD_CAMERA_H
25#include "qdengine/qdcore/qd_d3dutils.h"
26#include "qdengine/qdcore/qd_camera_mode.h"
53 sGridCell(uint16 atr, int16 h) {
58 bool is_walkable()
const {
61 void make_impassable() {
64 void make_walkable() {
74 void toggle_select() {
77 bool is_selected()
const {
81 int16 height()
const {
84 void set_height(int16 h) { }
86 void set_attribute(uint32 attr) {
89 void toggle_attribute(uint32 attr) {
92 void drop_attribute(uint32 attr) {
95 bool check_attribute(uint32 attr)
const {
96 if (_attributes & attr)
return true;
100 uint32 attributes()
const {
103 void set_attributes(uint32 attr) {
116enum qdCameraRedrawMode {
130 bool set_grid_cell_attributes(
const Vect2s &cell_pos,
int attr);
148 bool is_walkable(
const Vect2s ¢er_pos,
const Vect2s &size,
bool ignore_personages =
false)
const;
160 bool restore_grid_cell(
const Vect2s cell_pos);
162 void cycle_coords(
int &x,
int &y)
const;
164 void set_redraw_mode(
int md)
const {
167 int get_redraw_mode()
const {
171 void set_grid_size(
int xs,
int ys);
173 void scale_grid(
int sx,
int sy,
int csx,
int csy);
174 void resize_grid(
int sx,
int sy);
176 int get_grid_sx()
const {
179 int get_grid_sy()
const {
183 const sGridCell *get_grid()
const {
187 int get_cell_sx()
const {
190 int get_cell_sy()
const {
194 void set_cell_size(
int csx,
int csy) {
202 void rotate_and_scale(
float XA,
float YA,
float ZA,
float kX,
float kY,
float kZ);
204 float get_focus()
const {
207 void set_focus(
float focus) {
211 void set_R(
const float r);
212 float get_R()
const {
216 float get_x_angle()
const {
219 float get_y_angle()
const {
222 float get_z_angle()
const {
226 inline void set_scr_size(
int xs,
int ys) {
231 const Vect2i &get_scr_size()
const {
236 int get_scr_sx()
const {
240 int get_scr_sy()
const {
244 void set_scr_center(
int xc,
int yc) {
249 const Vect2i &get_scr_center()
const {
253 int get_scr_center_x()
const {
256 int get_scr_center_y()
const {
260 const Vect2i screen_center_limit_x()
const;
261 const Vect2i screen_center_limit_y()
const;
263 const Vect2i &get_scr_offset()
const {
266 void set_scr_offset(
const Vect2i &offs) {
270 const Vect2i &get_scr_center_initial()
const {
271 return _scrCenterInitial;
273 void set_scr_center_initial(
const Vect2i &v) {
274 _scrCenterInitial = v;
277 void move_scr_center(
int dxc,
int dyc);
279 float scrolling_phase_x()
const;
280 float scrolling_phase_y()
const;
282 const Vect3f scr2plane(
const Vect2s &scrPoint)
const;
283 const Vect3f rscr2plane(
const Vect2s &rscrPoint)
const;
285 const Vect3f scr2plane_camera_coord(
const Vect2s &scrPoint)
const;
286 const Vect3f rscr2plane_camera_coord(
const Vect2s &scrPoint)
const;
287 const Vect2s plane2scr(
const Vect3f &plnPoint)
const;
288 const Vect2s plane2rscr(
const Vect3f &plnPoint)
const;
290 const Vect3f rscr2camera_coord(
const Vect2s &rScrPoint,
float z)
const;
291 const Vect2s camera_coord2rscr(
const Vect3f &coord)
const;
293 const Vect2s rscr2scr(
const Vect2s &v)
const;
294 const Vect2s scr2rscr(
const Vect2s &v)
const;
296 const Vect2s camera_coord2scr(
const Vect3f &coord)
const;
298 const Vect3f scr2global(
const Vect2s &vScrPoint,
float zInCameraCoord)
const;
299 const Vect3f rscr2global(
const Vect2s rScrPoint,
const float zInCameraCoord)
const;
300 const Vect3f global2camera_coord(
const Vect3f &glCoord)
const;
301 const Vect3f camera_coord2global(
const Vect3f &v)
const;
303 const Vect2s global2scr(
const Vect3f &glCoord)
const;
304 const Vect2s global2rscr(
const Vect3f &glCoord)
const;
308 bool line_cutting(Vect3f &b, Vect3f &e)
const;
316 float get_scale(
const Vect3f &glCoord)
const;
318 const Vect3f &get_grid_center()
const {
321 void set_grid_center(
const Vect3f &v) {
325 const sGridCell *get_cell(
float X,
float Y)
const;
326 const Vect2s get_cell_index(
float X,
float Y,
bool grid_crop =
true)
const;
327 const Vect2s get_cell_index(
const Vect3f &v,
bool grid_crop =
true)
const;
328 const Vect3f get_cell_coords(
int x_idx,
int y_idx)
const;
329 const Vect3f get_cell_coords(
const Vect2s &idxs)
const;
331 void reset_all_select();
333 bool select_cell(
int x,
int y);
336 bool deselect_cell(
int x,
int y);
338 void load_script(
const xml::tag *p);
349 bool draw_grid()
const;
350 bool draw_cell(
int x,
int y,
int z,
int penWidth, uint32 color)
const;
374 void set_cycle(
bool cx,
bool cy) {
379 void dump_grid(
const char *file_name)
const;
385 void set_scale_pow(
float sp) {
388 float scale_z_offset()
const {
389 return _scale_z_offset;
391 void set_scale_z_offset(
float szo) {
392 _scale_z_offset = szo;
395 bool need_perspective_correction()
const {
396 return (fabs(_scale_pow - 1) > 0.001 || fabs(_scale_z_offset) > 0.001);
401 return _default_mode;
405 _default_mode = mode;
409 return _current_camera;
411 static void set_current_camera(qdCamera *p) {
415 MATRIX3D
const &get_view_matrix()
const {
423 float _xAngle, _yAngle, _zAngle;
431 int _cellSX, _cellSY;
439 Vect2i _scrCenterInitial;
449 mutable int _redraw_mode;
452 qdCameraMode _current_mode;
455 float _current_mode_work_time;
456 bool _current_mode_switch;
459 qdGameObjectAnimated *_current_object;
462 qdGameObjectAnimated *_default_object;
464 qdCameraMode _default_mode;
468 float _scale_z_offset;
470 static qdCamera *_current_camera;
472 static const float _NEAR_PLANE;
473 static const float _FAR_PLANE;
482 inline int clip_out_code(
const Vect2s &v)
const {
496 void clip_center_coords(
int &x,
int &y)
const;
499inline Vect3f To3D(
const Vect2f &v) {
500 return Vect3f(v.x, v.y, 0);
Definition: qd_camera.h:122
bool set_grid_attributes(const Vect2s ¢er_pos, const Vect2s &size, int attr)
Устанавливает атрибуты для клеток из прямоугольника на сетке с ценром center_pos и размерами size.
bool can_change_mode() const
Возвращает true, если в данный момент можно менять режим камеры.
bool drop_grid_attributes(int attr)
Очищает атрибуты attr для всех клеток сетки.
bool set_grid_attributes(int attr)
Устанавливает атрибуты attr для всех клеток сетки.
bool set_mode(const qdCameraMode &mode, qdGameObjectAnimated *object=NULL)
Установка текущего режима камеры.
bool check_grid_attributes(const Vect2s ¢er_pos, const Vect2s &size, int attr) const
Возвращает true, если в прямоугольнике на сетке ЕСТЬ ХОТЯ БЫ ОДНА ячейка с атрибутами attr.
void set_default_object(qdGameObjectAnimated *p)
Установка объекта, за которым камера следит по умолчанию.
Definition: qd_camera.h:361
bool load_data(Common::SeekableReadStream &fh, int save_version)
Загрузка данных из сэйва.
int cells_num_with_exact_attributes(const Vect2s ¢er_pos, const Vect2s &size, int attr) const
Возвращает количество ячеек в заданной области, имеющих именно аттрибуты attr.
bool init()
Инициализация данных, вызывается при старте и перезапуске игры.
const qdCameraMode & default_mode() const
Возвращает режим работы камеры по умолчанию.
Definition: qd_camera.h:400
bool quant(float dt)
Обсчет логики (движения камеры и т.д), параметр - время в секундах.
void set_default_mode(const qdCameraMode &mode)
Установка режима работы камеры по умолчанию.
Definition: qd_camera.h:404
bool drop_grid_line_attributes(const Vect2s &start_pos, const Vect2s &end_pos, const Vect2s &size, int attr)
Очищает атрибуты для линии клеток.
bool set_grid_line_attributes(const Vect2s &start_pos, const Vect2s &end_pos, const Vect2s &size, int attr)
Устанавливает атрибуты для линии клеток.
bool clip_grid_line(Vect2s &v0, Vect2s &v1) const
Обрезка линиии, так чтобы она за сетку не выходила.
bool check_grid_line_attributes(const Vect2s &start_pos, const Vect2s &end_pos, const Vect2s &size, int attr) const
Возвращает true, если в линии на сетке есть хотя бы одна ячейка с атрибутами attr.
bool drop_grid_attributes(const Vect2s ¢er_pos, const Vect2s &size, int attr)
Очищает атрибуты для клеток из прямоугольника на сетке с ценром center_pos и размерами size.
float scale_pow() const
Параметры функции масштабирования
Definition: qd_camera.h:382
bool save_data(Common::WriteStream &fh) const
Запись данных в сэйв.
bool is_visible(const Vect2i ¢er_offs=Vect2i(0, 0)) const
Возвращает false, если вся рабочая область камеры находится за пределами экрана.
Режим работы камеры.
Definition: qd_camera_mode.h:40
Dynamic object.
Definition: qd_game_object_animated.h:37
Definition: qd_camera.h:34
cell_attribute_t
Атрибуты
Definition: qd_camera.h:37
@ CELL_OCCUPIED
ячейка занята объектом
Definition: qd_camera.h:43
@ CELL_SELECTED
ячейка выделена
Definition: qd_camera.h:39
@ CELL_IMPASSABLE
ячейка непроходима
Definition: qd_camera.h:41
@ CELL_PERSONAGE_PATH
по ячейке проходит путь персонажа
Definition: qd_camera.h:47
@ CELL_PERSONAGE_OCCUPIED
ячейка занята персонажем
Definition: qd_camera.h:45
Definition: algorithm.h:29
Базовый класс для игровых ресурсов.
Definition: console.h:28