aboutsummaryrefslogtreecommitdiff
path: root/vmodeled
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-02-01 16:04:54 +0000
committerrodri <rgl@antares-labs.eu>2023-02-01 16:04:54 +0000
commit9e5da826ebcec801b11eefca036bfa408492d4c6 (patch)
treea1b1732c07a841fa4f3938c00999dce760d8eb60 /vmodeled
parent06f817044e7b2ec0bf63ed37a1cadd9f3818a787 (diff)
downloadmusw-9e5da826ebcec801b11eefca036bfa408492d4c6.tar.gz
musw-9e5da826ebcec801b11eefca036bfa408492d4c6.tar.bz2
musw-9e5da826ebcec801b11eefca036bfa408492d4c6.zip
vmodeled: added the ability to rotate a model.
Diffstat (limited to 'vmodeled')
-rw-r--r--vmodeled/main.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/vmodeled/main.c b/vmodeled/main.c
index 54001f8..32dae42 100644
--- a/vmodeled/main.c
+++ b/vmodeled/main.c
@@ -24,6 +24,7 @@ struct VModel
RFrame worldrf;
VModel *model;
+double θ;
double scale = 1;
void resized(void);
@@ -131,8 +132,13 @@ drawvmodel(Image *dst, VModel *mdl)
scale, 0, 1,
0, scale, 1,
0, 0, 1,
+ }, R = {
+ cos(θ), -sin(θ), 1,
+ sin(θ), cos(θ), 1,
+ 0, 0, 1,
};
+ mulm(S, R);
p = mdl->pts;
for(s = mdl->strokefmt; s != 0 && p-mdl->pts < mdl->npts; s++)
switch(*s){
@@ -168,8 +174,24 @@ redraw(void)
}
void
-rmb(Mousectl *, Keyboardctl *)
+rmb(Mousectl *mc, Keyboardctl *)
{
+ Point2 p;
+ double oldmθ, oldθ;
+
+ p = fromscreen(mc->xy);
+ oldmθ = atan2(p.y, p.x);
+ oldθ = θ;
+
+ for(;;){
+ readmouse(mc);
+ if(mc->buttons != 4)
+ break;
+ p = fromscreen(mc->xy);
+ θ = oldθ + (atan2(p.y, p.x) - oldmθ);
+ fprint(2, "θ %g\n", θ);
+ redraw();
+ }
}
void
@@ -178,7 +200,7 @@ lmb(Mousectl *mc, Keyboardctl *)
Point2 mpos;
mpos = fromscreen(mc->xy);
- fprint(2, "%v\n", mpos);
+ fprint(2, "mpos %v\n", mpos);
}
void