Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Camera
- {
- public:
- Camera()
- : pos( 0, 0, 5 ),
- dir( 0, 0, -1 ),
- up( 0, 1, 0 )
- {
- }
- sf::Vector3f pos;
- sf::Vector3f dir;
- sf::Vector3f up;
- void Display()
- {
- gluLookAt( pos.x, pos.y, pos.z,
- pos.x + dir.x, pos.y + dir.y, pos.z + dir.z,
- up.x, up.y, up.z );
- }
- };
- // Update
- {
- // I know this should be a seperate function, but it was easier to just put it here. :P
- #define Distance(a,b) std::sqrt( std::pow( b.x - a.x, 2 ) + std::pow( b.y - a.y, 2 ) + std::pow( b.z - a.z, 2 ) )
- float speed = 1;
- sf::Vector3f amount( cam.dir.x * speed, cam.dir.y * speed, cam.dir.z * speed );
- if ( sf::Keyboard::IsKeyPressed( sf::Keyboard::W ) )
- {
- cam.pos += amount;
- }
- if ( sf::Keyboard::IsKeyPressed( sf::Keyboard::S ) )
- {
- cam.pos -= amount;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement