#include "point.h"
#define POST_SHIFT 8
-#define ENABLE_ROLL
struct transformation {
int yaw; /* Rotation angle */
int m10,m11,m12;
int m20,m21,m22;
int xscale,yscale,wscale;
+ int xscale3d,yscale3d,wscale3d;
#ifdef ENABLE_ROLL
int roll;
int hog;
#define HOG(t) 0
#endif
-
+static void
+transform_set_screen_dist(struct transformation *t, int dist)
+{
+ t->screen_dist=dist;
+ t->xscale3d=dist;
+ t->yscale3d=dist;
+ t->wscale3d=dist << POST_SHIFT;
+}
static void
transform_setup_matrix(struct transformation *t)
{
navit_float det;
navit_float fac;
-#if 0 /* FIXME */
-#if 0
- t->roll=0;
- t->pitch=90;
- t->yaw=0;
-#endif
-#if 0
- t->scale=1;
-#endif
- t->hog=2;
- t->ddd=1;
-#endif
navit_float yawc=navit_cos(-M_PI*t->yaw/180);
navit_float yaws=navit_sin(-M_PI*t->yaw/180);
navit_float pitchc=navit_cos(-M_PI*t->pitch/180);
t->m21=(pitchc*rolls*yaws-pitchs*yawc)*fac;
t->m22=pitchc*rollc*fac;
- t->offz=0;
- t->xscale=1;
- t->yscale=1;
- t->wscale=1;
- t->ddd=0;
t->offx=t->screen_center.x;
t->offy=t->screen_center.y;
if (t->pitch) {
t->ddd=1;
t->offz=t->screen_dist;
- dbg(0,"near %d far %d\n",t->znear,t->zfar);
- t->xscale=t->offz;
- t->yscale=t->offz;
- t->wscale=t->offz << POST_SHIFT;
+ dbg(1,"near %d far %d\n",t->znear,t->zfar);
+ t->xscale=t->xscale3d;
+ t->yscale=t->yscale3d;
+ t->wscale=t->wscale3d;
+ } else {
+ t->ddd=0;
+ t->offz=0;
+ t->xscale=1;
+ t->yscale=1;
+ t->wscale=1;
}
-#if 0 /* FIXME */
- t->offz=0;
- t->xscale=750;
- t->yscale=620;
- t->wscale=32 << POST_SHIFT;
-#endif
det=(navit_float)t->m00*(navit_float)t->m11*(navit_float)t->m22+
(navit_float)t->m01*(navit_float)t->m12*(navit_float)t->m20+
(navit_float)t->m02*(navit_float)t->m10*(navit_float)t->m21-
struct transformation *this_;
this_=g_new0(struct transformation, 1);
- this_->screen_dist=100;
+ transform_set_screen_dist(this_, 100);
this_->order_base=14;
#if 0
this_->pitch=20;
}
int
+transform_get_attr(struct transformation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
+{
+ switch (type) {
+#ifdef ENABLE_ROLL
+ case attr_hog:
+ attr->u.num=this_->hog;
+ break;
+#endif
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return 1;
+}
+
+int
+transform_set_attr(struct transformation *this_, struct attr *attr)
+{
+ switch (attr->type) {
+#ifdef ENABLE_ROLL
+ case attr_hog:
+ this_->hog=attr->u.num;
+ return 1;
+#endif
+ default:
+ return 0;
+ }
+}
+
+int
transformation_get_order_base(struct transformation *this_)
{
return this_->order_base;
yc=c1.y;
}
if (i != 0 && i != count-1 && mindist) {
- if (xc > c[k].x-mindist && xc < c[k].x+mindist && yc > c[k].y-mindist && yc < c[k].y+mindist)
+ if (xc > c[k].x-mindist && xc < c[k].x+mindist && yc > c[k].y-mindist && yc < c[k].y+mindist &&
+ (c[i+1].x != c[0].x || c[i+1].y != c[0].y))
continue;
k=i;
}
void
transform_set_distance(struct transformation *this_,int distance)
{
- this_->screen_dist=distance;
+ transform_set_screen_dist(this_, distance);
transform_setup_matrix(this_);
}
}
void
+transform_set_scales(struct transformation *this_, int xscale, int yscale, int wscale)
+{
+ this_->xscale3d=xscale;
+ this_->yscale3d=yscale;
+ this_->wscale3d=wscale;
+}
+
+void
transform_set_screen_selection(struct transformation *t, struct map_selection *sel)
{
map_selection_destroy(t->screen_sel);
if (transform_zplane_intersection(&cg[edgenodes[i*2]], &cg[edgenodes[i*2+1]], HOG(*t), &tmp) == 1) {
c.x=tmp.x*(1 << t->scale_shift)+t->map_center.x;
c.y=tmp.y*(1 << t->scale_shift)+t->map_center.y;
- dbg(0,"intersection with edge %d at 0x%x,0x%x\n",i,c.x,c.y);
+ dbg(1,"intersection with edge %d at 0x%x,0x%x\n",i,c.x,c.y);
if (valid)
coord_rect_extend(&msm->u.c_rect, &c);
else {
msm->u.c_rect.rl=c;
valid=1;
}
- dbg(0,"rect 0x%x,0x%x - 0x%x,0x%x\n",msm->u.c_rect.lu.x,msm->u.c_rect.lu.y,msm->u.c_rect.rl.x,msm->u.c_rect.rl.y);
+ dbg(1,"rect 0x%x,0x%x - 0x%x,0x%x\n",msm->u.c_rect.lu.x,msm->u.c_rect.lu.y,msm->u.c_rect.rl.x,msm->u.c_rect.rl.y);
}
}
} else {