summaryrefslogtreecommitdiff
path: root/navit/transform.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-21 10:13:03 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-21 10:13:03 +0000
commit97d66dd6e3d1dc845b465d8df38b0e3ecb1b5d85 (patch)
treed53b1003ce89f848edc328971ee41ef0ab4ad94d /navit/transform.c
parentf78c963a2443aedbf54cec861cae3a9deaadad08 (diff)
downloadnavit-svn-97d66dd6e3d1dc845b465d8df38b0e3ecb1b5d85.tar.gz
Fix:Core:Made transformation more flexible
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2780 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/transform.c')
-rw-r--r--navit/transform.c88
1 files changed, 58 insertions, 30 deletions
diff --git a/navit/transform.c b/navit/transform.c
index 35c0d7e5..5125d062 100644
--- a/navit/transform.c
+++ b/navit/transform.c
@@ -33,7 +33,6 @@
#include "point.h"
#define POST_SHIFT 8
-#define ENABLE_ROLL
struct transformation {
int yaw; /* Rotation angle */
@@ -43,6 +42,7 @@ struct transformation {
int m10,m11,m12;
int m20,m21,m22;
int xscale,yscale,wscale;
+ int xscale3d,yscale3d,wscale3d;
#ifdef ENABLE_ROLL
int roll;
int hog;
@@ -70,25 +70,20 @@ struct transformation {
#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);
@@ -134,27 +129,22 @@ transform_setup_matrix(struct transformation *t)
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;
+ 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-
@@ -179,7 +169,7 @@ transform_new(void)
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;
@@ -210,6 +200,36 @@ transform_set_hog(struct transformation *this_, int hog)
}
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;
@@ -700,7 +720,7 @@ transform_get_roll(struct transformation *this_)
void
transform_set_distance(struct transformation *this_,int distance)
{
- this_->screen_dist=distance;
+ transform_set_screen_dist(this_, distance);
transform_setup_matrix(this_);
}
@@ -711,6 +731,14 @@ transform_get_distance(struct transformation *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);