Mercurial > fife-parpg
comparison engine/core/view/camera.h @ 482:16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 29 Apr 2010 13:51:45 +0000 |
parents | 9d94f4676d17 |
children | c9113e23b004 |
comparison
equal
deleted
inserted
replaced
481:1f37adc9a685 | 482:16c2b3ee59ce |
---|---|
45 class Rect; | 45 class Rect; |
46 class Instance; | 46 class Instance; |
47 class ImagePool; | 47 class ImagePool; |
48 class AnimationPool; | 48 class AnimationPool; |
49 class RenderBackend; | 49 class RenderBackend; |
50 typedef std::map<Layer*, std::vector<Instance*> > t_layer_to_instances; | 50 class LayerCache; |
51 class MapObserver; | |
52 typedef std::map<Layer*, RenderList > t_layer_to_instances; | |
51 | 53 |
52 /** Camera describes properties of a view port shown in the main screen | 54 /** Camera describes properties of a view port shown in the main screen |
53 * Main screen can have multiple cameras active simultanously | 55 * Main screen can have multiple cameras active simultanously |
54 * Different cameras can have different properties, like location | 56 * Different cameras can have different properties, like location |
55 * to shoot, zoom or tilt | 57 * to shoot, zoom or tilt |
56 */ | 58 */ |
57 class Camera: public IRendererListener, public IRendererContainer { | 59 class Camera: public IRendererListener, public IRendererContainer { |
58 public: | 60 public: |
61 enum Transform { | |
62 NormalTransform = 0, | |
63 WarpedTransform = 1 | |
64 }; | |
65 | |
59 /** Constructor | 66 /** Constructor |
60 * Camera needs to be added to the view. If not done so, it is not rendered. | 67 * Camera needs to be added to the view. If not done so, it is not rendered. |
61 * @param id identifier for the camera | 68 * @param id identifier for the camera |
62 * @param layer layer where camera is bound. Camera is bound to a layer for two reasons: | 69 * @param layer layer where camera is bound. Camera is bound to a layer for two reasons: |
63 * * camera's scaling is done based on cell image dimensions. Cell image is layer based (@see setCellImageDimensions) | 70 * * camera's scaling is done based on cell image dimensions. Cell image is layer based (@see setCellImageDimensions) |
147 /** Gets the location camera is rendering | 154 /** Gets the location camera is rendering |
148 * @return camera location | 155 * @return camera location |
149 */ | 156 */ |
150 Location getLocation() const; | 157 Location getLocation() const; |
151 | 158 |
159 Point3D getOrigin() const; | |
160 | |
152 /** Gets a reference to the camera location | 161 /** Gets a reference to the camera location |
153 * @note if you change returned location without calling Camera::setLocation(...), | 162 * @note if you change returned location without calling Camera::setLocation(...), |
154 * remember to call Camera::refresh() (otherwise camera transforms are not updated) | 163 * remember to call Camera::refresh() (otherwise camera transforms are not updated) |
155 * @return reference to the camera location | 164 * @return reference to the camera location |
156 */ | 165 */ |
190 | 199 |
191 /** Transforms given point from map coordinates to screen coordinates | 200 /** Transforms given point from map coordinates to screen coordinates |
192 * @return point in screen coordinates | 201 * @return point in screen coordinates |
193 */ | 202 */ |
194 ScreenPoint toScreenCoordinates(ExactModelCoordinate map_coords); | 203 ScreenPoint toScreenCoordinates(ExactModelCoordinate map_coords); |
204 | |
205 /** Transforms given point from map coordinates to virtual screen coordinates | |
206 * @return point in screen coordinates | |
207 */ | |
208 DoublePoint3D toVirtualScreenCoordinates(ExactModelCoordinate map_coords); | |
209 | |
210 ScreenPoint virtualScreenToScreen(const DoublePoint3D& p); | |
211 DoublePoint3D screenToVirtualScreen(const ScreenPoint& p); | |
195 | 212 |
196 /** Sets camera enabled / disabled | 213 /** Sets camera enabled / disabled |
197 */ | 214 */ |
198 void setEnabled(bool enabled); | 215 void setEnabled(bool enabled); |
199 | 216 |
264 void onRendererEnabledChanged(RendererBase* renderer); | 281 void onRendererEnabledChanged(RendererBase* renderer); |
265 | 282 |
266 /** Renders camera | 283 /** Renders camera |
267 */ | 284 */ |
268 void render(); | 285 void render(); |
269 | |
270 private: | 286 private: |
287 friend class MapObserver; | |
288 void addLayer(Layer* layer); | |
289 void removeLayer(Layer* layer); | |
290 void updateMap(Map* map); | |
271 std::string m_id; | 291 std::string m_id; |
292 | |
272 | 293 |
273 /** Updates the camera transformation matrix T with requested values. | 294 /** Updates the camera transformation matrix T with requested values. |
274 * The requests are done using these functions : | 295 * The requests are done using these functions : |
275 * - setLocation | 296 * - setLocation |
276 * - setRotation | 297 * - setRotation |
290 */ | 311 */ |
291 DoublePoint getLogicalCellDimensions(Layer* layer); | 312 DoublePoint getLogicalCellDimensions(Layer* layer); |
292 | 313 |
293 DoubleMatrix m_matrix; | 314 DoubleMatrix m_matrix; |
294 DoubleMatrix m_inverse_matrix; | 315 DoubleMatrix m_inverse_matrix; |
316 | |
317 DoubleMatrix m_vs_matrix; | |
318 DoubleMatrix m_vs_inverse_matrix; | |
319 DoubleMatrix m_vscreen_2_screen; | |
320 DoubleMatrix m_screen_2_vscreen; | |
321 | |
295 double m_tilt; | 322 double m_tilt; |
296 double m_rotation; | 323 double m_rotation; |
297 double m_zoom; | 324 double m_zoom; |
298 Location m_location; | 325 Location m_location; |
299 ScreenPoint m_prev_origo; | 326 ScreenPoint m_prev_origo; |
318 ImagePool* m_ipool; | 345 ImagePool* m_ipool; |
319 AnimationPool* m_apool; | 346 AnimationPool* m_apool; |
320 | 347 |
321 // caches layer -> instances structure between renders e.g. to fast query of mouse picking order | 348 // caches layer -> instances structure between renders e.g. to fast query of mouse picking order |
322 t_layer_to_instances m_layer_to_instances; | 349 t_layer_to_instances m_layer_to_instances; |
350 | |
351 std::map<Layer*,LayerCache*> m_cache; | |
352 MapObserver* m_map_observer; | |
353 Map* m_map; | |
323 }; | 354 }; |
324 } | 355 } |
325 #endif | 356 #endif |