// File: SpiritLooper[P]RDV_OBJRender/camera.cpp
// Function: Camera::Camera(Vec3<float>, Image, int)
Camera::Camera(Vec3f position, Image i, int m) : eye(position), mode(m) {
    ViewPort = Matrix::identity(4);
    
    int x , y , h, w;
    x = i.get_width()  / 8;
    y = i.get_height() / 8;
    w = i.get_width()  * 3/4;
    h = i.get_height() * 3/4;

    ViewPort[0][3] = x+w/2.f;
    ViewPort[1][3] = y+h/2.f;
    ViewPort[2][3] = depth/2.f;
    
    ViewPort[0][0] = w/2.f;
    ViewPort[1][1] = h/2.f;
    ViewPort[2][2] = depth/2.f;

    Projection = Matrix::identity(4);
    Projection[3][2] = -1.f/position.z;

    center = Vec3f(0, 0, 0);
    up = Vec3f(0, 1, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rsi, -0xd8(%rbp)
movlpd %xmm0, -0x20(%rbp)
movss %xmm1, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movl %edx, -0x34(%rbp)
movq -0x28(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, 0x8(%rdi)
movq -0x10(%rbp), %rax
movq %rax, (%rdi)
addq $0xc, %rdi
callq 0x5b90
movq -0xc8(%rbp), %rdi
addq $0x18, %rdi
callq 0x5b90
movq -0xc8(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0xd0(%rbp)
movl $0x4, %edx
movl %edx, -0xbc(%rbp)
movl %edx, %esi
callq 0x2690
movq -0xc8(%rbp), %rdi
movl -0xbc(%rbp), %edx
addq $0x48, %rdi
movq %rdi, -0xb8(%rbp)
movl %edx, %esi
callq 0x2690
jmp 0x48cb
movq -0xc8(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, 0x68(%rax)
leaq -0x68(%rbp), %rdi
movl $0x4, %esi
callq 0x2780
jmp 0x48e8
movq -0xc8(%rbp), %rdi
addq $0x28, %rdi
leaq -0x68(%rbp), %rsi
movq %rsi, -0xe8(%rbp)
callq 0x5bc0
movq -0xe8(%rbp), %rdi
callq 0x33e0
movq -0xd8(%rbp), %rdi
callq 0x6600
movl %eax, -0xdc(%rbp)
jmp 0x4923
movq -0xd8(%rbp), %rdi
movl -0xdc(%rbp), %eax
movl %eax, %ecx
addl $0x7, %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x3, %eax
movl %eax, -0x6c(%rbp)
callq 0x6620
movl %eax, -0xec(%rbp)
jmp 0x494d
movq -0xd8(%rbp), %rdi
movl -0xec(%rbp), %eax
movl %eax, %ecx
addl $0x7, %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x3, %eax
movl %eax, -0x70(%rbp)
callq 0x6600
movl %eax, -0xf0(%rbp)
jmp 0x4977
movq -0xd8(%rbp), %rdi
movl -0xf0(%rbp), %eax
movl %eax, %ecx
leal (%rcx,%rcx,2), %eax
leal 0x3(%rcx,%rcx,2), %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x2, %eax
movl %eax, -0x78(%rbp)
callq 0x6620
movl %eax, -0xf4(%rbp)
jmp 0x49a5
movq -0xc8(%rbp), %rdi
movl -0xf4(%rbp), %eax
movl %eax, %ecx
leal (%rcx,%rcx,2), %eax
leal 0x3(%rcx,%rcx,2), %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x2, %eax
movl %eax, -0x74(%rbp)
cvtsi2ssl -0x6c(%rbp), %xmm0
cvtsi2ssl -0x78(%rbp), %xmm1
movss 0xa710(%rip), %xmm2     # 0xf0e8
mulss %xmm2, %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0x104(%rbp)
addq $0x28, %rdi
xorl %esi, %esi
callq 0x2890
movq %rax, -0x100(%rbp)
jmp 0x49fc
movq -0x100(%rbp), %rdi
movl $0x3, %esi
callq 0x33c0
movss -0x104(%rbp), %xmm0
movq -0xc8(%rbp), %rdi
movss %xmm0, (%rax)
cvtsi2ssl -0x70(%rbp), %xmm0
cvtsi2ssl -0x74(%rbp), %xmm1
movss 0xa6b6(%rip), %xmm2     # 0xf0e8
mulss %xmm2, %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
addq $0x28, %rdi
movl $0x1, %esi
callq 0x2890
movq %rax, -0x110(%rbp)
jmp 0x4a59
movq -0x110(%rbp), %rdi
movl $0x3, %esi
callq 0x33c0
movss -0x114(%rbp), %xmm0
movq -0xc8(%rbp), %rdi
movss %xmm0, (%rax)
addq $0x28, %rdi
movl $0x2, %esi
callq 0x2890
movq %rax, -0x120(%rbp)
jmp 0x4a94
movq -0x120(%rbp), %rdi
movl $0x3, %esi
callq 0x33c0
movq -0xc8(%rbp), %rdi
movl $0x42ff0000, (%rax)     # imm = 0x42FF0000
cvtsi2ssl -0x78(%rbp), %xmm0
movss 0xa629(%rip), %xmm1     # 0xf0e8
mulss %xmm1, %xmm0
movss %xmm0, -0x12c(%rbp)
addq $0x28, %rdi
xorl %esi, %esi
callq 0x2890
movq %rax, -0x128(%rbp)
jmp 0x4adf
movq -0x128(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x33c0
movss -0x12c(%rbp), %xmm0
movq -0xc8(%rbp), %rdi
movss %xmm0, (%rax)
cvtsi2ssl -0x74(%rbp), %xmm0
movss 0xa5d9(%rip), %xmm1     # 0xf0e8
mulss %xmm1, %xmm0
movss %xmm0, -0x13c(%rbp)
addq $0x28, %rdi
movl $0x1, %esi
callq 0x2890
movq %rax, -0x138(%rbp)
jmp 0x4b32
movq -0x138(%rbp), %rdi
movl $0x1, %esi
callq 0x33c0
movss -0x13c(%rbp), %xmm0
movq -0xc8(%rbp), %rdi
movss %xmm0, (%rax)
addq $0x28, %rdi
movl $0x2, %esi
callq 0x2890
movq %rax, -0x148(%rbp)
jmp 0x4b6d
movq -0x148(%rbp), %rdi
movl $0x2, %esi
callq 0x33c0
movl $0x42ff0000, (%rax)     # imm = 0x42FF0000
leaq -0x98(%rbp), %rdi
movl $0x4, %esi
callq 0x2780
jmp 0x4b97
movq -0xc8(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x160(%rbp)
leaq -0x98(%rbp), %rsi
movq %rsi, -0x168(%rbp)
callq 0x5bc0
movq -0x168(%rbp), %rdi
callq 0x33e0
movq -0x160(%rbp), %rdi
movss -0x8(%rbp), %xmm1
movss 0xa510(%rip), %xmm0     # 0xf0ec
divss %xmm1, %xmm0
movss %xmm0, -0x154(%rbp)
movl $0x3, %esi
callq 0x2890
movq %rax, -0x150(%rbp)
jmp 0x4bfb
movq -0x150(%rbp), %rdi
movl $0x2, %esi
callq 0x33c0
movss -0x154(%rbp), %xmm0
movss %xmm0, (%rax)
leaq -0xa4(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x5c00
jmp 0x4c2f
movq -0xc8(%rbp), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, 0x14(%rax)
movq -0xa4(%rbp), %rcx
movq %rcx, 0xc(%rax)
leaq -0xb0(%rbp), %rdi
movss 0xa3ab(%rip), %xmm1     # 0xf004
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0x5c00
jmp 0x4c66
movq -0xc8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl -0xa8(%rbp), %ecx
movl %ecx, 0x20(%rax)
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4cb0
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x33e0
movq -0xd0(%rbp), %rdi
callq 0x33e0
movq -0x40(%rbp), %rdi
callq 0x2380
nopw %cs:(%rax,%rax)