Kukatz 3D  0.1
Török Attila szakdolgozata
projects/Kukatz 3D/include/camera.hpp
00001 /*
00002  * camera.hpp - Kukatz 3D
00003  * Copyright (c) 2010, 2011 - TÖRÖK Attila (torokati44@gmail.com)
00004  *
00005  * This software is provided 'as-is', without any express or implied
00006  * warranty. In no event will the authors be held liable for any damages
00007  * arising from the use of this software.
00008  *
00009  * Permission is granted to anyone to use this software for any purpose,
00010  * including commercial applications, and to alter it and redistribute it
00011  * freely, subject to the following restrictions:
00012  *
00013  *       1. The origin of this software must not be misrepresented; you must not
00014  *                      claim that you wrote the original software. If you use this software
00015  *                      in a product, an acknowledgment in the product documentation would be
00016  *                      appreciated but is not required.
00017  *
00018  *       2. Altered source versions must be plainly marked as such, and must not be
00019  *                      misrepresented as being the original software.
00020  *
00021  *       3. This notice may not be removed or altered from any source
00022  *                      distribution.
00023  */
00024 
00025 #ifndef CAMERA_HPP_INCLUDED
00026 #define CAMERA_HPP_INCLUDED
00027 
00028 #include <SFML/System/Vector2.hpp>
00029 #include <SFML/System/Vector3.hpp>
00030 
00031 #include "resourcemanager.hpp"
00032 #include "staticobject.hpp"
00033 #include "updatable.hpp"
00034 #include "renderable.hpp"
00035 #include "viewport.hpp"
00036 
00037 class Camera: public Viewport, public Renderable
00038 {
00039 protected:
00040         sf::Vector3f pos, center, up;
00041         
00042         StaticObject* object;
00043         static Camera* current_cam;
00044         
00045         void update_object();
00046         
00047         GLdouble modelview_matrix[16], projection_matrix[16];
00048         GLint viewport[4];
00049         
00050         struct plane_t
00051         {
00052                 sf::Vector3f point;
00053                 sf::Vector3f normal;
00054         } planes[6];
00055         
00056         void get_corners(float); // will be left and right too
00057         void get_planes(); // works from the 8 corners
00058         
00059         sf::Vector3f bln, blf, brn, brf, tln, tlf, trn, trf; // view frustum corners
00060         
00061         //void get_planes_left();
00062         //void get_planes_right();
00063         
00064         
00065         //static unsigned long int culled[7]; // for statistics
00066         
00067 public:
00068         Camera(const sf::Vector3f&, const sf::Vector3f&, const sf::Vector3f&,
00069                 const sf::Vector2i&, const sf::Vector2i&, float = 65, float = 0.1f,
00070                 float = 1000);
00071         
00072         float fov;
00073         float eye_distance;
00074         float screen_distance;
00075         
00076         virtual void render();
00077         
00078         void set_pos(const sf::Vector3f&, const sf::Vector3f&, const sf::Vector3f&);
00079         
00080         const sf::Vector3f& get_pos();
00081         const sf::Vector3f& get_center();
00082         const sf::Vector3f& get_up();
00083         
00084         static Camera& get_current();
00085         bool sees(const sf::Vector3f&, float);
00086         
00087         void look_3d(float);
00088         
00089         virtual ~Camera();
00090 };
00091 
00092 #endif // CAMERA_HPP_INCLUDED
 Összes Osztályok