1 /* 2 Copyright (c) 2013 Andrey Penechko 3 4 Boost Software License - Version 1.0 - August 17th, 2003 5 6 Permission is hereby granted, free of charge, to any person or organization 7 obtaining a copy of the software and accompanying documentation covered by 8 this license the "Software" to use, reproduce, display, distribute, 9 execute, and transmit the Software, and to prepare derivative works of the 10 Software, and to permit third-parties to whom the Software is furnished to 11 do so, all subject to the following: 12 13 The copyright notices in the Software and this entire statement, including 14 the above license grant, this restriction and the following disclaimer, 15 must be included in all copies of the Software, in whole or in part, and 16 all derivative works of the Software, unless such copies or derivative 17 works are solely in the form of machine-executable object code generated by 18 a source language processor. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 23 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 24 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 25 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 DEALINGS IN THE SOFTWARE. 27 */ 28 29 module anchovy.graphics.camera; 30 31 // Magic bug like in shaderprogram.d 32 //import dlib.math.matrix4x4; 33 import dlib.math.vector; 34 35 class Camera 36 { 37 public: 38 /*this() 39 { 40 UpdatePerspective(); 41 } 42 43 this(float fov , 44 float aspect, 45 float near, 46 float far) 47 { 48 _fov = fov; 49 _aspect = aspect; 50 _near = near; 51 _far = far; 52 UpdatePerspective(); 53 } 54 55 Matrix4x4f UpdatePerspective() 56 { 57 perspective = perspectiveMatrix(_fov, _aspect, _near, _far); 58 return perspective; 59 } 60 61 @property { 62 float fov(){ return fov; } 63 float fov(float newFov){ return _fov = newFov; } 64 65 float aspect(){ return fov; } 66 float aspect(float newAspect){ return _aspect = newAspect; } 67 68 float near(){ return fov; } 69 float near(float newNear){ return _near = newNear; } 70 71 float far(){ return fov; } 72 float far(float newFar){ return _far = newFar; } 73 } 74 75 76 Matrix4x4f perspective; 77 Vector3f position = vec3(0, 0, 0); 78 Vector3f target = vec3(0, 0, 1); 79 Vector3f up = vec3(0, 1, 0); 80 81 private : 82 float _fov = 60, _aspect = 1, _near = 0.01, _far = 2000;*/ 83 }