Subversion Repositories gelsvn

Rev

Rev 353 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 353 Rev 630
1
#include "camera.h"
1
#include "camera.h"
2
 
2
 
3
using namespace CGLA;
3
using namespace CGLA;
4
 
4
 
5
camera::camera(const CGLA::Vec3f& eye,
5
camera::camera(const CGLA::Vec3f& eye,
6
               const CGLA::Vec3f& cnt,
6
               const CGLA::Vec3f& cnt,
7
               const CGLA::Vec3f& up,
7
               const CGLA::Vec3f& up,
8
               float focal)
8
               float focal)
9
{
9
{
10
    eye_ = eye;
10
    eye_ = eye;
11
 
11
 
12
    z_ = normalize(eye - cnt);
12
    z_ = normalize(eye - cnt);
13
 
13
 
14
    x_ = normalize(cross(up, z_));
14
    x_ = normalize(cross(up, z_));
15
    y_ = cross(z_, x_);
15
    y_ = cross(z_, x_);
16
 
16
 
17
    x_ *= 0.012f;
17
    x_ *= 0.012f;
18
    y_ *= 0.012f;
18
    y_ *= 0.012f;
19
 
19
 
20
    focal_ = focal;
20
    focal_ = focal;
21
}
21
}
22
 
22
 
23
ray camera::generate(const Vec2f& uv) const
23
ray camera::generate(const Vec2f& uv) const
24
{
24
{
25
    Vec2f xy = 2.f * uv - Vec2f(1.f);
25
    Vec2f xy = 2.f * uv - Vec2f(1.f);
26
 
26
 
27
    ray r;
27
    ray r;
28
    r.origin = eye_;
28
    r.origin = eye_;
29
    r.direction = normalize(-focal_*z_ + xy[0]*x_ + xy[1]*y_);
29
    r.direction = normalize(-focal_*z_ + xy[0]*x_ + xy[1]*y_);
30
    r.depth = 0;
30
    r.depth = 0;
31
    r.distance = std::numeric_limits<float>::infinity();
31
    r.distance = std::numeric_limits<float>::infinity();
32
    return r;
32
    return r;
33
}
33
}
34
 
34
 
35
//02566 framework, Anders Wang Kristensen, awk@imm.dtu.dk, 2007
35
//02566 framework, Anders Wang Kristensen, awk@imm.dtu.dk, 2007
36
 
36
 
37
 
37
 
38

Generated by GNU Enscript 1.6.6.
38

Generated by GNU Enscript 1.6.6.
39
 
39
 
40
 
40
 
41
 
41