calculate proper tile position
This commit is contained in:
@@ -11,9 +11,12 @@ class tile;
|
||||
|
||||
class map {
|
||||
public:
|
||||
map(class platform *platform, class painter *painter);
|
||||
map(class platform *platform);
|
||||
~map();
|
||||
|
||||
void setup();
|
||||
void resize(uint32_t width, uint32_t height);
|
||||
|
||||
/* callback */
|
||||
bool render();
|
||||
void moveBy(double dx, double dy);
|
||||
@@ -23,8 +26,8 @@ public:
|
||||
|
||||
private:
|
||||
platform *platform;
|
||||
painter *painter;
|
||||
transform *transform;
|
||||
painter *painter;
|
||||
|
||||
std::vector<tile *> tiles;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef LLMR_MAP_TRANSFORM
|
||||
#define LLMR_MAP_TRANSFORM
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
class tile;
|
||||
@@ -9,12 +11,40 @@ class transform {
|
||||
public:
|
||||
transform();
|
||||
|
||||
// Relative changes
|
||||
void moveBy(double dx, double dy);
|
||||
void scaleBy(double ds, double cx, double cy);
|
||||
|
||||
// Absolute changes
|
||||
void setScale(double scale);
|
||||
void setZoom(double zoom);
|
||||
void setLonLat(double lon, double lat);
|
||||
// void setAngle(double angle);
|
||||
|
||||
|
||||
// Getters
|
||||
void matrixFor(float matrix[16], uint32_t z, uint32_t x, uint32_t y) const;
|
||||
void getLonLat(double& lon, double& lat) const;
|
||||
|
||||
private:
|
||||
double pixel_x() const;
|
||||
double pixel_y() const;
|
||||
|
||||
public:
|
||||
double x, y;
|
||||
// double x, y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
|
||||
private:
|
||||
double x, y; // spherical mercator meters of the view center
|
||||
double angle;
|
||||
double scale;
|
||||
|
||||
|
||||
const int32_t size = 512;
|
||||
|
||||
double zc, Bc, Cc;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,10 @@ class tile;
|
||||
|
||||
class painter {
|
||||
public:
|
||||
painter(class platform *platform);
|
||||
painter(class platform *platform, class transform *tranform);
|
||||
|
||||
void setup();
|
||||
void teardown();
|
||||
|
||||
void resize(uint32_t new_width, uint32_t new_height);
|
||||
void viewport();
|
||||
|
||||
|
||||
@@ -25,18 +23,16 @@ public:
|
||||
void render(tile *tile);
|
||||
|
||||
void switchShader(Shader *shader, float matrix[16]);
|
||||
void setTransform(transform *transform);
|
||||
|
||||
private:
|
||||
void setupShaders();
|
||||
void changeMatrix();
|
||||
void changeMatrix(tile *tile);
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
platform *platform;
|
||||
transform *transform;
|
||||
uint32_t width, height;
|
||||
float matrix[16];
|
||||
|
||||
Shader *currentShader;
|
||||
|
||||
Reference in New Issue
Block a user