# Path: cuwo/vector.py
# def ivec3(x=0, y=0, z=0):
# def vec3(x=0, y=0, z=0):
# def qvec3(x=0, y=0, z=0):


import sys
import sdl2
import sdl2.ext
import threading
import math
import os
                import traceback
from cuwo import tgen
from cuwo.vector import Vector3, Quaternion
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.constants import GLfloat_4
from OpenGL.GL import shaders
from OpenGL.GL.ARB.vertex_buffer_object import *
from queue import PriorityQueue, Full
from ctypes import *
    def run(self):
        print('Initializing tgen...')
        tgen.initialize(self.parent.seed, './data/')
        print('Done')
        while self.running:
            key = self.gen_queue.get()
            x, y = key
            print('Generating chunk', x, y)
            off_x = (x - self.parent.chunk_x) * 256.0
            off_y = (y - self.parent.chunk_y) * 256.0
            data = tgen.generate(x, y).get_render(off_x, off_y)
            res = ChunkData(data)
            self.cache[key] = res


class Camera(object):
    up = down = left = right = False
    shift = False
    x_rot = -27.0
    z_rot = 244

    def __init__(self):
        self.pos = Vector3((40.31, 158.36, 173.21))

    def on_mouse(self, dx, dy):
        self.z_rot -= dx
        self.x_rot -= dy

    def get_rot(self):
        rot = Quaternion()

# Path: cuwo/vector.py
# def ivec3(x=0, y=0, z=0):
# def vec3(x=0, y=0, z=0):
# def qvec3(x=0, y=0, z=0):


# Path: tools/mapviewer.py
import sys
import sdl2
import sdl2.ext
import threading
import math
import os
                import traceback
from cuwo import tgen
from cuwo.vector import Vector3, Quaternion
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.constants import GLfloat_4
from OpenGL.GL import shaders
from OpenGL.GL.ARB.vertex_buffer_object import *
from queue import PriorityQueue, Full
from ctypes import *

    def run(self):
        print('Initializing tgen...')
        tgen.initialize(self.parent.seed, './data/')
        print('Done')
        while self.running:
            key = self.gen_queue.get()
            x, y = key
            print('Generating chunk', x, y)
            off_x = (x - self.parent.chunk_x) * 256.0
            off_y = (y - self.parent.chunk_y) * 256.0
            data = tgen.generate(x, y).get_render(off_x, off_y)
            res = ChunkData(data)
            self.cache[key] = res


class Camera(object):
    up = down = left = right = False
    shift = False
    x_rot = -27.0
    z_rot = 244

    def __init__(self):
        self.pos = Vector3((40.31, 158.36, 173.21))

    def on_mouse(self, dx, dy):
        self.z_rot -= dx
        self.x_rot -= dy

    def get_rot(self):
        rot = Quaternion()

        rot *= Quaternion.from_z_rotation(math.radians(self.z_rot))